babylon.module.d.ts 5.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256
  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. get 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 get 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 set LogLevels(level: 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/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. }
  409. }
  410. declare module "babylonjs/Misc/deepCopier" {
  411. /**
  412. * Class containing a set of static utilities functions for deep copy.
  413. */
  414. export class DeepCopier {
  415. /**
  416. * Tries to copy an object by duplicating every property
  417. * @param source defines the source object
  418. * @param destination defines the target object
  419. * @param doNotCopyList defines a list of properties to avoid
  420. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  421. */
  422. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  423. }
  424. }
  425. declare module "babylonjs/Misc/precisionDate" {
  426. /**
  427. * Class containing a set of static utilities functions for precision date
  428. */
  429. export class PrecisionDate {
  430. /**
  431. * Gets either window.performance.now() if supported or Date.now() else
  432. */
  433. static get Now(): number;
  434. }
  435. }
  436. declare module "babylonjs/Misc/devTools" {
  437. /** @hidden */
  438. export class _DevTools {
  439. static WarnImport(name: string): string;
  440. }
  441. }
  442. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  443. /**
  444. * Interface used to define the mechanism to get data from the network
  445. */
  446. export interface IWebRequest {
  447. /**
  448. * Returns client's response url
  449. */
  450. responseURL: string;
  451. /**
  452. * Returns client's status
  453. */
  454. status: number;
  455. /**
  456. * Returns client's status as a text
  457. */
  458. statusText: string;
  459. }
  460. }
  461. declare module "babylonjs/Misc/webRequest" {
  462. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  463. import { Nullable } from "babylonjs/types";
  464. /**
  465. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  466. */
  467. export class WebRequest implements IWebRequest {
  468. private _xhr;
  469. /**
  470. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  471. * i.e. when loading files, where the server/service expects an Authorization header
  472. */
  473. static CustomRequestHeaders: {
  474. [key: string]: string;
  475. };
  476. /**
  477. * Add callback functions in this array to update all the requests before they get sent to the network
  478. */
  479. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  480. private _injectCustomRequestHeaders;
  481. /**
  482. * Gets or sets a function to be called when loading progress changes
  483. */
  484. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  485. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  486. /**
  487. * Returns client's state
  488. */
  489. get readyState(): number;
  490. /**
  491. * Returns client's status
  492. */
  493. get status(): number;
  494. /**
  495. * Returns client's status as a text
  496. */
  497. get statusText(): string;
  498. /**
  499. * Returns client's response
  500. */
  501. get response(): any;
  502. /**
  503. * Returns client's response url
  504. */
  505. get responseURL(): string;
  506. /**
  507. * Returns client's response as text
  508. */
  509. get responseText(): string;
  510. /**
  511. * Gets or sets the expected response type
  512. */
  513. get responseType(): XMLHttpRequestResponseType;
  514. set responseType(value: XMLHttpRequestResponseType);
  515. /** @hidden */
  516. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  517. /** @hidden */
  518. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  519. /**
  520. * Cancels any network activity
  521. */
  522. abort(): void;
  523. /**
  524. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  525. * @param body defines an optional request body
  526. */
  527. send(body?: Document | BodyInit | null): void;
  528. /**
  529. * Sets the request method, request URL
  530. * @param method defines the method to use (GET, POST, etc..)
  531. * @param url defines the url to connect with
  532. */
  533. open(method: string, url: string): void;
  534. /**
  535. * Sets the value of a request header.
  536. * @param name The name of the header whose value is to be set
  537. * @param value The value to set as the body of the header
  538. */
  539. setRequestHeader(name: string, value: string): void;
  540. /**
  541. * Get the string containing the text of a particular header's value.
  542. * @param name The name of the header
  543. * @returns The string containing the text of the given header name
  544. */
  545. getResponseHeader(name: string): Nullable<string>;
  546. }
  547. }
  548. declare module "babylonjs/Misc/fileRequest" {
  549. import { Observable } from "babylonjs/Misc/observable";
  550. /**
  551. * File request interface
  552. */
  553. export interface IFileRequest {
  554. /**
  555. * Raised when the request is complete (success or error).
  556. */
  557. onCompleteObservable: Observable<IFileRequest>;
  558. /**
  559. * Aborts the request for a file.
  560. */
  561. abort: () => void;
  562. }
  563. }
  564. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  565. /**
  566. * Define options used to create a render target texture
  567. */
  568. export class RenderTargetCreationOptions {
  569. /**
  570. * Specifies is mipmaps must be generated
  571. */
  572. generateMipMaps?: boolean;
  573. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  574. generateDepthBuffer?: boolean;
  575. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  576. generateStencilBuffer?: boolean;
  577. /** Defines texture type (int by default) */
  578. type?: number;
  579. /** Defines sampling mode (trilinear by default) */
  580. samplingMode?: number;
  581. /** Defines format (RGBA by default) */
  582. format?: number;
  583. }
  584. }
  585. declare module "babylonjs/Instrumentation/timeToken" {
  586. import { Nullable } from "babylonjs/types";
  587. /**
  588. * @hidden
  589. **/
  590. export class _TimeToken {
  591. _startTimeQuery: Nullable<WebGLQuery>;
  592. _endTimeQuery: Nullable<WebGLQuery>;
  593. _timeElapsedQuery: Nullable<WebGLQuery>;
  594. _timeElapsedQueryEnded: boolean;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** 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 */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** 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 */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** 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 */
  693. static readonly GEQUAL: number;
  694. /** 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 */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and mip = nearest */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** Bilinear is mag = linear and min = linear and mip = nearest */
  779. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** nearest is mag = nearest and min = nearest and mip = linear */
  783. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  784. /** Bilinear is mag = linear and min = linear and mip = nearest */
  785. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** mag = nearest and min = nearest and mip = none */
  797. static readonly TEXTURE_NEAREST_NEAREST: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** mag = linear and min = linear and mip = none */
  803. static readonly TEXTURE_LINEAR_LINEAR: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  827. static readonly SCALEMODE_FLOOR: number;
  828. /** Defines that texture rescaling will look for the nearest power of 2 size */
  829. static readonly SCALEMODE_NEAREST: number;
  830. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  831. static readonly SCALEMODE_CEILING: number;
  832. /**
  833. * The dirty texture flag value
  834. */
  835. static readonly MATERIAL_TextureDirtyFlag: number;
  836. /**
  837. * The dirty light flag value
  838. */
  839. static readonly MATERIAL_LightDirtyFlag: number;
  840. /**
  841. * The dirty fresnel flag value
  842. */
  843. static readonly MATERIAL_FresnelDirtyFlag: number;
  844. /**
  845. * The dirty attribute flag value
  846. */
  847. static readonly MATERIAL_AttributesDirtyFlag: number;
  848. /**
  849. * The dirty misc flag value
  850. */
  851. static readonly MATERIAL_MiscDirtyFlag: number;
  852. /**
  853. * The all dirty flag value
  854. */
  855. static readonly MATERIAL_AllDirtyFlag: number;
  856. /**
  857. * Returns the triangle fill mode
  858. */
  859. static readonly MATERIAL_TriangleFillMode: number;
  860. /**
  861. * Returns the wireframe mode
  862. */
  863. static readonly MATERIAL_WireFrameFillMode: number;
  864. /**
  865. * Returns the point fill mode
  866. */
  867. static readonly MATERIAL_PointFillMode: number;
  868. /**
  869. * Returns the point list draw mode
  870. */
  871. static readonly MATERIAL_PointListDrawMode: number;
  872. /**
  873. * Returns the line list draw mode
  874. */
  875. static readonly MATERIAL_LineListDrawMode: number;
  876. /**
  877. * Returns the line loop draw mode
  878. */
  879. static readonly MATERIAL_LineLoopDrawMode: number;
  880. /**
  881. * Returns the line strip draw mode
  882. */
  883. static readonly MATERIAL_LineStripDrawMode: number;
  884. /**
  885. * Returns the triangle strip draw mode
  886. */
  887. static readonly MATERIAL_TriangleStripDrawMode: number;
  888. /**
  889. * Returns the triangle fan draw mode
  890. */
  891. static readonly MATERIAL_TriangleFanDrawMode: number;
  892. /**
  893. * Stores the clock-wise side orientation
  894. */
  895. static readonly MATERIAL_ClockWiseSideOrientation: number;
  896. /**
  897. * Stores the counter clock-wise side orientation
  898. */
  899. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  900. /**
  901. * Nothing
  902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  903. */
  904. static readonly ACTION_NothingTrigger: number;
  905. /**
  906. * On pick
  907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  908. */
  909. static readonly ACTION_OnPickTrigger: number;
  910. /**
  911. * On left pick
  912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  913. */
  914. static readonly ACTION_OnLeftPickTrigger: number;
  915. /**
  916. * On right pick
  917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  918. */
  919. static readonly ACTION_OnRightPickTrigger: number;
  920. /**
  921. * On center pick
  922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  923. */
  924. static readonly ACTION_OnCenterPickTrigger: number;
  925. /**
  926. * On pick down
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnPickDownTrigger: number;
  930. /**
  931. * On double pick
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnDoublePickTrigger: number;
  935. /**
  936. * On pick up
  937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  938. */
  939. static readonly ACTION_OnPickUpTrigger: number;
  940. /**
  941. * On pick out.
  942. * This trigger will only be raised if you also declared a OnPickDown
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnPickOutTrigger: number;
  946. /**
  947. * On long press
  948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  949. */
  950. static readonly ACTION_OnLongPressTrigger: number;
  951. /**
  952. * On pointer over
  953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_OnPointerOverTrigger: number;
  956. /**
  957. * On pointer out
  958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnPointerOutTrigger: number;
  961. /**
  962. * On every frame
  963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnEveryFrameTrigger: number;
  966. /**
  967. * On intersection enter
  968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnIntersectionEnterTrigger: number;
  971. /**
  972. * On intersection exit
  973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnIntersectionExitTrigger: number;
  976. /**
  977. * On key down
  978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnKeyDownTrigger: number;
  981. /**
  982. * On key up
  983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  984. */
  985. static readonly ACTION_OnKeyUpTrigger: number;
  986. /**
  987. * Billboard mode will only apply to Y axis
  988. */
  989. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  990. /**
  991. * Billboard mode will apply to all axes
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  994. /**
  995. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  998. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  999. * Test order :
  1000. * Is the bounding sphere outside the frustum ?
  1001. * If not, are the bounding box vertices outside the frustum ?
  1002. * It not, then the cullable object is in the frustum.
  1003. */
  1004. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1005. /** Culling strategy : Bounding Sphere Only.
  1006. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1007. * It's also less accurate than the standard because some not visible objects can still be selected.
  1008. * Test : is the bounding sphere outside the frustum ?
  1009. * If not, then the cullable object is in the frustum.
  1010. */
  1011. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1012. /** Culling strategy : Optimistic Inclusion.
  1013. * This in an inclusion test first, then the standard exclusion test.
  1014. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1015. * 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.
  1016. * Anyway, it's as accurate as the standard strategy.
  1017. * Test :
  1018. * Is the cullable object bounding sphere center in the frustum ?
  1019. * If not, apply the default culling strategy.
  1020. */
  1021. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1022. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1023. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1024. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1025. * 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.
  1026. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1027. * Test :
  1028. * Is the cullable object bounding sphere center in the frustum ?
  1029. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1030. */
  1031. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1032. /**
  1033. * No logging while loading
  1034. */
  1035. static readonly SCENELOADER_NO_LOGGING: number;
  1036. /**
  1037. * Minimal logging while loading
  1038. */
  1039. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1040. /**
  1041. * Summary logging while loading
  1042. */
  1043. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1044. /**
  1045. * Detailled logging while loading
  1046. */
  1047. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1048. }
  1049. }
  1050. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1051. import { Nullable } from "babylonjs/types";
  1052. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1053. /**
  1054. * This represents the required contract to create a new type of texture loader.
  1055. */
  1056. export interface IInternalTextureLoader {
  1057. /**
  1058. * Defines wether the loader supports cascade loading the different faces.
  1059. */
  1060. supportCascades: boolean;
  1061. /**
  1062. * This returns if the loader support the current file information.
  1063. * @param extension defines the file extension of the file being loaded
  1064. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1065. * @param fallback defines the fallback internal texture if any
  1066. * @param isBase64 defines whether the texture is encoded as a base64
  1067. * @param isBuffer defines whether the texture data are stored as a buffer
  1068. * @returns true if the loader can load the specified file
  1069. */
  1070. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1071. /**
  1072. * Transform the url before loading if required.
  1073. * @param rootUrl the url of the texture
  1074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1075. * @returns the transformed texture
  1076. */
  1077. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1078. /**
  1079. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1080. * @param rootUrl the url of the texture
  1081. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1082. * @returns the fallback texture
  1083. */
  1084. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1085. /**
  1086. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1087. * @param data contains the texture data
  1088. * @param texture defines the BabylonJS internal texture
  1089. * @param createPolynomials will be true if polynomials have been requested
  1090. * @param onLoad defines the callback to trigger once the texture is ready
  1091. * @param onError defines the callback to trigger in case of error
  1092. */
  1093. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1094. /**
  1095. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1096. * @param data contains the texture data
  1097. * @param texture defines the BabylonJS internal texture
  1098. * @param callback defines the method to call once ready to upload
  1099. */
  1100. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1101. }
  1102. }
  1103. declare module "babylonjs/Engines/IPipelineContext" {
  1104. /**
  1105. * Class used to store and describe the pipeline context associated with an effect
  1106. */
  1107. export interface IPipelineContext {
  1108. /**
  1109. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1110. */
  1111. isAsync: boolean;
  1112. /**
  1113. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1114. */
  1115. isReady: boolean;
  1116. /** @hidden */
  1117. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1118. }
  1119. }
  1120. declare module "babylonjs/Meshes/dataBuffer" {
  1121. /**
  1122. * Class used to store gfx data (like WebGLBuffer)
  1123. */
  1124. export class DataBuffer {
  1125. /**
  1126. * Gets or sets the number of objects referencing this buffer
  1127. */
  1128. references: number;
  1129. /** Gets or sets the size of the underlying buffer */
  1130. capacity: number;
  1131. /**
  1132. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1133. */
  1134. is32Bits: boolean;
  1135. /**
  1136. * Gets the underlying buffer
  1137. */
  1138. get underlyingResource(): any;
  1139. }
  1140. }
  1141. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1142. /** @hidden */
  1143. export interface IShaderProcessor {
  1144. attributeProcessor?: (attribute: string) => string;
  1145. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1146. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1147. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1148. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1149. lineProcessor?: (line: string, isFragment: boolean) => string;
  1150. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1151. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1152. }
  1153. }
  1154. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1155. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1156. /** @hidden */
  1157. export interface ProcessingOptions {
  1158. defines: string[];
  1159. indexParameters: any;
  1160. isFragment: boolean;
  1161. shouldUseHighPrecisionShader: boolean;
  1162. supportsUniformBuffers: boolean;
  1163. shadersRepository: string;
  1164. includesShadersStore: {
  1165. [key: string]: string;
  1166. };
  1167. processor?: IShaderProcessor;
  1168. version: string;
  1169. platformName: string;
  1170. lookForClosingBracketForUniformBuffer?: boolean;
  1171. }
  1172. }
  1173. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1174. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1175. /** @hidden */
  1176. export class ShaderCodeNode {
  1177. line: string;
  1178. children: ShaderCodeNode[];
  1179. additionalDefineKey?: string;
  1180. additionalDefineValue?: string;
  1181. isValid(preprocessors: {
  1182. [key: string]: string;
  1183. }): boolean;
  1184. process(preprocessors: {
  1185. [key: string]: string;
  1186. }, options: ProcessingOptions): string;
  1187. }
  1188. }
  1189. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1190. /** @hidden */
  1191. export class ShaderCodeCursor {
  1192. private _lines;
  1193. lineIndex: number;
  1194. get currentLine(): string;
  1195. get canRead(): boolean;
  1196. set lines(value: string[]);
  1197. }
  1198. }
  1199. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1200. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1201. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1202. /** @hidden */
  1203. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1204. process(preprocessors: {
  1205. [key: string]: string;
  1206. }, options: ProcessingOptions): string;
  1207. }
  1208. }
  1209. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1210. /** @hidden */
  1211. export class ShaderDefineExpression {
  1212. isTrue(preprocessors: {
  1213. [key: string]: string;
  1214. }): boolean;
  1215. }
  1216. }
  1217. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1218. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1219. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1220. /** @hidden */
  1221. export class ShaderCodeTestNode extends ShaderCodeNode {
  1222. testExpression: ShaderDefineExpression;
  1223. isValid(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. }
  1227. }
  1228. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1229. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1230. /** @hidden */
  1231. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1232. define: string;
  1233. not: boolean;
  1234. constructor(define: string, not?: boolean);
  1235. isTrue(preprocessors: {
  1236. [key: string]: string;
  1237. }): boolean;
  1238. }
  1239. }
  1240. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1241. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1242. /** @hidden */
  1243. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1244. leftOperand: ShaderDefineExpression;
  1245. rightOperand: ShaderDefineExpression;
  1246. isTrue(preprocessors: {
  1247. [key: string]: string;
  1248. }): boolean;
  1249. }
  1250. }
  1251. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1252. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1253. /** @hidden */
  1254. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1255. leftOperand: ShaderDefineExpression;
  1256. rightOperand: ShaderDefineExpression;
  1257. isTrue(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1263. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1264. /** @hidden */
  1265. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1266. define: string;
  1267. operand: string;
  1268. testValue: string;
  1269. constructor(define: string, operand: string, testValue: string);
  1270. isTrue(preprocessors: {
  1271. [key: string]: string;
  1272. }): boolean;
  1273. }
  1274. }
  1275. declare module "babylonjs/Offline/IOfflineProvider" {
  1276. /**
  1277. * Class used to enable access to offline support
  1278. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1279. */
  1280. export interface IOfflineProvider {
  1281. /**
  1282. * Gets a boolean indicating if scene must be saved in the database
  1283. */
  1284. enableSceneOffline: boolean;
  1285. /**
  1286. * Gets a boolean indicating if textures must be saved in the database
  1287. */
  1288. enableTexturesOffline: boolean;
  1289. /**
  1290. * Open the offline support and make it available
  1291. * @param successCallback defines the callback to call on success
  1292. * @param errorCallback defines the callback to call on error
  1293. */
  1294. open(successCallback: () => void, errorCallback: () => void): void;
  1295. /**
  1296. * Loads an image from the offline support
  1297. * @param url defines the url to load from
  1298. * @param image defines the target DOM image
  1299. */
  1300. loadImage(url: string, image: HTMLImageElement): void;
  1301. /**
  1302. * Loads a file from offline support
  1303. * @param url defines the URL to load from
  1304. * @param sceneLoaded defines a callback to call on success
  1305. * @param progressCallBack defines a callback to call when progress changed
  1306. * @param errorCallback defines a callback to call on error
  1307. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1308. */
  1309. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1310. }
  1311. }
  1312. declare module "babylonjs/Misc/filesInputStore" {
  1313. /**
  1314. * Class used to help managing file picking and drag'n'drop
  1315. * File Storage
  1316. */
  1317. export class FilesInputStore {
  1318. /**
  1319. * List of files ready to be loaded
  1320. */
  1321. static FilesToLoad: {
  1322. [key: string]: File;
  1323. };
  1324. }
  1325. }
  1326. declare module "babylonjs/Misc/retryStrategy" {
  1327. import { WebRequest } from "babylonjs/Misc/webRequest";
  1328. /**
  1329. * Class used to define a retry strategy when error happens while loading assets
  1330. */
  1331. export class RetryStrategy {
  1332. /**
  1333. * Function used to defines an exponential back off strategy
  1334. * @param maxRetries defines the maximum number of retries (3 by default)
  1335. * @param baseInterval defines the interval between retries
  1336. * @returns the strategy function to use
  1337. */
  1338. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1339. }
  1340. }
  1341. declare module "babylonjs/Misc/baseError" {
  1342. /**
  1343. * @ignore
  1344. * Application error to support additional information when loading a file
  1345. */
  1346. export abstract class BaseError extends Error {
  1347. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1348. }
  1349. }
  1350. declare module "babylonjs/Misc/fileTools" {
  1351. import { WebRequest } from "babylonjs/Misc/webRequest";
  1352. import { Nullable } from "babylonjs/types";
  1353. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1354. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1355. import { BaseError } from "babylonjs/Misc/baseError";
  1356. /** @ignore */
  1357. export class LoadFileError extends BaseError {
  1358. request?: WebRequest;
  1359. file?: File;
  1360. /**
  1361. * Creates a new LoadFileError
  1362. * @param message defines the message of the error
  1363. * @param request defines the optional web request
  1364. * @param file defines the optional file
  1365. */
  1366. constructor(message: string, object?: WebRequest | File);
  1367. }
  1368. /** @ignore */
  1369. export class RequestFileError extends BaseError {
  1370. request: WebRequest;
  1371. /**
  1372. * Creates a new LoadFileError
  1373. * @param message defines the message of the error
  1374. * @param request defines the optional web request
  1375. */
  1376. constructor(message: string, request: WebRequest);
  1377. }
  1378. /** @ignore */
  1379. export class ReadFileError extends BaseError {
  1380. file: File;
  1381. /**
  1382. * Creates a new ReadFileError
  1383. * @param message defines the message of the error
  1384. * @param file defines the optional file
  1385. */
  1386. constructor(message: string, file: File);
  1387. }
  1388. /**
  1389. * @hidden
  1390. */
  1391. export class FileTools {
  1392. /**
  1393. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1394. */
  1395. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1396. /**
  1397. * Gets or sets the base URL to use to load assets
  1398. */
  1399. static BaseUrl: string;
  1400. /**
  1401. * Default behaviour for cors in the application.
  1402. * It can be a string if the expected behavior is identical in the entire app.
  1403. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1404. */
  1405. static CorsBehavior: string | ((url: string | string[]) => string);
  1406. /**
  1407. * Gets or sets a function used to pre-process url before using them to load assets
  1408. */
  1409. static PreprocessUrl: (url: string) => string;
  1410. /**
  1411. * Removes unwanted characters from an url
  1412. * @param url defines the url to clean
  1413. * @returns the cleaned url
  1414. */
  1415. private static _CleanUrl;
  1416. /**
  1417. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1418. * @param url define the url we are trying
  1419. * @param element define the dom element where to configure the cors policy
  1420. */
  1421. static SetCorsBehavior(url: string | string[], element: {
  1422. crossOrigin: string | null;
  1423. }): void;
  1424. /**
  1425. * Loads an image as an HTMLImageElement.
  1426. * @param input url string, ArrayBuffer, or Blob to load
  1427. * @param onLoad callback called when the image successfully loads
  1428. * @param onError callback called when the image fails to load
  1429. * @param offlineProvider offline provider for caching
  1430. * @param mimeType optional mime type
  1431. * @returns the HTMLImageElement of the loaded image
  1432. */
  1433. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1434. /**
  1435. * Reads a file from a File object
  1436. * @param file defines the file to load
  1437. * @param onSuccess defines the callback to call when data is loaded
  1438. * @param onProgress defines the callback to call during loading process
  1439. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1440. * @param onError defines the callback to call when an error occurs
  1441. * @returns a file request object
  1442. */
  1443. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1444. /**
  1445. * Loads a file from a url
  1446. * @param url url to load
  1447. * @param onSuccess callback called when the file successfully loads
  1448. * @param onProgress callback called while file is loading (if the server supports this mode)
  1449. * @param offlineProvider defines the offline provider for caching
  1450. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1451. * @param onError callback called when the file fails to load
  1452. * @returns a file request object
  1453. */
  1454. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1455. /**
  1456. * Loads a file
  1457. * @param url url to load
  1458. * @param onSuccess callback called when the file successfully loads
  1459. * @param onProgress callback called while file is loading (if the server supports this mode)
  1460. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1461. * @param onError callback called when the file fails to load
  1462. * @param onOpened callback called when the web request is opened
  1463. * @returns a file request object
  1464. */
  1465. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1466. /**
  1467. * Checks if the loaded document was accessed via `file:`-Protocol.
  1468. * @returns boolean
  1469. */
  1470. static IsFileURL(): boolean;
  1471. }
  1472. }
  1473. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1474. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1475. import { WebRequest } from "babylonjs/Misc/webRequest";
  1476. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1477. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1478. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1479. /** @hidden */
  1480. export class ShaderProcessor {
  1481. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1482. private static _ProcessPrecision;
  1483. private static _ExtractOperation;
  1484. private static _BuildSubExpression;
  1485. private static _BuildExpression;
  1486. private static _MoveCursorWithinIf;
  1487. private static _MoveCursor;
  1488. private static _EvaluatePreProcessors;
  1489. private static _PreparePreProcessors;
  1490. private static _ProcessShaderConversion;
  1491. private static _ProcessIncludes;
  1492. /**
  1493. * Loads a file from a url
  1494. * @param url url to load
  1495. * @param onSuccess callback called when the file successfully loads
  1496. * @param onProgress callback called while file is loading (if the server supports this mode)
  1497. * @param offlineProvider defines the offline provider for caching
  1498. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1499. * @param onError callback called when the file fails to load
  1500. * @returns a file request object
  1501. * @hidden
  1502. */
  1503. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1504. }
  1505. }
  1506. declare module "babylonjs/Maths/math.like" {
  1507. import { float, int, DeepImmutable } from "babylonjs/types";
  1508. /**
  1509. * @hidden
  1510. */
  1511. export interface IColor4Like {
  1512. r: float;
  1513. g: float;
  1514. b: float;
  1515. a: float;
  1516. }
  1517. /**
  1518. * @hidden
  1519. */
  1520. export interface IColor3Like {
  1521. r: float;
  1522. g: float;
  1523. b: float;
  1524. }
  1525. /**
  1526. * @hidden
  1527. */
  1528. export interface IVector4Like {
  1529. x: float;
  1530. y: float;
  1531. z: float;
  1532. w: float;
  1533. }
  1534. /**
  1535. * @hidden
  1536. */
  1537. export interface IVector3Like {
  1538. x: float;
  1539. y: float;
  1540. z: float;
  1541. }
  1542. /**
  1543. * @hidden
  1544. */
  1545. export interface IVector2Like {
  1546. x: float;
  1547. y: float;
  1548. }
  1549. /**
  1550. * @hidden
  1551. */
  1552. export interface IMatrixLike {
  1553. toArray(): DeepImmutable<Float32Array>;
  1554. updateFlag: int;
  1555. }
  1556. /**
  1557. * @hidden
  1558. */
  1559. export interface IViewportLike {
  1560. x: float;
  1561. y: float;
  1562. width: float;
  1563. height: float;
  1564. }
  1565. /**
  1566. * @hidden
  1567. */
  1568. export interface IPlaneLike {
  1569. normal: IVector3Like;
  1570. d: float;
  1571. normalize(): void;
  1572. }
  1573. }
  1574. declare module "babylonjs/Materials/iEffectFallbacks" {
  1575. import { Effect } from "babylonjs/Materials/effect";
  1576. /**
  1577. * Interface used to define common properties for effect fallbacks
  1578. */
  1579. export interface IEffectFallbacks {
  1580. /**
  1581. * Removes the defines that should be removed when falling back.
  1582. * @param currentDefines defines the current define statements for the shader.
  1583. * @param effect defines the current effect we try to compile
  1584. * @returns The resulting defines with defines of the current rank removed.
  1585. */
  1586. reduce(currentDefines: string, effect: Effect): string;
  1587. /**
  1588. * Removes the fallback from the bound mesh.
  1589. */
  1590. unBindMesh(): void;
  1591. /**
  1592. * Checks to see if more fallbacks are still availible.
  1593. */
  1594. hasMoreFallbacks: boolean;
  1595. }
  1596. }
  1597. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1598. /**
  1599. * Class used to evalaute queries containing `and` and `or` operators
  1600. */
  1601. export class AndOrNotEvaluator {
  1602. /**
  1603. * Evaluate a query
  1604. * @param query defines the query to evaluate
  1605. * @param evaluateCallback defines the callback used to filter result
  1606. * @returns true if the query matches
  1607. */
  1608. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1609. private static _HandleParenthesisContent;
  1610. private static _SimplifyNegation;
  1611. }
  1612. }
  1613. declare module "babylonjs/Misc/tags" {
  1614. /**
  1615. * Class used to store custom tags
  1616. */
  1617. export class Tags {
  1618. /**
  1619. * Adds support for tags on the given object
  1620. * @param obj defines the object to use
  1621. */
  1622. static EnableFor(obj: any): void;
  1623. /**
  1624. * Removes tags support
  1625. * @param obj defines the object to use
  1626. */
  1627. static DisableFor(obj: any): void;
  1628. /**
  1629. * Gets a boolean indicating if the given object has tags
  1630. * @param obj defines the object to use
  1631. * @returns a boolean
  1632. */
  1633. static HasTags(obj: any): boolean;
  1634. /**
  1635. * Gets the tags available on a given object
  1636. * @param obj defines the object to use
  1637. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1638. * @returns the tags
  1639. */
  1640. static GetTags(obj: any, asString?: boolean): any;
  1641. /**
  1642. * Adds tags to an object
  1643. * @param obj defines the object to use
  1644. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1645. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1646. */
  1647. static AddTagsTo(obj: any, tagsString: string): void;
  1648. /**
  1649. * @hidden
  1650. */
  1651. static _AddTagTo(obj: any, tag: string): void;
  1652. /**
  1653. * Removes specific tags from a specific object
  1654. * @param obj defines the object to use
  1655. * @param tagsString defines the tags to remove
  1656. */
  1657. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1658. /**
  1659. * @hidden
  1660. */
  1661. static _RemoveTagFrom(obj: any, tag: string): void;
  1662. /**
  1663. * Defines if tags hosted on an object match a given query
  1664. * @param obj defines the object to use
  1665. * @param tagsQuery defines the tag query
  1666. * @returns a boolean
  1667. */
  1668. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1669. }
  1670. }
  1671. declare module "babylonjs/Maths/math.scalar" {
  1672. /**
  1673. * Scalar computation library
  1674. */
  1675. export class Scalar {
  1676. /**
  1677. * Two pi constants convenient for computation.
  1678. */
  1679. static TwoPi: number;
  1680. /**
  1681. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1682. * @param a number
  1683. * @param b number
  1684. * @param epsilon (default = 1.401298E-45)
  1685. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1686. */
  1687. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1688. /**
  1689. * Returns a string : the upper case translation of the number i to hexadecimal.
  1690. * @param i number
  1691. * @returns the upper case translation of the number i to hexadecimal.
  1692. */
  1693. static ToHex(i: number): string;
  1694. /**
  1695. * Returns -1 if value is negative and +1 is value is positive.
  1696. * @param value the value
  1697. * @returns the value itself if it's equal to zero.
  1698. */
  1699. static Sign(value: number): number;
  1700. /**
  1701. * Returns the value itself if it's between min and max.
  1702. * Returns min if the value is lower than min.
  1703. * Returns max if the value is greater than max.
  1704. * @param value the value to clmap
  1705. * @param min the min value to clamp to (default: 0)
  1706. * @param max the max value to clamp to (default: 1)
  1707. * @returns the clamped value
  1708. */
  1709. static Clamp(value: number, min?: number, max?: number): number;
  1710. /**
  1711. * the log2 of value.
  1712. * @param value the value to compute log2 of
  1713. * @returns the log2 of value.
  1714. */
  1715. static Log2(value: number): number;
  1716. /**
  1717. * Loops the value, so that it is never larger than length and never smaller than 0.
  1718. *
  1719. * This is similar to the modulo operator but it works with floating point numbers.
  1720. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1721. * With t = 5 and length = 2.5, the result would be 0.0.
  1722. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1723. * @param value the value
  1724. * @param length the length
  1725. * @returns the looped value
  1726. */
  1727. static Repeat(value: number, length: number): number;
  1728. /**
  1729. * Normalize the value between 0.0 and 1.0 using min and max values
  1730. * @param value value to normalize
  1731. * @param min max to normalize between
  1732. * @param max min to normalize between
  1733. * @returns the normalized value
  1734. */
  1735. static Normalize(value: number, min: number, max: number): number;
  1736. /**
  1737. * Denormalize the value from 0.0 and 1.0 using min and max values
  1738. * @param normalized value to denormalize
  1739. * @param min max to denormalize between
  1740. * @param max min to denormalize between
  1741. * @returns the denormalized value
  1742. */
  1743. static Denormalize(normalized: number, min: number, max: number): number;
  1744. /**
  1745. * Calculates the shortest difference between two given angles given in degrees.
  1746. * @param current current angle in degrees
  1747. * @param target target angle in degrees
  1748. * @returns the delta
  1749. */
  1750. static DeltaAngle(current: number, target: number): number;
  1751. /**
  1752. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1753. * @param tx value
  1754. * @param length length
  1755. * @returns The returned value will move back and forth between 0 and length
  1756. */
  1757. static PingPong(tx: number, length: number): number;
  1758. /**
  1759. * Interpolates between min and max with smoothing at the limits.
  1760. *
  1761. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1762. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1763. * @param from from
  1764. * @param to to
  1765. * @param tx value
  1766. * @returns the smooth stepped value
  1767. */
  1768. static SmoothStep(from: number, to: number, tx: number): number;
  1769. /**
  1770. * Moves a value current towards target.
  1771. *
  1772. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1773. * Negative values of maxDelta pushes the value away from target.
  1774. * @param current current value
  1775. * @param target target value
  1776. * @param maxDelta max distance to move
  1777. * @returns resulting value
  1778. */
  1779. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1780. /**
  1781. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1782. *
  1783. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1784. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1785. * @param current current value
  1786. * @param target target value
  1787. * @param maxDelta max distance to move
  1788. * @returns resulting angle
  1789. */
  1790. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1791. /**
  1792. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1793. * @param start start value
  1794. * @param end target value
  1795. * @param amount amount to lerp between
  1796. * @returns the lerped value
  1797. */
  1798. static Lerp(start: number, end: number, amount: number): number;
  1799. /**
  1800. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1801. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1802. * @param start start value
  1803. * @param end target value
  1804. * @param amount amount to lerp between
  1805. * @returns the lerped value
  1806. */
  1807. static LerpAngle(start: number, end: number, amount: number): number;
  1808. /**
  1809. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1810. * @param a start value
  1811. * @param b target value
  1812. * @param value value between a and b
  1813. * @returns the inverseLerp value
  1814. */
  1815. static InverseLerp(a: number, b: number, value: number): number;
  1816. /**
  1817. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1818. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1819. * @param value1 spline value
  1820. * @param tangent1 spline value
  1821. * @param value2 spline value
  1822. * @param tangent2 spline value
  1823. * @param amount input value
  1824. * @returns hermite result
  1825. */
  1826. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1827. /**
  1828. * Returns a random float number between and min and max values
  1829. * @param min min value of random
  1830. * @param max max value of random
  1831. * @returns random value
  1832. */
  1833. static RandomRange(min: number, max: number): number;
  1834. /**
  1835. * This function returns percentage of a number in a given range.
  1836. *
  1837. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1838. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1839. * @param number to convert to percentage
  1840. * @param min min range
  1841. * @param max max range
  1842. * @returns the percentage
  1843. */
  1844. static RangeToPercent(number: number, min: number, max: number): number;
  1845. /**
  1846. * This function returns number that corresponds to the percentage in a given range.
  1847. *
  1848. * PercentToRange(0.34,0,100) will return 34.
  1849. * @param percent to convert to number
  1850. * @param min min range
  1851. * @param max max range
  1852. * @returns the number
  1853. */
  1854. static PercentToRange(percent: number, min: number, max: number): number;
  1855. /**
  1856. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1857. * @param angle The angle to normalize in radian.
  1858. * @return The converted angle.
  1859. */
  1860. static NormalizeRadians(angle: number): number;
  1861. }
  1862. }
  1863. declare module "babylonjs/Maths/math.constants" {
  1864. /**
  1865. * Constant used to convert a value to gamma space
  1866. * @ignorenaming
  1867. */
  1868. export const ToGammaSpace: number;
  1869. /**
  1870. * Constant used to convert a value to linear space
  1871. * @ignorenaming
  1872. */
  1873. export const ToLinearSpace = 2.2;
  1874. /**
  1875. * Constant used to define the minimal number value in Babylon.js
  1876. * @ignorenaming
  1877. */
  1878. let Epsilon: number;
  1879. export { Epsilon };
  1880. }
  1881. declare module "babylonjs/Maths/math.viewport" {
  1882. /**
  1883. * Class used to represent a viewport on screen
  1884. */
  1885. export class Viewport {
  1886. /** viewport left coordinate */
  1887. x: number;
  1888. /** viewport top coordinate */
  1889. y: number;
  1890. /**viewport width */
  1891. width: number;
  1892. /** viewport height */
  1893. height: number;
  1894. /**
  1895. * Creates a Viewport object located at (x, y) and sized (width, height)
  1896. * @param x defines viewport left coordinate
  1897. * @param y defines viewport top coordinate
  1898. * @param width defines the viewport width
  1899. * @param height defines the viewport height
  1900. */
  1901. constructor(
  1902. /** viewport left coordinate */
  1903. x: number,
  1904. /** viewport top coordinate */
  1905. y: number,
  1906. /**viewport width */
  1907. width: number,
  1908. /** viewport height */
  1909. height: number);
  1910. /**
  1911. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1912. * @param renderWidth defines the rendering width
  1913. * @param renderHeight defines the rendering height
  1914. * @returns a new Viewport
  1915. */
  1916. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1917. /**
  1918. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1919. * @param renderWidth defines the rendering width
  1920. * @param renderHeight defines the rendering height
  1921. * @param ref defines the target viewport
  1922. * @returns the current viewport
  1923. */
  1924. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1925. /**
  1926. * Returns a new Viewport copied from the current one
  1927. * @returns a new Viewport
  1928. */
  1929. clone(): Viewport;
  1930. }
  1931. }
  1932. declare module "babylonjs/Misc/arrayTools" {
  1933. /**
  1934. * Class containing a set of static utilities functions for arrays.
  1935. */
  1936. export class ArrayTools {
  1937. /**
  1938. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1939. * @param size the number of element to construct and put in the array
  1940. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1941. * @returns a new array filled with new objects
  1942. */
  1943. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1944. }
  1945. }
  1946. declare module "babylonjs/Maths/math.vector" {
  1947. import { Viewport } from "babylonjs/Maths/math.viewport";
  1948. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1949. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1950. /**
  1951. * Class representing a vector containing 2 coordinates
  1952. */
  1953. export class Vector2 {
  1954. /** defines the first coordinate */
  1955. x: number;
  1956. /** defines the second coordinate */
  1957. y: number;
  1958. /**
  1959. * Creates a new Vector2 from the given x and y coordinates
  1960. * @param x defines the first coordinate
  1961. * @param y defines the second coordinate
  1962. */
  1963. constructor(
  1964. /** defines the first coordinate */
  1965. x?: number,
  1966. /** defines the second coordinate */
  1967. y?: number);
  1968. /**
  1969. * Gets a string with the Vector2 coordinates
  1970. * @returns a string with the Vector2 coordinates
  1971. */
  1972. toString(): string;
  1973. /**
  1974. * Gets class name
  1975. * @returns the string "Vector2"
  1976. */
  1977. getClassName(): string;
  1978. /**
  1979. * Gets current vector hash code
  1980. * @returns the Vector2 hash code as a number
  1981. */
  1982. getHashCode(): number;
  1983. /**
  1984. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1985. * @param array defines the source array
  1986. * @param index defines the offset in source array
  1987. * @returns the current Vector2
  1988. */
  1989. toArray(array: FloatArray, index?: number): Vector2;
  1990. /**
  1991. * Copy the current vector to an array
  1992. * @returns a new array with 2 elements: the Vector2 coordinates.
  1993. */
  1994. asArray(): number[];
  1995. /**
  1996. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1997. * @param source defines the source Vector2
  1998. * @returns the current updated Vector2
  1999. */
  2000. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2001. /**
  2002. * Sets the Vector2 coordinates with the given floats
  2003. * @param x defines the first coordinate
  2004. * @param y defines the second coordinate
  2005. * @returns the current updated Vector2
  2006. */
  2007. copyFromFloats(x: number, y: number): Vector2;
  2008. /**
  2009. * Sets the Vector2 coordinates with the given floats
  2010. * @param x defines the first coordinate
  2011. * @param y defines the second coordinate
  2012. * @returns the current updated Vector2
  2013. */
  2014. set(x: number, y: number): Vector2;
  2015. /**
  2016. * Add another vector with the current one
  2017. * @param otherVector defines the other vector
  2018. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2019. */
  2020. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2021. /**
  2022. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2023. * @param otherVector defines the other vector
  2024. * @param result defines the target vector
  2025. * @returns the unmodified current Vector2
  2026. */
  2027. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2028. /**
  2029. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2030. * @param otherVector defines the other vector
  2031. * @returns the current updated Vector2
  2032. */
  2033. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2034. /**
  2035. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2036. * @param otherVector defines the other vector
  2037. * @returns a new Vector2
  2038. */
  2039. addVector3(otherVector: Vector3): Vector2;
  2040. /**
  2041. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2042. * @param otherVector defines the other vector
  2043. * @returns a new Vector2
  2044. */
  2045. subtract(otherVector: Vector2): Vector2;
  2046. /**
  2047. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2048. * @param otherVector defines the other vector
  2049. * @param result defines the target vector
  2050. * @returns the unmodified current Vector2
  2051. */
  2052. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2053. /**
  2054. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2055. * @param otherVector defines the other vector
  2056. * @returns the current updated Vector2
  2057. */
  2058. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2059. /**
  2060. * Multiplies in place the current Vector2 coordinates by the given ones
  2061. * @param otherVector defines the other vector
  2062. * @returns the current updated Vector2
  2063. */
  2064. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2065. /**
  2066. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2067. * @param otherVector defines the other vector
  2068. * @returns a new Vector2
  2069. */
  2070. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2071. /**
  2072. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2073. * @param otherVector defines the other vector
  2074. * @param result defines the target vector
  2075. * @returns the unmodified current Vector2
  2076. */
  2077. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2078. /**
  2079. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2080. * @param x defines the first coordinate
  2081. * @param y defines the second coordinate
  2082. * @returns a new Vector2
  2083. */
  2084. multiplyByFloats(x: number, y: number): Vector2;
  2085. /**
  2086. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2087. * @param otherVector defines the other vector
  2088. * @returns a new Vector2
  2089. */
  2090. divide(otherVector: Vector2): Vector2;
  2091. /**
  2092. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2093. * @param otherVector defines the other vector
  2094. * @param result defines the target vector
  2095. * @returns the unmodified current Vector2
  2096. */
  2097. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2098. /**
  2099. * Divides the current Vector2 coordinates by the given ones
  2100. * @param otherVector defines the other vector
  2101. * @returns the current updated Vector2
  2102. */
  2103. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2104. /**
  2105. * Gets a new Vector2 with current Vector2 negated coordinates
  2106. * @returns a new Vector2
  2107. */
  2108. negate(): Vector2;
  2109. /**
  2110. * Multiply the Vector2 coordinates by scale
  2111. * @param scale defines the scaling factor
  2112. * @returns the current updated Vector2
  2113. */
  2114. scaleInPlace(scale: number): Vector2;
  2115. /**
  2116. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2117. * @param scale defines the scaling factor
  2118. * @returns a new Vector2
  2119. */
  2120. scale(scale: number): Vector2;
  2121. /**
  2122. * Scale the current Vector2 values by a factor to a given Vector2
  2123. * @param scale defines the scale factor
  2124. * @param result defines the Vector2 object where to store the result
  2125. * @returns the unmodified current Vector2
  2126. */
  2127. scaleToRef(scale: number, result: Vector2): Vector2;
  2128. /**
  2129. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2130. * @param scale defines the scale factor
  2131. * @param result defines the Vector2 object where to store the result
  2132. * @returns the unmodified current Vector2
  2133. */
  2134. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2135. /**
  2136. * Gets a boolean if two vectors are equals
  2137. * @param otherVector defines the other vector
  2138. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2139. */
  2140. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2141. /**
  2142. * Gets a boolean if two vectors are equals (using an epsilon value)
  2143. * @param otherVector defines the other vector
  2144. * @param epsilon defines the minimal distance to consider equality
  2145. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2146. */
  2147. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2148. /**
  2149. * Gets a new Vector2 from current Vector2 floored values
  2150. * @returns a new Vector2
  2151. */
  2152. floor(): Vector2;
  2153. /**
  2154. * Gets a new Vector2 from current Vector2 floored values
  2155. * @returns a new Vector2
  2156. */
  2157. fract(): Vector2;
  2158. /**
  2159. * Gets the length of the vector
  2160. * @returns the vector length (float)
  2161. */
  2162. length(): number;
  2163. /**
  2164. * Gets the vector squared length
  2165. * @returns the vector squared length (float)
  2166. */
  2167. lengthSquared(): number;
  2168. /**
  2169. * Normalize the vector
  2170. * @returns the current updated Vector2
  2171. */
  2172. normalize(): Vector2;
  2173. /**
  2174. * Gets a new Vector2 copied from the Vector2
  2175. * @returns a new Vector2
  2176. */
  2177. clone(): Vector2;
  2178. /**
  2179. * Gets a new Vector2(0, 0)
  2180. * @returns a new Vector2
  2181. */
  2182. static Zero(): Vector2;
  2183. /**
  2184. * Gets a new Vector2(1, 1)
  2185. * @returns a new Vector2
  2186. */
  2187. static One(): Vector2;
  2188. /**
  2189. * Gets a new Vector2 set from the given index element of the given array
  2190. * @param array defines the data source
  2191. * @param offset defines the offset in the data source
  2192. * @returns a new Vector2
  2193. */
  2194. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2195. /**
  2196. * Sets "result" from the given index element of the given array
  2197. * @param array defines the data source
  2198. * @param offset defines the offset in the data source
  2199. * @param result defines the target vector
  2200. */
  2201. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2202. /**
  2203. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2204. * @param value1 defines 1st point of control
  2205. * @param value2 defines 2nd point of control
  2206. * @param value3 defines 3rd point of control
  2207. * @param value4 defines 4th point of control
  2208. * @param amount defines the interpolation factor
  2209. * @returns a new Vector2
  2210. */
  2211. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2212. /**
  2213. * 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".
  2214. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2215. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2216. * @param value defines the value to clamp
  2217. * @param min defines the lower limit
  2218. * @param max defines the upper limit
  2219. * @returns a new Vector2
  2220. */
  2221. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2222. /**
  2223. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2224. * @param value1 defines the 1st control point
  2225. * @param tangent1 defines the outgoing tangent
  2226. * @param value2 defines the 2nd control point
  2227. * @param tangent2 defines the incoming tangent
  2228. * @param amount defines the interpolation factor
  2229. * @returns a new Vector2
  2230. */
  2231. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2232. /**
  2233. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2234. * @param start defines the start vector
  2235. * @param end defines the end vector
  2236. * @param amount defines the interpolation factor
  2237. * @returns a new Vector2
  2238. */
  2239. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2240. /**
  2241. * Gets the dot product of the vector "left" and the vector "right"
  2242. * @param left defines first vector
  2243. * @param right defines second vector
  2244. * @returns the dot product (float)
  2245. */
  2246. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2247. /**
  2248. * Returns a new Vector2 equal to the normalized given vector
  2249. * @param vector defines the vector to normalize
  2250. * @returns a new Vector2
  2251. */
  2252. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2253. /**
  2254. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2255. * @param left defines 1st vector
  2256. * @param right defines 2nd vector
  2257. * @returns a new Vector2
  2258. */
  2259. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2260. /**
  2261. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2262. * @param left defines 1st vector
  2263. * @param right defines 2nd vector
  2264. * @returns a new Vector2
  2265. */
  2266. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2267. /**
  2268. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2269. * @param vector defines the vector to transform
  2270. * @param transformation defines the matrix to apply
  2271. * @returns a new Vector2
  2272. */
  2273. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2274. /**
  2275. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2276. * @param vector defines the vector to transform
  2277. * @param transformation defines the matrix to apply
  2278. * @param result defines the target vector
  2279. */
  2280. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2281. /**
  2282. * Determines if a given vector is included in a triangle
  2283. * @param p defines the vector to test
  2284. * @param p0 defines 1st triangle point
  2285. * @param p1 defines 2nd triangle point
  2286. * @param p2 defines 3rd triangle point
  2287. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2288. */
  2289. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2290. /**
  2291. * Gets the distance between the vectors "value1" and "value2"
  2292. * @param value1 defines first vector
  2293. * @param value2 defines second vector
  2294. * @returns the distance between vectors
  2295. */
  2296. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2297. /**
  2298. * Returns the squared distance between the vectors "value1" and "value2"
  2299. * @param value1 defines first vector
  2300. * @param value2 defines second vector
  2301. * @returns the squared distance between vectors
  2302. */
  2303. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2304. /**
  2305. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2306. * @param value1 defines first vector
  2307. * @param value2 defines second vector
  2308. * @returns a new Vector2
  2309. */
  2310. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2311. /**
  2312. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2313. * @param p defines the middle point
  2314. * @param segA defines one point of the segment
  2315. * @param segB defines the other point of the segment
  2316. * @returns the shortest distance
  2317. */
  2318. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2319. }
  2320. /**
  2321. * Class used to store (x,y,z) vector representation
  2322. * A Vector3 is the main object used in 3D geometry
  2323. * It can represent etiher the coordinates of a point the space, either a direction
  2324. * Reminder: js uses a left handed forward facing system
  2325. */
  2326. export class Vector3 {
  2327. /**
  2328. * Defines the first coordinates (on X axis)
  2329. */
  2330. x: number;
  2331. /**
  2332. * Defines the second coordinates (on Y axis)
  2333. */
  2334. y: number;
  2335. /**
  2336. * Defines the third coordinates (on Z axis)
  2337. */
  2338. z: number;
  2339. private static _UpReadOnly;
  2340. private static _ZeroReadOnly;
  2341. /**
  2342. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2343. * @param x defines the first coordinates (on X axis)
  2344. * @param y defines the second coordinates (on Y axis)
  2345. * @param z defines the third coordinates (on Z axis)
  2346. */
  2347. constructor(
  2348. /**
  2349. * Defines the first coordinates (on X axis)
  2350. */
  2351. x?: number,
  2352. /**
  2353. * Defines the second coordinates (on Y axis)
  2354. */
  2355. y?: number,
  2356. /**
  2357. * Defines the third coordinates (on Z axis)
  2358. */
  2359. z?: number);
  2360. /**
  2361. * Creates a string representation of the Vector3
  2362. * @returns a string with the Vector3 coordinates.
  2363. */
  2364. toString(): string;
  2365. /**
  2366. * Gets the class name
  2367. * @returns the string "Vector3"
  2368. */
  2369. getClassName(): string;
  2370. /**
  2371. * Creates the Vector3 hash code
  2372. * @returns a number which tends to be unique between Vector3 instances
  2373. */
  2374. getHashCode(): number;
  2375. /**
  2376. * Creates an array containing three elements : the coordinates of the Vector3
  2377. * @returns a new array of numbers
  2378. */
  2379. asArray(): number[];
  2380. /**
  2381. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2382. * @param array defines the destination array
  2383. * @param index defines the offset in the destination array
  2384. * @returns the current Vector3
  2385. */
  2386. toArray(array: FloatArray, index?: number): Vector3;
  2387. /**
  2388. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2389. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2390. */
  2391. toQuaternion(): Quaternion;
  2392. /**
  2393. * Adds the given vector to the current Vector3
  2394. * @param otherVector defines the second operand
  2395. * @returns the current updated Vector3
  2396. */
  2397. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2398. /**
  2399. * Adds the given coordinates to the current Vector3
  2400. * @param x defines the x coordinate of the operand
  2401. * @param y defines the y coordinate of the operand
  2402. * @param z defines the z coordinate of the operand
  2403. * @returns the current updated Vector3
  2404. */
  2405. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2406. /**
  2407. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2408. * @param otherVector defines the second operand
  2409. * @returns the resulting Vector3
  2410. */
  2411. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2412. /**
  2413. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2414. * @param otherVector defines the second operand
  2415. * @param result defines the Vector3 object where to store the result
  2416. * @returns the current Vector3
  2417. */
  2418. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2419. /**
  2420. * Subtract the given vector from the current Vector3
  2421. * @param otherVector defines the second operand
  2422. * @returns the current updated Vector3
  2423. */
  2424. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2425. /**
  2426. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2427. * @param otherVector defines the second operand
  2428. * @returns the resulting Vector3
  2429. */
  2430. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2431. /**
  2432. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2433. * @param otherVector defines the second operand
  2434. * @param result defines the Vector3 object where to store the result
  2435. * @returns the current Vector3
  2436. */
  2437. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2438. /**
  2439. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2440. * @param x defines the x coordinate of the operand
  2441. * @param y defines the y coordinate of the operand
  2442. * @param z defines the z coordinate of the operand
  2443. * @returns the resulting Vector3
  2444. */
  2445. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2446. /**
  2447. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2448. * @param x defines the x coordinate of the operand
  2449. * @param y defines the y coordinate of the operand
  2450. * @param z defines the z coordinate of the operand
  2451. * @param result defines the Vector3 object where to store the result
  2452. * @returns the current Vector3
  2453. */
  2454. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2455. /**
  2456. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2457. * @returns a new Vector3
  2458. */
  2459. negate(): Vector3;
  2460. /**
  2461. * Multiplies the Vector3 coordinates by the float "scale"
  2462. * @param scale defines the multiplier factor
  2463. * @returns the current updated Vector3
  2464. */
  2465. scaleInPlace(scale: number): Vector3;
  2466. /**
  2467. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2468. * @param scale defines the multiplier factor
  2469. * @returns a new Vector3
  2470. */
  2471. scale(scale: number): Vector3;
  2472. /**
  2473. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2474. * @param scale defines the multiplier factor
  2475. * @param result defines the Vector3 object where to store the result
  2476. * @returns the current Vector3
  2477. */
  2478. scaleToRef(scale: number, result: Vector3): Vector3;
  2479. /**
  2480. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2481. * @param scale defines the scale factor
  2482. * @param result defines the Vector3 object where to store the result
  2483. * @returns the unmodified current Vector3
  2484. */
  2485. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2486. /**
  2487. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2488. * @param otherVector defines the second operand
  2489. * @returns true if both vectors are equals
  2490. */
  2491. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2492. /**
  2493. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2494. * @param otherVector defines the second operand
  2495. * @param epsilon defines the minimal distance to define values as equals
  2496. * @returns true if both vectors are distant less than epsilon
  2497. */
  2498. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2499. /**
  2500. * Returns true if the current Vector3 coordinates equals the given floats
  2501. * @param x defines the x coordinate of the operand
  2502. * @param y defines the y coordinate of the operand
  2503. * @param z defines the z coordinate of the operand
  2504. * @returns true if both vectors are equals
  2505. */
  2506. equalsToFloats(x: number, y: number, z: number): boolean;
  2507. /**
  2508. * Multiplies the current Vector3 coordinates by the given ones
  2509. * @param otherVector defines the second operand
  2510. * @returns the current updated Vector3
  2511. */
  2512. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2513. /**
  2514. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2515. * @param otherVector defines the second operand
  2516. * @returns the new Vector3
  2517. */
  2518. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2519. /**
  2520. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2521. * @param otherVector defines the second operand
  2522. * @param result defines the Vector3 object where to store the result
  2523. * @returns the current Vector3
  2524. */
  2525. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2526. /**
  2527. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2528. * @param x defines the x coordinate of the operand
  2529. * @param y defines the y coordinate of the operand
  2530. * @param z defines the z coordinate of the operand
  2531. * @returns the new Vector3
  2532. */
  2533. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2534. /**
  2535. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2536. * @param otherVector defines the second operand
  2537. * @returns the new Vector3
  2538. */
  2539. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2540. /**
  2541. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2542. * @param otherVector defines the second operand
  2543. * @param result defines the Vector3 object where to store the result
  2544. * @returns the current Vector3
  2545. */
  2546. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2547. /**
  2548. * Divides the current Vector3 coordinates by the given ones.
  2549. * @param otherVector defines the second operand
  2550. * @returns the current updated Vector3
  2551. */
  2552. divideInPlace(otherVector: Vector3): Vector3;
  2553. /**
  2554. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2555. * @param other defines the second operand
  2556. * @returns the current updated Vector3
  2557. */
  2558. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2559. /**
  2560. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2561. * @param other defines the second operand
  2562. * @returns the current updated Vector3
  2563. */
  2564. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2565. /**
  2566. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2567. * @param x defines the x coordinate of the operand
  2568. * @param y defines the y coordinate of the operand
  2569. * @param z defines the z coordinate of the operand
  2570. * @returns the current updated Vector3
  2571. */
  2572. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2573. /**
  2574. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2575. * @param x defines the x coordinate of the operand
  2576. * @param y defines the y coordinate of the operand
  2577. * @param z defines the z coordinate of the operand
  2578. * @returns the current updated Vector3
  2579. */
  2580. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2581. /**
  2582. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2583. * Check if is non uniform within a certain amount of decimal places to account for this
  2584. * @param epsilon the amount the values can differ
  2585. * @returns if the the vector is non uniform to a certain number of decimal places
  2586. */
  2587. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2588. /**
  2589. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2590. */
  2591. get isNonUniform(): boolean;
  2592. /**
  2593. * Gets a new Vector3 from current Vector3 floored values
  2594. * @returns a new Vector3
  2595. */
  2596. floor(): Vector3;
  2597. /**
  2598. * Gets a new Vector3 from current Vector3 floored values
  2599. * @returns a new Vector3
  2600. */
  2601. fract(): Vector3;
  2602. /**
  2603. * Gets the length of the Vector3
  2604. * @returns the length of the Vector3
  2605. */
  2606. length(): number;
  2607. /**
  2608. * Gets the squared length of the Vector3
  2609. * @returns squared length of the Vector3
  2610. */
  2611. lengthSquared(): number;
  2612. /**
  2613. * Normalize the current Vector3.
  2614. * Please note that this is an in place operation.
  2615. * @returns the current updated Vector3
  2616. */
  2617. normalize(): Vector3;
  2618. /**
  2619. * Reorders the x y z properties of the vector in place
  2620. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2621. * @returns the current updated vector
  2622. */
  2623. reorderInPlace(order: string): this;
  2624. /**
  2625. * Rotates the vector around 0,0,0 by a quaternion
  2626. * @param quaternion the rotation quaternion
  2627. * @param result vector to store the result
  2628. * @returns the resulting vector
  2629. */
  2630. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2631. /**
  2632. * Rotates a vector around a given point
  2633. * @param quaternion the rotation quaternion
  2634. * @param point the point to rotate around
  2635. * @param result vector to store the result
  2636. * @returns the resulting vector
  2637. */
  2638. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2639. /**
  2640. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2641. * The cross product is then orthogonal to both current and "other"
  2642. * @param other defines the right operand
  2643. * @returns the cross product
  2644. */
  2645. cross(other: Vector3): Vector3;
  2646. /**
  2647. * Normalize the current Vector3 with the given input length.
  2648. * Please note that this is an in place operation.
  2649. * @param len the length of the vector
  2650. * @returns the current updated Vector3
  2651. */
  2652. normalizeFromLength(len: number): Vector3;
  2653. /**
  2654. * Normalize the current Vector3 to a new vector
  2655. * @returns the new Vector3
  2656. */
  2657. normalizeToNew(): Vector3;
  2658. /**
  2659. * Normalize the current Vector3 to the reference
  2660. * @param reference define the Vector3 to update
  2661. * @returns the updated Vector3
  2662. */
  2663. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2664. /**
  2665. * Creates a new Vector3 copied from the current Vector3
  2666. * @returns the new Vector3
  2667. */
  2668. clone(): Vector3;
  2669. /**
  2670. * Copies the given vector coordinates to the current Vector3 ones
  2671. * @param source defines the source Vector3
  2672. * @returns the current updated Vector3
  2673. */
  2674. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2675. /**
  2676. * Copies the given floats to the current Vector3 coordinates
  2677. * @param x defines the x coordinate of the operand
  2678. * @param y defines the y coordinate of the operand
  2679. * @param z defines the z coordinate of the operand
  2680. * @returns the current updated Vector3
  2681. */
  2682. copyFromFloats(x: number, y: number, z: number): Vector3;
  2683. /**
  2684. * Copies the given floats to the current Vector3 coordinates
  2685. * @param x defines the x coordinate of the operand
  2686. * @param y defines the y coordinate of the operand
  2687. * @param z defines the z coordinate of the operand
  2688. * @returns the current updated Vector3
  2689. */
  2690. set(x: number, y: number, z: number): Vector3;
  2691. /**
  2692. * Copies the given float to the current Vector3 coordinates
  2693. * @param v defines the x, y and z coordinates of the operand
  2694. * @returns the current updated Vector3
  2695. */
  2696. setAll(v: number): Vector3;
  2697. /**
  2698. * Get the clip factor between two vectors
  2699. * @param vector0 defines the first operand
  2700. * @param vector1 defines the second operand
  2701. * @param axis defines the axis to use
  2702. * @param size defines the size along the axis
  2703. * @returns the clip factor
  2704. */
  2705. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2706. /**
  2707. * Get angle between two vectors
  2708. * @param vector0 angle between vector0 and vector1
  2709. * @param vector1 angle between vector0 and vector1
  2710. * @param normal direction of the normal
  2711. * @return the angle between vector0 and vector1
  2712. */
  2713. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2714. /**
  2715. * Returns a new Vector3 set from the index "offset" of the given array
  2716. * @param array defines the source array
  2717. * @param offset defines the offset in the source array
  2718. * @returns the new Vector3
  2719. */
  2720. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2721. /**
  2722. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2723. * @param array defines the source array
  2724. * @param offset defines the offset in the source array
  2725. * @returns the new Vector3
  2726. * @deprecated Please use FromArray instead.
  2727. */
  2728. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2729. /**
  2730. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2731. * @param array defines the source array
  2732. * @param offset defines the offset in the source array
  2733. * @param result defines the Vector3 where to store the result
  2734. */
  2735. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2736. /**
  2737. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2738. * @param array defines the source array
  2739. * @param offset defines the offset in the source array
  2740. * @param result defines the Vector3 where to store the result
  2741. * @deprecated Please use FromArrayToRef instead.
  2742. */
  2743. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2744. /**
  2745. * Sets the given vector "result" with the given floats.
  2746. * @param x defines the x coordinate of the source
  2747. * @param y defines the y coordinate of the source
  2748. * @param z defines the z coordinate of the source
  2749. * @param result defines the Vector3 where to store the result
  2750. */
  2751. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2752. /**
  2753. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2754. * @returns a new empty Vector3
  2755. */
  2756. static Zero(): Vector3;
  2757. /**
  2758. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2759. * @returns a new unit Vector3
  2760. */
  2761. static One(): Vector3;
  2762. /**
  2763. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2764. * @returns a new up Vector3
  2765. */
  2766. static Up(): Vector3;
  2767. /**
  2768. * Gets a up Vector3 that must not be updated
  2769. */
  2770. static get UpReadOnly(): DeepImmutable<Vector3>;
  2771. /**
  2772. * Gets a zero Vector3 that must not be updated
  2773. */
  2774. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2775. /**
  2776. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2777. * @returns a new down Vector3
  2778. */
  2779. static Down(): Vector3;
  2780. /**
  2781. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2782. * @returns a new forward Vector3
  2783. */
  2784. static Forward(): Vector3;
  2785. /**
  2786. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2787. * @returns a new forward Vector3
  2788. */
  2789. static Backward(): Vector3;
  2790. /**
  2791. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2792. * @returns a new right Vector3
  2793. */
  2794. static Right(): Vector3;
  2795. /**
  2796. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2797. * @returns a new left Vector3
  2798. */
  2799. static Left(): Vector3;
  2800. /**
  2801. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2802. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2803. * @param vector defines the Vector3 to transform
  2804. * @param transformation defines the transformation matrix
  2805. * @returns the transformed Vector3
  2806. */
  2807. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2808. /**
  2809. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2810. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2811. * @param vector defines the Vector3 to transform
  2812. * @param transformation defines the transformation matrix
  2813. * @param result defines the Vector3 where to store the result
  2814. */
  2815. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2816. /**
  2817. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2818. * This method computes tranformed coordinates only, not transformed direction vectors
  2819. * @param x define the x coordinate of the source vector
  2820. * @param y define the y coordinate of the source vector
  2821. * @param z define the z coordinate of the source vector
  2822. * @param transformation defines the transformation matrix
  2823. * @param result defines the Vector3 where to store the result
  2824. */
  2825. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2826. /**
  2827. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2828. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2829. * @param vector defines the Vector3 to transform
  2830. * @param transformation defines the transformation matrix
  2831. * @returns the new Vector3
  2832. */
  2833. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2834. /**
  2835. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2836. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2837. * @param vector defines the Vector3 to transform
  2838. * @param transformation defines the transformation matrix
  2839. * @param result defines the Vector3 where to store the result
  2840. */
  2841. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2842. /**
  2843. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2844. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2845. * @param x define the x coordinate of the source vector
  2846. * @param y define the y coordinate of the source vector
  2847. * @param z define the z coordinate of the source vector
  2848. * @param transformation defines the transformation matrix
  2849. * @param result defines the Vector3 where to store the result
  2850. */
  2851. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2852. /**
  2853. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2854. * @param value1 defines the first control point
  2855. * @param value2 defines the second control point
  2856. * @param value3 defines the third control point
  2857. * @param value4 defines the fourth control point
  2858. * @param amount defines the amount on the spline to use
  2859. * @returns the new Vector3
  2860. */
  2861. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2862. /**
  2863. * 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"
  2864. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2865. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2866. * @param value defines the current value
  2867. * @param min defines the lower range value
  2868. * @param max defines the upper range value
  2869. * @returns the new Vector3
  2870. */
  2871. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2872. /**
  2873. * 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"
  2874. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2875. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2876. * @param value defines the current value
  2877. * @param min defines the lower range value
  2878. * @param max defines the upper range value
  2879. * @param result defines the Vector3 where to store the result
  2880. */
  2881. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2882. /**
  2883. * Checks if a given vector is inside a specific range
  2884. * @param v defines the vector to test
  2885. * @param min defines the minimum range
  2886. * @param max defines the maximum range
  2887. */
  2888. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2889. /**
  2890. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2891. * @param value1 defines the first control point
  2892. * @param tangent1 defines the first tangent vector
  2893. * @param value2 defines the second control point
  2894. * @param tangent2 defines the second tangent vector
  2895. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2896. * @returns the new Vector3
  2897. */
  2898. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2899. /**
  2900. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2901. * @param start defines the start value
  2902. * @param end defines the end value
  2903. * @param amount max defines amount between both (between 0 and 1)
  2904. * @returns the new Vector3
  2905. */
  2906. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2907. /**
  2908. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2909. * @param start defines the start value
  2910. * @param end defines the end value
  2911. * @param amount max defines amount between both (between 0 and 1)
  2912. * @param result defines the Vector3 where to store the result
  2913. */
  2914. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2915. /**
  2916. * Returns the dot product (float) between the vectors "left" and "right"
  2917. * @param left defines the left operand
  2918. * @param right defines the right operand
  2919. * @returns the dot product
  2920. */
  2921. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2922. /**
  2923. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2924. * The cross product is then orthogonal to both "left" and "right"
  2925. * @param left defines the left operand
  2926. * @param right defines the right operand
  2927. * @returns the cross product
  2928. */
  2929. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2930. /**
  2931. * Sets the given vector "result" with the cross product of "left" and "right"
  2932. * The cross product is then orthogonal to both "left" and "right"
  2933. * @param left defines the left operand
  2934. * @param right defines the right operand
  2935. * @param result defines the Vector3 where to store the result
  2936. */
  2937. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2938. /**
  2939. * Returns a new Vector3 as the normalization of the given vector
  2940. * @param vector defines the Vector3 to normalize
  2941. * @returns the new Vector3
  2942. */
  2943. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2944. /**
  2945. * Sets the given vector "result" with the normalization of the given first vector
  2946. * @param vector defines the Vector3 to normalize
  2947. * @param result defines the Vector3 where to store the result
  2948. */
  2949. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2950. /**
  2951. * Project a Vector3 onto screen space
  2952. * @param vector defines the Vector3 to project
  2953. * @param world defines the world matrix to use
  2954. * @param transform defines the transform (view x projection) matrix to use
  2955. * @param viewport defines the screen viewport to use
  2956. * @returns the new Vector3
  2957. */
  2958. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2959. /** @hidden */
  2960. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2961. /**
  2962. * Unproject from screen space to object space
  2963. * @param source defines the screen space Vector3 to use
  2964. * @param viewportWidth defines the current width of the viewport
  2965. * @param viewportHeight defines the current height of the viewport
  2966. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2967. * @param transform defines the transform (view x projection) matrix to use
  2968. * @returns the new Vector3
  2969. */
  2970. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2971. /**
  2972. * Unproject from screen space to object space
  2973. * @param source defines the screen space Vector3 to use
  2974. * @param viewportWidth defines the current width of the viewport
  2975. * @param viewportHeight defines the current height of the viewport
  2976. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2977. * @param view defines the view matrix to use
  2978. * @param projection defines the projection matrix to use
  2979. * @returns the new Vector3
  2980. */
  2981. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2982. /**
  2983. * Unproject from screen space to object space
  2984. * @param source defines the screen space Vector3 to use
  2985. * @param viewportWidth defines the current width of the viewport
  2986. * @param viewportHeight defines the current height of the viewport
  2987. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2988. * @param view defines the view matrix to use
  2989. * @param projection defines the projection matrix to use
  2990. * @param result defines the Vector3 where to store the result
  2991. */
  2992. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2993. /**
  2994. * Unproject from screen space to object space
  2995. * @param sourceX defines the screen space x coordinate to use
  2996. * @param sourceY defines the screen space y coordinate to use
  2997. * @param sourceZ defines the screen space z coordinate to use
  2998. * @param viewportWidth defines the current width of the viewport
  2999. * @param viewportHeight defines the current height of the viewport
  3000. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3001. * @param view defines the view matrix to use
  3002. * @param projection defines the projection matrix to use
  3003. * @param result defines the Vector3 where to store the result
  3004. */
  3005. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3006. /**
  3007. * Gets the minimal coordinate values between two Vector3
  3008. * @param left defines the first operand
  3009. * @param right defines the second operand
  3010. * @returns the new Vector3
  3011. */
  3012. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3013. /**
  3014. * Gets the maximal coordinate values between two Vector3
  3015. * @param left defines the first operand
  3016. * @param right defines the second operand
  3017. * @returns the new Vector3
  3018. */
  3019. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3020. /**
  3021. * Returns the distance between the vectors "value1" and "value2"
  3022. * @param value1 defines the first operand
  3023. * @param value2 defines the second operand
  3024. * @returns the distance
  3025. */
  3026. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3027. /**
  3028. * Returns the squared distance between the vectors "value1" and "value2"
  3029. * @param value1 defines the first operand
  3030. * @param value2 defines the second operand
  3031. * @returns the squared distance
  3032. */
  3033. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3034. /**
  3035. * Returns a new Vector3 located at the center between "value1" and "value2"
  3036. * @param value1 defines the first operand
  3037. * @param value2 defines the second operand
  3038. * @returns the new Vector3
  3039. */
  3040. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3041. /**
  3042. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3043. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3044. * to something in order to rotate it from its local system to the given target system
  3045. * Note: axis1, axis2 and axis3 are normalized during this operation
  3046. * @param axis1 defines the first axis
  3047. * @param axis2 defines the second axis
  3048. * @param axis3 defines the third axis
  3049. * @returns a new Vector3
  3050. */
  3051. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3052. /**
  3053. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3054. * @param axis1 defines the first axis
  3055. * @param axis2 defines the second axis
  3056. * @param axis3 defines the third axis
  3057. * @param ref defines the Vector3 where to store the result
  3058. */
  3059. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3060. }
  3061. /**
  3062. * Vector4 class created for EulerAngle class conversion to Quaternion
  3063. */
  3064. export class Vector4 {
  3065. /** x value of the vector */
  3066. x: number;
  3067. /** y value of the vector */
  3068. y: number;
  3069. /** z value of the vector */
  3070. z: number;
  3071. /** w value of the vector */
  3072. w: number;
  3073. /**
  3074. * Creates a Vector4 object from the given floats.
  3075. * @param x x value of the vector
  3076. * @param y y value of the vector
  3077. * @param z z value of the vector
  3078. * @param w w value of the vector
  3079. */
  3080. constructor(
  3081. /** x value of the vector */
  3082. x: number,
  3083. /** y value of the vector */
  3084. y: number,
  3085. /** z value of the vector */
  3086. z: number,
  3087. /** w value of the vector */
  3088. w: number);
  3089. /**
  3090. * Returns the string with the Vector4 coordinates.
  3091. * @returns a string containing all the vector values
  3092. */
  3093. toString(): string;
  3094. /**
  3095. * Returns the string "Vector4".
  3096. * @returns "Vector4"
  3097. */
  3098. getClassName(): string;
  3099. /**
  3100. * Returns the Vector4 hash code.
  3101. * @returns a unique hash code
  3102. */
  3103. getHashCode(): number;
  3104. /**
  3105. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3106. * @returns the resulting array
  3107. */
  3108. asArray(): number[];
  3109. /**
  3110. * Populates the given array from the given index with the Vector4 coordinates.
  3111. * @param array array to populate
  3112. * @param index index of the array to start at (default: 0)
  3113. * @returns the Vector4.
  3114. */
  3115. toArray(array: FloatArray, index?: number): Vector4;
  3116. /**
  3117. * Adds the given vector to the current Vector4.
  3118. * @param otherVector the vector to add
  3119. * @returns the updated Vector4.
  3120. */
  3121. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3122. /**
  3123. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3124. * @param otherVector the vector to add
  3125. * @returns the resulting vector
  3126. */
  3127. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3128. /**
  3129. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3130. * @param otherVector the vector to add
  3131. * @param result the vector to store the result
  3132. * @returns the current Vector4.
  3133. */
  3134. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3135. /**
  3136. * Subtract in place the given vector from the current Vector4.
  3137. * @param otherVector the vector to subtract
  3138. * @returns the updated Vector4.
  3139. */
  3140. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3141. /**
  3142. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3143. * @param otherVector the vector to add
  3144. * @returns the new vector with the result
  3145. */
  3146. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3147. /**
  3148. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3149. * @param otherVector the vector to subtract
  3150. * @param result the vector to store the result
  3151. * @returns the current Vector4.
  3152. */
  3153. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3154. /**
  3155. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3156. */
  3157. /**
  3158. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3159. * @param x value to subtract
  3160. * @param y value to subtract
  3161. * @param z value to subtract
  3162. * @param w value to subtract
  3163. * @returns new vector containing the result
  3164. */
  3165. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3166. /**
  3167. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3168. * @param x value to subtract
  3169. * @param y value to subtract
  3170. * @param z value to subtract
  3171. * @param w value to subtract
  3172. * @param result the vector to store the result in
  3173. * @returns the current Vector4.
  3174. */
  3175. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3176. /**
  3177. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3178. * @returns a new vector with the negated values
  3179. */
  3180. negate(): Vector4;
  3181. /**
  3182. * Multiplies the current Vector4 coordinates by scale (float).
  3183. * @param scale the number to scale with
  3184. * @returns the updated Vector4.
  3185. */
  3186. scaleInPlace(scale: number): Vector4;
  3187. /**
  3188. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3189. * @param scale the number to scale with
  3190. * @returns a new vector with the result
  3191. */
  3192. scale(scale: number): Vector4;
  3193. /**
  3194. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3195. * @param scale the number to scale with
  3196. * @param result a vector to store the result in
  3197. * @returns the current Vector4.
  3198. */
  3199. scaleToRef(scale: number, result: Vector4): Vector4;
  3200. /**
  3201. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3202. * @param scale defines the scale factor
  3203. * @param result defines the Vector4 object where to store the result
  3204. * @returns the unmodified current Vector4
  3205. */
  3206. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3207. /**
  3208. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3209. * @param otherVector the vector to compare against
  3210. * @returns true if they are equal
  3211. */
  3212. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3213. /**
  3214. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3215. * @param otherVector vector to compare against
  3216. * @param epsilon (Default: very small number)
  3217. * @returns true if they are equal
  3218. */
  3219. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3220. /**
  3221. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3222. * @param x x value to compare against
  3223. * @param y y value to compare against
  3224. * @param z z value to compare against
  3225. * @param w w value to compare against
  3226. * @returns true if equal
  3227. */
  3228. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3229. /**
  3230. * Multiplies in place the current Vector4 by the given one.
  3231. * @param otherVector vector to multiple with
  3232. * @returns the updated Vector4.
  3233. */
  3234. multiplyInPlace(otherVector: Vector4): Vector4;
  3235. /**
  3236. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3237. * @param otherVector vector to multiple with
  3238. * @returns resulting new vector
  3239. */
  3240. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3241. /**
  3242. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3243. * @param otherVector vector to multiple with
  3244. * @param result vector to store the result
  3245. * @returns the current Vector4.
  3246. */
  3247. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3248. /**
  3249. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3250. * @param x x value multiply with
  3251. * @param y y value multiply with
  3252. * @param z z value multiply with
  3253. * @param w w value multiply with
  3254. * @returns resulting new vector
  3255. */
  3256. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3257. /**
  3258. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3259. * @param otherVector vector to devide with
  3260. * @returns resulting new vector
  3261. */
  3262. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3263. /**
  3264. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3265. * @param otherVector vector to devide with
  3266. * @param result vector to store the result
  3267. * @returns the current Vector4.
  3268. */
  3269. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3270. /**
  3271. * Divides the current Vector3 coordinates by the given ones.
  3272. * @param otherVector vector to devide with
  3273. * @returns the updated Vector3.
  3274. */
  3275. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3276. /**
  3277. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3278. * @param other defines the second operand
  3279. * @returns the current updated Vector4
  3280. */
  3281. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3282. /**
  3283. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3284. * @param other defines the second operand
  3285. * @returns the current updated Vector4
  3286. */
  3287. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3288. /**
  3289. * Gets a new Vector4 from current Vector4 floored values
  3290. * @returns a new Vector4
  3291. */
  3292. floor(): Vector4;
  3293. /**
  3294. * Gets a new Vector4 from current Vector3 floored values
  3295. * @returns a new Vector4
  3296. */
  3297. fract(): Vector4;
  3298. /**
  3299. * Returns the Vector4 length (float).
  3300. * @returns the length
  3301. */
  3302. length(): number;
  3303. /**
  3304. * Returns the Vector4 squared length (float).
  3305. * @returns the length squared
  3306. */
  3307. lengthSquared(): number;
  3308. /**
  3309. * Normalizes in place the Vector4.
  3310. * @returns the updated Vector4.
  3311. */
  3312. normalize(): Vector4;
  3313. /**
  3314. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3315. * @returns this converted to a new vector3
  3316. */
  3317. toVector3(): Vector3;
  3318. /**
  3319. * Returns a new Vector4 copied from the current one.
  3320. * @returns the new cloned vector
  3321. */
  3322. clone(): Vector4;
  3323. /**
  3324. * Updates the current Vector4 with the given one coordinates.
  3325. * @param source the source vector to copy from
  3326. * @returns the updated Vector4.
  3327. */
  3328. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3329. /**
  3330. * Updates the current Vector4 coordinates with the given floats.
  3331. * @param x float to copy from
  3332. * @param y float to copy from
  3333. * @param z float to copy from
  3334. * @param w float to copy from
  3335. * @returns the updated Vector4.
  3336. */
  3337. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3338. /**
  3339. * Updates the current Vector4 coordinates with the given floats.
  3340. * @param x float to set from
  3341. * @param y float to set from
  3342. * @param z float to set from
  3343. * @param w float to set from
  3344. * @returns the updated Vector4.
  3345. */
  3346. set(x: number, y: number, z: number, w: number): Vector4;
  3347. /**
  3348. * Copies the given float to the current Vector3 coordinates
  3349. * @param v defines the x, y, z and w coordinates of the operand
  3350. * @returns the current updated Vector3
  3351. */
  3352. setAll(v: number): Vector4;
  3353. /**
  3354. * Returns a new Vector4 set from the starting index of the given array.
  3355. * @param array the array to pull values from
  3356. * @param offset the offset into the array to start at
  3357. * @returns the new vector
  3358. */
  3359. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3360. /**
  3361. * Updates the given vector "result" from the starting index of the given array.
  3362. * @param array the array to pull values from
  3363. * @param offset the offset into the array to start at
  3364. * @param result the vector to store the result in
  3365. */
  3366. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3367. /**
  3368. * Updates the given vector "result" from the starting index of the given Float32Array.
  3369. * @param array the array to pull values from
  3370. * @param offset the offset into the array to start at
  3371. * @param result the vector to store the result in
  3372. */
  3373. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3374. /**
  3375. * Updates the given vector "result" coordinates from the given floats.
  3376. * @param x float to set from
  3377. * @param y float to set from
  3378. * @param z float to set from
  3379. * @param w float to set from
  3380. * @param result the vector to the floats in
  3381. */
  3382. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3383. /**
  3384. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3385. * @returns the new vector
  3386. */
  3387. static Zero(): Vector4;
  3388. /**
  3389. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3390. * @returns the new vector
  3391. */
  3392. static One(): Vector4;
  3393. /**
  3394. * Returns a new normalized Vector4 from the given one.
  3395. * @param vector the vector to normalize
  3396. * @returns the vector
  3397. */
  3398. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3399. /**
  3400. * Updates the given vector "result" from the normalization of the given one.
  3401. * @param vector the vector to normalize
  3402. * @param result the vector to store the result in
  3403. */
  3404. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3405. /**
  3406. * Returns a vector with the minimum values from the left and right vectors
  3407. * @param left left vector to minimize
  3408. * @param right right vector to minimize
  3409. * @returns a new vector with the minimum of the left and right vector values
  3410. */
  3411. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3412. /**
  3413. * Returns a vector with the maximum values from the left and right vectors
  3414. * @param left left vector to maximize
  3415. * @param right right vector to maximize
  3416. * @returns a new vector with the maximum of the left and right vector values
  3417. */
  3418. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3419. /**
  3420. * Returns the distance (float) between the vectors "value1" and "value2".
  3421. * @param value1 value to calulate the distance between
  3422. * @param value2 value to calulate the distance between
  3423. * @return the distance between the two vectors
  3424. */
  3425. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3426. /**
  3427. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3428. * @param value1 value to calulate the distance between
  3429. * @param value2 value to calulate the distance between
  3430. * @return the distance between the two vectors squared
  3431. */
  3432. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3433. /**
  3434. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3435. * @param value1 value to calulate the center between
  3436. * @param value2 value to calulate the center between
  3437. * @return the center between the two vectors
  3438. */
  3439. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3440. /**
  3441. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3442. * This methods computes transformed normalized direction vectors only.
  3443. * @param vector the vector to transform
  3444. * @param transformation the transformation matrix to apply
  3445. * @returns the new vector
  3446. */
  3447. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3448. /**
  3449. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3450. * This methods computes transformed normalized direction vectors only.
  3451. * @param vector the vector to transform
  3452. * @param transformation the transformation matrix to apply
  3453. * @param result the vector to store the result in
  3454. */
  3455. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3456. /**
  3457. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3458. * This methods computes transformed normalized direction vectors only.
  3459. * @param x value to transform
  3460. * @param y value to transform
  3461. * @param z value to transform
  3462. * @param w value to transform
  3463. * @param transformation the transformation matrix to apply
  3464. * @param result the vector to store the results in
  3465. */
  3466. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3467. /**
  3468. * Creates a new Vector4 from a Vector3
  3469. * @param source defines the source data
  3470. * @param w defines the 4th component (default is 0)
  3471. * @returns a new Vector4
  3472. */
  3473. static FromVector3(source: Vector3, w?: number): Vector4;
  3474. }
  3475. /**
  3476. * Class used to store quaternion data
  3477. * @see https://en.wikipedia.org/wiki/Quaternion
  3478. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3479. */
  3480. export class Quaternion {
  3481. /** defines the first component (0 by default) */
  3482. x: number;
  3483. /** defines the second component (0 by default) */
  3484. y: number;
  3485. /** defines the third component (0 by default) */
  3486. z: number;
  3487. /** defines the fourth component (1.0 by default) */
  3488. w: number;
  3489. /**
  3490. * Creates a new Quaternion from the given floats
  3491. * @param x defines the first component (0 by default)
  3492. * @param y defines the second component (0 by default)
  3493. * @param z defines the third component (0 by default)
  3494. * @param w defines the fourth component (1.0 by default)
  3495. */
  3496. constructor(
  3497. /** defines the first component (0 by default) */
  3498. x?: number,
  3499. /** defines the second component (0 by default) */
  3500. y?: number,
  3501. /** defines the third component (0 by default) */
  3502. z?: number,
  3503. /** defines the fourth component (1.0 by default) */
  3504. w?: number);
  3505. /**
  3506. * Gets a string representation for the current quaternion
  3507. * @returns a string with the Quaternion coordinates
  3508. */
  3509. toString(): string;
  3510. /**
  3511. * Gets the class name of the quaternion
  3512. * @returns the string "Quaternion"
  3513. */
  3514. getClassName(): string;
  3515. /**
  3516. * Gets a hash code for this quaternion
  3517. * @returns the quaternion hash code
  3518. */
  3519. getHashCode(): number;
  3520. /**
  3521. * Copy the quaternion to an array
  3522. * @returns a new array populated with 4 elements from the quaternion coordinates
  3523. */
  3524. asArray(): number[];
  3525. /**
  3526. * Check if two quaternions are equals
  3527. * @param otherQuaternion defines the second operand
  3528. * @return true if the current quaternion and the given one coordinates are strictly equals
  3529. */
  3530. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3531. /**
  3532. * Clone the current quaternion
  3533. * @returns a new quaternion copied from the current one
  3534. */
  3535. clone(): Quaternion;
  3536. /**
  3537. * Copy a quaternion to the current one
  3538. * @param other defines the other quaternion
  3539. * @returns the updated current quaternion
  3540. */
  3541. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3542. /**
  3543. * Updates the current quaternion with the given float coordinates
  3544. * @param x defines the x coordinate
  3545. * @param y defines the y coordinate
  3546. * @param z defines the z coordinate
  3547. * @param w defines the w coordinate
  3548. * @returns the updated current quaternion
  3549. */
  3550. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3551. /**
  3552. * Updates the current quaternion from the given float coordinates
  3553. * @param x defines the x coordinate
  3554. * @param y defines the y coordinate
  3555. * @param z defines the z coordinate
  3556. * @param w defines the w coordinate
  3557. * @returns the updated current quaternion
  3558. */
  3559. set(x: number, y: number, z: number, w: number): Quaternion;
  3560. /**
  3561. * Adds two quaternions
  3562. * @param other defines the second operand
  3563. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3564. */
  3565. add(other: DeepImmutable<Quaternion>): Quaternion;
  3566. /**
  3567. * Add a quaternion to the current one
  3568. * @param other defines the quaternion to add
  3569. * @returns the current quaternion
  3570. */
  3571. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3572. /**
  3573. * Subtract two quaternions
  3574. * @param other defines the second operand
  3575. * @returns a new quaternion as the subtraction result of the given one from the current one
  3576. */
  3577. subtract(other: Quaternion): Quaternion;
  3578. /**
  3579. * Multiplies the current quaternion by a scale factor
  3580. * @param value defines the scale factor
  3581. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3582. */
  3583. scale(value: number): Quaternion;
  3584. /**
  3585. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3586. * @param scale defines the scale factor
  3587. * @param result defines the Quaternion object where to store the result
  3588. * @returns the unmodified current quaternion
  3589. */
  3590. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3591. /**
  3592. * Multiplies in place the current quaternion by a scale factor
  3593. * @param value defines the scale factor
  3594. * @returns the current modified quaternion
  3595. */
  3596. scaleInPlace(value: number): Quaternion;
  3597. /**
  3598. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3599. * @param scale defines the scale factor
  3600. * @param result defines the Quaternion object where to store the result
  3601. * @returns the unmodified current quaternion
  3602. */
  3603. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3604. /**
  3605. * Multiplies two quaternions
  3606. * @param q1 defines the second operand
  3607. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3608. */
  3609. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3610. /**
  3611. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3612. * @param q1 defines the second operand
  3613. * @param result defines the target quaternion
  3614. * @returns the current quaternion
  3615. */
  3616. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3617. /**
  3618. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3619. * @param q1 defines the second operand
  3620. * @returns the currentupdated quaternion
  3621. */
  3622. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3623. /**
  3624. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3625. * @param ref defines the target quaternion
  3626. * @returns the current quaternion
  3627. */
  3628. conjugateToRef(ref: Quaternion): Quaternion;
  3629. /**
  3630. * Conjugates in place (1-q) the current quaternion
  3631. * @returns the current updated quaternion
  3632. */
  3633. conjugateInPlace(): Quaternion;
  3634. /**
  3635. * Conjugates in place (1-q) the current quaternion
  3636. * @returns a new quaternion
  3637. */
  3638. conjugate(): Quaternion;
  3639. /**
  3640. * Gets length of current quaternion
  3641. * @returns the quaternion length (float)
  3642. */
  3643. length(): number;
  3644. /**
  3645. * Normalize in place the current quaternion
  3646. * @returns the current updated quaternion
  3647. */
  3648. normalize(): Quaternion;
  3649. /**
  3650. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3651. * @param order is a reserved parameter and is ignore for now
  3652. * @returns a new Vector3 containing the Euler angles
  3653. */
  3654. toEulerAngles(order?: string): Vector3;
  3655. /**
  3656. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3657. * @param result defines the vector which will be filled with the Euler angles
  3658. * @param order is a reserved parameter and is ignore for now
  3659. * @returns the current unchanged quaternion
  3660. */
  3661. toEulerAnglesToRef(result: Vector3): Quaternion;
  3662. /**
  3663. * Updates the given rotation matrix with the current quaternion values
  3664. * @param result defines the target matrix
  3665. * @returns the current unchanged quaternion
  3666. */
  3667. toRotationMatrix(result: Matrix): Quaternion;
  3668. /**
  3669. * Updates the current quaternion from the given rotation matrix values
  3670. * @param matrix defines the source matrix
  3671. * @returns the current updated quaternion
  3672. */
  3673. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3674. /**
  3675. * Creates a new quaternion from a rotation matrix
  3676. * @param matrix defines the source matrix
  3677. * @returns a new quaternion created from the given rotation matrix values
  3678. */
  3679. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3680. /**
  3681. * Updates the given quaternion with the given rotation matrix values
  3682. * @param matrix defines the source matrix
  3683. * @param result defines the target quaternion
  3684. */
  3685. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3686. /**
  3687. * Returns the dot product (float) between the quaternions "left" and "right"
  3688. * @param left defines the left operand
  3689. * @param right defines the right operand
  3690. * @returns the dot product
  3691. */
  3692. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3693. /**
  3694. * Checks if the two quaternions are close to each other
  3695. * @param quat0 defines the first quaternion to check
  3696. * @param quat1 defines the second quaternion to check
  3697. * @returns true if the two quaternions are close to each other
  3698. */
  3699. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3700. /**
  3701. * Creates an empty quaternion
  3702. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3703. */
  3704. static Zero(): Quaternion;
  3705. /**
  3706. * Inverse a given quaternion
  3707. * @param q defines the source quaternion
  3708. * @returns a new quaternion as the inverted current quaternion
  3709. */
  3710. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3711. /**
  3712. * Inverse a given quaternion
  3713. * @param q defines the source quaternion
  3714. * @param result the quaternion the result will be stored in
  3715. * @returns the result quaternion
  3716. */
  3717. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3718. /**
  3719. * Creates an identity quaternion
  3720. * @returns the identity quaternion
  3721. */
  3722. static Identity(): Quaternion;
  3723. /**
  3724. * Gets a boolean indicating if the given quaternion is identity
  3725. * @param quaternion defines the quaternion to check
  3726. * @returns true if the quaternion is identity
  3727. */
  3728. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3729. /**
  3730. * Creates a quaternion from a rotation around an axis
  3731. * @param axis defines the axis to use
  3732. * @param angle defines the angle to use
  3733. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3734. */
  3735. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3736. /**
  3737. * Creates a rotation around an axis and stores it into the given quaternion
  3738. * @param axis defines the axis to use
  3739. * @param angle defines the angle to use
  3740. * @param result defines the target quaternion
  3741. * @returns the target quaternion
  3742. */
  3743. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3744. /**
  3745. * Creates a new quaternion from data stored into an array
  3746. * @param array defines the data source
  3747. * @param offset defines the offset in the source array where the data starts
  3748. * @returns a new quaternion
  3749. */
  3750. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3751. /**
  3752. * Create a quaternion from Euler rotation angles
  3753. * @param x Pitch
  3754. * @param y Yaw
  3755. * @param z Roll
  3756. * @returns the new Quaternion
  3757. */
  3758. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3759. /**
  3760. * Updates a quaternion from Euler rotation angles
  3761. * @param x Pitch
  3762. * @param y Yaw
  3763. * @param z Roll
  3764. * @param result the quaternion to store the result
  3765. * @returns the updated quaternion
  3766. */
  3767. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3768. /**
  3769. * Create a quaternion from Euler rotation vector
  3770. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3771. * @returns the new Quaternion
  3772. */
  3773. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3774. /**
  3775. * Updates a quaternion from Euler rotation vector
  3776. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3777. * @param result the quaternion to store the result
  3778. * @returns the updated quaternion
  3779. */
  3780. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3781. /**
  3782. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3783. * @param yaw defines the rotation around Y axis
  3784. * @param pitch defines the rotation around X axis
  3785. * @param roll defines the rotation around Z axis
  3786. * @returns the new quaternion
  3787. */
  3788. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3789. /**
  3790. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3791. * @param yaw defines the rotation around Y axis
  3792. * @param pitch defines the rotation around X axis
  3793. * @param roll defines the rotation around Z axis
  3794. * @param result defines the target quaternion
  3795. */
  3796. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3797. /**
  3798. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3799. * @param alpha defines the rotation around first axis
  3800. * @param beta defines the rotation around second axis
  3801. * @param gamma defines the rotation around third axis
  3802. * @returns the new quaternion
  3803. */
  3804. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3805. /**
  3806. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3807. * @param alpha defines the rotation around first axis
  3808. * @param beta defines the rotation around second axis
  3809. * @param gamma defines the rotation around third axis
  3810. * @param result defines the target quaternion
  3811. */
  3812. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3813. /**
  3814. * 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)
  3815. * @param axis1 defines the first axis
  3816. * @param axis2 defines the second axis
  3817. * @param axis3 defines the third axis
  3818. * @returns the new quaternion
  3819. */
  3820. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3821. /**
  3822. * 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
  3823. * @param axis1 defines the first axis
  3824. * @param axis2 defines the second axis
  3825. * @param axis3 defines the third axis
  3826. * @param ref defines the target quaternion
  3827. */
  3828. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3829. /**
  3830. * Interpolates between two quaternions
  3831. * @param left defines first quaternion
  3832. * @param right defines second quaternion
  3833. * @param amount defines the gradient to use
  3834. * @returns the new interpolated quaternion
  3835. */
  3836. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3837. /**
  3838. * Interpolates between two quaternions and stores it into a target quaternion
  3839. * @param left defines first quaternion
  3840. * @param right defines second quaternion
  3841. * @param amount defines the gradient to use
  3842. * @param result defines the target quaternion
  3843. */
  3844. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3845. /**
  3846. * Interpolate between two quaternions using Hermite interpolation
  3847. * @param value1 defines first quaternion
  3848. * @param tangent1 defines the incoming tangent
  3849. * @param value2 defines second quaternion
  3850. * @param tangent2 defines the outgoing tangent
  3851. * @param amount defines the target quaternion
  3852. * @returns the new interpolated quaternion
  3853. */
  3854. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3855. }
  3856. /**
  3857. * Class used to store matrix data (4x4)
  3858. */
  3859. export class Matrix {
  3860. private static _updateFlagSeed;
  3861. private static _identityReadOnly;
  3862. private _isIdentity;
  3863. private _isIdentityDirty;
  3864. private _isIdentity3x2;
  3865. private _isIdentity3x2Dirty;
  3866. /**
  3867. * Gets the update flag of the matrix which is an unique number for the matrix.
  3868. * It will be incremented every time the matrix data change.
  3869. * You can use it to speed the comparison between two versions of the same matrix.
  3870. */
  3871. updateFlag: number;
  3872. private readonly _m;
  3873. /**
  3874. * Gets the internal data of the matrix
  3875. */
  3876. get m(): DeepImmutable<Float32Array>;
  3877. /** @hidden */
  3878. _markAsUpdated(): void;
  3879. /** @hidden */
  3880. private _updateIdentityStatus;
  3881. /**
  3882. * Creates an empty matrix (filled with zeros)
  3883. */
  3884. constructor();
  3885. /**
  3886. * Check if the current matrix is identity
  3887. * @returns true is the matrix is the identity matrix
  3888. */
  3889. isIdentity(): boolean;
  3890. /**
  3891. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3892. * @returns true is the matrix is the identity matrix
  3893. */
  3894. isIdentityAs3x2(): boolean;
  3895. /**
  3896. * Gets the determinant of the matrix
  3897. * @returns the matrix determinant
  3898. */
  3899. determinant(): number;
  3900. /**
  3901. * Returns the matrix as a Float32Array
  3902. * @returns the matrix underlying array
  3903. */
  3904. toArray(): DeepImmutable<Float32Array>;
  3905. /**
  3906. * Returns the matrix as a Float32Array
  3907. * @returns the matrix underlying array.
  3908. */
  3909. asArray(): DeepImmutable<Float32Array>;
  3910. /**
  3911. * Inverts the current matrix in place
  3912. * @returns the current inverted matrix
  3913. */
  3914. invert(): Matrix;
  3915. /**
  3916. * Sets all the matrix elements to zero
  3917. * @returns the current matrix
  3918. */
  3919. reset(): Matrix;
  3920. /**
  3921. * Adds the current matrix with a second one
  3922. * @param other defines the matrix to add
  3923. * @returns a new matrix as the addition of the current matrix and the given one
  3924. */
  3925. add(other: DeepImmutable<Matrix>): Matrix;
  3926. /**
  3927. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3928. * @param other defines the matrix to add
  3929. * @param result defines the target matrix
  3930. * @returns the current matrix
  3931. */
  3932. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3933. /**
  3934. * Adds in place the given matrix to the current matrix
  3935. * @param other defines the second operand
  3936. * @returns the current updated matrix
  3937. */
  3938. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3939. /**
  3940. * Sets the given matrix to the current inverted Matrix
  3941. * @param other defines the target matrix
  3942. * @returns the unmodified current matrix
  3943. */
  3944. invertToRef(other: Matrix): Matrix;
  3945. /**
  3946. * add a value at the specified position in the current Matrix
  3947. * @param index the index of the value within the matrix. between 0 and 15.
  3948. * @param value the value to be added
  3949. * @returns the current updated matrix
  3950. */
  3951. addAtIndex(index: number, value: number): Matrix;
  3952. /**
  3953. * mutiply the specified position in the current Matrix by a value
  3954. * @param index the index of the value within the matrix. between 0 and 15.
  3955. * @param value the value to be added
  3956. * @returns the current updated matrix
  3957. */
  3958. multiplyAtIndex(index: number, value: number): Matrix;
  3959. /**
  3960. * Inserts the translation vector (using 3 floats) in the current matrix
  3961. * @param x defines the 1st component of the translation
  3962. * @param y defines the 2nd component of the translation
  3963. * @param z defines the 3rd component of the translation
  3964. * @returns the current updated matrix
  3965. */
  3966. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3967. /**
  3968. * Adds the translation vector (using 3 floats) in the current matrix
  3969. * @param x defines the 1st component of the translation
  3970. * @param y defines the 2nd component of the translation
  3971. * @param z defines the 3rd component of the translation
  3972. * @returns the current updated matrix
  3973. */
  3974. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3975. /**
  3976. * Inserts the translation vector in the current matrix
  3977. * @param vector3 defines the translation to insert
  3978. * @returns the current updated matrix
  3979. */
  3980. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3981. /**
  3982. * Gets the translation value of the current matrix
  3983. * @returns a new Vector3 as the extracted translation from the matrix
  3984. */
  3985. getTranslation(): Vector3;
  3986. /**
  3987. * Fill a Vector3 with the extracted translation from the matrix
  3988. * @param result defines the Vector3 where to store the translation
  3989. * @returns the current matrix
  3990. */
  3991. getTranslationToRef(result: Vector3): Matrix;
  3992. /**
  3993. * Remove rotation and scaling part from the matrix
  3994. * @returns the updated matrix
  3995. */
  3996. removeRotationAndScaling(): Matrix;
  3997. /**
  3998. * Multiply two matrices
  3999. * @param other defines the second operand
  4000. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4001. */
  4002. multiply(other: DeepImmutable<Matrix>): Matrix;
  4003. /**
  4004. * Copy the current matrix from the given one
  4005. * @param other defines the source matrix
  4006. * @returns the current updated matrix
  4007. */
  4008. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4009. /**
  4010. * Populates the given array from the starting index with the current matrix values
  4011. * @param array defines the target array
  4012. * @param offset defines the offset in the target array where to start storing values
  4013. * @returns the current matrix
  4014. */
  4015. copyToArray(array: Float32Array, offset?: number): Matrix;
  4016. /**
  4017. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4018. * @param other defines the second operand
  4019. * @param result defines the matrix where to store the multiplication
  4020. * @returns the current matrix
  4021. */
  4022. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4023. /**
  4024. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4025. * @param other defines the second operand
  4026. * @param result defines the array where to store the multiplication
  4027. * @param offset defines the offset in the target array where to start storing values
  4028. * @returns the current matrix
  4029. */
  4030. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4031. /**
  4032. * Check equality between this matrix and a second one
  4033. * @param value defines the second matrix to compare
  4034. * @returns true is the current matrix and the given one values are strictly equal
  4035. */
  4036. equals(value: DeepImmutable<Matrix>): boolean;
  4037. /**
  4038. * Clone the current matrix
  4039. * @returns a new matrix from the current matrix
  4040. */
  4041. clone(): Matrix;
  4042. /**
  4043. * Returns the name of the current matrix class
  4044. * @returns the string "Matrix"
  4045. */
  4046. getClassName(): string;
  4047. /**
  4048. * Gets the hash code of the current matrix
  4049. * @returns the hash code
  4050. */
  4051. getHashCode(): number;
  4052. /**
  4053. * Decomposes the current Matrix into a translation, rotation and scaling components
  4054. * @param scale defines the scale vector3 given as a reference to update
  4055. * @param rotation defines the rotation quaternion given as a reference to update
  4056. * @param translation defines the translation vector3 given as a reference to update
  4057. * @returns true if operation was successful
  4058. */
  4059. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4060. /**
  4061. * Gets specific row of the matrix
  4062. * @param index defines the number of the row to get
  4063. * @returns the index-th row of the current matrix as a new Vector4
  4064. */
  4065. getRow(index: number): Nullable<Vector4>;
  4066. /**
  4067. * Sets the index-th row of the current matrix to the vector4 values
  4068. * @param index defines the number of the row to set
  4069. * @param row defines the target vector4
  4070. * @returns the updated current matrix
  4071. */
  4072. setRow(index: number, row: Vector4): Matrix;
  4073. /**
  4074. * Compute the transpose of the matrix
  4075. * @returns the new transposed matrix
  4076. */
  4077. transpose(): Matrix;
  4078. /**
  4079. * Compute the transpose of the matrix and store it in a given matrix
  4080. * @param result defines the target matrix
  4081. * @returns the current matrix
  4082. */
  4083. transposeToRef(result: Matrix): Matrix;
  4084. /**
  4085. * Sets the index-th row of the current matrix with the given 4 x float values
  4086. * @param index defines the row index
  4087. * @param x defines the x component to set
  4088. * @param y defines the y component to set
  4089. * @param z defines the z component to set
  4090. * @param w defines the w component to set
  4091. * @returns the updated current matrix
  4092. */
  4093. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4094. /**
  4095. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4096. * @param scale defines the scale factor
  4097. * @returns a new matrix
  4098. */
  4099. scale(scale: number): Matrix;
  4100. /**
  4101. * Scale the current matrix values by a factor to a given result matrix
  4102. * @param scale defines the scale factor
  4103. * @param result defines the matrix to store the result
  4104. * @returns the current matrix
  4105. */
  4106. scaleToRef(scale: number, result: Matrix): Matrix;
  4107. /**
  4108. * Scale the current matrix values by a factor and add the result to a given matrix
  4109. * @param scale defines the scale factor
  4110. * @param result defines the Matrix to store the result
  4111. * @returns the current matrix
  4112. */
  4113. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4114. /**
  4115. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4116. * @param ref matrix to store the result
  4117. */
  4118. toNormalMatrix(ref: Matrix): void;
  4119. /**
  4120. * Gets only rotation part of the current matrix
  4121. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4122. */
  4123. getRotationMatrix(): Matrix;
  4124. /**
  4125. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4126. * @param result defines the target matrix to store data to
  4127. * @returns the current matrix
  4128. */
  4129. getRotationMatrixToRef(result: Matrix): Matrix;
  4130. /**
  4131. * Toggles model matrix from being right handed to left handed in place and vice versa
  4132. */
  4133. toggleModelMatrixHandInPlace(): void;
  4134. /**
  4135. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4136. */
  4137. toggleProjectionMatrixHandInPlace(): void;
  4138. /**
  4139. * Creates a matrix from an array
  4140. * @param array defines the source array
  4141. * @param offset defines an offset in the source array
  4142. * @returns a new Matrix set from the starting index of the given array
  4143. */
  4144. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4145. /**
  4146. * Copy the content of an array into a given matrix
  4147. * @param array defines the source array
  4148. * @param offset defines an offset in the source array
  4149. * @param result defines the target matrix
  4150. */
  4151. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4152. /**
  4153. * Stores an array into a matrix after having multiplied each component by a given factor
  4154. * @param array defines the source array
  4155. * @param offset defines the offset in the source array
  4156. * @param scale defines the scaling factor
  4157. * @param result defines the target matrix
  4158. */
  4159. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4160. /**
  4161. * Gets an identity matrix that must not be updated
  4162. */
  4163. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4164. /**
  4165. * Stores a list of values (16) inside a given matrix
  4166. * @param initialM11 defines 1st value of 1st row
  4167. * @param initialM12 defines 2nd value of 1st row
  4168. * @param initialM13 defines 3rd value of 1st row
  4169. * @param initialM14 defines 4th value of 1st row
  4170. * @param initialM21 defines 1st value of 2nd row
  4171. * @param initialM22 defines 2nd value of 2nd row
  4172. * @param initialM23 defines 3rd value of 2nd row
  4173. * @param initialM24 defines 4th value of 2nd row
  4174. * @param initialM31 defines 1st value of 3rd row
  4175. * @param initialM32 defines 2nd value of 3rd row
  4176. * @param initialM33 defines 3rd value of 3rd row
  4177. * @param initialM34 defines 4th value of 3rd row
  4178. * @param initialM41 defines 1st value of 4th row
  4179. * @param initialM42 defines 2nd value of 4th row
  4180. * @param initialM43 defines 3rd value of 4th row
  4181. * @param initialM44 defines 4th value of 4th row
  4182. * @param result defines the target matrix
  4183. */
  4184. 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;
  4185. /**
  4186. * Creates new matrix from a list of values (16)
  4187. * @param initialM11 defines 1st value of 1st row
  4188. * @param initialM12 defines 2nd value of 1st row
  4189. * @param initialM13 defines 3rd value of 1st row
  4190. * @param initialM14 defines 4th value of 1st row
  4191. * @param initialM21 defines 1st value of 2nd row
  4192. * @param initialM22 defines 2nd value of 2nd row
  4193. * @param initialM23 defines 3rd value of 2nd row
  4194. * @param initialM24 defines 4th value of 2nd row
  4195. * @param initialM31 defines 1st value of 3rd row
  4196. * @param initialM32 defines 2nd value of 3rd row
  4197. * @param initialM33 defines 3rd value of 3rd row
  4198. * @param initialM34 defines 4th value of 3rd row
  4199. * @param initialM41 defines 1st value of 4th row
  4200. * @param initialM42 defines 2nd value of 4th row
  4201. * @param initialM43 defines 3rd value of 4th row
  4202. * @param initialM44 defines 4th value of 4th row
  4203. * @returns the new matrix
  4204. */
  4205. 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;
  4206. /**
  4207. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4208. * @param scale defines the scale vector3
  4209. * @param rotation defines the rotation quaternion
  4210. * @param translation defines the translation vector3
  4211. * @returns a new matrix
  4212. */
  4213. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4214. /**
  4215. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4216. * @param scale defines the scale vector3
  4217. * @param rotation defines the rotation quaternion
  4218. * @param translation defines the translation vector3
  4219. * @param result defines the target matrix
  4220. */
  4221. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4222. /**
  4223. * Creates a new identity matrix
  4224. * @returns a new identity matrix
  4225. */
  4226. static Identity(): Matrix;
  4227. /**
  4228. * Creates a new identity matrix and stores the result in a given matrix
  4229. * @param result defines the target matrix
  4230. */
  4231. static IdentityToRef(result: Matrix): void;
  4232. /**
  4233. * Creates a new zero matrix
  4234. * @returns a new zero matrix
  4235. */
  4236. static Zero(): Matrix;
  4237. /**
  4238. * Creates a new rotation matrix for "angle" radians around the X axis
  4239. * @param angle defines the angle (in radians) to use
  4240. * @return the new matrix
  4241. */
  4242. static RotationX(angle: number): Matrix;
  4243. /**
  4244. * Creates a new matrix as the invert of a given matrix
  4245. * @param source defines the source matrix
  4246. * @returns the new matrix
  4247. */
  4248. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4249. /**
  4250. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4251. * @param angle defines the angle (in radians) to use
  4252. * @param result defines the target matrix
  4253. */
  4254. static RotationXToRef(angle: number, result: Matrix): void;
  4255. /**
  4256. * Creates a new rotation matrix for "angle" radians around the Y axis
  4257. * @param angle defines the angle (in radians) to use
  4258. * @return the new matrix
  4259. */
  4260. static RotationY(angle: number): Matrix;
  4261. /**
  4262. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4263. * @param angle defines the angle (in radians) to use
  4264. * @param result defines the target matrix
  4265. */
  4266. static RotationYToRef(angle: number, result: Matrix): void;
  4267. /**
  4268. * Creates a new rotation matrix for "angle" radians around the Z axis
  4269. * @param angle defines the angle (in radians) to use
  4270. * @return the new matrix
  4271. */
  4272. static RotationZ(angle: number): Matrix;
  4273. /**
  4274. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4275. * @param angle defines the angle (in radians) to use
  4276. * @param result defines the target matrix
  4277. */
  4278. static RotationZToRef(angle: number, result: Matrix): void;
  4279. /**
  4280. * Creates a new rotation matrix for "angle" radians around the given axis
  4281. * @param axis defines the axis to use
  4282. * @param angle defines the angle (in radians) to use
  4283. * @return the new matrix
  4284. */
  4285. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4286. /**
  4287. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4288. * @param axis defines the axis to use
  4289. * @param angle defines the angle (in radians) to use
  4290. * @param result defines the target matrix
  4291. */
  4292. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4293. /**
  4294. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4295. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4296. * @param from defines the vector to align
  4297. * @param to defines the vector to align to
  4298. * @param result defines the target matrix
  4299. */
  4300. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4301. /**
  4302. * Creates a rotation matrix
  4303. * @param yaw defines the yaw angle in radians (Y axis)
  4304. * @param pitch defines the pitch angle in radians (X axis)
  4305. * @param roll defines the roll angle in radians (X axis)
  4306. * @returns the new rotation matrix
  4307. */
  4308. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4309. /**
  4310. * Creates a rotation matrix and stores it in a given matrix
  4311. * @param yaw defines the yaw angle in radians (Y axis)
  4312. * @param pitch defines the pitch angle in radians (X axis)
  4313. * @param roll defines the roll angle in radians (X axis)
  4314. * @param result defines the target matrix
  4315. */
  4316. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4317. /**
  4318. * Creates a scaling matrix
  4319. * @param x defines the scale factor on X axis
  4320. * @param y defines the scale factor on Y axis
  4321. * @param z defines the scale factor on Z axis
  4322. * @returns the new matrix
  4323. */
  4324. static Scaling(x: number, y: number, z: number): Matrix;
  4325. /**
  4326. * Creates a scaling matrix and stores it in a given matrix
  4327. * @param x defines the scale factor on X axis
  4328. * @param y defines the scale factor on Y axis
  4329. * @param z defines the scale factor on Z axis
  4330. * @param result defines the target matrix
  4331. */
  4332. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4333. /**
  4334. * Creates a translation matrix
  4335. * @param x defines the translation on X axis
  4336. * @param y defines the translation on Y axis
  4337. * @param z defines the translationon Z axis
  4338. * @returns the new matrix
  4339. */
  4340. static Translation(x: number, y: number, z: number): Matrix;
  4341. /**
  4342. * Creates a translation matrix and stores it in a given matrix
  4343. * @param x defines the translation on X axis
  4344. * @param y defines the translation on Y axis
  4345. * @param z defines the translationon Z axis
  4346. * @param result defines the target matrix
  4347. */
  4348. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4349. /**
  4350. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4351. * @param startValue defines the start value
  4352. * @param endValue defines the end value
  4353. * @param gradient defines the gradient factor
  4354. * @returns the new matrix
  4355. */
  4356. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4357. /**
  4358. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4359. * @param startValue defines the start value
  4360. * @param endValue defines the end value
  4361. * @param gradient defines the gradient factor
  4362. * @param result defines the Matrix object where to store data
  4363. */
  4364. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4365. /**
  4366. * Builds a new matrix whose values are computed by:
  4367. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4368. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4369. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4370. * @param startValue defines the first matrix
  4371. * @param endValue defines the second matrix
  4372. * @param gradient defines the gradient between the two matrices
  4373. * @returns the new matrix
  4374. */
  4375. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4376. /**
  4377. * Update a matrix to values which are computed by:
  4378. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4379. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4380. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4381. * @param startValue defines the first matrix
  4382. * @param endValue defines the second matrix
  4383. * @param gradient defines the gradient between the two matrices
  4384. * @param result defines the target matrix
  4385. */
  4386. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4387. /**
  4388. * 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"
  4389. * This function works in left handed mode
  4390. * @param eye defines the final position of the entity
  4391. * @param target defines where the entity should look at
  4392. * @param up defines the up vector for the entity
  4393. * @returns the new matrix
  4394. */
  4395. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4396. /**
  4397. * 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".
  4398. * This function works in left handed mode
  4399. * @param eye defines the final position of the entity
  4400. * @param target defines where the entity should look at
  4401. * @param up defines the up vector for the entity
  4402. * @param result defines the target matrix
  4403. */
  4404. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4405. /**
  4406. * 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"
  4407. * This function works in right handed mode
  4408. * @param eye defines the final position of the entity
  4409. * @param target defines where the entity should look at
  4410. * @param up defines the up vector for the entity
  4411. * @returns the new matrix
  4412. */
  4413. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4414. /**
  4415. * 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".
  4416. * This function works in right handed mode
  4417. * @param eye defines the final position of the entity
  4418. * @param target defines where the entity should look at
  4419. * @param up defines the up vector for the entity
  4420. * @param result defines the target matrix
  4421. */
  4422. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4423. /**
  4424. * Create a left-handed orthographic projection matrix
  4425. * @param width defines the viewport width
  4426. * @param height defines the viewport height
  4427. * @param znear defines the near clip plane
  4428. * @param zfar defines the far clip plane
  4429. * @returns a new matrix as a left-handed orthographic projection matrix
  4430. */
  4431. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4432. /**
  4433. * Store a left-handed orthographic projection to a given matrix
  4434. * @param width defines the viewport width
  4435. * @param height defines the viewport height
  4436. * @param znear defines the near clip plane
  4437. * @param zfar defines the far clip plane
  4438. * @param result defines the target matrix
  4439. */
  4440. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4441. /**
  4442. * Create a left-handed orthographic projection matrix
  4443. * @param left defines the viewport left coordinate
  4444. * @param right defines the viewport right coordinate
  4445. * @param bottom defines the viewport bottom coordinate
  4446. * @param top defines the viewport top coordinate
  4447. * @param znear defines the near clip plane
  4448. * @param zfar defines the far clip plane
  4449. * @returns a new matrix as a left-handed orthographic projection matrix
  4450. */
  4451. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4452. /**
  4453. * Stores a left-handed orthographic projection into a given matrix
  4454. * @param left defines the viewport left coordinate
  4455. * @param right defines the viewport right coordinate
  4456. * @param bottom defines the viewport bottom coordinate
  4457. * @param top defines the viewport top coordinate
  4458. * @param znear defines the near clip plane
  4459. * @param zfar defines the far clip plane
  4460. * @param result defines the target matrix
  4461. */
  4462. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4463. /**
  4464. * Creates a right-handed orthographic projection matrix
  4465. * @param left defines the viewport left coordinate
  4466. * @param right defines the viewport right coordinate
  4467. * @param bottom defines the viewport bottom coordinate
  4468. * @param top defines the viewport top coordinate
  4469. * @param znear defines the near clip plane
  4470. * @param zfar defines the far clip plane
  4471. * @returns a new matrix as a right-handed orthographic projection matrix
  4472. */
  4473. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4474. /**
  4475. * Stores a right-handed orthographic projection into a given matrix
  4476. * @param left defines the viewport left coordinate
  4477. * @param right defines the viewport right coordinate
  4478. * @param bottom defines the viewport bottom coordinate
  4479. * @param top defines the viewport top coordinate
  4480. * @param znear defines the near clip plane
  4481. * @param zfar defines the far clip plane
  4482. * @param result defines the target matrix
  4483. */
  4484. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4485. /**
  4486. * Creates a left-handed perspective projection matrix
  4487. * @param width defines the viewport width
  4488. * @param height defines the viewport height
  4489. * @param znear defines the near clip plane
  4490. * @param zfar defines the far clip plane
  4491. * @returns a new matrix as a left-handed perspective projection matrix
  4492. */
  4493. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4494. /**
  4495. * Creates a left-handed perspective projection matrix
  4496. * @param fov defines the horizontal field of view
  4497. * @param aspect defines the aspect ratio
  4498. * @param znear defines the near clip plane
  4499. * @param zfar defines the far clip plane
  4500. * @returns a new matrix as a left-handed perspective projection matrix
  4501. */
  4502. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4503. /**
  4504. * Stores a left-handed perspective projection into a given matrix
  4505. * @param fov defines the horizontal field of view
  4506. * @param aspect defines the aspect ratio
  4507. * @param znear defines the near clip plane
  4508. * @param zfar defines the far clip plane
  4509. * @param result defines the target matrix
  4510. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4511. */
  4512. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4513. /**
  4514. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4515. * @param fov defines the horizontal field of view
  4516. * @param aspect defines the aspect ratio
  4517. * @param znear defines the near clip plane
  4518. * @param zfar not used as infinity is used as far clip
  4519. * @param result defines the target matrix
  4520. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4521. */
  4522. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4523. /**
  4524. * Creates a right-handed perspective projection matrix
  4525. * @param fov defines the horizontal field of view
  4526. * @param aspect defines the aspect ratio
  4527. * @param znear defines the near clip plane
  4528. * @param zfar defines the far clip plane
  4529. * @returns a new matrix as a right-handed perspective projection matrix
  4530. */
  4531. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4532. /**
  4533. * Stores a right-handed perspective projection into a given matrix
  4534. * @param fov defines the horizontal field of view
  4535. * @param aspect defines the aspect ratio
  4536. * @param znear defines the near clip plane
  4537. * @param zfar defines the far clip plane
  4538. * @param result defines the target matrix
  4539. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4540. */
  4541. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4542. /**
  4543. * Stores a right-handed perspective projection into a given matrix
  4544. * @param fov defines the horizontal field of view
  4545. * @param aspect defines the aspect ratio
  4546. * @param znear defines the near clip plane
  4547. * @param zfar not used as infinity is used as far clip
  4548. * @param result defines the target matrix
  4549. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4550. */
  4551. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4552. /**
  4553. * Stores a perspective projection for WebVR info a given matrix
  4554. * @param fov defines the field of view
  4555. * @param znear defines the near clip plane
  4556. * @param zfar defines the far clip plane
  4557. * @param result defines the target matrix
  4558. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4559. */
  4560. static PerspectiveFovWebVRToRef(fov: {
  4561. upDegrees: number;
  4562. downDegrees: number;
  4563. leftDegrees: number;
  4564. rightDegrees: number;
  4565. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4566. /**
  4567. * Computes a complete transformation matrix
  4568. * @param viewport defines the viewport to use
  4569. * @param world defines the world matrix
  4570. * @param view defines the view matrix
  4571. * @param projection defines the projection matrix
  4572. * @param zmin defines the near clip plane
  4573. * @param zmax defines the far clip plane
  4574. * @returns the transformation matrix
  4575. */
  4576. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4577. /**
  4578. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4579. * @param matrix defines the matrix to use
  4580. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4581. */
  4582. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4583. /**
  4584. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4585. * @param matrix defines the matrix to use
  4586. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4587. */
  4588. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4589. /**
  4590. * Compute the transpose of a given matrix
  4591. * @param matrix defines the matrix to transpose
  4592. * @returns the new matrix
  4593. */
  4594. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4595. /**
  4596. * Compute the transpose of a matrix and store it in a target matrix
  4597. * @param matrix defines the matrix to transpose
  4598. * @param result defines the target matrix
  4599. */
  4600. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4601. /**
  4602. * Computes a reflection matrix from a plane
  4603. * @param plane defines the reflection plane
  4604. * @returns a new matrix
  4605. */
  4606. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4607. /**
  4608. * Computes a reflection matrix from a plane
  4609. * @param plane defines the reflection plane
  4610. * @param result defines the target matrix
  4611. */
  4612. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4613. /**
  4614. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4615. * @param xaxis defines the value of the 1st axis
  4616. * @param yaxis defines the value of the 2nd axis
  4617. * @param zaxis defines the value of the 3rd axis
  4618. * @param result defines the target matrix
  4619. */
  4620. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4621. /**
  4622. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4623. * @param quat defines the quaternion to use
  4624. * @param result defines the target matrix
  4625. */
  4626. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4627. }
  4628. /**
  4629. * @hidden
  4630. */
  4631. export class TmpVectors {
  4632. static Vector2: Vector2[];
  4633. static Vector3: Vector3[];
  4634. static Vector4: Vector4[];
  4635. static Quaternion: Quaternion[];
  4636. static Matrix: Matrix[];
  4637. }
  4638. }
  4639. declare module "babylonjs/Maths/math.path" {
  4640. import { DeepImmutable, Nullable } from "babylonjs/types";
  4641. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4642. /**
  4643. * Defines potential orientation for back face culling
  4644. */
  4645. export enum Orientation {
  4646. /**
  4647. * Clockwise
  4648. */
  4649. CW = 0,
  4650. /** Counter clockwise */
  4651. CCW = 1
  4652. }
  4653. /** Class used to represent a Bezier curve */
  4654. export class BezierCurve {
  4655. /**
  4656. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4657. * @param t defines the time
  4658. * @param x1 defines the left coordinate on X axis
  4659. * @param y1 defines the left coordinate on Y axis
  4660. * @param x2 defines the right coordinate on X axis
  4661. * @param y2 defines the right coordinate on Y axis
  4662. * @returns the interpolated value
  4663. */
  4664. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4665. }
  4666. /**
  4667. * Defines angle representation
  4668. */
  4669. export class Angle {
  4670. private _radians;
  4671. /**
  4672. * Creates an Angle object of "radians" radians (float).
  4673. * @param radians the angle in radians
  4674. */
  4675. constructor(radians: number);
  4676. /**
  4677. * Get value in degrees
  4678. * @returns the Angle value in degrees (float)
  4679. */
  4680. degrees(): number;
  4681. /**
  4682. * Get value in radians
  4683. * @returns the Angle value in radians (float)
  4684. */
  4685. radians(): number;
  4686. /**
  4687. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4688. * @param a defines first vector
  4689. * @param b defines second vector
  4690. * @returns a new Angle
  4691. */
  4692. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4693. /**
  4694. * Gets a new Angle object from the given float in radians
  4695. * @param radians defines the angle value in radians
  4696. * @returns a new Angle
  4697. */
  4698. static FromRadians(radians: number): Angle;
  4699. /**
  4700. * Gets a new Angle object from the given float in degrees
  4701. * @param degrees defines the angle value in degrees
  4702. * @returns a new Angle
  4703. */
  4704. static FromDegrees(degrees: number): Angle;
  4705. }
  4706. /**
  4707. * This represents an arc in a 2d space.
  4708. */
  4709. export class Arc2 {
  4710. /** Defines the start point of the arc */
  4711. startPoint: Vector2;
  4712. /** Defines the mid point of the arc */
  4713. midPoint: Vector2;
  4714. /** Defines the end point of the arc */
  4715. endPoint: Vector2;
  4716. /**
  4717. * Defines the center point of the arc.
  4718. */
  4719. centerPoint: Vector2;
  4720. /**
  4721. * Defines the radius of the arc.
  4722. */
  4723. radius: number;
  4724. /**
  4725. * Defines the angle of the arc (from mid point to end point).
  4726. */
  4727. angle: Angle;
  4728. /**
  4729. * Defines the start angle of the arc (from start point to middle point).
  4730. */
  4731. startAngle: Angle;
  4732. /**
  4733. * Defines the orientation of the arc (clock wise/counter clock wise).
  4734. */
  4735. orientation: Orientation;
  4736. /**
  4737. * Creates an Arc object from the three given points : start, middle and end.
  4738. * @param startPoint Defines the start point of the arc
  4739. * @param midPoint Defines the midlle point of the arc
  4740. * @param endPoint Defines the end point of the arc
  4741. */
  4742. constructor(
  4743. /** Defines the start point of the arc */
  4744. startPoint: Vector2,
  4745. /** Defines the mid point of the arc */
  4746. midPoint: Vector2,
  4747. /** Defines the end point of the arc */
  4748. endPoint: Vector2);
  4749. }
  4750. /**
  4751. * Represents a 2D path made up of multiple 2D points
  4752. */
  4753. export class Path2 {
  4754. private _points;
  4755. private _length;
  4756. /**
  4757. * If the path start and end point are the same
  4758. */
  4759. closed: boolean;
  4760. /**
  4761. * Creates a Path2 object from the starting 2D coordinates x and y.
  4762. * @param x the starting points x value
  4763. * @param y the starting points y value
  4764. */
  4765. constructor(x: number, y: number);
  4766. /**
  4767. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4768. * @param x the added points x value
  4769. * @param y the added points y value
  4770. * @returns the updated Path2.
  4771. */
  4772. addLineTo(x: number, y: number): Path2;
  4773. /**
  4774. * 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.
  4775. * @param midX middle point x value
  4776. * @param midY middle point y value
  4777. * @param endX end point x value
  4778. * @param endY end point y value
  4779. * @param numberOfSegments (default: 36)
  4780. * @returns the updated Path2.
  4781. */
  4782. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4783. /**
  4784. * Closes the Path2.
  4785. * @returns the Path2.
  4786. */
  4787. close(): Path2;
  4788. /**
  4789. * Gets the sum of the distance between each sequential point in the path
  4790. * @returns the Path2 total length (float).
  4791. */
  4792. length(): number;
  4793. /**
  4794. * Gets the points which construct the path
  4795. * @returns the Path2 internal array of points.
  4796. */
  4797. getPoints(): Vector2[];
  4798. /**
  4799. * Retreives the point at the distance aways from the starting point
  4800. * @param normalizedLengthPosition the length along the path to retreive the point from
  4801. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4802. */
  4803. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4804. /**
  4805. * Creates a new path starting from an x and y position
  4806. * @param x starting x value
  4807. * @param y starting y value
  4808. * @returns a new Path2 starting at the coordinates (x, y).
  4809. */
  4810. static StartingAt(x: number, y: number): Path2;
  4811. }
  4812. /**
  4813. * Represents a 3D path made up of multiple 3D points
  4814. */
  4815. export class Path3D {
  4816. /**
  4817. * an array of Vector3, the curve axis of the Path3D
  4818. */
  4819. path: Vector3[];
  4820. private _curve;
  4821. private _distances;
  4822. private _tangents;
  4823. private _normals;
  4824. private _binormals;
  4825. private _raw;
  4826. private _alignTangentsWithPath;
  4827. private readonly _pointAtData;
  4828. /**
  4829. * new Path3D(path, normal, raw)
  4830. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4831. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4832. * @param path an array of Vector3, the curve axis of the Path3D
  4833. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4834. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4835. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4836. */
  4837. constructor(
  4838. /**
  4839. * an array of Vector3, the curve axis of the Path3D
  4840. */
  4841. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4842. /**
  4843. * Returns the Path3D array of successive Vector3 designing its curve.
  4844. * @returns the Path3D array of successive Vector3 designing its curve.
  4845. */
  4846. getCurve(): Vector3[];
  4847. /**
  4848. * Returns the Path3D array of successive Vector3 designing its curve.
  4849. * @returns the Path3D array of successive Vector3 designing its curve.
  4850. */
  4851. getPoints(): Vector3[];
  4852. /**
  4853. * @returns the computed length (float) of the path.
  4854. */
  4855. length(): number;
  4856. /**
  4857. * Returns an array populated with tangent vectors on each Path3D curve point.
  4858. * @returns an array populated with tangent vectors on each Path3D curve point.
  4859. */
  4860. getTangents(): Vector3[];
  4861. /**
  4862. * Returns an array populated with normal vectors on each Path3D curve point.
  4863. * @returns an array populated with normal vectors on each Path3D curve point.
  4864. */
  4865. getNormals(): Vector3[];
  4866. /**
  4867. * Returns an array populated with binormal vectors on each Path3D curve point.
  4868. * @returns an array populated with binormal vectors on each Path3D curve point.
  4869. */
  4870. getBinormals(): Vector3[];
  4871. /**
  4872. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4873. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4874. */
  4875. getDistances(): number[];
  4876. /**
  4877. * Returns an interpolated point along this path
  4878. * @param position the position of the point along this path, from 0.0 to 1.0
  4879. * @returns a new Vector3 as the point
  4880. */
  4881. getPointAt(position: number): Vector3;
  4882. /**
  4883. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4884. * @param position the position of the point along this path, from 0.0 to 1.0
  4885. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4886. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4887. */
  4888. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4889. /**
  4890. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4891. * @param position the position of the point along this path, from 0.0 to 1.0
  4892. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4893. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4894. */
  4895. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4896. /**
  4897. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4898. * @param position the position of the point along this path, from 0.0 to 1.0
  4899. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4900. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4901. */
  4902. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4903. /**
  4904. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4905. * @param position the position of the point along this path, from 0.0 to 1.0
  4906. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4907. */
  4908. getDistanceAt(position: number): number;
  4909. /**
  4910. * Returns the array index of the previous point of an interpolated point along this path
  4911. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4912. * @returns the array index
  4913. */
  4914. getPreviousPointIndexAt(position: number): number;
  4915. /**
  4916. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4917. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4918. * @returns the sub position
  4919. */
  4920. getSubPositionAt(position: number): number;
  4921. /**
  4922. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4923. * @param target the vector of which to get the closest position to
  4924. * @returns the position of the closest virtual point on this path to the target vector
  4925. */
  4926. getClosestPositionTo(target: Vector3): number;
  4927. /**
  4928. * Returns a sub path (slice) of this path
  4929. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4930. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4931. * @returns a sub path (slice) of this path
  4932. */
  4933. slice(start?: number, end?: number): Path3D;
  4934. /**
  4935. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4936. * @param path path which all values are copied into the curves points
  4937. * @param firstNormal which should be projected onto the curve
  4938. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4939. * @returns the same object updated.
  4940. */
  4941. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4942. private _compute;
  4943. private _getFirstNonNullVector;
  4944. private _getLastNonNullVector;
  4945. private _normalVector;
  4946. /**
  4947. * Updates the point at data for an interpolated point along this curve
  4948. * @param position the position of the point along this curve, from 0.0 to 1.0
  4949. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4950. * @returns the (updated) point at data
  4951. */
  4952. private _updatePointAtData;
  4953. /**
  4954. * Updates the point at data from the specified parameters
  4955. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4956. * @param point the interpolated point
  4957. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4958. */
  4959. private _setPointAtData;
  4960. /**
  4961. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4962. */
  4963. private _updateInterpolationMatrix;
  4964. }
  4965. /**
  4966. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4967. * A Curve3 is designed from a series of successive Vector3.
  4968. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4969. */
  4970. export class Curve3 {
  4971. private _points;
  4972. private _length;
  4973. /**
  4974. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4975. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4976. * @param v1 (Vector3) the control point
  4977. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4978. * @param nbPoints (integer) the wanted number of points in the curve
  4979. * @returns the created Curve3
  4980. */
  4981. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4982. /**
  4983. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4984. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4985. * @param v1 (Vector3) the first control point
  4986. * @param v2 (Vector3) the second control point
  4987. * @param v3 (Vector3) the end point of the Cubic Bezier
  4988. * @param nbPoints (integer) the wanted number of points in the curve
  4989. * @returns the created Curve3
  4990. */
  4991. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4992. /**
  4993. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4994. * @param p1 (Vector3) the origin point of the Hermite Spline
  4995. * @param t1 (Vector3) the tangent vector at the origin point
  4996. * @param p2 (Vector3) the end point of the Hermite Spline
  4997. * @param t2 (Vector3) the tangent vector at the end point
  4998. * @param nbPoints (integer) the wanted number of points in the curve
  4999. * @returns the created Curve3
  5000. */
  5001. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5002. /**
  5003. * Returns a Curve3 object along a CatmullRom Spline curve :
  5004. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5005. * @param nbPoints (integer) the wanted number of points between each curve control points
  5006. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5007. * @returns the created Curve3
  5008. */
  5009. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5010. /**
  5011. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5012. * A Curve3 is designed from a series of successive Vector3.
  5013. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5014. * @param points points which make up the curve
  5015. */
  5016. constructor(points: Vector3[]);
  5017. /**
  5018. * @returns the Curve3 stored array of successive Vector3
  5019. */
  5020. getPoints(): Vector3[];
  5021. /**
  5022. * @returns the computed length (float) of the curve.
  5023. */
  5024. length(): number;
  5025. /**
  5026. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5027. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5028. * curveA and curveB keep unchanged.
  5029. * @param curve the curve to continue from this curve
  5030. * @returns the newly constructed curve
  5031. */
  5032. continue(curve: DeepImmutable<Curve3>): Curve3;
  5033. private _computeLength;
  5034. }
  5035. }
  5036. declare module "babylonjs/Animations/easing" {
  5037. /**
  5038. * This represents the main contract an easing function should follow.
  5039. * Easing functions are used throughout the animation system.
  5040. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5041. */
  5042. export interface IEasingFunction {
  5043. /**
  5044. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5045. * of the easing function.
  5046. * The link below provides some of the most common examples of easing functions.
  5047. * @see https://easings.net/
  5048. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5049. * @returns the corresponding value on the curve defined by the easing function
  5050. */
  5051. ease(gradient: number): number;
  5052. }
  5053. /**
  5054. * Base class used for every default easing function.
  5055. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5056. */
  5057. export class EasingFunction implements IEasingFunction {
  5058. /**
  5059. * Interpolation follows the mathematical formula associated with the easing function.
  5060. */
  5061. static readonly EASINGMODE_EASEIN: number;
  5062. /**
  5063. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5064. */
  5065. static readonly EASINGMODE_EASEOUT: number;
  5066. /**
  5067. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5068. */
  5069. static readonly EASINGMODE_EASEINOUT: number;
  5070. private _easingMode;
  5071. /**
  5072. * Sets the easing mode of the current function.
  5073. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5074. */
  5075. setEasingMode(easingMode: number): void;
  5076. /**
  5077. * Gets the current easing mode.
  5078. * @returns the easing mode
  5079. */
  5080. getEasingMode(): number;
  5081. /**
  5082. * @hidden
  5083. */
  5084. easeInCore(gradient: number): number;
  5085. /**
  5086. * Given an input gradient between 0 and 1, this returns the corresponding value
  5087. * of the easing function.
  5088. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5089. * @returns the corresponding value on the curve defined by the easing function
  5090. */
  5091. ease(gradient: number): number;
  5092. }
  5093. /**
  5094. * Easing function with a circle shape (see link below).
  5095. * @see https://easings.net/#easeInCirc
  5096. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5097. */
  5098. export class CircleEase extends EasingFunction implements IEasingFunction {
  5099. /** @hidden */
  5100. easeInCore(gradient: number): number;
  5101. }
  5102. /**
  5103. * Easing function with a ease back shape (see link below).
  5104. * @see https://easings.net/#easeInBack
  5105. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5106. */
  5107. export class BackEase extends EasingFunction implements IEasingFunction {
  5108. /** Defines the amplitude of the function */
  5109. amplitude: number;
  5110. /**
  5111. * Instantiates a back ease easing
  5112. * @see https://easings.net/#easeInBack
  5113. * @param amplitude Defines the amplitude of the function
  5114. */
  5115. constructor(
  5116. /** Defines the amplitude of the function */
  5117. amplitude?: number);
  5118. /** @hidden */
  5119. easeInCore(gradient: number): number;
  5120. }
  5121. /**
  5122. * Easing function with a bouncing shape (see link below).
  5123. * @see https://easings.net/#easeInBounce
  5124. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5125. */
  5126. export class BounceEase extends EasingFunction implements IEasingFunction {
  5127. /** Defines the number of bounces */
  5128. bounces: number;
  5129. /** Defines the amplitude of the bounce */
  5130. bounciness: number;
  5131. /**
  5132. * Instantiates a bounce easing
  5133. * @see https://easings.net/#easeInBounce
  5134. * @param bounces Defines the number of bounces
  5135. * @param bounciness Defines the amplitude of the bounce
  5136. */
  5137. constructor(
  5138. /** Defines the number of bounces */
  5139. bounces?: number,
  5140. /** Defines the amplitude of the bounce */
  5141. bounciness?: number);
  5142. /** @hidden */
  5143. easeInCore(gradient: number): number;
  5144. }
  5145. /**
  5146. * Easing function with a power of 3 shape (see link below).
  5147. * @see https://easings.net/#easeInCubic
  5148. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5149. */
  5150. export class CubicEase extends EasingFunction implements IEasingFunction {
  5151. /** @hidden */
  5152. easeInCore(gradient: number): number;
  5153. }
  5154. /**
  5155. * Easing function with an elastic shape (see link below).
  5156. * @see https://easings.net/#easeInElastic
  5157. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5158. */
  5159. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5160. /** Defines the number of oscillations*/
  5161. oscillations: number;
  5162. /** Defines the amplitude of the oscillations*/
  5163. springiness: number;
  5164. /**
  5165. * Instantiates an elastic easing function
  5166. * @see https://easings.net/#easeInElastic
  5167. * @param oscillations Defines the number of oscillations
  5168. * @param springiness Defines the amplitude of the oscillations
  5169. */
  5170. constructor(
  5171. /** Defines the number of oscillations*/
  5172. oscillations?: number,
  5173. /** Defines the amplitude of the oscillations*/
  5174. springiness?: number);
  5175. /** @hidden */
  5176. easeInCore(gradient: number): number;
  5177. }
  5178. /**
  5179. * Easing function with an exponential shape (see link below).
  5180. * @see https://easings.net/#easeInExpo
  5181. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5182. */
  5183. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5184. /** Defines the exponent of the function */
  5185. exponent: number;
  5186. /**
  5187. * Instantiates an exponential easing function
  5188. * @see https://easings.net/#easeInExpo
  5189. * @param exponent Defines the exponent of the function
  5190. */
  5191. constructor(
  5192. /** Defines the exponent of the function */
  5193. exponent?: number);
  5194. /** @hidden */
  5195. easeInCore(gradient: number): number;
  5196. }
  5197. /**
  5198. * Easing function with a power shape (see link below).
  5199. * @see https://easings.net/#easeInQuad
  5200. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5201. */
  5202. export class PowerEase extends EasingFunction implements IEasingFunction {
  5203. /** Defines the power of the function */
  5204. power: number;
  5205. /**
  5206. * Instantiates an power base easing function
  5207. * @see https://easings.net/#easeInQuad
  5208. * @param power Defines the power of the function
  5209. */
  5210. constructor(
  5211. /** Defines the power of the function */
  5212. power?: number);
  5213. /** @hidden */
  5214. easeInCore(gradient: number): number;
  5215. }
  5216. /**
  5217. * Easing function with a power of 2 shape (see link below).
  5218. * @see https://easings.net/#easeInQuad
  5219. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5220. */
  5221. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5222. /** @hidden */
  5223. easeInCore(gradient: number): number;
  5224. }
  5225. /**
  5226. * Easing function with a power of 4 shape (see link below).
  5227. * @see https://easings.net/#easeInQuart
  5228. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5229. */
  5230. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5231. /** @hidden */
  5232. easeInCore(gradient: number): number;
  5233. }
  5234. /**
  5235. * Easing function with a power of 5 shape (see link below).
  5236. * @see https://easings.net/#easeInQuint
  5237. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5238. */
  5239. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5240. /** @hidden */
  5241. easeInCore(gradient: number): number;
  5242. }
  5243. /**
  5244. * Easing function with a sin shape (see link below).
  5245. * @see https://easings.net/#easeInSine
  5246. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5247. */
  5248. export class SineEase extends EasingFunction implements IEasingFunction {
  5249. /** @hidden */
  5250. easeInCore(gradient: number): number;
  5251. }
  5252. /**
  5253. * Easing function with a bezier shape (see link below).
  5254. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5255. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5256. */
  5257. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5258. /** Defines the x component of the start tangent in the bezier curve */
  5259. x1: number;
  5260. /** Defines the y component of the start tangent in the bezier curve */
  5261. y1: number;
  5262. /** Defines the x component of the end tangent in the bezier curve */
  5263. x2: number;
  5264. /** Defines the y component of the end tangent in the bezier curve */
  5265. y2: number;
  5266. /**
  5267. * Instantiates a bezier function
  5268. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5269. * @param x1 Defines the x component of the start tangent in the bezier curve
  5270. * @param y1 Defines the y component of the start tangent in the bezier curve
  5271. * @param x2 Defines the x component of the end tangent in the bezier curve
  5272. * @param y2 Defines the y component of the end tangent in the bezier curve
  5273. */
  5274. constructor(
  5275. /** Defines the x component of the start tangent in the bezier curve */
  5276. x1?: number,
  5277. /** Defines the y component of the start tangent in the bezier curve */
  5278. y1?: number,
  5279. /** Defines the x component of the end tangent in the bezier curve */
  5280. x2?: number,
  5281. /** Defines the y component of the end tangent in the bezier curve */
  5282. y2?: number);
  5283. /** @hidden */
  5284. easeInCore(gradient: number): number;
  5285. }
  5286. }
  5287. declare module "babylonjs/Maths/math.color" {
  5288. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5289. /**
  5290. * Class used to hold a RBG color
  5291. */
  5292. export class Color3 {
  5293. /**
  5294. * Defines the red component (between 0 and 1, default is 0)
  5295. */
  5296. r: number;
  5297. /**
  5298. * Defines the green component (between 0 and 1, default is 0)
  5299. */
  5300. g: number;
  5301. /**
  5302. * Defines the blue component (between 0 and 1, default is 0)
  5303. */
  5304. b: number;
  5305. /**
  5306. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5307. * @param r defines the red component (between 0 and 1, default is 0)
  5308. * @param g defines the green component (between 0 and 1, default is 0)
  5309. * @param b defines the blue component (between 0 and 1, default is 0)
  5310. */
  5311. constructor(
  5312. /**
  5313. * Defines the red component (between 0 and 1, default is 0)
  5314. */
  5315. r?: number,
  5316. /**
  5317. * Defines the green component (between 0 and 1, default is 0)
  5318. */
  5319. g?: number,
  5320. /**
  5321. * Defines the blue component (between 0 and 1, default is 0)
  5322. */
  5323. b?: number);
  5324. /**
  5325. * Creates a string with the Color3 current values
  5326. * @returns the string representation of the Color3 object
  5327. */
  5328. toString(): string;
  5329. /**
  5330. * Returns the string "Color3"
  5331. * @returns "Color3"
  5332. */
  5333. getClassName(): string;
  5334. /**
  5335. * Compute the Color3 hash code
  5336. * @returns an unique number that can be used to hash Color3 objects
  5337. */
  5338. getHashCode(): number;
  5339. /**
  5340. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5341. * @param array defines the array where to store the r,g,b components
  5342. * @param index defines an optional index in the target array to define where to start storing values
  5343. * @returns the current Color3 object
  5344. */
  5345. toArray(array: FloatArray, index?: number): Color3;
  5346. /**
  5347. * Returns a new Color4 object from the current Color3 and the given alpha
  5348. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5349. * @returns a new Color4 object
  5350. */
  5351. toColor4(alpha?: number): Color4;
  5352. /**
  5353. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5354. * @returns the new array
  5355. */
  5356. asArray(): number[];
  5357. /**
  5358. * Returns the luminance value
  5359. * @returns a float value
  5360. */
  5361. toLuminance(): number;
  5362. /**
  5363. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5364. * @param otherColor defines the second operand
  5365. * @returns the new Color3 object
  5366. */
  5367. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5368. /**
  5369. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5370. * @param otherColor defines the second operand
  5371. * @param result defines the Color3 object where to store the result
  5372. * @returns the current Color3
  5373. */
  5374. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5375. /**
  5376. * Determines equality between Color3 objects
  5377. * @param otherColor defines the second operand
  5378. * @returns true if the rgb values are equal to the given ones
  5379. */
  5380. equals(otherColor: DeepImmutable<Color3>): boolean;
  5381. /**
  5382. * Determines equality between the current Color3 object and a set of r,b,g values
  5383. * @param r defines the red component to check
  5384. * @param g defines the green component to check
  5385. * @param b defines the blue component to check
  5386. * @returns true if the rgb values are equal to the given ones
  5387. */
  5388. equalsFloats(r: number, g: number, b: number): boolean;
  5389. /**
  5390. * Multiplies in place each rgb value by scale
  5391. * @param scale defines the scaling factor
  5392. * @returns the updated Color3
  5393. */
  5394. scale(scale: number): Color3;
  5395. /**
  5396. * Multiplies the rgb values by scale and stores the result into "result"
  5397. * @param scale defines the scaling factor
  5398. * @param result defines the Color3 object where to store the result
  5399. * @returns the unmodified current Color3
  5400. */
  5401. scaleToRef(scale: number, result: Color3): Color3;
  5402. /**
  5403. * Scale the current Color3 values by a factor and add the result to a given Color3
  5404. * @param scale defines the scale factor
  5405. * @param result defines color to store the result into
  5406. * @returns the unmodified current Color3
  5407. */
  5408. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5409. /**
  5410. * Clamps the rgb values by the min and max values and stores the result into "result"
  5411. * @param min defines minimum clamping value (default is 0)
  5412. * @param max defines maximum clamping value (default is 1)
  5413. * @param result defines color to store the result into
  5414. * @returns the original Color3
  5415. */
  5416. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5417. /**
  5418. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5419. * @param otherColor defines the second operand
  5420. * @returns the new Color3
  5421. */
  5422. add(otherColor: DeepImmutable<Color3>): Color3;
  5423. /**
  5424. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5425. * @param otherColor defines the second operand
  5426. * @param result defines Color3 object to store the result into
  5427. * @returns the unmodified current Color3
  5428. */
  5429. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5430. /**
  5431. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5432. * @param otherColor defines the second operand
  5433. * @returns the new Color3
  5434. */
  5435. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5436. /**
  5437. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5438. * @param otherColor defines the second operand
  5439. * @param result defines Color3 object to store the result into
  5440. * @returns the unmodified current Color3
  5441. */
  5442. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5443. /**
  5444. * Copy the current object
  5445. * @returns a new Color3 copied the current one
  5446. */
  5447. clone(): Color3;
  5448. /**
  5449. * Copies the rgb values from the source in the current Color3
  5450. * @param source defines the source Color3 object
  5451. * @returns the updated Color3 object
  5452. */
  5453. copyFrom(source: DeepImmutable<Color3>): Color3;
  5454. /**
  5455. * Updates the Color3 rgb values from the given floats
  5456. * @param r defines the red component to read from
  5457. * @param g defines the green component to read from
  5458. * @param b defines the blue component to read from
  5459. * @returns the current Color3 object
  5460. */
  5461. copyFromFloats(r: number, g: number, b: number): Color3;
  5462. /**
  5463. * Updates the Color3 rgb values from the given floats
  5464. * @param r defines the red component to read from
  5465. * @param g defines the green component to read from
  5466. * @param b defines the blue component to read from
  5467. * @returns the current Color3 object
  5468. */
  5469. set(r: number, g: number, b: number): Color3;
  5470. /**
  5471. * Compute the Color3 hexadecimal code as a string
  5472. * @returns a string containing the hexadecimal representation of the Color3 object
  5473. */
  5474. toHexString(): string;
  5475. /**
  5476. * Computes a new Color3 converted from the current one to linear space
  5477. * @returns a new Color3 object
  5478. */
  5479. toLinearSpace(): Color3;
  5480. /**
  5481. * Converts current color in rgb space to HSV values
  5482. * @returns a new color3 representing the HSV values
  5483. */
  5484. toHSV(): Color3;
  5485. /**
  5486. * Converts current color in rgb space to HSV values
  5487. * @param result defines the Color3 where to store the HSV values
  5488. */
  5489. toHSVToRef(result: Color3): void;
  5490. /**
  5491. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5492. * @param convertedColor defines the Color3 object where to store the linear space version
  5493. * @returns the unmodified Color3
  5494. */
  5495. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5496. /**
  5497. * Computes a new Color3 converted from the current one to gamma space
  5498. * @returns a new Color3 object
  5499. */
  5500. toGammaSpace(): Color3;
  5501. /**
  5502. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5503. * @param convertedColor defines the Color3 object where to store the gamma space version
  5504. * @returns the unmodified Color3
  5505. */
  5506. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5507. private static _BlackReadOnly;
  5508. /**
  5509. * Convert Hue, saturation and value to a Color3 (RGB)
  5510. * @param hue defines the hue
  5511. * @param saturation defines the saturation
  5512. * @param value defines the value
  5513. * @param result defines the Color3 where to store the RGB values
  5514. */
  5515. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5516. /**
  5517. * Creates a new Color3 from the string containing valid hexadecimal values
  5518. * @param hex defines a string containing valid hexadecimal values
  5519. * @returns a new Color3 object
  5520. */
  5521. static FromHexString(hex: string): Color3;
  5522. /**
  5523. * Creates a new Color3 from the starting index of the given array
  5524. * @param array defines the source array
  5525. * @param offset defines an offset in the source array
  5526. * @returns a new Color3 object
  5527. */
  5528. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5529. /**
  5530. * Creates a new Color3 from integer values (< 256)
  5531. * @param r defines the red component to read from (value between 0 and 255)
  5532. * @param g defines the green component to read from (value between 0 and 255)
  5533. * @param b defines the blue component to read from (value between 0 and 255)
  5534. * @returns a new Color3 object
  5535. */
  5536. static FromInts(r: number, g: number, b: number): Color3;
  5537. /**
  5538. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5539. * @param start defines the start Color3 value
  5540. * @param end defines the end Color3 value
  5541. * @param amount defines the gradient value between start and end
  5542. * @returns a new Color3 object
  5543. */
  5544. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5545. /**
  5546. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5547. * @param left defines the start value
  5548. * @param right defines the end value
  5549. * @param amount defines the gradient factor
  5550. * @param result defines the Color3 object where to store the result
  5551. */
  5552. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5553. /**
  5554. * Returns a Color3 value containing a red color
  5555. * @returns a new Color3 object
  5556. */
  5557. static Red(): Color3;
  5558. /**
  5559. * Returns a Color3 value containing a green color
  5560. * @returns a new Color3 object
  5561. */
  5562. static Green(): Color3;
  5563. /**
  5564. * Returns a Color3 value containing a blue color
  5565. * @returns a new Color3 object
  5566. */
  5567. static Blue(): Color3;
  5568. /**
  5569. * Returns a Color3 value containing a black color
  5570. * @returns a new Color3 object
  5571. */
  5572. static Black(): Color3;
  5573. /**
  5574. * Gets a Color3 value containing a black color that must not be updated
  5575. */
  5576. static get BlackReadOnly(): DeepImmutable<Color3>;
  5577. /**
  5578. * Returns a Color3 value containing a white color
  5579. * @returns a new Color3 object
  5580. */
  5581. static White(): Color3;
  5582. /**
  5583. * Returns a Color3 value containing a purple color
  5584. * @returns a new Color3 object
  5585. */
  5586. static Purple(): Color3;
  5587. /**
  5588. * Returns a Color3 value containing a magenta color
  5589. * @returns a new Color3 object
  5590. */
  5591. static Magenta(): Color3;
  5592. /**
  5593. * Returns a Color3 value containing a yellow color
  5594. * @returns a new Color3 object
  5595. */
  5596. static Yellow(): Color3;
  5597. /**
  5598. * Returns a Color3 value containing a gray color
  5599. * @returns a new Color3 object
  5600. */
  5601. static Gray(): Color3;
  5602. /**
  5603. * Returns a Color3 value containing a teal color
  5604. * @returns a new Color3 object
  5605. */
  5606. static Teal(): Color3;
  5607. /**
  5608. * Returns a Color3 value containing a random color
  5609. * @returns a new Color3 object
  5610. */
  5611. static Random(): Color3;
  5612. }
  5613. /**
  5614. * Class used to hold a RBGA color
  5615. */
  5616. export class Color4 {
  5617. /**
  5618. * Defines the red component (between 0 and 1, default is 0)
  5619. */
  5620. r: number;
  5621. /**
  5622. * Defines the green component (between 0 and 1, default is 0)
  5623. */
  5624. g: number;
  5625. /**
  5626. * Defines the blue component (between 0 and 1, default is 0)
  5627. */
  5628. b: number;
  5629. /**
  5630. * Defines the alpha component (between 0 and 1, default is 1)
  5631. */
  5632. a: number;
  5633. /**
  5634. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5635. * @param r defines the red component (between 0 and 1, default is 0)
  5636. * @param g defines the green component (between 0 and 1, default is 0)
  5637. * @param b defines the blue component (between 0 and 1, default is 0)
  5638. * @param a defines the alpha component (between 0 and 1, default is 1)
  5639. */
  5640. constructor(
  5641. /**
  5642. * Defines the red component (between 0 and 1, default is 0)
  5643. */
  5644. r?: number,
  5645. /**
  5646. * Defines the green component (between 0 and 1, default is 0)
  5647. */
  5648. g?: number,
  5649. /**
  5650. * Defines the blue component (between 0 and 1, default is 0)
  5651. */
  5652. b?: number,
  5653. /**
  5654. * Defines the alpha component (between 0 and 1, default is 1)
  5655. */
  5656. a?: number);
  5657. /**
  5658. * Adds in place the given Color4 values to the current Color4 object
  5659. * @param right defines the second operand
  5660. * @returns the current updated Color4 object
  5661. */
  5662. addInPlace(right: DeepImmutable<Color4>): Color4;
  5663. /**
  5664. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5665. * @returns the new array
  5666. */
  5667. asArray(): number[];
  5668. /**
  5669. * Stores from the starting index in the given array the Color4 successive values
  5670. * @param array defines the array where to store the r,g,b components
  5671. * @param index defines an optional index in the target array to define where to start storing values
  5672. * @returns the current Color4 object
  5673. */
  5674. toArray(array: number[], index?: number): Color4;
  5675. /**
  5676. * Determines equality between Color4 objects
  5677. * @param otherColor defines the second operand
  5678. * @returns true if the rgba values are equal to the given ones
  5679. */
  5680. equals(otherColor: DeepImmutable<Color4>): boolean;
  5681. /**
  5682. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5683. * @param right defines the second operand
  5684. * @returns a new Color4 object
  5685. */
  5686. add(right: DeepImmutable<Color4>): Color4;
  5687. /**
  5688. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5689. * @param right defines the second operand
  5690. * @returns a new Color4 object
  5691. */
  5692. subtract(right: DeepImmutable<Color4>): Color4;
  5693. /**
  5694. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5695. * @param right defines the second operand
  5696. * @param result defines the Color4 object where to store the result
  5697. * @returns the current Color4 object
  5698. */
  5699. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5700. /**
  5701. * Creates a new Color4 with the current Color4 values multiplied by scale
  5702. * @param scale defines the scaling factor to apply
  5703. * @returns a new Color4 object
  5704. */
  5705. scale(scale: number): Color4;
  5706. /**
  5707. * Multiplies the current Color4 values by scale and stores the result in "result"
  5708. * @param scale defines the scaling factor to apply
  5709. * @param result defines the Color4 object where to store the result
  5710. * @returns the current unmodified Color4
  5711. */
  5712. scaleToRef(scale: number, result: Color4): Color4;
  5713. /**
  5714. * Scale the current Color4 values by a factor and add the result to a given Color4
  5715. * @param scale defines the scale factor
  5716. * @param result defines the Color4 object where to store the result
  5717. * @returns the unmodified current Color4
  5718. */
  5719. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5720. /**
  5721. * Clamps the rgb values by the min and max values and stores the result into "result"
  5722. * @param min defines minimum clamping value (default is 0)
  5723. * @param max defines maximum clamping value (default is 1)
  5724. * @param result defines color to store the result into.
  5725. * @returns the cuurent Color4
  5726. */
  5727. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5728. /**
  5729. * Multipy an Color4 value by another and return a new Color4 object
  5730. * @param color defines the Color4 value to multiply by
  5731. * @returns a new Color4 object
  5732. */
  5733. multiply(color: Color4): Color4;
  5734. /**
  5735. * Multipy a Color4 value by another and push the result in a reference value
  5736. * @param color defines the Color4 value to multiply by
  5737. * @param result defines the Color4 to fill the result in
  5738. * @returns the result Color4
  5739. */
  5740. multiplyToRef(color: Color4, result: Color4): Color4;
  5741. /**
  5742. * Creates a string with the Color4 current values
  5743. * @returns the string representation of the Color4 object
  5744. */
  5745. toString(): string;
  5746. /**
  5747. * Returns the string "Color4"
  5748. * @returns "Color4"
  5749. */
  5750. getClassName(): string;
  5751. /**
  5752. * Compute the Color4 hash code
  5753. * @returns an unique number that can be used to hash Color4 objects
  5754. */
  5755. getHashCode(): number;
  5756. /**
  5757. * Creates a new Color4 copied from the current one
  5758. * @returns a new Color4 object
  5759. */
  5760. clone(): Color4;
  5761. /**
  5762. * Copies the given Color4 values into the current one
  5763. * @param source defines the source Color4 object
  5764. * @returns the current updated Color4 object
  5765. */
  5766. copyFrom(source: Color4): Color4;
  5767. /**
  5768. * Copies the given float values into the current one
  5769. * @param r defines the red component to read from
  5770. * @param g defines the green component to read from
  5771. * @param b defines the blue component to read from
  5772. * @param a defines the alpha component to read from
  5773. * @returns the current updated Color4 object
  5774. */
  5775. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5776. /**
  5777. * Copies the given float values into the current one
  5778. * @param r defines the red component to read from
  5779. * @param g defines the green component to read from
  5780. * @param b defines the blue component to read from
  5781. * @param a defines the alpha component to read from
  5782. * @returns the current updated Color4 object
  5783. */
  5784. set(r: number, g: number, b: number, a: number): Color4;
  5785. /**
  5786. * Compute the Color4 hexadecimal code as a string
  5787. * @returns a string containing the hexadecimal representation of the Color4 object
  5788. */
  5789. toHexString(): string;
  5790. /**
  5791. * Computes a new Color4 converted from the current one to linear space
  5792. * @returns a new Color4 object
  5793. */
  5794. toLinearSpace(): Color4;
  5795. /**
  5796. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5797. * @param convertedColor defines the Color4 object where to store the linear space version
  5798. * @returns the unmodified Color4
  5799. */
  5800. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5801. /**
  5802. * Computes a new Color4 converted from the current one to gamma space
  5803. * @returns a new Color4 object
  5804. */
  5805. toGammaSpace(): Color4;
  5806. /**
  5807. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5808. * @param convertedColor defines the Color4 object where to store the gamma space version
  5809. * @returns the unmodified Color4
  5810. */
  5811. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5812. /**
  5813. * Creates a new Color4 from the string containing valid hexadecimal values
  5814. * @param hex defines a string containing valid hexadecimal values
  5815. * @returns a new Color4 object
  5816. */
  5817. static FromHexString(hex: string): Color4;
  5818. /**
  5819. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5820. * @param left defines the start value
  5821. * @param right defines the end value
  5822. * @param amount defines the gradient factor
  5823. * @returns a new Color4 object
  5824. */
  5825. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5826. /**
  5827. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5828. * @param left defines the start value
  5829. * @param right defines the end value
  5830. * @param amount defines the gradient factor
  5831. * @param result defines the Color4 object where to store data
  5832. */
  5833. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5834. /**
  5835. * Creates a new Color4 from a Color3 and an alpha value
  5836. * @param color3 defines the source Color3 to read from
  5837. * @param alpha defines the alpha component (1.0 by default)
  5838. * @returns a new Color4 object
  5839. */
  5840. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5841. /**
  5842. * Creates a new Color4 from the starting index element of the given array
  5843. * @param array defines the source array to read from
  5844. * @param offset defines the offset in the source array
  5845. * @returns a new Color4 object
  5846. */
  5847. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5848. /**
  5849. * Creates a new Color3 from integer values (< 256)
  5850. * @param r defines the red component to read from (value between 0 and 255)
  5851. * @param g defines the green component to read from (value between 0 and 255)
  5852. * @param b defines the blue component to read from (value between 0 and 255)
  5853. * @param a defines the alpha component to read from (value between 0 and 255)
  5854. * @returns a new Color3 object
  5855. */
  5856. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5857. /**
  5858. * Check the content of a given array and convert it to an array containing RGBA data
  5859. * If the original array was already containing count * 4 values then it is returned directly
  5860. * @param colors defines the array to check
  5861. * @param count defines the number of RGBA data to expect
  5862. * @returns an array containing count * 4 values (RGBA)
  5863. */
  5864. static CheckColors4(colors: number[], count: number): number[];
  5865. }
  5866. /**
  5867. * @hidden
  5868. */
  5869. export class TmpColors {
  5870. static Color3: Color3[];
  5871. static Color4: Color4[];
  5872. }
  5873. }
  5874. declare module "babylonjs/Animations/animationKey" {
  5875. /**
  5876. * Defines an interface which represents an animation key frame
  5877. */
  5878. export interface IAnimationKey {
  5879. /**
  5880. * Frame of the key frame
  5881. */
  5882. frame: number;
  5883. /**
  5884. * Value at the specifies key frame
  5885. */
  5886. value: any;
  5887. /**
  5888. * The input tangent for the cubic hermite spline
  5889. */
  5890. inTangent?: any;
  5891. /**
  5892. * The output tangent for the cubic hermite spline
  5893. */
  5894. outTangent?: any;
  5895. /**
  5896. * The animation interpolation type
  5897. */
  5898. interpolation?: AnimationKeyInterpolation;
  5899. }
  5900. /**
  5901. * Enum for the animation key frame interpolation type
  5902. */
  5903. export enum AnimationKeyInterpolation {
  5904. /**
  5905. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5906. */
  5907. STEP = 1
  5908. }
  5909. }
  5910. declare module "babylonjs/Animations/animationRange" {
  5911. /**
  5912. * Represents the range of an animation
  5913. */
  5914. export class AnimationRange {
  5915. /**The name of the animation range**/
  5916. name: string;
  5917. /**The starting frame of the animation */
  5918. from: number;
  5919. /**The ending frame of the animation*/
  5920. to: number;
  5921. /**
  5922. * Initializes the range of an animation
  5923. * @param name The name of the animation range
  5924. * @param from The starting frame of the animation
  5925. * @param to The ending frame of the animation
  5926. */
  5927. constructor(
  5928. /**The name of the animation range**/
  5929. name: string,
  5930. /**The starting frame of the animation */
  5931. from: number,
  5932. /**The ending frame of the animation*/
  5933. to: number);
  5934. /**
  5935. * Makes a copy of the animation range
  5936. * @returns A copy of the animation range
  5937. */
  5938. clone(): AnimationRange;
  5939. }
  5940. }
  5941. declare module "babylonjs/Animations/animationEvent" {
  5942. /**
  5943. * Composed of a frame, and an action function
  5944. */
  5945. export class AnimationEvent {
  5946. /** The frame for which the event is triggered **/
  5947. frame: number;
  5948. /** The event to perform when triggered **/
  5949. action: (currentFrame: number) => void;
  5950. /** Specifies if the event should be triggered only once**/
  5951. onlyOnce?: boolean | undefined;
  5952. /**
  5953. * Specifies if the animation event is done
  5954. */
  5955. isDone: boolean;
  5956. /**
  5957. * Initializes the animation event
  5958. * @param frame The frame for which the event is triggered
  5959. * @param action The event to perform when triggered
  5960. * @param onlyOnce Specifies if the event should be triggered only once
  5961. */
  5962. constructor(
  5963. /** The frame for which the event is triggered **/
  5964. frame: number,
  5965. /** The event to perform when triggered **/
  5966. action: (currentFrame: number) => void,
  5967. /** Specifies if the event should be triggered only once**/
  5968. onlyOnce?: boolean | undefined);
  5969. /** @hidden */
  5970. _clone(): AnimationEvent;
  5971. }
  5972. }
  5973. declare module "babylonjs/Behaviors/behavior" {
  5974. import { Nullable } from "babylonjs/types";
  5975. /**
  5976. * Interface used to define a behavior
  5977. */
  5978. export interface Behavior<T> {
  5979. /** gets or sets behavior's name */
  5980. name: string;
  5981. /**
  5982. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5983. */
  5984. init(): void;
  5985. /**
  5986. * Called when the behavior is attached to a target
  5987. * @param target defines the target where the behavior is attached to
  5988. */
  5989. attach(target: T): void;
  5990. /**
  5991. * Called when the behavior is detached from its target
  5992. */
  5993. detach(): void;
  5994. }
  5995. /**
  5996. * Interface implemented by classes supporting behaviors
  5997. */
  5998. export interface IBehaviorAware<T> {
  5999. /**
  6000. * Attach a behavior
  6001. * @param behavior defines the behavior to attach
  6002. * @returns the current host
  6003. */
  6004. addBehavior(behavior: Behavior<T>): T;
  6005. /**
  6006. * Remove a behavior from the current object
  6007. * @param behavior defines the behavior to detach
  6008. * @returns the current host
  6009. */
  6010. removeBehavior(behavior: Behavior<T>): T;
  6011. /**
  6012. * Gets a behavior using its name to search
  6013. * @param name defines the name to search
  6014. * @returns the behavior or null if not found
  6015. */
  6016. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6017. }
  6018. }
  6019. declare module "babylonjs/Misc/smartArray" {
  6020. /**
  6021. * Defines an array and its length.
  6022. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6023. */
  6024. export interface ISmartArrayLike<T> {
  6025. /**
  6026. * The data of the array.
  6027. */
  6028. data: Array<T>;
  6029. /**
  6030. * The active length of the array.
  6031. */
  6032. length: number;
  6033. }
  6034. /**
  6035. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6036. */
  6037. export class SmartArray<T> implements ISmartArrayLike<T> {
  6038. /**
  6039. * The full set of data from the array.
  6040. */
  6041. data: Array<T>;
  6042. /**
  6043. * The active length of the array.
  6044. */
  6045. length: number;
  6046. protected _id: number;
  6047. /**
  6048. * Instantiates a Smart Array.
  6049. * @param capacity defines the default capacity of the array.
  6050. */
  6051. constructor(capacity: number);
  6052. /**
  6053. * Pushes a value at the end of the active data.
  6054. * @param value defines the object to push in the array.
  6055. */
  6056. push(value: T): void;
  6057. /**
  6058. * Iterates over the active data and apply the lambda to them.
  6059. * @param func defines the action to apply on each value.
  6060. */
  6061. forEach(func: (content: T) => void): void;
  6062. /**
  6063. * Sorts the full sets of data.
  6064. * @param compareFn defines the comparison function to apply.
  6065. */
  6066. sort(compareFn: (a: T, b: T) => number): void;
  6067. /**
  6068. * Resets the active data to an empty array.
  6069. */
  6070. reset(): void;
  6071. /**
  6072. * Releases all the data from the array as well as the array.
  6073. */
  6074. dispose(): void;
  6075. /**
  6076. * Concats the active data with a given array.
  6077. * @param array defines the data to concatenate with.
  6078. */
  6079. concat(array: any): void;
  6080. /**
  6081. * Returns the position of a value in the active data.
  6082. * @param value defines the value to find the index for
  6083. * @returns the index if found in the active data otherwise -1
  6084. */
  6085. indexOf(value: T): number;
  6086. /**
  6087. * Returns whether an element is part of the active data.
  6088. * @param value defines the value to look for
  6089. * @returns true if found in the active data otherwise false
  6090. */
  6091. contains(value: T): boolean;
  6092. private static _GlobalId;
  6093. }
  6094. /**
  6095. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6096. * The data in this array can only be present once
  6097. */
  6098. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6099. private _duplicateId;
  6100. /**
  6101. * Pushes a value at the end of the active data.
  6102. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6103. * @param value defines the object to push in the array.
  6104. */
  6105. push(value: T): void;
  6106. /**
  6107. * Pushes a value at the end of the active data.
  6108. * If the data is already present, it won t be added again
  6109. * @param value defines the object to push in the array.
  6110. * @returns true if added false if it was already present
  6111. */
  6112. pushNoDuplicate(value: T): boolean;
  6113. /**
  6114. * Resets the active data to an empty array.
  6115. */
  6116. reset(): void;
  6117. /**
  6118. * Concats the active data with a given array.
  6119. * This ensures no dupplicate will be present in the result.
  6120. * @param array defines the data to concatenate with.
  6121. */
  6122. concatWithNoDuplicate(array: any): void;
  6123. }
  6124. }
  6125. declare module "babylonjs/Cameras/cameraInputsManager" {
  6126. import { Nullable } from "babylonjs/types";
  6127. import { Camera } from "babylonjs/Cameras/camera";
  6128. /**
  6129. * @ignore
  6130. * This is a list of all the different input types that are available in the application.
  6131. * Fo instance: ArcRotateCameraGamepadInput...
  6132. */
  6133. export var CameraInputTypes: {};
  6134. /**
  6135. * This is the contract to implement in order to create a new input class.
  6136. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6137. */
  6138. export interface ICameraInput<TCamera extends Camera> {
  6139. /**
  6140. * Defines the camera the input is attached to.
  6141. */
  6142. camera: Nullable<TCamera>;
  6143. /**
  6144. * Gets the class name of the current intput.
  6145. * @returns the class name
  6146. */
  6147. getClassName(): string;
  6148. /**
  6149. * Get the friendly name associated with the input class.
  6150. * @returns the input friendly name
  6151. */
  6152. getSimpleName(): string;
  6153. /**
  6154. * Attach the input controls to a specific dom element to get the input from.
  6155. * @param element Defines the element the controls should be listened from
  6156. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6157. */
  6158. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6159. /**
  6160. * Detach the current controls from the specified dom element.
  6161. * @param element Defines the element to stop listening the inputs from
  6162. */
  6163. detachControl(element: Nullable<HTMLElement>): void;
  6164. /**
  6165. * Update the current camera state depending on the inputs that have been used this frame.
  6166. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6167. */
  6168. checkInputs?: () => void;
  6169. }
  6170. /**
  6171. * Represents a map of input types to input instance or input index to input instance.
  6172. */
  6173. export interface CameraInputsMap<TCamera extends Camera> {
  6174. /**
  6175. * Accessor to the input by input type.
  6176. */
  6177. [name: string]: ICameraInput<TCamera>;
  6178. /**
  6179. * Accessor to the input by input index.
  6180. */
  6181. [idx: number]: ICameraInput<TCamera>;
  6182. }
  6183. /**
  6184. * This represents the input manager used within a camera.
  6185. * It helps dealing with all the different kind of input attached to a camera.
  6186. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6187. */
  6188. export class CameraInputsManager<TCamera extends Camera> {
  6189. /**
  6190. * Defines the list of inputs attahed to the camera.
  6191. */
  6192. attached: CameraInputsMap<TCamera>;
  6193. /**
  6194. * Defines the dom element the camera is collecting inputs from.
  6195. * This is null if the controls have not been attached.
  6196. */
  6197. attachedElement: Nullable<HTMLElement>;
  6198. /**
  6199. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6200. */
  6201. noPreventDefault: boolean;
  6202. /**
  6203. * Defined the camera the input manager belongs to.
  6204. */
  6205. camera: TCamera;
  6206. /**
  6207. * Update the current camera state depending on the inputs that have been used this frame.
  6208. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6209. */
  6210. checkInputs: () => void;
  6211. /**
  6212. * Instantiate a new Camera Input Manager.
  6213. * @param camera Defines the camera the input manager blongs to
  6214. */
  6215. constructor(camera: TCamera);
  6216. /**
  6217. * Add an input method to a camera
  6218. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6219. * @param input camera input method
  6220. */
  6221. add(input: ICameraInput<TCamera>): void;
  6222. /**
  6223. * Remove a specific input method from a camera
  6224. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6225. * @param inputToRemove camera input method
  6226. */
  6227. remove(inputToRemove: ICameraInput<TCamera>): void;
  6228. /**
  6229. * Remove a specific input type from a camera
  6230. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6231. * @param inputType the type of the input to remove
  6232. */
  6233. removeByType(inputType: string): void;
  6234. private _addCheckInputs;
  6235. /**
  6236. * Attach the input controls to the currently attached dom element to listen the events from.
  6237. * @param input Defines the input to attach
  6238. */
  6239. attachInput(input: ICameraInput<TCamera>): void;
  6240. /**
  6241. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6242. * @param element Defines the dom element to collect the events from
  6243. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6244. */
  6245. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6246. /**
  6247. * Detach the current manager inputs controls from a specific dom element.
  6248. * @param element Defines the dom element to collect the events from
  6249. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6250. */
  6251. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6252. /**
  6253. * Rebuild the dynamic inputCheck function from the current list of
  6254. * defined inputs in the manager.
  6255. */
  6256. rebuildInputCheck(): void;
  6257. /**
  6258. * Remove all attached input methods from a camera
  6259. */
  6260. clear(): void;
  6261. /**
  6262. * Serialize the current input manager attached to a camera.
  6263. * This ensures than once parsed,
  6264. * the input associated to the camera will be identical to the current ones
  6265. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6266. */
  6267. serialize(serializedCamera: any): void;
  6268. /**
  6269. * Parses an input manager serialized JSON to restore the previous list of inputs
  6270. * and states associated to a camera.
  6271. * @param parsedCamera Defines the JSON to parse
  6272. */
  6273. parse(parsedCamera: any): void;
  6274. }
  6275. }
  6276. declare module "babylonjs/Meshes/buffer" {
  6277. import { Nullable, DataArray } from "babylonjs/types";
  6278. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6279. /**
  6280. * Class used to store data that will be store in GPU memory
  6281. */
  6282. export class Buffer {
  6283. private _engine;
  6284. private _buffer;
  6285. /** @hidden */
  6286. _data: Nullable<DataArray>;
  6287. private _updatable;
  6288. private _instanced;
  6289. private _divisor;
  6290. /**
  6291. * Gets the byte stride.
  6292. */
  6293. readonly byteStride: number;
  6294. /**
  6295. * Constructor
  6296. * @param engine the engine
  6297. * @param data the data to use for this buffer
  6298. * @param updatable whether the data is updatable
  6299. * @param stride the stride (optional)
  6300. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6301. * @param instanced whether the buffer is instanced (optional)
  6302. * @param useBytes set to true if the stride in in bytes (optional)
  6303. * @param divisor sets an optional divisor for instances (1 by default)
  6304. */
  6305. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6306. /**
  6307. * Create a new VertexBuffer based on the current buffer
  6308. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6309. * @param offset defines offset in the buffer (0 by default)
  6310. * @param size defines the size in floats of attributes (position is 3 for instance)
  6311. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6312. * @param instanced defines if the vertex buffer contains indexed data
  6313. * @param useBytes defines if the offset and stride are in bytes *
  6314. * @param divisor sets an optional divisor for instances (1 by default)
  6315. * @returns the new vertex buffer
  6316. */
  6317. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6318. /**
  6319. * Gets a boolean indicating if the Buffer is updatable?
  6320. * @returns true if the buffer is updatable
  6321. */
  6322. isUpdatable(): boolean;
  6323. /**
  6324. * Gets current buffer's data
  6325. * @returns a DataArray or null
  6326. */
  6327. getData(): Nullable<DataArray>;
  6328. /**
  6329. * Gets underlying native buffer
  6330. * @returns underlying native buffer
  6331. */
  6332. getBuffer(): Nullable<DataBuffer>;
  6333. /**
  6334. * Gets the stride in float32 units (i.e. byte stride / 4).
  6335. * May not be an integer if the byte stride is not divisible by 4.
  6336. * @returns the stride in float32 units
  6337. * @deprecated Please use byteStride instead.
  6338. */
  6339. getStrideSize(): number;
  6340. /**
  6341. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6342. * @param data defines the data to store
  6343. */
  6344. create(data?: Nullable<DataArray>): void;
  6345. /** @hidden */
  6346. _rebuild(): void;
  6347. /**
  6348. * Update current buffer data
  6349. * @param data defines the data to store
  6350. */
  6351. update(data: DataArray): void;
  6352. /**
  6353. * Updates the data directly.
  6354. * @param data the new data
  6355. * @param offset the new offset
  6356. * @param vertexCount the vertex count (optional)
  6357. * @param useBytes set to true if the offset is in bytes
  6358. */
  6359. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6360. /**
  6361. * Release all resources
  6362. */
  6363. dispose(): void;
  6364. }
  6365. /**
  6366. * Specialized buffer used to store vertex data
  6367. */
  6368. export class VertexBuffer {
  6369. /** @hidden */
  6370. _buffer: Buffer;
  6371. private _kind;
  6372. private _size;
  6373. private _ownsBuffer;
  6374. private _instanced;
  6375. private _instanceDivisor;
  6376. /**
  6377. * The byte type.
  6378. */
  6379. static readonly BYTE: number;
  6380. /**
  6381. * The unsigned byte type.
  6382. */
  6383. static readonly UNSIGNED_BYTE: number;
  6384. /**
  6385. * The short type.
  6386. */
  6387. static readonly SHORT: number;
  6388. /**
  6389. * The unsigned short type.
  6390. */
  6391. static readonly UNSIGNED_SHORT: number;
  6392. /**
  6393. * The integer type.
  6394. */
  6395. static readonly INT: number;
  6396. /**
  6397. * The unsigned integer type.
  6398. */
  6399. static readonly UNSIGNED_INT: number;
  6400. /**
  6401. * The float type.
  6402. */
  6403. static readonly FLOAT: number;
  6404. /**
  6405. * Gets or sets the instance divisor when in instanced mode
  6406. */
  6407. get instanceDivisor(): number;
  6408. set instanceDivisor(value: number);
  6409. /**
  6410. * Gets the byte stride.
  6411. */
  6412. readonly byteStride: number;
  6413. /**
  6414. * Gets the byte offset.
  6415. */
  6416. readonly byteOffset: number;
  6417. /**
  6418. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6419. */
  6420. readonly normalized: boolean;
  6421. /**
  6422. * Gets the data type of each component in the array.
  6423. */
  6424. readonly type: number;
  6425. /**
  6426. * Constructor
  6427. * @param engine the engine
  6428. * @param data the data to use for this vertex buffer
  6429. * @param kind the vertex buffer kind
  6430. * @param updatable whether the data is updatable
  6431. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6432. * @param stride the stride (optional)
  6433. * @param instanced whether the buffer is instanced (optional)
  6434. * @param offset the offset of the data (optional)
  6435. * @param size the number of components (optional)
  6436. * @param type the type of the component (optional)
  6437. * @param normalized whether the data contains normalized data (optional)
  6438. * @param useBytes set to true if stride and offset are in bytes (optional)
  6439. * @param divisor defines the instance divisor to use (1 by default)
  6440. */
  6441. 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, divisor?: number);
  6442. /** @hidden */
  6443. _rebuild(): void;
  6444. /**
  6445. * Returns the kind of the VertexBuffer (string)
  6446. * @returns a string
  6447. */
  6448. getKind(): string;
  6449. /**
  6450. * Gets a boolean indicating if the VertexBuffer is updatable?
  6451. * @returns true if the buffer is updatable
  6452. */
  6453. isUpdatable(): boolean;
  6454. /**
  6455. * Gets current buffer's data
  6456. * @returns a DataArray or null
  6457. */
  6458. getData(): Nullable<DataArray>;
  6459. /**
  6460. * Gets underlying native buffer
  6461. * @returns underlying native buffer
  6462. */
  6463. getBuffer(): Nullable<DataBuffer>;
  6464. /**
  6465. * Gets the stride in float32 units (i.e. byte stride / 4).
  6466. * May not be an integer if the byte stride is not divisible by 4.
  6467. * @returns the stride in float32 units
  6468. * @deprecated Please use byteStride instead.
  6469. */
  6470. getStrideSize(): number;
  6471. /**
  6472. * Returns the offset as a multiple of the type byte length.
  6473. * @returns the offset in bytes
  6474. * @deprecated Please use byteOffset instead.
  6475. */
  6476. getOffset(): number;
  6477. /**
  6478. * Returns the number of components per vertex attribute (integer)
  6479. * @returns the size in float
  6480. */
  6481. getSize(): number;
  6482. /**
  6483. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6484. * @returns true if this buffer is instanced
  6485. */
  6486. getIsInstanced(): boolean;
  6487. /**
  6488. * Returns the instancing divisor, zero for non-instanced (integer).
  6489. * @returns a number
  6490. */
  6491. getInstanceDivisor(): number;
  6492. /**
  6493. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6494. * @param data defines the data to store
  6495. */
  6496. create(data?: DataArray): void;
  6497. /**
  6498. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6499. * This function will create a new buffer if the current one is not updatable
  6500. * @param data defines the data to store
  6501. */
  6502. update(data: DataArray): void;
  6503. /**
  6504. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6505. * Returns the directly updated WebGLBuffer.
  6506. * @param data the new data
  6507. * @param offset the new offset
  6508. * @param useBytes set to true if the offset is in bytes
  6509. */
  6510. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6511. /**
  6512. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6513. */
  6514. dispose(): void;
  6515. /**
  6516. * Enumerates each value of this vertex buffer as numbers.
  6517. * @param count the number of values to enumerate
  6518. * @param callback the callback function called for each value
  6519. */
  6520. forEach(count: number, callback: (value: number, index: number) => void): void;
  6521. /**
  6522. * Positions
  6523. */
  6524. static readonly PositionKind: string;
  6525. /**
  6526. * Normals
  6527. */
  6528. static readonly NormalKind: string;
  6529. /**
  6530. * Tangents
  6531. */
  6532. static readonly TangentKind: string;
  6533. /**
  6534. * Texture coordinates
  6535. */
  6536. static readonly UVKind: string;
  6537. /**
  6538. * Texture coordinates 2
  6539. */
  6540. static readonly UV2Kind: string;
  6541. /**
  6542. * Texture coordinates 3
  6543. */
  6544. static readonly UV3Kind: string;
  6545. /**
  6546. * Texture coordinates 4
  6547. */
  6548. static readonly UV4Kind: string;
  6549. /**
  6550. * Texture coordinates 5
  6551. */
  6552. static readonly UV5Kind: string;
  6553. /**
  6554. * Texture coordinates 6
  6555. */
  6556. static readonly UV6Kind: string;
  6557. /**
  6558. * Colors
  6559. */
  6560. static readonly ColorKind: string;
  6561. /**
  6562. * Matrix indices (for bones)
  6563. */
  6564. static readonly MatricesIndicesKind: string;
  6565. /**
  6566. * Matrix weights (for bones)
  6567. */
  6568. static readonly MatricesWeightsKind: string;
  6569. /**
  6570. * Additional matrix indices (for bones)
  6571. */
  6572. static readonly MatricesIndicesExtraKind: string;
  6573. /**
  6574. * Additional matrix weights (for bones)
  6575. */
  6576. static readonly MatricesWeightsExtraKind: string;
  6577. /**
  6578. * Deduces the stride given a kind.
  6579. * @param kind The kind string to deduce
  6580. * @returns The deduced stride
  6581. */
  6582. static DeduceStride(kind: string): number;
  6583. /**
  6584. * Gets the byte length of the given type.
  6585. * @param type the type
  6586. * @returns the number of bytes
  6587. */
  6588. static GetTypeByteLength(type: number): number;
  6589. /**
  6590. * Enumerates each value of the given parameters as numbers.
  6591. * @param data the data to enumerate
  6592. * @param byteOffset the byte offset of the data
  6593. * @param byteStride the byte stride of the data
  6594. * @param componentCount the number of components per element
  6595. * @param componentType the type of the component
  6596. * @param count the number of values to enumerate
  6597. * @param normalized whether the data is normalized
  6598. * @param callback the callback function called for each value
  6599. */
  6600. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6601. private static _GetFloatValue;
  6602. }
  6603. }
  6604. declare module "babylonjs/Collisions/intersectionInfo" {
  6605. import { Nullable } from "babylonjs/types";
  6606. /**
  6607. * @hidden
  6608. */
  6609. export class IntersectionInfo {
  6610. bu: Nullable<number>;
  6611. bv: Nullable<number>;
  6612. distance: number;
  6613. faceId: number;
  6614. subMeshId: number;
  6615. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6616. }
  6617. }
  6618. declare module "babylonjs/Maths/math.plane" {
  6619. import { DeepImmutable } from "babylonjs/types";
  6620. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6621. /**
  6622. * Represens a plane by the equation ax + by + cz + d = 0
  6623. */
  6624. export class Plane {
  6625. private static _TmpMatrix;
  6626. /**
  6627. * Normal of the plane (a,b,c)
  6628. */
  6629. normal: Vector3;
  6630. /**
  6631. * d component of the plane
  6632. */
  6633. d: number;
  6634. /**
  6635. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6636. * @param a a component of the plane
  6637. * @param b b component of the plane
  6638. * @param c c component of the plane
  6639. * @param d d component of the plane
  6640. */
  6641. constructor(a: number, b: number, c: number, d: number);
  6642. /**
  6643. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6644. */
  6645. asArray(): number[];
  6646. /**
  6647. * @returns a new plane copied from the current Plane.
  6648. */
  6649. clone(): Plane;
  6650. /**
  6651. * @returns the string "Plane".
  6652. */
  6653. getClassName(): string;
  6654. /**
  6655. * @returns the Plane hash code.
  6656. */
  6657. getHashCode(): number;
  6658. /**
  6659. * Normalize the current Plane in place.
  6660. * @returns the updated Plane.
  6661. */
  6662. normalize(): Plane;
  6663. /**
  6664. * Applies a transformation the plane and returns the result
  6665. * @param transformation the transformation matrix to be applied to the plane
  6666. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6667. */
  6668. transform(transformation: DeepImmutable<Matrix>): Plane;
  6669. /**
  6670. * Calcualtte the dot product between the point and the plane normal
  6671. * @param point point to calculate the dot product with
  6672. * @returns the dot product (float) of the point coordinates and the plane normal.
  6673. */
  6674. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6675. /**
  6676. * Updates the current Plane from the plane defined by the three given points.
  6677. * @param point1 one of the points used to contruct the plane
  6678. * @param point2 one of the points used to contruct the plane
  6679. * @param point3 one of the points used to contruct the plane
  6680. * @returns the updated Plane.
  6681. */
  6682. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6683. /**
  6684. * Checks if the plane is facing a given direction
  6685. * @param direction the direction to check if the plane is facing
  6686. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6687. * @returns True is the vector "direction" is the same side than the plane normal.
  6688. */
  6689. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6690. /**
  6691. * Calculates the distance to a point
  6692. * @param point point to calculate distance to
  6693. * @returns the signed distance (float) from the given point to the Plane.
  6694. */
  6695. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6696. /**
  6697. * Creates a plane from an array
  6698. * @param array the array to create a plane from
  6699. * @returns a new Plane from the given array.
  6700. */
  6701. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6702. /**
  6703. * Creates a plane from three points
  6704. * @param point1 point used to create the plane
  6705. * @param point2 point used to create the plane
  6706. * @param point3 point used to create the plane
  6707. * @returns a new Plane defined by the three given points.
  6708. */
  6709. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6710. /**
  6711. * Creates a plane from an origin point and a normal
  6712. * @param origin origin of the plane to be constructed
  6713. * @param normal normal of the plane to be constructed
  6714. * @returns a new Plane the normal vector to this plane at the given origin point.
  6715. * Note : the vector "normal" is updated because normalized.
  6716. */
  6717. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6718. /**
  6719. * Calculates the distance from a plane and a point
  6720. * @param origin origin of the plane to be constructed
  6721. * @param normal normal of the plane to be constructed
  6722. * @param point point to calculate distance to
  6723. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6724. */
  6725. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6726. }
  6727. }
  6728. declare module "babylonjs/Culling/boundingSphere" {
  6729. import { DeepImmutable } from "babylonjs/types";
  6730. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6731. import { Plane } from "babylonjs/Maths/math.plane";
  6732. /**
  6733. * Class used to store bounding sphere information
  6734. */
  6735. export class BoundingSphere {
  6736. /**
  6737. * Gets the center of the bounding sphere in local space
  6738. */
  6739. readonly center: Vector3;
  6740. /**
  6741. * Radius of the bounding sphere in local space
  6742. */
  6743. radius: number;
  6744. /**
  6745. * Gets the center of the bounding sphere in world space
  6746. */
  6747. readonly centerWorld: Vector3;
  6748. /**
  6749. * Radius of the bounding sphere in world space
  6750. */
  6751. radiusWorld: number;
  6752. /**
  6753. * Gets the minimum vector in local space
  6754. */
  6755. readonly minimum: Vector3;
  6756. /**
  6757. * Gets the maximum vector in local space
  6758. */
  6759. readonly maximum: Vector3;
  6760. private _worldMatrix;
  6761. private static readonly TmpVector3;
  6762. /**
  6763. * Creates a new bounding sphere
  6764. * @param min defines the minimum vector (in local space)
  6765. * @param max defines the maximum vector (in local space)
  6766. * @param worldMatrix defines the new world matrix
  6767. */
  6768. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6769. /**
  6770. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6771. * @param min defines the new minimum vector (in local space)
  6772. * @param max defines the new maximum vector (in local space)
  6773. * @param worldMatrix defines the new world matrix
  6774. */
  6775. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6776. /**
  6777. * Scale the current bounding sphere by applying a scale factor
  6778. * @param factor defines the scale factor to apply
  6779. * @returns the current bounding box
  6780. */
  6781. scale(factor: number): BoundingSphere;
  6782. /**
  6783. * Gets the world matrix of the bounding box
  6784. * @returns a matrix
  6785. */
  6786. getWorldMatrix(): DeepImmutable<Matrix>;
  6787. /** @hidden */
  6788. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6789. /**
  6790. * Tests if the bounding sphere is intersecting the frustum planes
  6791. * @param frustumPlanes defines the frustum planes to test
  6792. * @returns true if there is an intersection
  6793. */
  6794. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6795. /**
  6796. * Tests if the bounding sphere center is in between the frustum planes.
  6797. * Used for optimistic fast inclusion.
  6798. * @param frustumPlanes defines the frustum planes to test
  6799. * @returns true if the sphere center is in between the frustum planes
  6800. */
  6801. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6802. /**
  6803. * Tests if a point is inside the bounding sphere
  6804. * @param point defines the point to test
  6805. * @returns true if the point is inside the bounding sphere
  6806. */
  6807. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6808. /**
  6809. * Checks if two sphere intersct
  6810. * @param sphere0 sphere 0
  6811. * @param sphere1 sphere 1
  6812. * @returns true if the speres intersect
  6813. */
  6814. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6815. }
  6816. }
  6817. declare module "babylonjs/Culling/boundingBox" {
  6818. import { DeepImmutable } from "babylonjs/types";
  6819. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6820. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6821. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6822. import { Plane } from "babylonjs/Maths/math.plane";
  6823. /**
  6824. * Class used to store bounding box information
  6825. */
  6826. export class BoundingBox implements ICullable {
  6827. /**
  6828. * Gets the 8 vectors representing the bounding box in local space
  6829. */
  6830. readonly vectors: Vector3[];
  6831. /**
  6832. * Gets the center of the bounding box in local space
  6833. */
  6834. readonly center: Vector3;
  6835. /**
  6836. * Gets the center of the bounding box in world space
  6837. */
  6838. readonly centerWorld: Vector3;
  6839. /**
  6840. * Gets the extend size in local space
  6841. */
  6842. readonly extendSize: Vector3;
  6843. /**
  6844. * Gets the extend size in world space
  6845. */
  6846. readonly extendSizeWorld: Vector3;
  6847. /**
  6848. * Gets the OBB (object bounding box) directions
  6849. */
  6850. readonly directions: Vector3[];
  6851. /**
  6852. * Gets the 8 vectors representing the bounding box in world space
  6853. */
  6854. readonly vectorsWorld: Vector3[];
  6855. /**
  6856. * Gets the minimum vector in world space
  6857. */
  6858. readonly minimumWorld: Vector3;
  6859. /**
  6860. * Gets the maximum vector in world space
  6861. */
  6862. readonly maximumWorld: Vector3;
  6863. /**
  6864. * Gets the minimum vector in local space
  6865. */
  6866. readonly minimum: Vector3;
  6867. /**
  6868. * Gets the maximum vector in local space
  6869. */
  6870. readonly maximum: Vector3;
  6871. private _worldMatrix;
  6872. private static readonly TmpVector3;
  6873. /**
  6874. * @hidden
  6875. */
  6876. _tag: number;
  6877. /**
  6878. * Creates a new bounding box
  6879. * @param min defines the minimum vector (in local space)
  6880. * @param max defines the maximum vector (in local space)
  6881. * @param worldMatrix defines the new world matrix
  6882. */
  6883. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6884. /**
  6885. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6886. * @param min defines the new minimum vector (in local space)
  6887. * @param max defines the new maximum vector (in local space)
  6888. * @param worldMatrix defines the new world matrix
  6889. */
  6890. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6891. /**
  6892. * Scale the current bounding box by applying a scale factor
  6893. * @param factor defines the scale factor to apply
  6894. * @returns the current bounding box
  6895. */
  6896. scale(factor: number): BoundingBox;
  6897. /**
  6898. * Gets the world matrix of the bounding box
  6899. * @returns a matrix
  6900. */
  6901. getWorldMatrix(): DeepImmutable<Matrix>;
  6902. /** @hidden */
  6903. _update(world: DeepImmutable<Matrix>): void;
  6904. /**
  6905. * Tests if the bounding box is intersecting the frustum planes
  6906. * @param frustumPlanes defines the frustum planes to test
  6907. * @returns true if there is an intersection
  6908. */
  6909. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6910. /**
  6911. * Tests if the bounding box is entirely inside the frustum planes
  6912. * @param frustumPlanes defines the frustum planes to test
  6913. * @returns true if there is an inclusion
  6914. */
  6915. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6916. /**
  6917. * Tests if a point is inside the bounding box
  6918. * @param point defines the point to test
  6919. * @returns true if the point is inside the bounding box
  6920. */
  6921. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6922. /**
  6923. * Tests if the bounding box intersects with a bounding sphere
  6924. * @param sphere defines the sphere to test
  6925. * @returns true if there is an intersection
  6926. */
  6927. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6928. /**
  6929. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6930. * @param min defines the min vector to use
  6931. * @param max defines the max vector to use
  6932. * @returns true if there is an intersection
  6933. */
  6934. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6935. /**
  6936. * Tests if two bounding boxes are intersections
  6937. * @param box0 defines the first box to test
  6938. * @param box1 defines the second box to test
  6939. * @returns true if there is an intersection
  6940. */
  6941. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6942. /**
  6943. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6944. * @param minPoint defines the minimum vector of the bounding box
  6945. * @param maxPoint defines the maximum vector of the bounding box
  6946. * @param sphereCenter defines the sphere center
  6947. * @param sphereRadius defines the sphere radius
  6948. * @returns true if there is an intersection
  6949. */
  6950. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6951. /**
  6952. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6953. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6954. * @param frustumPlanes defines the frustum planes to test
  6955. * @return true if there is an inclusion
  6956. */
  6957. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6958. /**
  6959. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6960. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6961. * @param frustumPlanes defines the frustum planes to test
  6962. * @return true if there is an intersection
  6963. */
  6964. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6965. }
  6966. }
  6967. declare module "babylonjs/Collisions/collider" {
  6968. import { Nullable, IndicesArray } from "babylonjs/types";
  6969. import { Vector3 } from "babylonjs/Maths/math.vector";
  6970. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6971. import { Plane } from "babylonjs/Maths/math.plane";
  6972. /** @hidden */
  6973. export class Collider {
  6974. /** Define if a collision was found */
  6975. collisionFound: boolean;
  6976. /**
  6977. * Define last intersection point in local space
  6978. */
  6979. intersectionPoint: Vector3;
  6980. /**
  6981. * Define last collided mesh
  6982. */
  6983. collidedMesh: Nullable<AbstractMesh>;
  6984. private _collisionPoint;
  6985. private _planeIntersectionPoint;
  6986. private _tempVector;
  6987. private _tempVector2;
  6988. private _tempVector3;
  6989. private _tempVector4;
  6990. private _edge;
  6991. private _baseToVertex;
  6992. private _destinationPoint;
  6993. private _slidePlaneNormal;
  6994. private _displacementVector;
  6995. /** @hidden */
  6996. _radius: Vector3;
  6997. /** @hidden */
  6998. _retry: number;
  6999. private _velocity;
  7000. private _basePoint;
  7001. private _epsilon;
  7002. /** @hidden */
  7003. _velocityWorldLength: number;
  7004. /** @hidden */
  7005. _basePointWorld: Vector3;
  7006. private _velocityWorld;
  7007. private _normalizedVelocity;
  7008. /** @hidden */
  7009. _initialVelocity: Vector3;
  7010. /** @hidden */
  7011. _initialPosition: Vector3;
  7012. private _nearestDistance;
  7013. private _collisionMask;
  7014. get collisionMask(): number;
  7015. set collisionMask(mask: number);
  7016. /**
  7017. * Gets the plane normal used to compute the sliding response (in local space)
  7018. */
  7019. get slidePlaneNormal(): Vector3;
  7020. /** @hidden */
  7021. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7022. /** @hidden */
  7023. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7024. /** @hidden */
  7025. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7026. /** @hidden */
  7027. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7028. /** @hidden */
  7029. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7030. /** @hidden */
  7031. _getResponse(pos: Vector3, vel: Vector3): void;
  7032. }
  7033. }
  7034. declare module "babylonjs/Culling/boundingInfo" {
  7035. import { DeepImmutable } from "babylonjs/types";
  7036. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7037. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7038. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7039. import { Plane } from "babylonjs/Maths/math.plane";
  7040. import { Collider } from "babylonjs/Collisions/collider";
  7041. /**
  7042. * Interface for cullable objects
  7043. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7044. */
  7045. export interface ICullable {
  7046. /**
  7047. * Checks if the object or part of the object is in the frustum
  7048. * @param frustumPlanes Camera near/planes
  7049. * @returns true if the object is in frustum otherwise false
  7050. */
  7051. isInFrustum(frustumPlanes: Plane[]): boolean;
  7052. /**
  7053. * Checks if a cullable object (mesh...) is in the camera frustum
  7054. * Unlike isInFrustum this cheks the full bounding box
  7055. * @param frustumPlanes Camera near/planes
  7056. * @returns true if the object is in frustum otherwise false
  7057. */
  7058. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7059. }
  7060. /**
  7061. * Info for a bounding data of a mesh
  7062. */
  7063. export class BoundingInfo implements ICullable {
  7064. /**
  7065. * Bounding box for the mesh
  7066. */
  7067. readonly boundingBox: BoundingBox;
  7068. /**
  7069. * Bounding sphere for the mesh
  7070. */
  7071. readonly boundingSphere: BoundingSphere;
  7072. private _isLocked;
  7073. private static readonly TmpVector3;
  7074. /**
  7075. * Constructs bounding info
  7076. * @param minimum min vector of the bounding box/sphere
  7077. * @param maximum max vector of the bounding box/sphere
  7078. * @param worldMatrix defines the new world matrix
  7079. */
  7080. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7081. /**
  7082. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7083. * @param min defines the new minimum vector (in local space)
  7084. * @param max defines the new maximum vector (in local space)
  7085. * @param worldMatrix defines the new world matrix
  7086. */
  7087. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7088. /**
  7089. * min vector of the bounding box/sphere
  7090. */
  7091. get minimum(): Vector3;
  7092. /**
  7093. * max vector of the bounding box/sphere
  7094. */
  7095. get maximum(): Vector3;
  7096. /**
  7097. * If the info is locked and won't be updated to avoid perf overhead
  7098. */
  7099. get isLocked(): boolean;
  7100. set isLocked(value: boolean);
  7101. /**
  7102. * Updates the bounding sphere and box
  7103. * @param world world matrix to be used to update
  7104. */
  7105. update(world: DeepImmutable<Matrix>): void;
  7106. /**
  7107. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7108. * @param center New center of the bounding info
  7109. * @param extend New extend of the bounding info
  7110. * @returns the current bounding info
  7111. */
  7112. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7113. /**
  7114. * Scale the current bounding info by applying a scale factor
  7115. * @param factor defines the scale factor to apply
  7116. * @returns the current bounding info
  7117. */
  7118. scale(factor: number): BoundingInfo;
  7119. /**
  7120. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7121. * @param frustumPlanes defines the frustum to test
  7122. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7123. * @returns true if the bounding info is in the frustum planes
  7124. */
  7125. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7126. /**
  7127. * Gets the world distance between the min and max points of the bounding box
  7128. */
  7129. get diagonalLength(): number;
  7130. /**
  7131. * Checks if a cullable object (mesh...) is in the camera frustum
  7132. * Unlike isInFrustum this cheks the full bounding box
  7133. * @param frustumPlanes Camera near/planes
  7134. * @returns true if the object is in frustum otherwise false
  7135. */
  7136. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7137. /** @hidden */
  7138. _checkCollision(collider: Collider): boolean;
  7139. /**
  7140. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7141. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7142. * @param point the point to check intersection with
  7143. * @returns if the point intersects
  7144. */
  7145. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7146. /**
  7147. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7148. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7149. * @param boundingInfo the bounding info to check intersection with
  7150. * @param precise if the intersection should be done using OBB
  7151. * @returns if the bounding info intersects
  7152. */
  7153. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7154. }
  7155. }
  7156. declare module "babylonjs/Maths/math.functions" {
  7157. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7158. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7159. /**
  7160. * Extracts minimum and maximum values from a list of indexed positions
  7161. * @param positions defines the positions to use
  7162. * @param indices defines the indices to the positions
  7163. * @param indexStart defines the start index
  7164. * @param indexCount defines the end index
  7165. * @param bias defines bias value to add to the result
  7166. * @return minimum and maximum values
  7167. */
  7168. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7169. minimum: Vector3;
  7170. maximum: Vector3;
  7171. };
  7172. /**
  7173. * Extracts minimum and maximum values from a list of positions
  7174. * @param positions defines the positions to use
  7175. * @param start defines the start index in the positions array
  7176. * @param count defines the number of positions to handle
  7177. * @param bias defines bias value to add to the result
  7178. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7179. * @return minimum and maximum values
  7180. */
  7181. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7182. minimum: Vector3;
  7183. maximum: Vector3;
  7184. };
  7185. }
  7186. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7187. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7188. /** @hidden */
  7189. export class WebGLDataBuffer extends DataBuffer {
  7190. private _buffer;
  7191. constructor(resource: WebGLBuffer);
  7192. get underlyingResource(): any;
  7193. }
  7194. }
  7195. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7196. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7197. import { Nullable } from "babylonjs/types";
  7198. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7199. /** @hidden */
  7200. export class WebGLPipelineContext implements IPipelineContext {
  7201. engine: ThinEngine;
  7202. program: Nullable<WebGLProgram>;
  7203. context?: WebGLRenderingContext;
  7204. vertexShader?: WebGLShader;
  7205. fragmentShader?: WebGLShader;
  7206. isParallelCompiled: boolean;
  7207. onCompiled?: () => void;
  7208. transformFeedback?: WebGLTransformFeedback | null;
  7209. vertexCompilationError: Nullable<string>;
  7210. fragmentCompilationError: Nullable<string>;
  7211. programLinkError: Nullable<string>;
  7212. programValidationError: Nullable<string>;
  7213. get isAsync(): boolean;
  7214. get isReady(): boolean;
  7215. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7216. }
  7217. }
  7218. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7219. import { FloatArray, Nullable } from "babylonjs/types";
  7220. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7221. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7222. module "babylonjs/Engines/thinEngine" {
  7223. interface ThinEngine {
  7224. /**
  7225. * Create an uniform buffer
  7226. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7227. * @param elements defines the content of the uniform buffer
  7228. * @returns the webGL uniform buffer
  7229. */
  7230. createUniformBuffer(elements: FloatArray): DataBuffer;
  7231. /**
  7232. * Create a dynamic uniform buffer
  7233. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7234. * @param elements defines the content of the uniform buffer
  7235. * @returns the webGL uniform buffer
  7236. */
  7237. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7238. /**
  7239. * Update an existing uniform buffer
  7240. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7241. * @param uniformBuffer defines the target uniform buffer
  7242. * @param elements defines the content to update
  7243. * @param offset defines the offset in the uniform buffer where update should start
  7244. * @param count defines the size of the data to update
  7245. */
  7246. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7247. /**
  7248. * Bind an uniform buffer to the current webGL context
  7249. * @param buffer defines the buffer to bind
  7250. */
  7251. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7252. /**
  7253. * Bind a buffer to the current webGL context at a given location
  7254. * @param buffer defines the buffer to bind
  7255. * @param location defines the index where to bind the buffer
  7256. */
  7257. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7258. /**
  7259. * Bind a specific block at a given index in a specific shader program
  7260. * @param pipelineContext defines the pipeline context to use
  7261. * @param blockName defines the block name
  7262. * @param index defines the index where to bind the block
  7263. */
  7264. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7265. }
  7266. }
  7267. }
  7268. declare module "babylonjs/Materials/uniformBuffer" {
  7269. import { Nullable, FloatArray } from "babylonjs/types";
  7270. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7271. import { Engine } from "babylonjs/Engines/engine";
  7272. import { Effect } from "babylonjs/Materials/effect";
  7273. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7274. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7275. import { Color3 } from "babylonjs/Maths/math.color";
  7276. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7277. /**
  7278. * Uniform buffer objects.
  7279. *
  7280. * Handles blocks of uniform on the GPU.
  7281. *
  7282. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7283. *
  7284. * For more information, please refer to :
  7285. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7286. */
  7287. export class UniformBuffer {
  7288. private _engine;
  7289. private _buffer;
  7290. private _data;
  7291. private _bufferData;
  7292. private _dynamic?;
  7293. private _uniformLocations;
  7294. private _uniformSizes;
  7295. private _uniformLocationPointer;
  7296. private _needSync;
  7297. private _noUBO;
  7298. private _currentEffect;
  7299. /** @hidden */
  7300. _alreadyBound: boolean;
  7301. private static _MAX_UNIFORM_SIZE;
  7302. private static _tempBuffer;
  7303. /**
  7304. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7305. * This is dynamic to allow compat with webgl 1 and 2.
  7306. * You will need to pass the name of the uniform as well as the value.
  7307. */
  7308. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7309. /**
  7310. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7311. * This is dynamic to allow compat with webgl 1 and 2.
  7312. * You will need to pass the name of the uniform as well as the value.
  7313. */
  7314. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7315. /**
  7316. * Lambda to Update a single float in a uniform buffer.
  7317. * This is dynamic to allow compat with webgl 1 and 2.
  7318. * You will need to pass the name of the uniform as well as the value.
  7319. */
  7320. updateFloat: (name: string, x: number) => void;
  7321. /**
  7322. * Lambda to Update a vec2 of float in a uniform buffer.
  7323. * This is dynamic to allow compat with webgl 1 and 2.
  7324. * You will need to pass the name of the uniform as well as the value.
  7325. */
  7326. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7327. /**
  7328. * Lambda to Update a vec3 of float in a uniform buffer.
  7329. * This is dynamic to allow compat with webgl 1 and 2.
  7330. * You will need to pass the name of the uniform as well as the value.
  7331. */
  7332. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7333. /**
  7334. * Lambda to Update a vec4 of float in a uniform buffer.
  7335. * This is dynamic to allow compat with webgl 1 and 2.
  7336. * You will need to pass the name of the uniform as well as the value.
  7337. */
  7338. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7339. /**
  7340. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7341. * This is dynamic to allow compat with webgl 1 and 2.
  7342. * You will need to pass the name of the uniform as well as the value.
  7343. */
  7344. updateMatrix: (name: string, mat: Matrix) => void;
  7345. /**
  7346. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7347. * This is dynamic to allow compat with webgl 1 and 2.
  7348. * You will need to pass the name of the uniform as well as the value.
  7349. */
  7350. updateVector3: (name: string, vector: Vector3) => void;
  7351. /**
  7352. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7353. * This is dynamic to allow compat with webgl 1 and 2.
  7354. * You will need to pass the name of the uniform as well as the value.
  7355. */
  7356. updateVector4: (name: string, vector: Vector4) => void;
  7357. /**
  7358. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7359. * This is dynamic to allow compat with webgl 1 and 2.
  7360. * You will need to pass the name of the uniform as well as the value.
  7361. */
  7362. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7363. /**
  7364. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7365. * This is dynamic to allow compat with webgl 1 and 2.
  7366. * You will need to pass the name of the uniform as well as the value.
  7367. */
  7368. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7369. /**
  7370. * Instantiates a new Uniform buffer objects.
  7371. *
  7372. * Handles blocks of uniform on the GPU.
  7373. *
  7374. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7375. *
  7376. * For more information, please refer to :
  7377. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7378. * @param engine Define the engine the buffer is associated with
  7379. * @param data Define the data contained in the buffer
  7380. * @param dynamic Define if the buffer is updatable
  7381. */
  7382. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7383. /**
  7384. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7385. * or just falling back on setUniformXXX calls.
  7386. */
  7387. get useUbo(): boolean;
  7388. /**
  7389. * Indicates if the WebGL underlying uniform buffer is in sync
  7390. * with the javascript cache data.
  7391. */
  7392. get isSync(): boolean;
  7393. /**
  7394. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7395. * Also, a dynamic UniformBuffer will disable cache verification and always
  7396. * update the underlying WebGL uniform buffer to the GPU.
  7397. * @returns if Dynamic, otherwise false
  7398. */
  7399. isDynamic(): boolean;
  7400. /**
  7401. * The data cache on JS side.
  7402. * @returns the underlying data as a float array
  7403. */
  7404. getData(): Float32Array;
  7405. /**
  7406. * The underlying WebGL Uniform buffer.
  7407. * @returns the webgl buffer
  7408. */
  7409. getBuffer(): Nullable<DataBuffer>;
  7410. /**
  7411. * std140 layout specifies how to align data within an UBO structure.
  7412. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7413. * for specs.
  7414. */
  7415. private _fillAlignment;
  7416. /**
  7417. * Adds an uniform in the buffer.
  7418. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7419. * for the layout to be correct !
  7420. * @param name Name of the uniform, as used in the uniform block in the shader.
  7421. * @param size Data size, or data directly.
  7422. */
  7423. addUniform(name: string, size: number | number[]): void;
  7424. /**
  7425. * Adds a Matrix 4x4 to the uniform buffer.
  7426. * @param name Name of the uniform, as used in the uniform block in the shader.
  7427. * @param mat A 4x4 matrix.
  7428. */
  7429. addMatrix(name: string, mat: Matrix): void;
  7430. /**
  7431. * Adds a vec2 to the uniform buffer.
  7432. * @param name Name of the uniform, as used in the uniform block in the shader.
  7433. * @param x Define the x component value of the vec2
  7434. * @param y Define the y component value of the vec2
  7435. */
  7436. addFloat2(name: string, x: number, y: number): void;
  7437. /**
  7438. * Adds a vec3 to the uniform buffer.
  7439. * @param name Name of the uniform, as used in the uniform block in the shader.
  7440. * @param x Define the x component value of the vec3
  7441. * @param y Define the y component value of the vec3
  7442. * @param z Define the z component value of the vec3
  7443. */
  7444. addFloat3(name: string, x: number, y: number, z: number): void;
  7445. /**
  7446. * Adds a vec3 to the uniform buffer.
  7447. * @param name Name of the uniform, as used in the uniform block in the shader.
  7448. * @param color Define the vec3 from a Color
  7449. */
  7450. addColor3(name: string, color: Color3): void;
  7451. /**
  7452. * Adds a vec4 to the uniform buffer.
  7453. * @param name Name of the uniform, as used in the uniform block in the shader.
  7454. * @param color Define the rgb components from a Color
  7455. * @param alpha Define the a component of the vec4
  7456. */
  7457. addColor4(name: string, color: Color3, alpha: number): void;
  7458. /**
  7459. * Adds a vec3 to the uniform buffer.
  7460. * @param name Name of the uniform, as used in the uniform block in the shader.
  7461. * @param vector Define the vec3 components from a Vector
  7462. */
  7463. addVector3(name: string, vector: Vector3): void;
  7464. /**
  7465. * Adds a Matrix 3x3 to the uniform buffer.
  7466. * @param name Name of the uniform, as used in the uniform block in the shader.
  7467. */
  7468. addMatrix3x3(name: string): void;
  7469. /**
  7470. * Adds a Matrix 2x2 to the uniform buffer.
  7471. * @param name Name of the uniform, as used in the uniform block in the shader.
  7472. */
  7473. addMatrix2x2(name: string): void;
  7474. /**
  7475. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7476. */
  7477. create(): void;
  7478. /** @hidden */
  7479. _rebuild(): void;
  7480. /**
  7481. * Updates the WebGL Uniform Buffer on the GPU.
  7482. * If the `dynamic` flag is set to true, no cache comparison is done.
  7483. * Otherwise, the buffer will be updated only if the cache differs.
  7484. */
  7485. update(): void;
  7486. /**
  7487. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7488. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7489. * @param data Define the flattened data
  7490. * @param size Define the size of the data.
  7491. */
  7492. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7493. private _valueCache;
  7494. private _cacheMatrix;
  7495. private _updateMatrix3x3ForUniform;
  7496. private _updateMatrix3x3ForEffect;
  7497. private _updateMatrix2x2ForEffect;
  7498. private _updateMatrix2x2ForUniform;
  7499. private _updateFloatForEffect;
  7500. private _updateFloatForUniform;
  7501. private _updateFloat2ForEffect;
  7502. private _updateFloat2ForUniform;
  7503. private _updateFloat3ForEffect;
  7504. private _updateFloat3ForUniform;
  7505. private _updateFloat4ForEffect;
  7506. private _updateFloat4ForUniform;
  7507. private _updateMatrixForEffect;
  7508. private _updateMatrixForUniform;
  7509. private _updateVector3ForEffect;
  7510. private _updateVector3ForUniform;
  7511. private _updateVector4ForEffect;
  7512. private _updateVector4ForUniform;
  7513. private _updateColor3ForEffect;
  7514. private _updateColor3ForUniform;
  7515. private _updateColor4ForEffect;
  7516. private _updateColor4ForUniform;
  7517. /**
  7518. * Sets a sampler uniform on the effect.
  7519. * @param name Define the name of the sampler.
  7520. * @param texture Define the texture to set in the sampler
  7521. */
  7522. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7523. /**
  7524. * Directly updates the value of the uniform in the cache AND on the GPU.
  7525. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7526. * @param data Define the flattened data
  7527. */
  7528. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7529. /**
  7530. * Binds this uniform buffer to an effect.
  7531. * @param effect Define the effect to bind the buffer to
  7532. * @param name Name of the uniform block in the shader.
  7533. */
  7534. bindToEffect(effect: Effect, name: string): void;
  7535. /**
  7536. * Disposes the uniform buffer.
  7537. */
  7538. dispose(): void;
  7539. }
  7540. }
  7541. declare module "babylonjs/Misc/iInspectable" {
  7542. /**
  7543. * Enum that determines the text-wrapping mode to use.
  7544. */
  7545. export enum InspectableType {
  7546. /**
  7547. * Checkbox for booleans
  7548. */
  7549. Checkbox = 0,
  7550. /**
  7551. * Sliders for numbers
  7552. */
  7553. Slider = 1,
  7554. /**
  7555. * Vector3
  7556. */
  7557. Vector3 = 2,
  7558. /**
  7559. * Quaternions
  7560. */
  7561. Quaternion = 3,
  7562. /**
  7563. * Color3
  7564. */
  7565. Color3 = 4,
  7566. /**
  7567. * String
  7568. */
  7569. String = 5
  7570. }
  7571. /**
  7572. * Interface used to define custom inspectable properties.
  7573. * This interface is used by the inspector to display custom property grids
  7574. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7575. */
  7576. export interface IInspectable {
  7577. /**
  7578. * Gets the label to display
  7579. */
  7580. label: string;
  7581. /**
  7582. * Gets the name of the property to edit
  7583. */
  7584. propertyName: string;
  7585. /**
  7586. * Gets the type of the editor to use
  7587. */
  7588. type: InspectableType;
  7589. /**
  7590. * Gets the minimum value of the property when using in "slider" mode
  7591. */
  7592. min?: number;
  7593. /**
  7594. * Gets the maximum value of the property when using in "slider" mode
  7595. */
  7596. max?: number;
  7597. /**
  7598. * Gets the setp to use when using in "slider" mode
  7599. */
  7600. step?: number;
  7601. }
  7602. }
  7603. declare module "babylonjs/Misc/timingTools" {
  7604. /**
  7605. * Class used to provide helper for timing
  7606. */
  7607. export class TimingTools {
  7608. /**
  7609. * Polyfill for setImmediate
  7610. * @param action defines the action to execute after the current execution block
  7611. */
  7612. static SetImmediate(action: () => void): void;
  7613. }
  7614. }
  7615. declare module "babylonjs/Misc/instantiationTools" {
  7616. /**
  7617. * Class used to enable instatition of objects by class name
  7618. */
  7619. export class InstantiationTools {
  7620. /**
  7621. * Use this object to register external classes like custom textures or material
  7622. * to allow the laoders to instantiate them
  7623. */
  7624. static RegisteredExternalClasses: {
  7625. [key: string]: Object;
  7626. };
  7627. /**
  7628. * Tries to instantiate a new object from a given class name
  7629. * @param className defines the class name to instantiate
  7630. * @returns the new object or null if the system was not able to do the instantiation
  7631. */
  7632. static Instantiate(className: string): any;
  7633. }
  7634. }
  7635. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7636. /**
  7637. * Define options used to create a depth texture
  7638. */
  7639. export class DepthTextureCreationOptions {
  7640. /** Specifies whether or not a stencil should be allocated in the texture */
  7641. generateStencil?: boolean;
  7642. /** Specifies whether or not bilinear filtering is enable on the texture */
  7643. bilinearFiltering?: boolean;
  7644. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7645. comparisonFunction?: number;
  7646. /** Specifies if the created texture is a cube texture */
  7647. isCube?: boolean;
  7648. }
  7649. }
  7650. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7651. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7652. import { Nullable } from "babylonjs/types";
  7653. import { Scene } from "babylonjs/scene";
  7654. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7655. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7656. module "babylonjs/Engines/thinEngine" {
  7657. interface ThinEngine {
  7658. /**
  7659. * Creates a depth stencil cube texture.
  7660. * This is only available in WebGL 2.
  7661. * @param size The size of face edge in the cube texture.
  7662. * @param options The options defining the cube texture.
  7663. * @returns The cube texture
  7664. */
  7665. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7666. /**
  7667. * Creates a cube texture
  7668. * @param rootUrl defines the url where the files to load is located
  7669. * @param scene defines the current scene
  7670. * @param files defines the list of files to load (1 per face)
  7671. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7672. * @param onLoad defines an optional callback raised when the texture is loaded
  7673. * @param onError defines an optional callback raised if there is an issue to load the texture
  7674. * @param format defines the format of the data
  7675. * @param forcedExtension defines the extension to use to pick the right loader
  7676. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7677. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7678. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7679. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7680. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7681. * @returns the cube texture as an InternalTexture
  7682. */
  7683. 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;
  7684. /**
  7685. * Creates a cube texture
  7686. * @param rootUrl defines the url where the files to load is located
  7687. * @param scene defines the current scene
  7688. * @param files defines the list of files to load (1 per face)
  7689. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7690. * @param onLoad defines an optional callback raised when the texture is loaded
  7691. * @param onError defines an optional callback raised if there is an issue to load the texture
  7692. * @param format defines the format of the data
  7693. * @param forcedExtension defines the extension to use to pick the right loader
  7694. * @returns the cube texture as an InternalTexture
  7695. */
  7696. 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;
  7697. /**
  7698. * Creates a cube texture
  7699. * @param rootUrl defines the url where the files to load is located
  7700. * @param scene defines the current scene
  7701. * @param files defines the list of files to load (1 per face)
  7702. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7703. * @param onLoad defines an optional callback raised when the texture is loaded
  7704. * @param onError defines an optional callback raised if there is an issue to load the texture
  7705. * @param format defines the format of the data
  7706. * @param forcedExtension defines the extension to use to pick the right loader
  7707. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7708. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7709. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7710. * @returns the cube texture as an InternalTexture
  7711. */
  7712. 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;
  7713. /** @hidden */
  7714. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7715. /** @hidden */
  7716. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7717. /** @hidden */
  7718. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7719. /** @hidden */
  7720. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7721. /**
  7722. * @hidden
  7723. */
  7724. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7725. }
  7726. }
  7727. }
  7728. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7729. import { Nullable } from "babylonjs/types";
  7730. import { Scene } from "babylonjs/scene";
  7731. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7732. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7733. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7734. /**
  7735. * Class for creating a cube texture
  7736. */
  7737. export class CubeTexture extends BaseTexture {
  7738. private _delayedOnLoad;
  7739. /**
  7740. * The url of the texture
  7741. */
  7742. url: string;
  7743. /**
  7744. * Gets or sets the center of the bounding box associated with the cube texture.
  7745. * It must define where the camera used to render the texture was set
  7746. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7747. */
  7748. boundingBoxPosition: Vector3;
  7749. private _boundingBoxSize;
  7750. /**
  7751. * Gets or sets the size of the bounding box associated with the cube texture
  7752. * When defined, the cubemap will switch to local mode
  7753. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7754. * @example https://www.babylonjs-playground.com/#RNASML
  7755. */
  7756. set boundingBoxSize(value: Vector3);
  7757. /**
  7758. * Returns the bounding box size
  7759. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7760. */
  7761. get boundingBoxSize(): Vector3;
  7762. protected _rotationY: number;
  7763. /**
  7764. * Sets texture matrix rotation angle around Y axis in radians.
  7765. */
  7766. set rotationY(value: number);
  7767. /**
  7768. * Gets texture matrix rotation angle around Y axis radians.
  7769. */
  7770. get rotationY(): number;
  7771. /**
  7772. * Are mip maps generated for this texture or not.
  7773. */
  7774. get noMipmap(): boolean;
  7775. private _noMipmap;
  7776. private _files;
  7777. protected _forcedExtension: Nullable<string>;
  7778. private _extensions;
  7779. private _textureMatrix;
  7780. private _format;
  7781. private _createPolynomials;
  7782. /** @hidden */
  7783. _prefiltered: boolean;
  7784. /**
  7785. * Creates a cube texture from an array of image urls
  7786. * @param files defines an array of image urls
  7787. * @param scene defines the hosting scene
  7788. * @param noMipmap specifies if mip maps are not used
  7789. * @returns a cube texture
  7790. */
  7791. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7792. /**
  7793. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7794. * @param url defines the url of the prefiltered texture
  7795. * @param scene defines the scene the texture is attached to
  7796. * @param forcedExtension defines the extension of the file if different from the url
  7797. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7798. * @return the prefiltered texture
  7799. */
  7800. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7801. /**
  7802. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7803. * as prefiltered data.
  7804. * @param rootUrl defines the url of the texture or the root name of the six images
  7805. * @param scene defines the scene the texture is attached to
  7806. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7807. * @param noMipmap defines if mipmaps should be created or not
  7808. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7809. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7810. * @param onError defines a callback triggered in case of error during load
  7811. * @param format defines the internal format to use for the texture once loaded
  7812. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7813. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7814. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7815. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7816. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7817. * @return the cube texture
  7818. */
  7819. 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);
  7820. /**
  7821. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7822. */
  7823. get isPrefiltered(): boolean;
  7824. /**
  7825. * Get the current class name of the texture useful for serialization or dynamic coding.
  7826. * @returns "CubeTexture"
  7827. */
  7828. getClassName(): string;
  7829. /**
  7830. * Update the url (and optional buffer) of this texture if url was null during construction.
  7831. * @param url the url of the texture
  7832. * @param forcedExtension defines the extension to use
  7833. * @param onLoad callback called when the texture is loaded (defaults to null)
  7834. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7835. */
  7836. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7837. /**
  7838. * Delays loading of the cube texture
  7839. * @param forcedExtension defines the extension to use
  7840. */
  7841. delayLoad(forcedExtension?: string): void;
  7842. /**
  7843. * Returns the reflection texture matrix
  7844. * @returns the reflection texture matrix
  7845. */
  7846. getReflectionTextureMatrix(): Matrix;
  7847. /**
  7848. * Sets the reflection texture matrix
  7849. * @param value Reflection texture matrix
  7850. */
  7851. setReflectionTextureMatrix(value: Matrix): void;
  7852. /**
  7853. * Parses text to create a cube texture
  7854. * @param parsedTexture define the serialized text to read from
  7855. * @param scene defines the hosting scene
  7856. * @param rootUrl defines the root url of the cube texture
  7857. * @returns a cube texture
  7858. */
  7859. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7860. /**
  7861. * Makes a clone, or deep copy, of the cube texture
  7862. * @returns a new cube texture
  7863. */
  7864. clone(): CubeTexture;
  7865. }
  7866. }
  7867. declare module "babylonjs/Materials/materialDefines" {
  7868. /**
  7869. * Manages the defines for the Material
  7870. */
  7871. export class MaterialDefines {
  7872. /** @hidden */
  7873. protected _keys: string[];
  7874. private _isDirty;
  7875. /** @hidden */
  7876. _renderId: number;
  7877. /** @hidden */
  7878. _areLightsDirty: boolean;
  7879. /** @hidden */
  7880. _areLightsDisposed: boolean;
  7881. /** @hidden */
  7882. _areAttributesDirty: boolean;
  7883. /** @hidden */
  7884. _areTexturesDirty: boolean;
  7885. /** @hidden */
  7886. _areFresnelDirty: boolean;
  7887. /** @hidden */
  7888. _areMiscDirty: boolean;
  7889. /** @hidden */
  7890. _areImageProcessingDirty: boolean;
  7891. /** @hidden */
  7892. _normals: boolean;
  7893. /** @hidden */
  7894. _uvs: boolean;
  7895. /** @hidden */
  7896. _needNormals: boolean;
  7897. /** @hidden */
  7898. _needUVs: boolean;
  7899. [id: string]: any;
  7900. /**
  7901. * Specifies if the material needs to be re-calculated
  7902. */
  7903. get isDirty(): boolean;
  7904. /**
  7905. * Marks the material to indicate that it has been re-calculated
  7906. */
  7907. markAsProcessed(): void;
  7908. /**
  7909. * Marks the material to indicate that it needs to be re-calculated
  7910. */
  7911. markAsUnprocessed(): void;
  7912. /**
  7913. * Marks the material to indicate all of its defines need to be re-calculated
  7914. */
  7915. markAllAsDirty(): void;
  7916. /**
  7917. * Marks the material to indicate that image processing needs to be re-calculated
  7918. */
  7919. markAsImageProcessingDirty(): void;
  7920. /**
  7921. * Marks the material to indicate the lights need to be re-calculated
  7922. * @param disposed Defines whether the light is dirty due to dispose or not
  7923. */
  7924. markAsLightDirty(disposed?: boolean): void;
  7925. /**
  7926. * Marks the attribute state as changed
  7927. */
  7928. markAsAttributesDirty(): void;
  7929. /**
  7930. * Marks the texture state as changed
  7931. */
  7932. markAsTexturesDirty(): void;
  7933. /**
  7934. * Marks the fresnel state as changed
  7935. */
  7936. markAsFresnelDirty(): void;
  7937. /**
  7938. * Marks the misc state as changed
  7939. */
  7940. markAsMiscDirty(): void;
  7941. /**
  7942. * Rebuilds the material defines
  7943. */
  7944. rebuild(): void;
  7945. /**
  7946. * Specifies if two material defines are equal
  7947. * @param other - A material define instance to compare to
  7948. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7949. */
  7950. isEqual(other: MaterialDefines): boolean;
  7951. /**
  7952. * Clones this instance's defines to another instance
  7953. * @param other - material defines to clone values to
  7954. */
  7955. cloneTo(other: MaterialDefines): void;
  7956. /**
  7957. * Resets the material define values
  7958. */
  7959. reset(): void;
  7960. /**
  7961. * Converts the material define values to a string
  7962. * @returns - String of material define information
  7963. */
  7964. toString(): string;
  7965. }
  7966. }
  7967. declare module "babylonjs/Materials/colorCurves" {
  7968. import { Effect } from "babylonjs/Materials/effect";
  7969. /**
  7970. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7971. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7972. * 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;
  7973. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7974. */
  7975. export class ColorCurves {
  7976. private _dirty;
  7977. private _tempColor;
  7978. private _globalCurve;
  7979. private _highlightsCurve;
  7980. private _midtonesCurve;
  7981. private _shadowsCurve;
  7982. private _positiveCurve;
  7983. private _negativeCurve;
  7984. private _globalHue;
  7985. private _globalDensity;
  7986. private _globalSaturation;
  7987. private _globalExposure;
  7988. /**
  7989. * Gets the global Hue value.
  7990. * 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).
  7991. */
  7992. get globalHue(): number;
  7993. /**
  7994. * Sets the global Hue value.
  7995. * 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).
  7996. */
  7997. set globalHue(value: number);
  7998. /**
  7999. * Gets the global Density value.
  8000. * 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.
  8001. * Values less than zero provide a filter of opposite hue.
  8002. */
  8003. get globalDensity(): number;
  8004. /**
  8005. * Sets the global Density value.
  8006. * 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.
  8007. * Values less than zero provide a filter of opposite hue.
  8008. */
  8009. set globalDensity(value: number);
  8010. /**
  8011. * Gets the global Saturation value.
  8012. * 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.
  8013. */
  8014. get globalSaturation(): number;
  8015. /**
  8016. * Sets the global Saturation value.
  8017. * 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.
  8018. */
  8019. set globalSaturation(value: number);
  8020. /**
  8021. * Gets the global Exposure value.
  8022. * 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.
  8023. */
  8024. get globalExposure(): number;
  8025. /**
  8026. * Sets the global Exposure value.
  8027. * 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.
  8028. */
  8029. set globalExposure(value: number);
  8030. private _highlightsHue;
  8031. private _highlightsDensity;
  8032. private _highlightsSaturation;
  8033. private _highlightsExposure;
  8034. /**
  8035. * Gets the highlights Hue value.
  8036. * 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).
  8037. */
  8038. get highlightsHue(): number;
  8039. /**
  8040. * Sets the highlights Hue value.
  8041. * 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).
  8042. */
  8043. set highlightsHue(value: number);
  8044. /**
  8045. * Gets the highlights Density value.
  8046. * 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.
  8047. * Values less than zero provide a filter of opposite hue.
  8048. */
  8049. get highlightsDensity(): number;
  8050. /**
  8051. * Sets the highlights Density value.
  8052. * 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.
  8053. * Values less than zero provide a filter of opposite hue.
  8054. */
  8055. set highlightsDensity(value: number);
  8056. /**
  8057. * Gets the highlights Saturation value.
  8058. * 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.
  8059. */
  8060. get highlightsSaturation(): number;
  8061. /**
  8062. * Sets the highlights Saturation value.
  8063. * 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.
  8064. */
  8065. set highlightsSaturation(value: number);
  8066. /**
  8067. * Gets the highlights Exposure value.
  8068. * 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.
  8069. */
  8070. get highlightsExposure(): number;
  8071. /**
  8072. * Sets the highlights Exposure value.
  8073. * 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.
  8074. */
  8075. set highlightsExposure(value: number);
  8076. private _midtonesHue;
  8077. private _midtonesDensity;
  8078. private _midtonesSaturation;
  8079. private _midtonesExposure;
  8080. /**
  8081. * Gets the midtones Hue value.
  8082. * 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).
  8083. */
  8084. get midtonesHue(): number;
  8085. /**
  8086. * Sets the midtones Hue value.
  8087. * 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).
  8088. */
  8089. set midtonesHue(value: number);
  8090. /**
  8091. * Gets the midtones Density value.
  8092. * 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.
  8093. * Values less than zero provide a filter of opposite hue.
  8094. */
  8095. get midtonesDensity(): number;
  8096. /**
  8097. * Sets the midtones Density value.
  8098. * 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.
  8099. * Values less than zero provide a filter of opposite hue.
  8100. */
  8101. set midtonesDensity(value: number);
  8102. /**
  8103. * Gets the midtones Saturation value.
  8104. * 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.
  8105. */
  8106. get midtonesSaturation(): number;
  8107. /**
  8108. * Sets the midtones Saturation value.
  8109. * 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.
  8110. */
  8111. set midtonesSaturation(value: number);
  8112. /**
  8113. * Gets the midtones Exposure value.
  8114. * 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.
  8115. */
  8116. get midtonesExposure(): number;
  8117. /**
  8118. * Sets the midtones Exposure value.
  8119. * 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.
  8120. */
  8121. set midtonesExposure(value: number);
  8122. private _shadowsHue;
  8123. private _shadowsDensity;
  8124. private _shadowsSaturation;
  8125. private _shadowsExposure;
  8126. /**
  8127. * Gets the shadows Hue value.
  8128. * 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).
  8129. */
  8130. get shadowsHue(): number;
  8131. /**
  8132. * Sets the shadows Hue value.
  8133. * 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).
  8134. */
  8135. set shadowsHue(value: number);
  8136. /**
  8137. * Gets the shadows Density value.
  8138. * 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.
  8139. * Values less than zero provide a filter of opposite hue.
  8140. */
  8141. get shadowsDensity(): number;
  8142. /**
  8143. * Sets the shadows Density value.
  8144. * 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.
  8145. * Values less than zero provide a filter of opposite hue.
  8146. */
  8147. set shadowsDensity(value: number);
  8148. /**
  8149. * Gets the shadows Saturation value.
  8150. * 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.
  8151. */
  8152. get shadowsSaturation(): number;
  8153. /**
  8154. * Sets the shadows Saturation value.
  8155. * 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.
  8156. */
  8157. set shadowsSaturation(value: number);
  8158. /**
  8159. * Gets the shadows Exposure value.
  8160. * 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.
  8161. */
  8162. get shadowsExposure(): number;
  8163. /**
  8164. * Sets the shadows Exposure value.
  8165. * 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.
  8166. */
  8167. set shadowsExposure(value: number);
  8168. /**
  8169. * Returns the class name
  8170. * @returns The class name
  8171. */
  8172. getClassName(): string;
  8173. /**
  8174. * Binds the color curves to the shader.
  8175. * @param colorCurves The color curve to bind
  8176. * @param effect The effect to bind to
  8177. * @param positiveUniform The positive uniform shader parameter
  8178. * @param neutralUniform The neutral uniform shader parameter
  8179. * @param negativeUniform The negative uniform shader parameter
  8180. */
  8181. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8182. /**
  8183. * Prepare the list of uniforms associated with the ColorCurves effects.
  8184. * @param uniformsList The list of uniforms used in the effect
  8185. */
  8186. static PrepareUniforms(uniformsList: string[]): void;
  8187. /**
  8188. * Returns color grading data based on a hue, density, saturation and exposure value.
  8189. * @param filterHue The hue of the color filter.
  8190. * @param filterDensity The density of the color filter.
  8191. * @param saturation The saturation.
  8192. * @param exposure The exposure.
  8193. * @param result The result data container.
  8194. */
  8195. private getColorGradingDataToRef;
  8196. /**
  8197. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8198. * @param value The input slider value in range [-100,100].
  8199. * @returns Adjusted value.
  8200. */
  8201. private static applyColorGradingSliderNonlinear;
  8202. /**
  8203. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8204. * @param hue The hue (H) input.
  8205. * @param saturation The saturation (S) input.
  8206. * @param brightness The brightness (B) input.
  8207. * @result An RGBA color represented as Vector4.
  8208. */
  8209. private static fromHSBToRef;
  8210. /**
  8211. * Returns a value clamped between min and max
  8212. * @param value The value to clamp
  8213. * @param min The minimum of value
  8214. * @param max The maximum of value
  8215. * @returns The clamped value.
  8216. */
  8217. private static clamp;
  8218. /**
  8219. * Clones the current color curve instance.
  8220. * @return The cloned curves
  8221. */
  8222. clone(): ColorCurves;
  8223. /**
  8224. * Serializes the current color curve instance to a json representation.
  8225. * @return a JSON representation
  8226. */
  8227. serialize(): any;
  8228. /**
  8229. * Parses the color curve from a json representation.
  8230. * @param source the JSON source to parse
  8231. * @return The parsed curves
  8232. */
  8233. static Parse(source: any): ColorCurves;
  8234. }
  8235. }
  8236. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8237. import { Observable } from "babylonjs/Misc/observable";
  8238. import { Nullable } from "babylonjs/types";
  8239. import { Color4 } from "babylonjs/Maths/math.color";
  8240. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8241. import { Effect } from "babylonjs/Materials/effect";
  8242. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8243. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8244. /**
  8245. * Interface to follow in your material defines to integrate easily the
  8246. * Image proccessing functions.
  8247. * @hidden
  8248. */
  8249. export interface IImageProcessingConfigurationDefines {
  8250. IMAGEPROCESSING: boolean;
  8251. VIGNETTE: boolean;
  8252. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8253. VIGNETTEBLENDMODEOPAQUE: boolean;
  8254. TONEMAPPING: boolean;
  8255. TONEMAPPING_ACES: boolean;
  8256. CONTRAST: boolean;
  8257. EXPOSURE: boolean;
  8258. COLORCURVES: boolean;
  8259. COLORGRADING: boolean;
  8260. COLORGRADING3D: boolean;
  8261. SAMPLER3DGREENDEPTH: boolean;
  8262. SAMPLER3DBGRMAP: boolean;
  8263. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8264. }
  8265. /**
  8266. * @hidden
  8267. */
  8268. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8269. IMAGEPROCESSING: boolean;
  8270. VIGNETTE: boolean;
  8271. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8272. VIGNETTEBLENDMODEOPAQUE: boolean;
  8273. TONEMAPPING: boolean;
  8274. TONEMAPPING_ACES: boolean;
  8275. CONTRAST: boolean;
  8276. COLORCURVES: boolean;
  8277. COLORGRADING: boolean;
  8278. COLORGRADING3D: boolean;
  8279. SAMPLER3DGREENDEPTH: boolean;
  8280. SAMPLER3DBGRMAP: boolean;
  8281. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8282. EXPOSURE: boolean;
  8283. constructor();
  8284. }
  8285. /**
  8286. * This groups together the common properties used for image processing either in direct forward pass
  8287. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8288. * or not.
  8289. */
  8290. export class ImageProcessingConfiguration {
  8291. /**
  8292. * Default tone mapping applied in BabylonJS.
  8293. */
  8294. static readonly TONEMAPPING_STANDARD: number;
  8295. /**
  8296. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8297. * to other engines rendering to increase portability.
  8298. */
  8299. static readonly TONEMAPPING_ACES: number;
  8300. /**
  8301. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8302. */
  8303. colorCurves: Nullable<ColorCurves>;
  8304. private _colorCurvesEnabled;
  8305. /**
  8306. * Gets wether the color curves effect is enabled.
  8307. */
  8308. get colorCurvesEnabled(): boolean;
  8309. /**
  8310. * Sets wether the color curves effect is enabled.
  8311. */
  8312. set colorCurvesEnabled(value: boolean);
  8313. private _colorGradingTexture;
  8314. /**
  8315. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8316. */
  8317. get colorGradingTexture(): Nullable<BaseTexture>;
  8318. /**
  8319. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8320. */
  8321. set colorGradingTexture(value: Nullable<BaseTexture>);
  8322. private _colorGradingEnabled;
  8323. /**
  8324. * Gets wether the color grading effect is enabled.
  8325. */
  8326. get colorGradingEnabled(): boolean;
  8327. /**
  8328. * Sets wether the color grading effect is enabled.
  8329. */
  8330. set colorGradingEnabled(value: boolean);
  8331. private _colorGradingWithGreenDepth;
  8332. /**
  8333. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8334. */
  8335. get colorGradingWithGreenDepth(): boolean;
  8336. /**
  8337. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8338. */
  8339. set colorGradingWithGreenDepth(value: boolean);
  8340. private _colorGradingBGR;
  8341. /**
  8342. * Gets wether the color grading texture contains BGR values.
  8343. */
  8344. get colorGradingBGR(): boolean;
  8345. /**
  8346. * Sets wether the color grading texture contains BGR values.
  8347. */
  8348. set colorGradingBGR(value: boolean);
  8349. /** @hidden */
  8350. _exposure: number;
  8351. /**
  8352. * Gets the Exposure used in the effect.
  8353. */
  8354. get exposure(): number;
  8355. /**
  8356. * Sets the Exposure used in the effect.
  8357. */
  8358. set exposure(value: number);
  8359. private _toneMappingEnabled;
  8360. /**
  8361. * Gets wether the tone mapping effect is enabled.
  8362. */
  8363. get toneMappingEnabled(): boolean;
  8364. /**
  8365. * Sets wether the tone mapping effect is enabled.
  8366. */
  8367. set toneMappingEnabled(value: boolean);
  8368. private _toneMappingType;
  8369. /**
  8370. * Gets the type of tone mapping effect.
  8371. */
  8372. get toneMappingType(): number;
  8373. /**
  8374. * Sets the type of tone mapping effect used in BabylonJS.
  8375. */
  8376. set toneMappingType(value: number);
  8377. protected _contrast: number;
  8378. /**
  8379. * Gets the contrast used in the effect.
  8380. */
  8381. get contrast(): number;
  8382. /**
  8383. * Sets the contrast used in the effect.
  8384. */
  8385. set contrast(value: number);
  8386. /**
  8387. * Vignette stretch size.
  8388. */
  8389. vignetteStretch: number;
  8390. /**
  8391. * Vignette centre X Offset.
  8392. */
  8393. vignetteCentreX: number;
  8394. /**
  8395. * Vignette centre Y Offset.
  8396. */
  8397. vignetteCentreY: number;
  8398. /**
  8399. * Vignette weight or intensity of the vignette effect.
  8400. */
  8401. vignetteWeight: number;
  8402. /**
  8403. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8404. * if vignetteEnabled is set to true.
  8405. */
  8406. vignetteColor: Color4;
  8407. /**
  8408. * Camera field of view used by the Vignette effect.
  8409. */
  8410. vignetteCameraFov: number;
  8411. private _vignetteBlendMode;
  8412. /**
  8413. * Gets the vignette blend mode allowing different kind of effect.
  8414. */
  8415. get vignetteBlendMode(): number;
  8416. /**
  8417. * Sets the vignette blend mode allowing different kind of effect.
  8418. */
  8419. set vignetteBlendMode(value: number);
  8420. private _vignetteEnabled;
  8421. /**
  8422. * Gets wether the vignette effect is enabled.
  8423. */
  8424. get vignetteEnabled(): boolean;
  8425. /**
  8426. * Sets wether the vignette effect is enabled.
  8427. */
  8428. set vignetteEnabled(value: boolean);
  8429. private _applyByPostProcess;
  8430. /**
  8431. * Gets wether the image processing is applied through a post process or not.
  8432. */
  8433. get applyByPostProcess(): boolean;
  8434. /**
  8435. * Sets wether the image processing is applied through a post process or not.
  8436. */
  8437. set applyByPostProcess(value: boolean);
  8438. private _isEnabled;
  8439. /**
  8440. * Gets wether the image processing is enabled or not.
  8441. */
  8442. get isEnabled(): boolean;
  8443. /**
  8444. * Sets wether the image processing is enabled or not.
  8445. */
  8446. set isEnabled(value: boolean);
  8447. /**
  8448. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8449. */
  8450. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8451. /**
  8452. * Method called each time the image processing information changes requires to recompile the effect.
  8453. */
  8454. protected _updateParameters(): void;
  8455. /**
  8456. * Gets the current class name.
  8457. * @return "ImageProcessingConfiguration"
  8458. */
  8459. getClassName(): string;
  8460. /**
  8461. * Prepare the list of uniforms associated with the Image Processing effects.
  8462. * @param uniforms The list of uniforms used in the effect
  8463. * @param defines the list of defines currently in use
  8464. */
  8465. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8466. /**
  8467. * Prepare the list of samplers associated with the Image Processing effects.
  8468. * @param samplersList The list of uniforms used in the effect
  8469. * @param defines the list of defines currently in use
  8470. */
  8471. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8472. /**
  8473. * Prepare the list of defines associated to the shader.
  8474. * @param defines the list of defines to complete
  8475. * @param forPostProcess Define if we are currently in post process mode or not
  8476. */
  8477. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8478. /**
  8479. * Returns true if all the image processing information are ready.
  8480. * @returns True if ready, otherwise, false
  8481. */
  8482. isReady(): boolean;
  8483. /**
  8484. * Binds the image processing to the shader.
  8485. * @param effect The effect to bind to
  8486. * @param overrideAspectRatio Override the aspect ratio of the effect
  8487. */
  8488. bind(effect: Effect, overrideAspectRatio?: number): void;
  8489. /**
  8490. * Clones the current image processing instance.
  8491. * @return The cloned image processing
  8492. */
  8493. clone(): ImageProcessingConfiguration;
  8494. /**
  8495. * Serializes the current image processing instance to a json representation.
  8496. * @return a JSON representation
  8497. */
  8498. serialize(): any;
  8499. /**
  8500. * Parses the image processing from a json representation.
  8501. * @param source the JSON source to parse
  8502. * @return The parsed image processing
  8503. */
  8504. static Parse(source: any): ImageProcessingConfiguration;
  8505. private static _VIGNETTEMODE_MULTIPLY;
  8506. private static _VIGNETTEMODE_OPAQUE;
  8507. /**
  8508. * Used to apply the vignette as a mix with the pixel color.
  8509. */
  8510. static get VIGNETTEMODE_MULTIPLY(): number;
  8511. /**
  8512. * Used to apply the vignette as a replacement of the pixel color.
  8513. */
  8514. static get VIGNETTEMODE_OPAQUE(): number;
  8515. }
  8516. }
  8517. declare module "babylonjs/Shaders/postprocess.vertex" {
  8518. /** @hidden */
  8519. export var postprocessVertexShader: {
  8520. name: string;
  8521. shader: string;
  8522. };
  8523. }
  8524. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8525. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8526. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8527. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8528. module "babylonjs/Engines/thinEngine" {
  8529. interface ThinEngine {
  8530. /**
  8531. * Creates a new render target texture
  8532. * @param size defines the size of the texture
  8533. * @param options defines the options used to create the texture
  8534. * @returns a new render target texture stored in an InternalTexture
  8535. */
  8536. createRenderTargetTexture(size: number | {
  8537. width: number;
  8538. height: number;
  8539. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8540. /**
  8541. * Creates a depth stencil texture.
  8542. * This is only available in WebGL 2 or with the depth texture extension available.
  8543. * @param size The size of face edge in the texture.
  8544. * @param options The options defining the texture.
  8545. * @returns The texture
  8546. */
  8547. createDepthStencilTexture(size: number | {
  8548. width: number;
  8549. height: number;
  8550. }, options: DepthTextureCreationOptions): InternalTexture;
  8551. /** @hidden */
  8552. _createDepthStencilTexture(size: number | {
  8553. width: number;
  8554. height: number;
  8555. }, options: DepthTextureCreationOptions): InternalTexture;
  8556. }
  8557. }
  8558. }
  8559. declare module "babylonjs/Maths/math.axis" {
  8560. import { Vector3 } from "babylonjs/Maths/math.vector";
  8561. /** Defines supported spaces */
  8562. export enum Space {
  8563. /** Local (object) space */
  8564. LOCAL = 0,
  8565. /** World space */
  8566. WORLD = 1,
  8567. /** Bone space */
  8568. BONE = 2
  8569. }
  8570. /** Defines the 3 main axes */
  8571. export class Axis {
  8572. /** X axis */
  8573. static X: Vector3;
  8574. /** Y axis */
  8575. static Y: Vector3;
  8576. /** Z axis */
  8577. static Z: Vector3;
  8578. }
  8579. }
  8580. declare module "babylonjs/Cameras/targetCamera" {
  8581. import { Nullable } from "babylonjs/types";
  8582. import { Camera } from "babylonjs/Cameras/camera";
  8583. import { Scene } from "babylonjs/scene";
  8584. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8585. /**
  8586. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8587. * This is the base of the follow, arc rotate cameras and Free camera
  8588. * @see http://doc.babylonjs.com/features/cameras
  8589. */
  8590. export class TargetCamera extends Camera {
  8591. private static _RigCamTransformMatrix;
  8592. private static _TargetTransformMatrix;
  8593. private static _TargetFocalPoint;
  8594. /**
  8595. * Define the current direction the camera is moving to
  8596. */
  8597. cameraDirection: Vector3;
  8598. /**
  8599. * Define the current rotation the camera is rotating to
  8600. */
  8601. cameraRotation: Vector2;
  8602. /**
  8603. * When set, the up vector of the camera will be updated by the rotation of the camera
  8604. */
  8605. updateUpVectorFromRotation: boolean;
  8606. private _tmpQuaternion;
  8607. /**
  8608. * Define the current rotation of the camera
  8609. */
  8610. rotation: Vector3;
  8611. /**
  8612. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8613. */
  8614. rotationQuaternion: Quaternion;
  8615. /**
  8616. * Define the current speed of the camera
  8617. */
  8618. speed: number;
  8619. /**
  8620. * Add constraint to the camera to prevent it to move freely in all directions and
  8621. * around all axis.
  8622. */
  8623. noRotationConstraint: boolean;
  8624. /**
  8625. * Define the current target of the camera as an object or a position.
  8626. */
  8627. lockedTarget: any;
  8628. /** @hidden */
  8629. _currentTarget: Vector3;
  8630. /** @hidden */
  8631. _initialFocalDistance: number;
  8632. /** @hidden */
  8633. _viewMatrix: Matrix;
  8634. /** @hidden */
  8635. _camMatrix: Matrix;
  8636. /** @hidden */
  8637. _cameraTransformMatrix: Matrix;
  8638. /** @hidden */
  8639. _cameraRotationMatrix: Matrix;
  8640. /** @hidden */
  8641. _referencePoint: Vector3;
  8642. /** @hidden */
  8643. _transformedReferencePoint: Vector3;
  8644. protected _globalCurrentTarget: Vector3;
  8645. protected _globalCurrentUpVector: Vector3;
  8646. /** @hidden */
  8647. _reset: () => void;
  8648. private _defaultUp;
  8649. /**
  8650. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8651. * This is the base of the follow, arc rotate cameras and Free camera
  8652. * @see http://doc.babylonjs.com/features/cameras
  8653. * @param name Defines the name of the camera in the scene
  8654. * @param position Defines the start position of the camera in the scene
  8655. * @param scene Defines the scene the camera belongs to
  8656. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8657. */
  8658. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8659. /**
  8660. * Gets the position in front of the camera at a given distance.
  8661. * @param distance The distance from the camera we want the position to be
  8662. * @returns the position
  8663. */
  8664. getFrontPosition(distance: number): Vector3;
  8665. /** @hidden */
  8666. _getLockedTargetPosition(): Nullable<Vector3>;
  8667. private _storedPosition;
  8668. private _storedRotation;
  8669. private _storedRotationQuaternion;
  8670. /**
  8671. * Store current camera state of the camera (fov, position, rotation, etc..)
  8672. * @returns the camera
  8673. */
  8674. storeState(): Camera;
  8675. /**
  8676. * Restored camera state. You must call storeState() first
  8677. * @returns whether it was successful or not
  8678. * @hidden
  8679. */
  8680. _restoreStateValues(): boolean;
  8681. /** @hidden */
  8682. _initCache(): void;
  8683. /** @hidden */
  8684. _updateCache(ignoreParentClass?: boolean): void;
  8685. /** @hidden */
  8686. _isSynchronizedViewMatrix(): boolean;
  8687. /** @hidden */
  8688. _computeLocalCameraSpeed(): number;
  8689. /**
  8690. * Defines the target the camera should look at.
  8691. * @param target Defines the new target as a Vector or a mesh
  8692. */
  8693. setTarget(target: Vector3): void;
  8694. /**
  8695. * Return the current target position of the camera. This value is expressed in local space.
  8696. * @returns the target position
  8697. */
  8698. getTarget(): Vector3;
  8699. /** @hidden */
  8700. _decideIfNeedsToMove(): boolean;
  8701. /** @hidden */
  8702. _updatePosition(): void;
  8703. /** @hidden */
  8704. _checkInputs(): void;
  8705. protected _updateCameraRotationMatrix(): void;
  8706. /**
  8707. * 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)
  8708. * @returns the current camera
  8709. */
  8710. private _rotateUpVectorWithCameraRotationMatrix;
  8711. private _cachedRotationZ;
  8712. private _cachedQuaternionRotationZ;
  8713. /** @hidden */
  8714. _getViewMatrix(): Matrix;
  8715. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8716. /**
  8717. * @hidden
  8718. */
  8719. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8720. /**
  8721. * @hidden
  8722. */
  8723. _updateRigCameras(): void;
  8724. private _getRigCamPositionAndTarget;
  8725. /**
  8726. * Gets the current object class name.
  8727. * @return the class name
  8728. */
  8729. getClassName(): string;
  8730. }
  8731. }
  8732. declare module "babylonjs/Events/keyboardEvents" {
  8733. /**
  8734. * Gather the list of keyboard event types as constants.
  8735. */
  8736. export class KeyboardEventTypes {
  8737. /**
  8738. * The keydown event is fired when a key becomes active (pressed).
  8739. */
  8740. static readonly KEYDOWN: number;
  8741. /**
  8742. * The keyup event is fired when a key has been released.
  8743. */
  8744. static readonly KEYUP: number;
  8745. }
  8746. /**
  8747. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8748. */
  8749. export class KeyboardInfo {
  8750. /**
  8751. * Defines the type of event (KeyboardEventTypes)
  8752. */
  8753. type: number;
  8754. /**
  8755. * Defines the related dom event
  8756. */
  8757. event: KeyboardEvent;
  8758. /**
  8759. * Instantiates a new keyboard info.
  8760. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8761. * @param type Defines the type of event (KeyboardEventTypes)
  8762. * @param event Defines the related dom event
  8763. */
  8764. constructor(
  8765. /**
  8766. * Defines the type of event (KeyboardEventTypes)
  8767. */
  8768. type: number,
  8769. /**
  8770. * Defines the related dom event
  8771. */
  8772. event: KeyboardEvent);
  8773. }
  8774. /**
  8775. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8776. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8777. */
  8778. export class KeyboardInfoPre extends KeyboardInfo {
  8779. /**
  8780. * Defines the type of event (KeyboardEventTypes)
  8781. */
  8782. type: number;
  8783. /**
  8784. * Defines the related dom event
  8785. */
  8786. event: KeyboardEvent;
  8787. /**
  8788. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8789. */
  8790. skipOnPointerObservable: boolean;
  8791. /**
  8792. * Instantiates a new keyboard pre info.
  8793. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8794. * @param type Defines the type of event (KeyboardEventTypes)
  8795. * @param event Defines the related dom event
  8796. */
  8797. constructor(
  8798. /**
  8799. * Defines the type of event (KeyboardEventTypes)
  8800. */
  8801. type: number,
  8802. /**
  8803. * Defines the related dom event
  8804. */
  8805. event: KeyboardEvent);
  8806. }
  8807. }
  8808. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8809. import { Nullable } from "babylonjs/types";
  8810. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8811. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8812. /**
  8813. * Manage the keyboard inputs to control the movement of a free camera.
  8814. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8815. */
  8816. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8817. /**
  8818. * Defines the camera the input is attached to.
  8819. */
  8820. camera: FreeCamera;
  8821. /**
  8822. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8823. */
  8824. keysUp: number[];
  8825. /**
  8826. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8827. */
  8828. keysDown: number[];
  8829. /**
  8830. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8831. */
  8832. keysLeft: number[];
  8833. /**
  8834. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8835. */
  8836. keysRight: number[];
  8837. private _keys;
  8838. private _onCanvasBlurObserver;
  8839. private _onKeyboardObserver;
  8840. private _engine;
  8841. private _scene;
  8842. /**
  8843. * Attach the input controls to a specific dom element to get the input from.
  8844. * @param element Defines the element the controls should be listened from
  8845. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8846. */
  8847. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8848. /**
  8849. * Detach the current controls from the specified dom element.
  8850. * @param element Defines the element to stop listening the inputs from
  8851. */
  8852. detachControl(element: Nullable<HTMLElement>): void;
  8853. /**
  8854. * Update the current camera state depending on the inputs that have been used this frame.
  8855. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8856. */
  8857. checkInputs(): void;
  8858. /**
  8859. * Gets the class name of the current intput.
  8860. * @returns the class name
  8861. */
  8862. getClassName(): string;
  8863. /** @hidden */
  8864. _onLostFocus(): void;
  8865. /**
  8866. * Get the friendly name associated with the input class.
  8867. * @returns the input friendly name
  8868. */
  8869. getSimpleName(): string;
  8870. }
  8871. }
  8872. declare module "babylonjs/Lights/shadowLight" {
  8873. import { Camera } from "babylonjs/Cameras/camera";
  8874. import { Scene } from "babylonjs/scene";
  8875. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8877. import { Light } from "babylonjs/Lights/light";
  8878. /**
  8879. * Interface describing all the common properties and methods a shadow light needs to implement.
  8880. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8881. * as well as binding the different shadow properties to the effects.
  8882. */
  8883. export interface IShadowLight extends Light {
  8884. /**
  8885. * The light id in the scene (used in scene.findLighById for instance)
  8886. */
  8887. id: string;
  8888. /**
  8889. * The position the shdow will be casted from.
  8890. */
  8891. position: Vector3;
  8892. /**
  8893. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8894. */
  8895. direction: Vector3;
  8896. /**
  8897. * The transformed position. Position of the light in world space taking parenting in account.
  8898. */
  8899. transformedPosition: Vector3;
  8900. /**
  8901. * The transformed direction. Direction of the light in world space taking parenting in account.
  8902. */
  8903. transformedDirection: Vector3;
  8904. /**
  8905. * The friendly name of the light in the scene.
  8906. */
  8907. name: string;
  8908. /**
  8909. * Defines the shadow projection clipping minimum z value.
  8910. */
  8911. shadowMinZ: number;
  8912. /**
  8913. * Defines the shadow projection clipping maximum z value.
  8914. */
  8915. shadowMaxZ: number;
  8916. /**
  8917. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8918. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8919. */
  8920. computeTransformedInformation(): boolean;
  8921. /**
  8922. * Gets the scene the light belongs to.
  8923. * @returns The scene
  8924. */
  8925. getScene(): Scene;
  8926. /**
  8927. * Callback defining a custom Projection Matrix Builder.
  8928. * This can be used to override the default projection matrix computation.
  8929. */
  8930. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8931. /**
  8932. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8933. * @param matrix The materix to updated with the projection information
  8934. * @param viewMatrix The transform matrix of the light
  8935. * @param renderList The list of mesh to render in the map
  8936. * @returns The current light
  8937. */
  8938. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8939. /**
  8940. * Gets the current depth scale used in ESM.
  8941. * @returns The scale
  8942. */
  8943. getDepthScale(): number;
  8944. /**
  8945. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8946. * @returns true if a cube texture needs to be use
  8947. */
  8948. needCube(): boolean;
  8949. /**
  8950. * Detects if the projection matrix requires to be recomputed this frame.
  8951. * @returns true if it requires to be recomputed otherwise, false.
  8952. */
  8953. needProjectionMatrixCompute(): boolean;
  8954. /**
  8955. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8956. */
  8957. forceProjectionMatrixCompute(): void;
  8958. /**
  8959. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8960. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8961. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8962. */
  8963. getShadowDirection(faceIndex?: number): Vector3;
  8964. /**
  8965. * Gets the minZ used for shadow according to both the scene and the light.
  8966. * @param activeCamera The camera we are returning the min for
  8967. * @returns the depth min z
  8968. */
  8969. getDepthMinZ(activeCamera: Camera): number;
  8970. /**
  8971. * Gets the maxZ used for shadow according to both the scene and the light.
  8972. * @param activeCamera The camera we are returning the max for
  8973. * @returns the depth max z
  8974. */
  8975. getDepthMaxZ(activeCamera: Camera): number;
  8976. }
  8977. /**
  8978. * Base implementation IShadowLight
  8979. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8980. */
  8981. export abstract class ShadowLight extends Light implements IShadowLight {
  8982. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8983. protected _position: Vector3;
  8984. protected _setPosition(value: Vector3): void;
  8985. /**
  8986. * Sets the position the shadow will be casted from. Also use as the light position for both
  8987. * point and spot lights.
  8988. */
  8989. get position(): Vector3;
  8990. /**
  8991. * Sets the position the shadow will be casted from. Also use as the light position for both
  8992. * point and spot lights.
  8993. */
  8994. set position(value: Vector3);
  8995. protected _direction: Vector3;
  8996. protected _setDirection(value: Vector3): void;
  8997. /**
  8998. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8999. * Also use as the light direction on spot and directional lights.
  9000. */
  9001. get direction(): Vector3;
  9002. /**
  9003. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9004. * Also use as the light direction on spot and directional lights.
  9005. */
  9006. set direction(value: Vector3);
  9007. private _shadowMinZ;
  9008. /**
  9009. * Gets the shadow projection clipping minimum z value.
  9010. */
  9011. get shadowMinZ(): number;
  9012. /**
  9013. * Sets the shadow projection clipping minimum z value.
  9014. */
  9015. set shadowMinZ(value: number);
  9016. private _shadowMaxZ;
  9017. /**
  9018. * Sets the shadow projection clipping maximum z value.
  9019. */
  9020. get shadowMaxZ(): number;
  9021. /**
  9022. * Gets the shadow projection clipping maximum z value.
  9023. */
  9024. set shadowMaxZ(value: number);
  9025. /**
  9026. * Callback defining a custom Projection Matrix Builder.
  9027. * This can be used to override the default projection matrix computation.
  9028. */
  9029. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9030. /**
  9031. * The transformed position. Position of the light in world space taking parenting in account.
  9032. */
  9033. transformedPosition: Vector3;
  9034. /**
  9035. * The transformed direction. Direction of the light in world space taking parenting in account.
  9036. */
  9037. transformedDirection: Vector3;
  9038. private _needProjectionMatrixCompute;
  9039. /**
  9040. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9041. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9042. */
  9043. computeTransformedInformation(): boolean;
  9044. /**
  9045. * Return the depth scale used for the shadow map.
  9046. * @returns the depth scale.
  9047. */
  9048. getDepthScale(): number;
  9049. /**
  9050. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9051. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9052. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9053. */
  9054. getShadowDirection(faceIndex?: number): Vector3;
  9055. /**
  9056. * Returns the ShadowLight absolute position in the World.
  9057. * @returns the position vector in world space
  9058. */
  9059. getAbsolutePosition(): Vector3;
  9060. /**
  9061. * Sets the ShadowLight direction toward the passed target.
  9062. * @param target The point to target in local space
  9063. * @returns the updated ShadowLight direction
  9064. */
  9065. setDirectionToTarget(target: Vector3): Vector3;
  9066. /**
  9067. * Returns the light rotation in euler definition.
  9068. * @returns the x y z rotation in local space.
  9069. */
  9070. getRotation(): Vector3;
  9071. /**
  9072. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9073. * @returns true if a cube texture needs to be use
  9074. */
  9075. needCube(): boolean;
  9076. /**
  9077. * Detects if the projection matrix requires to be recomputed this frame.
  9078. * @returns true if it requires to be recomputed otherwise, false.
  9079. */
  9080. needProjectionMatrixCompute(): boolean;
  9081. /**
  9082. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9083. */
  9084. forceProjectionMatrixCompute(): void;
  9085. /** @hidden */
  9086. _initCache(): void;
  9087. /** @hidden */
  9088. _isSynchronized(): boolean;
  9089. /**
  9090. * Computes the world matrix of the node
  9091. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9092. * @returns the world matrix
  9093. */
  9094. computeWorldMatrix(force?: boolean): Matrix;
  9095. /**
  9096. * Gets the minZ used for shadow according to both the scene and the light.
  9097. * @param activeCamera The camera we are returning the min for
  9098. * @returns the depth min z
  9099. */
  9100. getDepthMinZ(activeCamera: Camera): number;
  9101. /**
  9102. * Gets the maxZ used for shadow according to both the scene and the light.
  9103. * @param activeCamera The camera we are returning the max for
  9104. * @returns the depth max z
  9105. */
  9106. getDepthMaxZ(activeCamera: Camera): number;
  9107. /**
  9108. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9109. * @param matrix The materix to updated with the projection information
  9110. * @param viewMatrix The transform matrix of the light
  9111. * @param renderList The list of mesh to render in the map
  9112. * @returns The current light
  9113. */
  9114. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9115. }
  9116. }
  9117. declare module "babylonjs/Materials/effectFallbacks" {
  9118. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9119. import { Effect } from "babylonjs/Materials/effect";
  9120. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9121. /**
  9122. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9123. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9124. */
  9125. export class EffectFallbacks implements IEffectFallbacks {
  9126. private _defines;
  9127. private _currentRank;
  9128. private _maxRank;
  9129. private _mesh;
  9130. /**
  9131. * Removes the fallback from the bound mesh.
  9132. */
  9133. unBindMesh(): void;
  9134. /**
  9135. * Adds a fallback on the specified property.
  9136. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9137. * @param define The name of the define in the shader
  9138. */
  9139. addFallback(rank: number, define: string): void;
  9140. /**
  9141. * Sets the mesh to use CPU skinning when needing to fallback.
  9142. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9143. * @param mesh The mesh to use the fallbacks.
  9144. */
  9145. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9146. /**
  9147. * Checks to see if more fallbacks are still availible.
  9148. */
  9149. get hasMoreFallbacks(): boolean;
  9150. /**
  9151. * Removes the defines that should be removed when falling back.
  9152. * @param currentDefines defines the current define statements for the shader.
  9153. * @param effect defines the current effect we try to compile
  9154. * @returns The resulting defines with defines of the current rank removed.
  9155. */
  9156. reduce(currentDefines: string, effect: Effect): string;
  9157. }
  9158. }
  9159. declare module "babylonjs/Materials/materialHelper" {
  9160. import { Nullable } from "babylonjs/types";
  9161. import { Scene } from "babylonjs/scene";
  9162. import { Engine } from "babylonjs/Engines/engine";
  9163. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9164. import { Light } from "babylonjs/Lights/light";
  9165. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9166. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9167. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9168. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9169. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9170. /**
  9171. * "Static Class" containing the most commonly used helper while dealing with material for
  9172. * rendering purpose.
  9173. *
  9174. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9175. *
  9176. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9177. */
  9178. export class MaterialHelper {
  9179. /**
  9180. * Bind the current view position to an effect.
  9181. * @param effect The effect to be bound
  9182. * @param scene The scene the eyes position is used from
  9183. */
  9184. static BindEyePosition(effect: Effect, scene: Scene): void;
  9185. /**
  9186. * Helps preparing the defines values about the UVs in used in the effect.
  9187. * UVs are shared as much as we can accross channels in the shaders.
  9188. * @param texture The texture we are preparing the UVs for
  9189. * @param defines The defines to update
  9190. * @param key The channel key "diffuse", "specular"... used in the shader
  9191. */
  9192. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9193. /**
  9194. * Binds a texture matrix value to its corrsponding uniform
  9195. * @param texture The texture to bind the matrix for
  9196. * @param uniformBuffer The uniform buffer receivin the data
  9197. * @param key The channel key "diffuse", "specular"... used in the shader
  9198. */
  9199. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9200. /**
  9201. * Gets the current status of the fog (should it be enabled?)
  9202. * @param mesh defines the mesh to evaluate for fog support
  9203. * @param scene defines the hosting scene
  9204. * @returns true if fog must be enabled
  9205. */
  9206. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9207. /**
  9208. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9209. * @param mesh defines the current mesh
  9210. * @param scene defines the current scene
  9211. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9212. * @param pointsCloud defines if point cloud rendering has to be turned on
  9213. * @param fogEnabled defines if fog has to be turned on
  9214. * @param alphaTest defines if alpha testing has to be turned on
  9215. * @param defines defines the current list of defines
  9216. */
  9217. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9218. /**
  9219. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9220. * @param scene defines the current scene
  9221. * @param engine defines the current engine
  9222. * @param defines specifies the list of active defines
  9223. * @param useInstances defines if instances have to be turned on
  9224. * @param useClipPlane defines if clip plane have to be turned on
  9225. */
  9226. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9227. /**
  9228. * Prepares the defines for bones
  9229. * @param mesh The mesh containing the geometry data we will draw
  9230. * @param defines The defines to update
  9231. */
  9232. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9233. /**
  9234. * Prepares the defines for morph targets
  9235. * @param mesh The mesh containing the geometry data we will draw
  9236. * @param defines The defines to update
  9237. */
  9238. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9239. /**
  9240. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9241. * @param mesh The mesh containing the geometry data we will draw
  9242. * @param defines The defines to update
  9243. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9244. * @param useBones Precise whether bones should be used or not (override mesh info)
  9245. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9246. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9247. * @returns false if defines are considered not dirty and have not been checked
  9248. */
  9249. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9250. /**
  9251. * Prepares the defines related to multiview
  9252. * @param scene The scene we are intending to draw
  9253. * @param defines The defines to update
  9254. */
  9255. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9256. /**
  9257. * Prepares the defines related to the light information passed in parameter
  9258. * @param scene The scene we are intending to draw
  9259. * @param mesh The mesh the effect is compiling for
  9260. * @param light The light the effect is compiling for
  9261. * @param lightIndex The index of the light
  9262. * @param defines The defines to update
  9263. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9264. * @param state Defines the current state regarding what is needed (normals, etc...)
  9265. */
  9266. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9267. needNormals: boolean;
  9268. needRebuild: boolean;
  9269. shadowEnabled: boolean;
  9270. specularEnabled: boolean;
  9271. lightmapMode: boolean;
  9272. }): void;
  9273. /**
  9274. * Prepares the defines related to the light information passed in parameter
  9275. * @param scene The scene we are intending to draw
  9276. * @param mesh The mesh the effect is compiling for
  9277. * @param defines The defines to update
  9278. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9279. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9280. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9281. * @returns true if normals will be required for the rest of the effect
  9282. */
  9283. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9284. /**
  9285. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9286. * @param lightIndex defines the light index
  9287. * @param uniformsList The uniform list
  9288. * @param samplersList The sampler list
  9289. * @param projectedLightTexture defines if projected texture must be used
  9290. * @param uniformBuffersList defines an optional list of uniform buffers
  9291. */
  9292. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9293. /**
  9294. * Prepares the uniforms and samplers list to be used in the effect
  9295. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9296. * @param samplersList The sampler list
  9297. * @param defines The defines helping in the list generation
  9298. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9299. */
  9300. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9301. /**
  9302. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9303. * @param defines The defines to update while falling back
  9304. * @param fallbacks The authorized effect fallbacks
  9305. * @param maxSimultaneousLights The maximum number of lights allowed
  9306. * @param rank the current rank of the Effect
  9307. * @returns The newly affected rank
  9308. */
  9309. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9310. private static _TmpMorphInfluencers;
  9311. /**
  9312. * Prepares the list of attributes required for morph targets according to the effect defines.
  9313. * @param attribs The current list of supported attribs
  9314. * @param mesh The mesh to prepare the morph targets attributes for
  9315. * @param influencers The number of influencers
  9316. */
  9317. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9318. /**
  9319. * Prepares the list of attributes required for morph targets according to the effect defines.
  9320. * @param attribs The current list of supported attribs
  9321. * @param mesh The mesh to prepare the morph targets attributes for
  9322. * @param defines The current Defines of the effect
  9323. */
  9324. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9325. /**
  9326. * Prepares the list of attributes required for bones according to the effect defines.
  9327. * @param attribs The current list of supported attribs
  9328. * @param mesh The mesh to prepare the bones attributes for
  9329. * @param defines The current Defines of the effect
  9330. * @param fallbacks The current efffect fallback strategy
  9331. */
  9332. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9333. /**
  9334. * Check and prepare the list of attributes required for instances according to the effect defines.
  9335. * @param attribs The current list of supported attribs
  9336. * @param defines The current MaterialDefines of the effect
  9337. */
  9338. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9339. /**
  9340. * Add the list of attributes required for instances to the attribs array.
  9341. * @param attribs The current list of supported attribs
  9342. */
  9343. static PushAttributesForInstances(attribs: string[]): void;
  9344. /**
  9345. * Binds the light information to the effect.
  9346. * @param light The light containing the generator
  9347. * @param effect The effect we are binding the data to
  9348. * @param lightIndex The light index in the effect used to render
  9349. */
  9350. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9351. /**
  9352. * Binds the lights information from the scene to the effect for the given mesh.
  9353. * @param light Light to bind
  9354. * @param lightIndex Light index
  9355. * @param scene The scene where the light belongs to
  9356. * @param effect The effect we are binding the data to
  9357. * @param useSpecular Defines if specular is supported
  9358. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9359. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9360. */
  9361. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9362. /**
  9363. * Binds the lights information from the scene to the effect for the given mesh.
  9364. * @param scene The scene the lights belongs to
  9365. * @param mesh The mesh we are binding the information to render
  9366. * @param effect The effect we are binding the data to
  9367. * @param defines The generated defines for the effect
  9368. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9369. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9370. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9371. */
  9372. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9373. private static _tempFogColor;
  9374. /**
  9375. * Binds the fog information from the scene to the effect for the given mesh.
  9376. * @param scene The scene the lights belongs to
  9377. * @param mesh The mesh we are binding the information to render
  9378. * @param effect The effect we are binding the data to
  9379. * @param linearSpace Defines if the fog effect is applied in linear space
  9380. */
  9381. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9382. /**
  9383. * Binds the bones information from the mesh to the effect.
  9384. * @param mesh The mesh we are binding the information to render
  9385. * @param effect The effect we are binding the data to
  9386. */
  9387. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9388. /**
  9389. * Binds the morph targets information from the mesh to the effect.
  9390. * @param abstractMesh The mesh we are binding the information to render
  9391. * @param effect The effect we are binding the data to
  9392. */
  9393. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9394. /**
  9395. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9396. * @param defines The generated defines used in the effect
  9397. * @param effect The effect we are binding the data to
  9398. * @param scene The scene we are willing to render with logarithmic scale for
  9399. */
  9400. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9401. /**
  9402. * Binds the clip plane information from the scene to the effect.
  9403. * @param scene The scene the clip plane information are extracted from
  9404. * @param effect The effect we are binding the data to
  9405. */
  9406. static BindClipPlane(effect: Effect, scene: Scene): void;
  9407. }
  9408. }
  9409. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9410. /** @hidden */
  9411. export var packingFunctions: {
  9412. name: string;
  9413. shader: string;
  9414. };
  9415. }
  9416. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9417. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9418. /** @hidden */
  9419. export var shadowMapPixelShader: {
  9420. name: string;
  9421. shader: string;
  9422. };
  9423. }
  9424. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9425. /** @hidden */
  9426. export var bonesDeclaration: {
  9427. name: string;
  9428. shader: string;
  9429. };
  9430. }
  9431. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9432. /** @hidden */
  9433. export var morphTargetsVertexGlobalDeclaration: {
  9434. name: string;
  9435. shader: string;
  9436. };
  9437. }
  9438. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9439. /** @hidden */
  9440. export var morphTargetsVertexDeclaration: {
  9441. name: string;
  9442. shader: string;
  9443. };
  9444. }
  9445. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9446. /** @hidden */
  9447. export var instancesDeclaration: {
  9448. name: string;
  9449. shader: string;
  9450. };
  9451. }
  9452. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9453. /** @hidden */
  9454. export var helperFunctions: {
  9455. name: string;
  9456. shader: string;
  9457. };
  9458. }
  9459. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9460. /** @hidden */
  9461. export var morphTargetsVertex: {
  9462. name: string;
  9463. shader: string;
  9464. };
  9465. }
  9466. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9467. /** @hidden */
  9468. export var instancesVertex: {
  9469. name: string;
  9470. shader: string;
  9471. };
  9472. }
  9473. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9474. /** @hidden */
  9475. export var bonesVertex: {
  9476. name: string;
  9477. shader: string;
  9478. };
  9479. }
  9480. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9481. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9482. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9483. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9484. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9485. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9486. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9487. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9488. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9489. /** @hidden */
  9490. export var shadowMapVertexShader: {
  9491. name: string;
  9492. shader: string;
  9493. };
  9494. }
  9495. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9496. /** @hidden */
  9497. export var depthBoxBlurPixelShader: {
  9498. name: string;
  9499. shader: string;
  9500. };
  9501. }
  9502. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9503. import { Nullable } from "babylonjs/types";
  9504. import { Scene } from "babylonjs/scene";
  9505. import { Matrix } from "babylonjs/Maths/math.vector";
  9506. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9507. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9508. import { Mesh } from "babylonjs/Meshes/mesh";
  9509. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9510. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9511. import { Effect } from "babylonjs/Materials/effect";
  9512. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9513. import "babylonjs/Shaders/shadowMap.fragment";
  9514. import "babylonjs/Shaders/shadowMap.vertex";
  9515. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9516. import { Observable } from "babylonjs/Misc/observable";
  9517. /**
  9518. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9519. */
  9520. export interface ICustomShaderOptions {
  9521. /**
  9522. * Gets or sets the custom shader name to use
  9523. */
  9524. shaderName: string;
  9525. /**
  9526. * The list of attribute names used in the shader
  9527. */
  9528. attributes?: string[];
  9529. /**
  9530. * The list of unifrom names used in the shader
  9531. */
  9532. uniforms?: string[];
  9533. /**
  9534. * The list of sampler names used in the shader
  9535. */
  9536. samplers?: string[];
  9537. /**
  9538. * The list of defines used in the shader
  9539. */
  9540. defines?: string[];
  9541. }
  9542. /**
  9543. * Interface to implement to create a shadow generator compatible with BJS.
  9544. */
  9545. export interface IShadowGenerator {
  9546. /**
  9547. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9548. * @returns The render target texture if present otherwise, null
  9549. */
  9550. getShadowMap(): Nullable<RenderTargetTexture>;
  9551. /**
  9552. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9553. * @returns The render target texture if the shadow map is present otherwise, null
  9554. */
  9555. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9556. /**
  9557. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9558. * @param subMesh The submesh we want to render in the shadow map
  9559. * @param useInstances Defines wether will draw in the map using instances
  9560. * @returns true if ready otherwise, false
  9561. */
  9562. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9563. /**
  9564. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9565. * @param defines Defines of the material we want to update
  9566. * @param lightIndex Index of the light in the enabled light list of the material
  9567. */
  9568. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9569. /**
  9570. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9571. * defined in the generator but impacting the effect).
  9572. * It implies the unifroms available on the materials are the standard BJS ones.
  9573. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9574. * @param effect The effect we are binfing the information for
  9575. */
  9576. bindShadowLight(lightIndex: string, effect: Effect): void;
  9577. /**
  9578. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9579. * (eq to shadow prjection matrix * light transform matrix)
  9580. * @returns The transform matrix used to create the shadow map
  9581. */
  9582. getTransformMatrix(): Matrix;
  9583. /**
  9584. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9585. * Cube and 2D textures for instance.
  9586. */
  9587. recreateShadowMap(): void;
  9588. /**
  9589. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9590. * @param onCompiled Callback triggered at the and of the effects compilation
  9591. * @param options Sets of optional options forcing the compilation with different modes
  9592. */
  9593. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9594. useInstances: boolean;
  9595. }>): void;
  9596. /**
  9597. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9598. * @param options Sets of optional options forcing the compilation with different modes
  9599. * @returns A promise that resolves when the compilation completes
  9600. */
  9601. forceCompilationAsync(options?: Partial<{
  9602. useInstances: boolean;
  9603. }>): Promise<void>;
  9604. /**
  9605. * Serializes the shadow generator setup to a json object.
  9606. * @returns The serialized JSON object
  9607. */
  9608. serialize(): any;
  9609. /**
  9610. * Disposes the Shadow map and related Textures and effects.
  9611. */
  9612. dispose(): void;
  9613. }
  9614. /**
  9615. * Default implementation IShadowGenerator.
  9616. * This is the main object responsible of generating shadows in the framework.
  9617. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9618. */
  9619. export class ShadowGenerator implements IShadowGenerator {
  9620. /**
  9621. * Shadow generator mode None: no filtering applied.
  9622. */
  9623. static readonly FILTER_NONE: number;
  9624. /**
  9625. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9626. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9627. */
  9628. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9629. /**
  9630. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9631. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9632. */
  9633. static readonly FILTER_POISSONSAMPLING: number;
  9634. /**
  9635. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9636. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9637. */
  9638. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9639. /**
  9640. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9641. * edge artifacts on steep falloff.
  9642. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9643. */
  9644. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9645. /**
  9646. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9647. * edge artifacts on steep falloff.
  9648. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9649. */
  9650. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9651. /**
  9652. * Shadow generator mode PCF: Percentage Closer Filtering
  9653. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9654. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9655. */
  9656. static readonly FILTER_PCF: number;
  9657. /**
  9658. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9659. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9660. * Contact Hardening
  9661. */
  9662. static readonly FILTER_PCSS: number;
  9663. /**
  9664. * Reserved for PCF and PCSS
  9665. * Highest Quality.
  9666. *
  9667. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9668. *
  9669. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9670. */
  9671. static readonly QUALITY_HIGH: number;
  9672. /**
  9673. * Reserved for PCF and PCSS
  9674. * Good tradeoff for quality/perf cross devices
  9675. *
  9676. * Execute PCF on a 3*3 kernel.
  9677. *
  9678. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9679. */
  9680. static readonly QUALITY_MEDIUM: number;
  9681. /**
  9682. * Reserved for PCF and PCSS
  9683. * The lowest quality but the fastest.
  9684. *
  9685. * Execute PCF on a 1*1 kernel.
  9686. *
  9687. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9688. */
  9689. static readonly QUALITY_LOW: number;
  9690. /** Gets or sets the custom shader name to use */
  9691. customShaderOptions: ICustomShaderOptions;
  9692. /**
  9693. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9694. */
  9695. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9696. /**
  9697. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9698. */
  9699. onAfterShadowMapRenderObservable: Observable<Effect>;
  9700. /**
  9701. * Observable triggered before a mesh is rendered in the shadow map.
  9702. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9703. */
  9704. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9705. /**
  9706. * Observable triggered after a mesh is rendered in the shadow map.
  9707. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9708. */
  9709. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9710. private _bias;
  9711. /**
  9712. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9713. */
  9714. get bias(): number;
  9715. /**
  9716. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9717. */
  9718. set bias(bias: number);
  9719. private _normalBias;
  9720. /**
  9721. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9722. */
  9723. get normalBias(): number;
  9724. /**
  9725. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9726. */
  9727. set normalBias(normalBias: number);
  9728. private _blurBoxOffset;
  9729. /**
  9730. * Gets the blur box offset: offset applied during the blur pass.
  9731. * Only useful if useKernelBlur = false
  9732. */
  9733. get blurBoxOffset(): number;
  9734. /**
  9735. * Sets the blur box offset: offset applied during the blur pass.
  9736. * Only useful if useKernelBlur = false
  9737. */
  9738. set blurBoxOffset(value: number);
  9739. private _blurScale;
  9740. /**
  9741. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9742. * 2 means half of the size.
  9743. */
  9744. get blurScale(): number;
  9745. /**
  9746. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9747. * 2 means half of the size.
  9748. */
  9749. set blurScale(value: number);
  9750. private _blurKernel;
  9751. /**
  9752. * Gets the blur kernel: kernel size of the blur pass.
  9753. * Only useful if useKernelBlur = true
  9754. */
  9755. get blurKernel(): number;
  9756. /**
  9757. * Sets the blur kernel: kernel size of the blur pass.
  9758. * Only useful if useKernelBlur = true
  9759. */
  9760. set blurKernel(value: number);
  9761. private _useKernelBlur;
  9762. /**
  9763. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9764. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9765. */
  9766. get useKernelBlur(): boolean;
  9767. /**
  9768. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9769. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9770. */
  9771. set useKernelBlur(value: boolean);
  9772. private _depthScale;
  9773. /**
  9774. * Gets the depth scale used in ESM mode.
  9775. */
  9776. get depthScale(): number;
  9777. /**
  9778. * Sets the depth scale used in ESM mode.
  9779. * This can override the scale stored on the light.
  9780. */
  9781. set depthScale(value: number);
  9782. private _filter;
  9783. /**
  9784. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9785. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9786. */
  9787. get filter(): number;
  9788. /**
  9789. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9790. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9791. */
  9792. set filter(value: number);
  9793. /**
  9794. * Gets if the current filter is set to Poisson Sampling.
  9795. */
  9796. get usePoissonSampling(): boolean;
  9797. /**
  9798. * Sets the current filter to Poisson Sampling.
  9799. */
  9800. set usePoissonSampling(value: boolean);
  9801. /**
  9802. * Gets if the current filter is set to ESM.
  9803. */
  9804. get useExponentialShadowMap(): boolean;
  9805. /**
  9806. * Sets the current filter is to ESM.
  9807. */
  9808. set useExponentialShadowMap(value: boolean);
  9809. /**
  9810. * Gets if the current filter is set to filtered ESM.
  9811. */
  9812. get useBlurExponentialShadowMap(): boolean;
  9813. /**
  9814. * Gets if the current filter is set to filtered ESM.
  9815. */
  9816. set useBlurExponentialShadowMap(value: boolean);
  9817. /**
  9818. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9819. * exponential to prevent steep falloff artifacts).
  9820. */
  9821. get useCloseExponentialShadowMap(): boolean;
  9822. /**
  9823. * Sets the current filter to "close ESM" (using the inverse of the
  9824. * exponential to prevent steep falloff artifacts).
  9825. */
  9826. set useCloseExponentialShadowMap(value: boolean);
  9827. /**
  9828. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9829. * exponential to prevent steep falloff artifacts).
  9830. */
  9831. get useBlurCloseExponentialShadowMap(): boolean;
  9832. /**
  9833. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9834. * exponential to prevent steep falloff artifacts).
  9835. */
  9836. set useBlurCloseExponentialShadowMap(value: boolean);
  9837. /**
  9838. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9839. */
  9840. get usePercentageCloserFiltering(): boolean;
  9841. /**
  9842. * Sets the current filter to "PCF" (percentage closer filtering).
  9843. */
  9844. set usePercentageCloserFiltering(value: boolean);
  9845. private _filteringQuality;
  9846. /**
  9847. * Gets the PCF or PCSS Quality.
  9848. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9849. */
  9850. get filteringQuality(): number;
  9851. /**
  9852. * Sets the PCF or PCSS Quality.
  9853. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9854. */
  9855. set filteringQuality(filteringQuality: number);
  9856. /**
  9857. * Gets if the current filter is set to "PCSS" (contact hardening).
  9858. */
  9859. get useContactHardeningShadow(): boolean;
  9860. /**
  9861. * Sets the current filter to "PCSS" (contact hardening).
  9862. */
  9863. set useContactHardeningShadow(value: boolean);
  9864. private _contactHardeningLightSizeUVRatio;
  9865. /**
  9866. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9867. * Using a ratio helps keeping shape stability independently of the map size.
  9868. *
  9869. * It does not account for the light projection as it was having too much
  9870. * instability during the light setup or during light position changes.
  9871. *
  9872. * Only valid if useContactHardeningShadow is true.
  9873. */
  9874. get contactHardeningLightSizeUVRatio(): number;
  9875. /**
  9876. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9877. * Using a ratio helps keeping shape stability independently of the map size.
  9878. *
  9879. * It does not account for the light projection as it was having too much
  9880. * instability during the light setup or during light position changes.
  9881. *
  9882. * Only valid if useContactHardeningShadow is true.
  9883. */
  9884. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  9885. private _darkness;
  9886. /** Gets or sets the actual darkness of a shadow */
  9887. get darkness(): number;
  9888. set darkness(value: number);
  9889. /**
  9890. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9891. * 0 means strongest and 1 would means no shadow.
  9892. * @returns the darkness.
  9893. */
  9894. getDarkness(): number;
  9895. /**
  9896. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9897. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9898. * @returns the shadow generator allowing fluent coding.
  9899. */
  9900. setDarkness(darkness: number): ShadowGenerator;
  9901. private _transparencyShadow;
  9902. /** Gets or sets the ability to have transparent shadow */
  9903. get transparencyShadow(): boolean;
  9904. set transparencyShadow(value: boolean);
  9905. /**
  9906. * Sets the ability to have transparent shadow (boolean).
  9907. * @param transparent True if transparent else False
  9908. * @returns the shadow generator allowing fluent coding
  9909. */
  9910. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9911. private _shadowMap;
  9912. private _shadowMap2;
  9913. /**
  9914. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9915. * @returns The render target texture if present otherwise, null
  9916. */
  9917. getShadowMap(): Nullable<RenderTargetTexture>;
  9918. /**
  9919. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9920. * @returns The render target texture if the shadow map is present otherwise, null
  9921. */
  9922. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9923. /**
  9924. * Gets the class name of that object
  9925. * @returns "ShadowGenerator"
  9926. */
  9927. getClassName(): string;
  9928. /**
  9929. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9930. * @param mesh Mesh to add
  9931. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9932. * @returns the Shadow Generator itself
  9933. */
  9934. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9935. /**
  9936. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9937. * @param mesh Mesh to remove
  9938. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9939. * @returns the Shadow Generator itself
  9940. */
  9941. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9942. /**
  9943. * Controls the extent to which the shadows fade out at the edge of the frustum
  9944. * Used only by directionals and spots
  9945. */
  9946. frustumEdgeFalloff: number;
  9947. private _light;
  9948. /**
  9949. * Returns the associated light object.
  9950. * @returns the light generating the shadow
  9951. */
  9952. getLight(): IShadowLight;
  9953. /**
  9954. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9955. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9956. * It might on the other hand introduce peter panning.
  9957. */
  9958. forceBackFacesOnly: boolean;
  9959. private _scene;
  9960. private _lightDirection;
  9961. private _effect;
  9962. private _viewMatrix;
  9963. private _projectionMatrix;
  9964. private _transformMatrix;
  9965. private _cachedPosition;
  9966. private _cachedDirection;
  9967. private _cachedDefines;
  9968. private _currentRenderID;
  9969. private _boxBlurPostprocess;
  9970. private _kernelBlurXPostprocess;
  9971. private _kernelBlurYPostprocess;
  9972. private _blurPostProcesses;
  9973. private _mapSize;
  9974. private _currentFaceIndex;
  9975. private _currentFaceIndexCache;
  9976. private _textureType;
  9977. private _defaultTextureMatrix;
  9978. private _storedUniqueId;
  9979. /** @hidden */
  9980. static _SceneComponentInitialization: (scene: Scene) => void;
  9981. /**
  9982. * Creates a ShadowGenerator object.
  9983. * A ShadowGenerator is the required tool to use the shadows.
  9984. * Each light casting shadows needs to use its own ShadowGenerator.
  9985. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9986. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9987. * @param light The light object generating the shadows.
  9988. * @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.
  9989. */
  9990. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9991. private _initializeGenerator;
  9992. private _initializeShadowMap;
  9993. private _initializeBlurRTTAndPostProcesses;
  9994. private _renderForShadowMap;
  9995. private _renderSubMeshForShadowMap;
  9996. private _applyFilterValues;
  9997. /**
  9998. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9999. * @param onCompiled Callback triggered at the and of the effects compilation
  10000. * @param options Sets of optional options forcing the compilation with different modes
  10001. */
  10002. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10003. useInstances: boolean;
  10004. }>): void;
  10005. /**
  10006. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10007. * @param options Sets of optional options forcing the compilation with different modes
  10008. * @returns A promise that resolves when the compilation completes
  10009. */
  10010. forceCompilationAsync(options?: Partial<{
  10011. useInstances: boolean;
  10012. }>): Promise<void>;
  10013. /**
  10014. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10015. * @param subMesh The submesh we want to render in the shadow map
  10016. * @param useInstances Defines wether will draw in the map using instances
  10017. * @returns true if ready otherwise, false
  10018. */
  10019. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10020. /**
  10021. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10022. * @param defines Defines of the material we want to update
  10023. * @param lightIndex Index of the light in the enabled light list of the material
  10024. */
  10025. prepareDefines(defines: any, lightIndex: number): void;
  10026. /**
  10027. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10028. * defined in the generator but impacting the effect).
  10029. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10030. * @param effect The effect we are binfing the information for
  10031. */
  10032. bindShadowLight(lightIndex: string, effect: Effect): void;
  10033. /**
  10034. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10035. * (eq to shadow prjection matrix * light transform matrix)
  10036. * @returns The transform matrix used to create the shadow map
  10037. */
  10038. getTransformMatrix(): Matrix;
  10039. /**
  10040. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10041. * Cube and 2D textures for instance.
  10042. */
  10043. recreateShadowMap(): void;
  10044. private _disposeBlurPostProcesses;
  10045. private _disposeRTTandPostProcesses;
  10046. /**
  10047. * Disposes the ShadowGenerator.
  10048. * Returns nothing.
  10049. */
  10050. dispose(): void;
  10051. /**
  10052. * Serializes the shadow generator setup to a json object.
  10053. * @returns The serialized JSON object
  10054. */
  10055. serialize(): any;
  10056. /**
  10057. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10058. * @param parsedShadowGenerator The JSON object to parse
  10059. * @param scene The scene to create the shadow map for
  10060. * @returns The parsed shadow generator
  10061. */
  10062. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10063. }
  10064. }
  10065. declare module "babylonjs/Lights/light" {
  10066. import { Nullable } from "babylonjs/types";
  10067. import { Scene } from "babylonjs/scene";
  10068. import { Vector3 } from "babylonjs/Maths/math.vector";
  10069. import { Color3 } from "babylonjs/Maths/math.color";
  10070. import { Node } from "babylonjs/node";
  10071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10072. import { Effect } from "babylonjs/Materials/effect";
  10073. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10074. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10075. /**
  10076. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10077. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10078. * 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.
  10079. */
  10080. export abstract class Light extends Node {
  10081. /**
  10082. * Falloff Default: light is falling off following the material specification:
  10083. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10084. */
  10085. static readonly FALLOFF_DEFAULT: number;
  10086. /**
  10087. * Falloff Physical: light is falling off following the inverse squared distance law.
  10088. */
  10089. static readonly FALLOFF_PHYSICAL: number;
  10090. /**
  10091. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10092. * to enhance interoperability with other engines.
  10093. */
  10094. static readonly FALLOFF_GLTF: number;
  10095. /**
  10096. * Falloff Standard: light is falling off like in the standard material
  10097. * to enhance interoperability with other materials.
  10098. */
  10099. static readonly FALLOFF_STANDARD: number;
  10100. /**
  10101. * If every light affecting the material is in this lightmapMode,
  10102. * material.lightmapTexture adds or multiplies
  10103. * (depends on material.useLightmapAsShadowmap)
  10104. * after every other light calculations.
  10105. */
  10106. static readonly LIGHTMAP_DEFAULT: number;
  10107. /**
  10108. * material.lightmapTexture as only diffuse lighting from this light
  10109. * adds only specular lighting from this light
  10110. * adds dynamic shadows
  10111. */
  10112. static readonly LIGHTMAP_SPECULAR: number;
  10113. /**
  10114. * material.lightmapTexture as only lighting
  10115. * no light calculation from this light
  10116. * only adds dynamic shadows from this light
  10117. */
  10118. static readonly LIGHTMAP_SHADOWSONLY: number;
  10119. /**
  10120. * Each light type uses the default quantity according to its type:
  10121. * point/spot lights use luminous intensity
  10122. * directional lights use illuminance
  10123. */
  10124. static readonly INTENSITYMODE_AUTOMATIC: number;
  10125. /**
  10126. * lumen (lm)
  10127. */
  10128. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10129. /**
  10130. * candela (lm/sr)
  10131. */
  10132. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10133. /**
  10134. * lux (lm/m^2)
  10135. */
  10136. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10137. /**
  10138. * nit (cd/m^2)
  10139. */
  10140. static readonly INTENSITYMODE_LUMINANCE: number;
  10141. /**
  10142. * Light type const id of the point light.
  10143. */
  10144. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10145. /**
  10146. * Light type const id of the directional light.
  10147. */
  10148. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10149. /**
  10150. * Light type const id of the spot light.
  10151. */
  10152. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10153. /**
  10154. * Light type const id of the hemispheric light.
  10155. */
  10156. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10157. /**
  10158. * Diffuse gives the basic color to an object.
  10159. */
  10160. diffuse: Color3;
  10161. /**
  10162. * Specular produces a highlight color on an object.
  10163. * Note: This is note affecting PBR materials.
  10164. */
  10165. specular: Color3;
  10166. /**
  10167. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10168. * falling off base on range or angle.
  10169. * This can be set to any values in Light.FALLOFF_x.
  10170. *
  10171. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10172. * other types of materials.
  10173. */
  10174. falloffType: number;
  10175. /**
  10176. * Strength of the light.
  10177. * Note: By default it is define in the framework own unit.
  10178. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10179. */
  10180. intensity: number;
  10181. private _range;
  10182. protected _inverseSquaredRange: number;
  10183. /**
  10184. * Defines how far from the source the light is impacting in scene units.
  10185. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10186. */
  10187. get range(): number;
  10188. /**
  10189. * Defines how far from the source the light is impacting in scene units.
  10190. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10191. */
  10192. set range(value: number);
  10193. /**
  10194. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10195. * of light.
  10196. */
  10197. private _photometricScale;
  10198. private _intensityMode;
  10199. /**
  10200. * Gets the photometric scale used to interpret the intensity.
  10201. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10202. */
  10203. get intensityMode(): number;
  10204. /**
  10205. * Sets the photometric scale used to interpret the intensity.
  10206. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10207. */
  10208. set intensityMode(value: number);
  10209. private _radius;
  10210. /**
  10211. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10212. */
  10213. get radius(): number;
  10214. /**
  10215. * sets the light radius used by PBR Materials to simulate soft area lights.
  10216. */
  10217. set radius(value: number);
  10218. private _renderPriority;
  10219. /**
  10220. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10221. * exceeding the number allowed of the materials.
  10222. */
  10223. renderPriority: number;
  10224. private _shadowEnabled;
  10225. /**
  10226. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10227. * the current shadow generator.
  10228. */
  10229. get shadowEnabled(): boolean;
  10230. /**
  10231. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10232. * the current shadow generator.
  10233. */
  10234. set shadowEnabled(value: boolean);
  10235. private _includedOnlyMeshes;
  10236. /**
  10237. * Gets the only meshes impacted by this light.
  10238. */
  10239. get includedOnlyMeshes(): AbstractMesh[];
  10240. /**
  10241. * Sets the only meshes impacted by this light.
  10242. */
  10243. set includedOnlyMeshes(value: AbstractMesh[]);
  10244. private _excludedMeshes;
  10245. /**
  10246. * Gets the meshes not impacted by this light.
  10247. */
  10248. get excludedMeshes(): AbstractMesh[];
  10249. /**
  10250. * Sets the meshes not impacted by this light.
  10251. */
  10252. set excludedMeshes(value: AbstractMesh[]);
  10253. private _excludeWithLayerMask;
  10254. /**
  10255. * Gets the layer id use to find what meshes are not impacted by the light.
  10256. * Inactive if 0
  10257. */
  10258. get excludeWithLayerMask(): number;
  10259. /**
  10260. * Sets the layer id use to find what meshes are not impacted by the light.
  10261. * Inactive if 0
  10262. */
  10263. set excludeWithLayerMask(value: number);
  10264. private _includeOnlyWithLayerMask;
  10265. /**
  10266. * Gets the layer id use to find what meshes are impacted by the light.
  10267. * Inactive if 0
  10268. */
  10269. get includeOnlyWithLayerMask(): number;
  10270. /**
  10271. * Sets the layer id use to find what meshes are impacted by the light.
  10272. * Inactive if 0
  10273. */
  10274. set includeOnlyWithLayerMask(value: number);
  10275. private _lightmapMode;
  10276. /**
  10277. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10278. */
  10279. get lightmapMode(): number;
  10280. /**
  10281. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10282. */
  10283. set lightmapMode(value: number);
  10284. /**
  10285. * Shadow generator associted to the light.
  10286. * @hidden Internal use only.
  10287. */
  10288. _shadowGenerator: Nullable<IShadowGenerator>;
  10289. /**
  10290. * @hidden Internal use only.
  10291. */
  10292. _excludedMeshesIds: string[];
  10293. /**
  10294. * @hidden Internal use only.
  10295. */
  10296. _includedOnlyMeshesIds: string[];
  10297. /**
  10298. * The current light unifom buffer.
  10299. * @hidden Internal use only.
  10300. */
  10301. _uniformBuffer: UniformBuffer;
  10302. /** @hidden */
  10303. _renderId: number;
  10304. /**
  10305. * Creates a Light object in the scene.
  10306. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10307. * @param name The firendly name of the light
  10308. * @param scene The scene the light belongs too
  10309. */
  10310. constructor(name: string, scene: Scene);
  10311. protected abstract _buildUniformLayout(): void;
  10312. /**
  10313. * Sets the passed Effect "effect" with the Light information.
  10314. * @param effect The effect to update
  10315. * @param lightIndex The index of the light in the effect to update
  10316. * @returns The light
  10317. */
  10318. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10319. /**
  10320. * Sets the passed Effect "effect" with the Light textures.
  10321. * @param effect The effect to update
  10322. * @param lightIndex The index of the light in the effect to update
  10323. * @returns The light
  10324. */
  10325. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10326. /**
  10327. * Binds the lights information from the scene to the effect for the given mesh.
  10328. * @param lightIndex Light index
  10329. * @param scene The scene where the light belongs to
  10330. * @param effect The effect we are binding the data to
  10331. * @param useSpecular Defines if specular is supported
  10332. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  10333. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10334. */
  10335. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  10336. /**
  10337. * Sets the passed Effect "effect" with the Light information.
  10338. * @param effect The effect to update
  10339. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10340. * @returns The light
  10341. */
  10342. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10343. /**
  10344. * Returns the string "Light".
  10345. * @returns the class name
  10346. */
  10347. getClassName(): string;
  10348. /** @hidden */
  10349. readonly _isLight: boolean;
  10350. /**
  10351. * Converts the light information to a readable string for debug purpose.
  10352. * @param fullDetails Supports for multiple levels of logging within scene loading
  10353. * @returns the human readable light info
  10354. */
  10355. toString(fullDetails?: boolean): string;
  10356. /** @hidden */
  10357. protected _syncParentEnabledState(): void;
  10358. /**
  10359. * Set the enabled state of this node.
  10360. * @param value - the new enabled state
  10361. */
  10362. setEnabled(value: boolean): void;
  10363. /**
  10364. * Returns the Light associated shadow generator if any.
  10365. * @return the associated shadow generator.
  10366. */
  10367. getShadowGenerator(): Nullable<IShadowGenerator>;
  10368. /**
  10369. * Returns a Vector3, the absolute light position in the World.
  10370. * @returns the world space position of the light
  10371. */
  10372. getAbsolutePosition(): Vector3;
  10373. /**
  10374. * Specifies if the light will affect the passed mesh.
  10375. * @param mesh The mesh to test against the light
  10376. * @return true the mesh is affected otherwise, false.
  10377. */
  10378. canAffectMesh(mesh: AbstractMesh): boolean;
  10379. /**
  10380. * Sort function to order lights for rendering.
  10381. * @param a First Light object to compare to second.
  10382. * @param b Second Light object to compare first.
  10383. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10384. */
  10385. static CompareLightsPriority(a: Light, b: Light): number;
  10386. /**
  10387. * Releases resources associated with this node.
  10388. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10389. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10390. */
  10391. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10392. /**
  10393. * Returns the light type ID (integer).
  10394. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10395. */
  10396. getTypeID(): number;
  10397. /**
  10398. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10399. * @returns the scaled intensity in intensity mode unit
  10400. */
  10401. getScaledIntensity(): number;
  10402. /**
  10403. * Returns a new Light object, named "name", from the current one.
  10404. * @param name The name of the cloned light
  10405. * @returns the new created light
  10406. */
  10407. clone(name: string): Nullable<Light>;
  10408. /**
  10409. * Serializes the current light into a Serialization object.
  10410. * @returns the serialized object.
  10411. */
  10412. serialize(): any;
  10413. /**
  10414. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10415. * This new light is named "name" and added to the passed scene.
  10416. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10417. * @param name The friendly name of the light
  10418. * @param scene The scene the new light will belong to
  10419. * @returns the constructor function
  10420. */
  10421. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10422. /**
  10423. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10424. * @param parsedLight The JSON representation of the light
  10425. * @param scene The scene to create the parsed light in
  10426. * @returns the created light after parsing
  10427. */
  10428. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10429. private _hookArrayForExcluded;
  10430. private _hookArrayForIncludedOnly;
  10431. private _resyncMeshes;
  10432. /**
  10433. * Forces the meshes to update their light related information in their rendering used effects
  10434. * @hidden Internal Use Only
  10435. */
  10436. _markMeshesAsLightDirty(): void;
  10437. /**
  10438. * Recomputes the cached photometric scale if needed.
  10439. */
  10440. private _computePhotometricScale;
  10441. /**
  10442. * Returns the Photometric Scale according to the light type and intensity mode.
  10443. */
  10444. private _getPhotometricScale;
  10445. /**
  10446. * Reorder the light in the scene according to their defined priority.
  10447. * @hidden Internal Use Only
  10448. */
  10449. _reorderLightsInScene(): void;
  10450. /**
  10451. * Prepares the list of defines specific to the light type.
  10452. * @param defines the list of defines
  10453. * @param lightIndex defines the index of the light for the effect
  10454. */
  10455. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10456. }
  10457. }
  10458. declare module "babylonjs/Actions/action" {
  10459. import { Observable } from "babylonjs/Misc/observable";
  10460. import { Condition } from "babylonjs/Actions/condition";
  10461. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10462. import { ActionManager } from "babylonjs/Actions/actionManager";
  10463. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10464. /**
  10465. * Interface used to define Action
  10466. */
  10467. export interface IAction {
  10468. /**
  10469. * Trigger for the action
  10470. */
  10471. trigger: number;
  10472. /** Options of the trigger */
  10473. triggerOptions: any;
  10474. /**
  10475. * Gets the trigger parameters
  10476. * @returns the trigger parameters
  10477. */
  10478. getTriggerParameter(): any;
  10479. /**
  10480. * Internal only - executes current action event
  10481. * @hidden
  10482. */
  10483. _executeCurrent(evt?: ActionEvent): void;
  10484. /**
  10485. * Serialize placeholder for child classes
  10486. * @param parent of child
  10487. * @returns the serialized object
  10488. */
  10489. serialize(parent: any): any;
  10490. /**
  10491. * Internal only
  10492. * @hidden
  10493. */
  10494. _prepare(): void;
  10495. /**
  10496. * Internal only - manager for action
  10497. * @hidden
  10498. */
  10499. _actionManager: AbstractActionManager;
  10500. /**
  10501. * Adds action to chain of actions, may be a DoNothingAction
  10502. * @param action defines the next action to execute
  10503. * @returns The action passed in
  10504. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10505. */
  10506. then(action: IAction): IAction;
  10507. }
  10508. /**
  10509. * The action to be carried out following a trigger
  10510. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10511. */
  10512. export class Action implements IAction {
  10513. /** the trigger, with or without parameters, for the action */
  10514. triggerOptions: any;
  10515. /**
  10516. * Trigger for the action
  10517. */
  10518. trigger: number;
  10519. /**
  10520. * Internal only - manager for action
  10521. * @hidden
  10522. */
  10523. _actionManager: ActionManager;
  10524. private _nextActiveAction;
  10525. private _child;
  10526. private _condition?;
  10527. private _triggerParameter;
  10528. /**
  10529. * An event triggered prior to action being executed.
  10530. */
  10531. onBeforeExecuteObservable: Observable<Action>;
  10532. /**
  10533. * Creates a new Action
  10534. * @param triggerOptions the trigger, with or without parameters, for the action
  10535. * @param condition an optional determinant of action
  10536. */
  10537. constructor(
  10538. /** the trigger, with or without parameters, for the action */
  10539. triggerOptions: any, condition?: Condition);
  10540. /**
  10541. * Internal only
  10542. * @hidden
  10543. */
  10544. _prepare(): void;
  10545. /**
  10546. * Gets the trigger parameters
  10547. * @returns the trigger parameters
  10548. */
  10549. getTriggerParameter(): any;
  10550. /**
  10551. * Internal only - executes current action event
  10552. * @hidden
  10553. */
  10554. _executeCurrent(evt?: ActionEvent): void;
  10555. /**
  10556. * Execute placeholder for child classes
  10557. * @param evt optional action event
  10558. */
  10559. execute(evt?: ActionEvent): void;
  10560. /**
  10561. * Skips to next active action
  10562. */
  10563. skipToNextActiveAction(): void;
  10564. /**
  10565. * Adds action to chain of actions, may be a DoNothingAction
  10566. * @param action defines the next action to execute
  10567. * @returns The action passed in
  10568. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10569. */
  10570. then(action: Action): Action;
  10571. /**
  10572. * Internal only
  10573. * @hidden
  10574. */
  10575. _getProperty(propertyPath: string): string;
  10576. /**
  10577. * Internal only
  10578. * @hidden
  10579. */
  10580. _getEffectiveTarget(target: any, propertyPath: string): any;
  10581. /**
  10582. * Serialize placeholder for child classes
  10583. * @param parent of child
  10584. * @returns the serialized object
  10585. */
  10586. serialize(parent: any): any;
  10587. /**
  10588. * Internal only called by serialize
  10589. * @hidden
  10590. */
  10591. protected _serialize(serializedAction: any, parent?: any): any;
  10592. /**
  10593. * Internal only
  10594. * @hidden
  10595. */
  10596. static _SerializeValueAsString: (value: any) => string;
  10597. /**
  10598. * Internal only
  10599. * @hidden
  10600. */
  10601. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10602. name: string;
  10603. targetType: string;
  10604. value: string;
  10605. };
  10606. }
  10607. }
  10608. declare module "babylonjs/Actions/condition" {
  10609. import { ActionManager } from "babylonjs/Actions/actionManager";
  10610. /**
  10611. * A Condition applied to an Action
  10612. */
  10613. export class Condition {
  10614. /**
  10615. * Internal only - manager for action
  10616. * @hidden
  10617. */
  10618. _actionManager: ActionManager;
  10619. /**
  10620. * Internal only
  10621. * @hidden
  10622. */
  10623. _evaluationId: number;
  10624. /**
  10625. * Internal only
  10626. * @hidden
  10627. */
  10628. _currentResult: boolean;
  10629. /**
  10630. * Creates a new Condition
  10631. * @param actionManager the manager of the action the condition is applied to
  10632. */
  10633. constructor(actionManager: ActionManager);
  10634. /**
  10635. * Check if the current condition is valid
  10636. * @returns a boolean
  10637. */
  10638. isValid(): boolean;
  10639. /**
  10640. * Internal only
  10641. * @hidden
  10642. */
  10643. _getProperty(propertyPath: string): string;
  10644. /**
  10645. * Internal only
  10646. * @hidden
  10647. */
  10648. _getEffectiveTarget(target: any, propertyPath: string): any;
  10649. /**
  10650. * Serialize placeholder for child classes
  10651. * @returns the serialized object
  10652. */
  10653. serialize(): any;
  10654. /**
  10655. * Internal only
  10656. * @hidden
  10657. */
  10658. protected _serialize(serializedCondition: any): any;
  10659. }
  10660. /**
  10661. * Defines specific conditional operators as extensions of Condition
  10662. */
  10663. export class ValueCondition extends Condition {
  10664. /** path to specify the property of the target the conditional operator uses */
  10665. propertyPath: string;
  10666. /** the value compared by the conditional operator against the current value of the property */
  10667. value: any;
  10668. /** the conditional operator, default ValueCondition.IsEqual */
  10669. operator: number;
  10670. /**
  10671. * Internal only
  10672. * @hidden
  10673. */
  10674. private static _IsEqual;
  10675. /**
  10676. * Internal only
  10677. * @hidden
  10678. */
  10679. private static _IsDifferent;
  10680. /**
  10681. * Internal only
  10682. * @hidden
  10683. */
  10684. private static _IsGreater;
  10685. /**
  10686. * Internal only
  10687. * @hidden
  10688. */
  10689. private static _IsLesser;
  10690. /**
  10691. * returns the number for IsEqual
  10692. */
  10693. static get IsEqual(): number;
  10694. /**
  10695. * Returns the number for IsDifferent
  10696. */
  10697. static get IsDifferent(): number;
  10698. /**
  10699. * Returns the number for IsGreater
  10700. */
  10701. static get IsGreater(): number;
  10702. /**
  10703. * Returns the number for IsLesser
  10704. */
  10705. static get IsLesser(): number;
  10706. /**
  10707. * Internal only The action manager for the condition
  10708. * @hidden
  10709. */
  10710. _actionManager: ActionManager;
  10711. /**
  10712. * Internal only
  10713. * @hidden
  10714. */
  10715. private _target;
  10716. /**
  10717. * Internal only
  10718. * @hidden
  10719. */
  10720. private _effectiveTarget;
  10721. /**
  10722. * Internal only
  10723. * @hidden
  10724. */
  10725. private _property;
  10726. /**
  10727. * Creates a new ValueCondition
  10728. * @param actionManager manager for the action the condition applies to
  10729. * @param target for the action
  10730. * @param propertyPath path to specify the property of the target the conditional operator uses
  10731. * @param value the value compared by the conditional operator against the current value of the property
  10732. * @param operator the conditional operator, default ValueCondition.IsEqual
  10733. */
  10734. constructor(actionManager: ActionManager, target: any,
  10735. /** path to specify the property of the target the conditional operator uses */
  10736. propertyPath: string,
  10737. /** the value compared by the conditional operator against the current value of the property */
  10738. value: any,
  10739. /** the conditional operator, default ValueCondition.IsEqual */
  10740. operator?: number);
  10741. /**
  10742. * Compares the given value with the property value for the specified conditional operator
  10743. * @returns the result of the comparison
  10744. */
  10745. isValid(): boolean;
  10746. /**
  10747. * Serialize the ValueCondition into a JSON compatible object
  10748. * @returns serialization object
  10749. */
  10750. serialize(): any;
  10751. /**
  10752. * Gets the name of the conditional operator for the ValueCondition
  10753. * @param operator the conditional operator
  10754. * @returns the name
  10755. */
  10756. static GetOperatorName(operator: number): string;
  10757. }
  10758. /**
  10759. * Defines a predicate condition as an extension of Condition
  10760. */
  10761. export class PredicateCondition extends Condition {
  10762. /** defines the predicate function used to validate the condition */
  10763. predicate: () => boolean;
  10764. /**
  10765. * Internal only - manager for action
  10766. * @hidden
  10767. */
  10768. _actionManager: ActionManager;
  10769. /**
  10770. * Creates a new PredicateCondition
  10771. * @param actionManager manager for the action the condition applies to
  10772. * @param predicate defines the predicate function used to validate the condition
  10773. */
  10774. constructor(actionManager: ActionManager,
  10775. /** defines the predicate function used to validate the condition */
  10776. predicate: () => boolean);
  10777. /**
  10778. * @returns the validity of the predicate condition
  10779. */
  10780. isValid(): boolean;
  10781. }
  10782. /**
  10783. * Defines a state condition as an extension of Condition
  10784. */
  10785. export class StateCondition extends Condition {
  10786. /** Value to compare with target state */
  10787. value: string;
  10788. /**
  10789. * Internal only - manager for action
  10790. * @hidden
  10791. */
  10792. _actionManager: ActionManager;
  10793. /**
  10794. * Internal only
  10795. * @hidden
  10796. */
  10797. private _target;
  10798. /**
  10799. * Creates a new StateCondition
  10800. * @param actionManager manager for the action the condition applies to
  10801. * @param target of the condition
  10802. * @param value to compare with target state
  10803. */
  10804. constructor(actionManager: ActionManager, target: any,
  10805. /** Value to compare with target state */
  10806. value: string);
  10807. /**
  10808. * Gets a boolean indicating if the current condition is met
  10809. * @returns the validity of the state
  10810. */
  10811. isValid(): boolean;
  10812. /**
  10813. * Serialize the StateCondition into a JSON compatible object
  10814. * @returns serialization object
  10815. */
  10816. serialize(): any;
  10817. }
  10818. }
  10819. declare module "babylonjs/Actions/directActions" {
  10820. import { Action } from "babylonjs/Actions/action";
  10821. import { Condition } from "babylonjs/Actions/condition";
  10822. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10823. /**
  10824. * This defines an action responsible to toggle a boolean once triggered.
  10825. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10826. */
  10827. export class SwitchBooleanAction extends Action {
  10828. /**
  10829. * The path to the boolean property in the target object
  10830. */
  10831. propertyPath: string;
  10832. private _target;
  10833. private _effectiveTarget;
  10834. private _property;
  10835. /**
  10836. * Instantiate the action
  10837. * @param triggerOptions defines the trigger options
  10838. * @param target defines the object containing the boolean
  10839. * @param propertyPath defines the path to the boolean property in the target object
  10840. * @param condition defines the trigger related conditions
  10841. */
  10842. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10843. /** @hidden */
  10844. _prepare(): void;
  10845. /**
  10846. * Execute the action toggle the boolean value.
  10847. */
  10848. execute(): void;
  10849. /**
  10850. * Serializes the actions and its related information.
  10851. * @param parent defines the object to serialize in
  10852. * @returns the serialized object
  10853. */
  10854. serialize(parent: any): any;
  10855. }
  10856. /**
  10857. * This defines an action responsible to set a the state field of the target
  10858. * to a desired value once triggered.
  10859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10860. */
  10861. export class SetStateAction extends Action {
  10862. /**
  10863. * The value to store in the state field.
  10864. */
  10865. value: string;
  10866. private _target;
  10867. /**
  10868. * Instantiate the action
  10869. * @param triggerOptions defines the trigger options
  10870. * @param target defines the object containing the state property
  10871. * @param value defines the value to store in the state field
  10872. * @param condition defines the trigger related conditions
  10873. */
  10874. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10875. /**
  10876. * Execute the action and store the value on the target state property.
  10877. */
  10878. execute(): void;
  10879. /**
  10880. * Serializes the actions and its related information.
  10881. * @param parent defines the object to serialize in
  10882. * @returns the serialized object
  10883. */
  10884. serialize(parent: any): any;
  10885. }
  10886. /**
  10887. * This defines an action responsible to set a property of the target
  10888. * to a desired value once triggered.
  10889. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10890. */
  10891. export class SetValueAction extends Action {
  10892. /**
  10893. * The path of the property to set in the target.
  10894. */
  10895. propertyPath: string;
  10896. /**
  10897. * The value to set in the property
  10898. */
  10899. value: any;
  10900. private _target;
  10901. private _effectiveTarget;
  10902. private _property;
  10903. /**
  10904. * Instantiate the action
  10905. * @param triggerOptions defines the trigger options
  10906. * @param target defines the object containing the property
  10907. * @param propertyPath defines the path of the property to set in the target
  10908. * @param value defines the value to set in the property
  10909. * @param condition defines the trigger related conditions
  10910. */
  10911. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10912. /** @hidden */
  10913. _prepare(): void;
  10914. /**
  10915. * Execute the action and set the targetted property to the desired value.
  10916. */
  10917. execute(): void;
  10918. /**
  10919. * Serializes the actions and its related information.
  10920. * @param parent defines the object to serialize in
  10921. * @returns the serialized object
  10922. */
  10923. serialize(parent: any): any;
  10924. }
  10925. /**
  10926. * This defines an action responsible to increment the target value
  10927. * to a desired value once triggered.
  10928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10929. */
  10930. export class IncrementValueAction extends Action {
  10931. /**
  10932. * The path of the property to increment in the target.
  10933. */
  10934. propertyPath: string;
  10935. /**
  10936. * The value we should increment the property by.
  10937. */
  10938. value: any;
  10939. private _target;
  10940. private _effectiveTarget;
  10941. private _property;
  10942. /**
  10943. * Instantiate the action
  10944. * @param triggerOptions defines the trigger options
  10945. * @param target defines the object containing the property
  10946. * @param propertyPath defines the path of the property to increment in the target
  10947. * @param value defines the value value we should increment the property by
  10948. * @param condition defines the trigger related conditions
  10949. */
  10950. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10951. /** @hidden */
  10952. _prepare(): void;
  10953. /**
  10954. * Execute the action and increment the target of the value amount.
  10955. */
  10956. execute(): void;
  10957. /**
  10958. * Serializes the actions and its related information.
  10959. * @param parent defines the object to serialize in
  10960. * @returns the serialized object
  10961. */
  10962. serialize(parent: any): any;
  10963. }
  10964. /**
  10965. * This defines an action responsible to start an animation once triggered.
  10966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10967. */
  10968. export class PlayAnimationAction extends Action {
  10969. /**
  10970. * Where the animation should start (animation frame)
  10971. */
  10972. from: number;
  10973. /**
  10974. * Where the animation should stop (animation frame)
  10975. */
  10976. to: number;
  10977. /**
  10978. * Define if the animation should loop or stop after the first play.
  10979. */
  10980. loop?: boolean;
  10981. private _target;
  10982. /**
  10983. * Instantiate the action
  10984. * @param triggerOptions defines the trigger options
  10985. * @param target defines the target animation or animation name
  10986. * @param from defines from where the animation should start (animation frame)
  10987. * @param end defines where the animation should stop (animation frame)
  10988. * @param loop defines if the animation should loop or stop after the first play
  10989. * @param condition defines the trigger related conditions
  10990. */
  10991. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10992. /** @hidden */
  10993. _prepare(): void;
  10994. /**
  10995. * Execute the action and play the animation.
  10996. */
  10997. execute(): void;
  10998. /**
  10999. * Serializes the actions and its related information.
  11000. * @param parent defines the object to serialize in
  11001. * @returns the serialized object
  11002. */
  11003. serialize(parent: any): any;
  11004. }
  11005. /**
  11006. * This defines an action responsible to stop an animation once triggered.
  11007. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11008. */
  11009. export class StopAnimationAction extends Action {
  11010. private _target;
  11011. /**
  11012. * Instantiate the action
  11013. * @param triggerOptions defines the trigger options
  11014. * @param target defines the target animation or animation name
  11015. * @param condition defines the trigger related conditions
  11016. */
  11017. constructor(triggerOptions: any, target: any, condition?: Condition);
  11018. /** @hidden */
  11019. _prepare(): void;
  11020. /**
  11021. * Execute the action and stop the animation.
  11022. */
  11023. execute(): void;
  11024. /**
  11025. * Serializes the actions and its related information.
  11026. * @param parent defines the object to serialize in
  11027. * @returns the serialized object
  11028. */
  11029. serialize(parent: any): any;
  11030. }
  11031. /**
  11032. * This defines an action responsible that does nothing once triggered.
  11033. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11034. */
  11035. export class DoNothingAction extends Action {
  11036. /**
  11037. * Instantiate the action
  11038. * @param triggerOptions defines the trigger options
  11039. * @param condition defines the trigger related conditions
  11040. */
  11041. constructor(triggerOptions?: any, condition?: Condition);
  11042. /**
  11043. * Execute the action and do nothing.
  11044. */
  11045. execute(): void;
  11046. /**
  11047. * Serializes the actions and its related information.
  11048. * @param parent defines the object to serialize in
  11049. * @returns the serialized object
  11050. */
  11051. serialize(parent: any): any;
  11052. }
  11053. /**
  11054. * This defines an action responsible to trigger several actions once triggered.
  11055. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11056. */
  11057. export class CombineAction extends Action {
  11058. /**
  11059. * The list of aggregated animations to run.
  11060. */
  11061. children: Action[];
  11062. /**
  11063. * Instantiate the action
  11064. * @param triggerOptions defines the trigger options
  11065. * @param children defines the list of aggregated animations to run
  11066. * @param condition defines the trigger related conditions
  11067. */
  11068. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11069. /** @hidden */
  11070. _prepare(): void;
  11071. /**
  11072. * Execute the action and executes all the aggregated actions.
  11073. */
  11074. execute(evt: ActionEvent): void;
  11075. /**
  11076. * Serializes the actions and its related information.
  11077. * @param parent defines the object to serialize in
  11078. * @returns the serialized object
  11079. */
  11080. serialize(parent: any): any;
  11081. }
  11082. /**
  11083. * This defines an action responsible to run code (external event) once triggered.
  11084. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11085. */
  11086. export class ExecuteCodeAction extends Action {
  11087. /**
  11088. * The callback function to run.
  11089. */
  11090. func: (evt: ActionEvent) => void;
  11091. /**
  11092. * Instantiate the action
  11093. * @param triggerOptions defines the trigger options
  11094. * @param func defines the callback function to run
  11095. * @param condition defines the trigger related conditions
  11096. */
  11097. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11098. /**
  11099. * Execute the action and run the attached code.
  11100. */
  11101. execute(evt: ActionEvent): void;
  11102. }
  11103. /**
  11104. * This defines an action responsible to set the parent property of the target once triggered.
  11105. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11106. */
  11107. export class SetParentAction extends Action {
  11108. private _parent;
  11109. private _target;
  11110. /**
  11111. * Instantiate the action
  11112. * @param triggerOptions defines the trigger options
  11113. * @param target defines the target containing the parent property
  11114. * @param parent defines from where the animation should start (animation frame)
  11115. * @param condition defines the trigger related conditions
  11116. */
  11117. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11118. /** @hidden */
  11119. _prepare(): void;
  11120. /**
  11121. * Execute the action and set the parent property.
  11122. */
  11123. execute(): void;
  11124. /**
  11125. * Serializes the actions and its related information.
  11126. * @param parent defines the object to serialize in
  11127. * @returns the serialized object
  11128. */
  11129. serialize(parent: any): any;
  11130. }
  11131. }
  11132. declare module "babylonjs/Actions/actionManager" {
  11133. import { Nullable } from "babylonjs/types";
  11134. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11135. import { Scene } from "babylonjs/scene";
  11136. import { IAction } from "babylonjs/Actions/action";
  11137. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11138. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11139. /**
  11140. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11141. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11142. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11143. */
  11144. export class ActionManager extends AbstractActionManager {
  11145. /**
  11146. * Nothing
  11147. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11148. */
  11149. static readonly NothingTrigger: number;
  11150. /**
  11151. * On pick
  11152. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11153. */
  11154. static readonly OnPickTrigger: number;
  11155. /**
  11156. * On left pick
  11157. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11158. */
  11159. static readonly OnLeftPickTrigger: number;
  11160. /**
  11161. * On right pick
  11162. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11163. */
  11164. static readonly OnRightPickTrigger: number;
  11165. /**
  11166. * On center pick
  11167. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11168. */
  11169. static readonly OnCenterPickTrigger: number;
  11170. /**
  11171. * On pick down
  11172. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11173. */
  11174. static readonly OnPickDownTrigger: number;
  11175. /**
  11176. * On double pick
  11177. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11178. */
  11179. static readonly OnDoublePickTrigger: number;
  11180. /**
  11181. * On pick up
  11182. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11183. */
  11184. static readonly OnPickUpTrigger: number;
  11185. /**
  11186. * On pick out.
  11187. * This trigger will only be raised if you also declared a OnPickDown
  11188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11189. */
  11190. static readonly OnPickOutTrigger: number;
  11191. /**
  11192. * On long press
  11193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11194. */
  11195. static readonly OnLongPressTrigger: number;
  11196. /**
  11197. * On pointer over
  11198. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11199. */
  11200. static readonly OnPointerOverTrigger: number;
  11201. /**
  11202. * On pointer out
  11203. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11204. */
  11205. static readonly OnPointerOutTrigger: number;
  11206. /**
  11207. * On every frame
  11208. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11209. */
  11210. static readonly OnEveryFrameTrigger: number;
  11211. /**
  11212. * On intersection enter
  11213. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11214. */
  11215. static readonly OnIntersectionEnterTrigger: number;
  11216. /**
  11217. * On intersection exit
  11218. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11219. */
  11220. static readonly OnIntersectionExitTrigger: number;
  11221. /**
  11222. * On key down
  11223. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11224. */
  11225. static readonly OnKeyDownTrigger: number;
  11226. /**
  11227. * On key up
  11228. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11229. */
  11230. static readonly OnKeyUpTrigger: number;
  11231. private _scene;
  11232. /**
  11233. * Creates a new action manager
  11234. * @param scene defines the hosting scene
  11235. */
  11236. constructor(scene: Scene);
  11237. /**
  11238. * Releases all associated resources
  11239. */
  11240. dispose(): void;
  11241. /**
  11242. * Gets hosting scene
  11243. * @returns the hosting scene
  11244. */
  11245. getScene(): Scene;
  11246. /**
  11247. * Does this action manager handles actions of any of the given triggers
  11248. * @param triggers defines the triggers to be tested
  11249. * @return a boolean indicating whether one (or more) of the triggers is handled
  11250. */
  11251. hasSpecificTriggers(triggers: number[]): boolean;
  11252. /**
  11253. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11254. * speed.
  11255. * @param triggerA defines the trigger to be tested
  11256. * @param triggerB defines the trigger to be tested
  11257. * @return a boolean indicating whether one (or more) of the triggers is handled
  11258. */
  11259. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11260. /**
  11261. * Does this action manager handles actions of a given trigger
  11262. * @param trigger defines the trigger to be tested
  11263. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11264. * @return whether the trigger is handled
  11265. */
  11266. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11267. /**
  11268. * Does this action manager has pointer triggers
  11269. */
  11270. get hasPointerTriggers(): boolean;
  11271. /**
  11272. * Does this action manager has pick triggers
  11273. */
  11274. get hasPickTriggers(): boolean;
  11275. /**
  11276. * Registers an action to this action manager
  11277. * @param action defines the action to be registered
  11278. * @return the action amended (prepared) after registration
  11279. */
  11280. registerAction(action: IAction): Nullable<IAction>;
  11281. /**
  11282. * Unregisters an action to this action manager
  11283. * @param action defines the action to be unregistered
  11284. * @return a boolean indicating whether the action has been unregistered
  11285. */
  11286. unregisterAction(action: IAction): Boolean;
  11287. /**
  11288. * Process a specific trigger
  11289. * @param trigger defines the trigger to process
  11290. * @param evt defines the event details to be processed
  11291. */
  11292. processTrigger(trigger: number, evt?: IActionEvent): void;
  11293. /** @hidden */
  11294. _getEffectiveTarget(target: any, propertyPath: string): any;
  11295. /** @hidden */
  11296. _getProperty(propertyPath: string): string;
  11297. /**
  11298. * Serialize this manager to a JSON object
  11299. * @param name defines the property name to store this manager
  11300. * @returns a JSON representation of this manager
  11301. */
  11302. serialize(name: string): any;
  11303. /**
  11304. * Creates a new ActionManager from a JSON data
  11305. * @param parsedActions defines the JSON data to read from
  11306. * @param object defines the hosting mesh
  11307. * @param scene defines the hosting scene
  11308. */
  11309. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11310. /**
  11311. * Get a trigger name by index
  11312. * @param trigger defines the trigger index
  11313. * @returns a trigger name
  11314. */
  11315. static GetTriggerName(trigger: number): string;
  11316. }
  11317. }
  11318. declare module "babylonjs/Culling/ray" {
  11319. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11320. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11322. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11323. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11324. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11325. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11326. import { Plane } from "babylonjs/Maths/math.plane";
  11327. /**
  11328. * Class representing a ray with position and direction
  11329. */
  11330. export class Ray {
  11331. /** origin point */
  11332. origin: Vector3;
  11333. /** direction */
  11334. direction: Vector3;
  11335. /** length of the ray */
  11336. length: number;
  11337. private static readonly TmpVector3;
  11338. private _tmpRay;
  11339. /**
  11340. * Creates a new ray
  11341. * @param origin origin point
  11342. * @param direction direction
  11343. * @param length length of the ray
  11344. */
  11345. constructor(
  11346. /** origin point */
  11347. origin: Vector3,
  11348. /** direction */
  11349. direction: Vector3,
  11350. /** length of the ray */
  11351. length?: number);
  11352. /**
  11353. * Checks if the ray intersects a box
  11354. * @param minimum bound of the box
  11355. * @param maximum bound of the box
  11356. * @param intersectionTreshold extra extend to be added to the box in all direction
  11357. * @returns if the box was hit
  11358. */
  11359. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11360. /**
  11361. * Checks if the ray intersects a box
  11362. * @param box the bounding box to check
  11363. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11364. * @returns if the box was hit
  11365. */
  11366. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11367. /**
  11368. * If the ray hits a sphere
  11369. * @param sphere the bounding sphere to check
  11370. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11371. * @returns true if it hits the sphere
  11372. */
  11373. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11374. /**
  11375. * If the ray hits a triange
  11376. * @param vertex0 triangle vertex
  11377. * @param vertex1 triangle vertex
  11378. * @param vertex2 triangle vertex
  11379. * @returns intersection information if hit
  11380. */
  11381. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11382. /**
  11383. * Checks if ray intersects a plane
  11384. * @param plane the plane to check
  11385. * @returns the distance away it was hit
  11386. */
  11387. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11388. /**
  11389. * Calculate the intercept of a ray on a given axis
  11390. * @param axis to check 'x' | 'y' | 'z'
  11391. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11392. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11393. */
  11394. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11395. /**
  11396. * Checks if ray intersects a mesh
  11397. * @param mesh the mesh to check
  11398. * @param fastCheck if only the bounding box should checked
  11399. * @returns picking info of the intersecton
  11400. */
  11401. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11402. /**
  11403. * Checks if ray intersects a mesh
  11404. * @param meshes the meshes to check
  11405. * @param fastCheck if only the bounding box should checked
  11406. * @param results array to store result in
  11407. * @returns Array of picking infos
  11408. */
  11409. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11410. private _comparePickingInfo;
  11411. private static smallnum;
  11412. private static rayl;
  11413. /**
  11414. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11415. * @param sega the first point of the segment to test the intersection against
  11416. * @param segb the second point of the segment to test the intersection against
  11417. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11418. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11419. */
  11420. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11421. /**
  11422. * Update the ray from viewport position
  11423. * @param x position
  11424. * @param y y position
  11425. * @param viewportWidth viewport width
  11426. * @param viewportHeight viewport height
  11427. * @param world world matrix
  11428. * @param view view matrix
  11429. * @param projection projection matrix
  11430. * @returns this ray updated
  11431. */
  11432. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11433. /**
  11434. * Creates a ray with origin and direction of 0,0,0
  11435. * @returns the new ray
  11436. */
  11437. static Zero(): Ray;
  11438. /**
  11439. * Creates a new ray from screen space and viewport
  11440. * @param x position
  11441. * @param y y position
  11442. * @param viewportWidth viewport width
  11443. * @param viewportHeight viewport height
  11444. * @param world world matrix
  11445. * @param view view matrix
  11446. * @param projection projection matrix
  11447. * @returns new ray
  11448. */
  11449. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11450. /**
  11451. * 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
  11452. * transformed to the given world matrix.
  11453. * @param origin The origin point
  11454. * @param end The end point
  11455. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11456. * @returns the new ray
  11457. */
  11458. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11459. /**
  11460. * Transforms a ray by a matrix
  11461. * @param ray ray to transform
  11462. * @param matrix matrix to apply
  11463. * @returns the resulting new ray
  11464. */
  11465. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11466. /**
  11467. * Transforms a ray by a matrix
  11468. * @param ray ray to transform
  11469. * @param matrix matrix to apply
  11470. * @param result ray to store result in
  11471. */
  11472. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11473. /**
  11474. * Unproject a ray from screen space to object space
  11475. * @param sourceX defines the screen space x coordinate to use
  11476. * @param sourceY defines the screen space y coordinate to use
  11477. * @param viewportWidth defines the current width of the viewport
  11478. * @param viewportHeight defines the current height of the viewport
  11479. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11480. * @param view defines the view matrix to use
  11481. * @param projection defines the projection matrix to use
  11482. */
  11483. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11484. }
  11485. /**
  11486. * Type used to define predicate used to select faces when a mesh intersection is detected
  11487. */
  11488. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11489. module "babylonjs/scene" {
  11490. interface Scene {
  11491. /** @hidden */
  11492. _tempPickingRay: Nullable<Ray>;
  11493. /** @hidden */
  11494. _cachedRayForTransform: Ray;
  11495. /** @hidden */
  11496. _pickWithRayInverseMatrix: Matrix;
  11497. /** @hidden */
  11498. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11499. /** @hidden */
  11500. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11501. }
  11502. }
  11503. }
  11504. declare module "babylonjs/sceneComponent" {
  11505. import { Scene } from "babylonjs/scene";
  11506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11507. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11508. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11509. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11510. import { Nullable } from "babylonjs/types";
  11511. import { Camera } from "babylonjs/Cameras/camera";
  11512. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11513. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11514. import { AbstractScene } from "babylonjs/abstractScene";
  11515. import { Mesh } from "babylonjs/Meshes/mesh";
  11516. /**
  11517. * Groups all the scene component constants in one place to ease maintenance.
  11518. * @hidden
  11519. */
  11520. export class SceneComponentConstants {
  11521. static readonly NAME_EFFECTLAYER: string;
  11522. static readonly NAME_LAYER: string;
  11523. static readonly NAME_LENSFLARESYSTEM: string;
  11524. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11525. static readonly NAME_PARTICLESYSTEM: string;
  11526. static readonly NAME_GAMEPAD: string;
  11527. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11528. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11529. static readonly NAME_DEPTHRENDERER: string;
  11530. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11531. static readonly NAME_SPRITE: string;
  11532. static readonly NAME_OUTLINERENDERER: string;
  11533. static readonly NAME_PROCEDURALTEXTURE: string;
  11534. static readonly NAME_SHADOWGENERATOR: string;
  11535. static readonly NAME_OCTREE: string;
  11536. static readonly NAME_PHYSICSENGINE: string;
  11537. static readonly NAME_AUDIO: string;
  11538. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11539. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11540. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11541. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11542. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11543. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11544. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11545. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11546. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11547. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11548. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11549. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11550. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11551. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11552. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11553. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11554. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11555. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11556. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11557. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11558. static readonly STEP_AFTERRENDER_AUDIO: number;
  11559. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11560. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11561. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11562. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11563. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11564. static readonly STEP_POINTERMOVE_SPRITE: number;
  11565. static readonly STEP_POINTERDOWN_SPRITE: number;
  11566. static readonly STEP_POINTERUP_SPRITE: number;
  11567. }
  11568. /**
  11569. * This represents a scene component.
  11570. *
  11571. * This is used to decouple the dependency the scene is having on the different workloads like
  11572. * layers, post processes...
  11573. */
  11574. export interface ISceneComponent {
  11575. /**
  11576. * The name of the component. Each component must have a unique name.
  11577. */
  11578. name: string;
  11579. /**
  11580. * The scene the component belongs to.
  11581. */
  11582. scene: Scene;
  11583. /**
  11584. * Register the component to one instance of a scene.
  11585. */
  11586. register(): void;
  11587. /**
  11588. * Rebuilds the elements related to this component in case of
  11589. * context lost for instance.
  11590. */
  11591. rebuild(): void;
  11592. /**
  11593. * Disposes the component and the associated ressources.
  11594. */
  11595. dispose(): void;
  11596. }
  11597. /**
  11598. * This represents a SERIALIZABLE scene component.
  11599. *
  11600. * This extends Scene Component to add Serialization methods on top.
  11601. */
  11602. export interface ISceneSerializableComponent extends ISceneComponent {
  11603. /**
  11604. * Adds all the elements from the container to the scene
  11605. * @param container the container holding the elements
  11606. */
  11607. addFromContainer(container: AbstractScene): void;
  11608. /**
  11609. * Removes all the elements in the container from the scene
  11610. * @param container contains the elements to remove
  11611. * @param dispose if the removed element should be disposed (default: false)
  11612. */
  11613. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11614. /**
  11615. * Serializes the component data to the specified json object
  11616. * @param serializationObject The object to serialize to
  11617. */
  11618. serialize(serializationObject: any): void;
  11619. }
  11620. /**
  11621. * Strong typing of a Mesh related stage step action
  11622. */
  11623. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11624. /**
  11625. * Strong typing of a Evaluate Sub Mesh related stage step action
  11626. */
  11627. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11628. /**
  11629. * Strong typing of a Active Mesh related stage step action
  11630. */
  11631. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11632. /**
  11633. * Strong typing of a Camera related stage step action
  11634. */
  11635. export type CameraStageAction = (camera: Camera) => void;
  11636. /**
  11637. * Strong typing of a Camera Frame buffer related stage step action
  11638. */
  11639. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11640. /**
  11641. * Strong typing of a Render Target related stage step action
  11642. */
  11643. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11644. /**
  11645. * Strong typing of a RenderingGroup related stage step action
  11646. */
  11647. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11648. /**
  11649. * Strong typing of a Mesh Render related stage step action
  11650. */
  11651. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11652. /**
  11653. * Strong typing of a simple stage step action
  11654. */
  11655. export type SimpleStageAction = () => void;
  11656. /**
  11657. * Strong typing of a render target action.
  11658. */
  11659. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11660. /**
  11661. * Strong typing of a pointer move action.
  11662. */
  11663. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11664. /**
  11665. * Strong typing of a pointer up/down action.
  11666. */
  11667. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11668. /**
  11669. * Representation of a stage in the scene (Basically a list of ordered steps)
  11670. * @hidden
  11671. */
  11672. export class Stage<T extends Function> extends Array<{
  11673. index: number;
  11674. component: ISceneComponent;
  11675. action: T;
  11676. }> {
  11677. /**
  11678. * Hide ctor from the rest of the world.
  11679. * @param items The items to add.
  11680. */
  11681. private constructor();
  11682. /**
  11683. * Creates a new Stage.
  11684. * @returns A new instance of a Stage
  11685. */
  11686. static Create<T extends Function>(): Stage<T>;
  11687. /**
  11688. * Registers a step in an ordered way in the targeted stage.
  11689. * @param index Defines the position to register the step in
  11690. * @param component Defines the component attached to the step
  11691. * @param action Defines the action to launch during the step
  11692. */
  11693. registerStep(index: number, component: ISceneComponent, action: T): void;
  11694. /**
  11695. * Clears all the steps from the stage.
  11696. */
  11697. clear(): void;
  11698. }
  11699. }
  11700. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11701. import { Nullable } from "babylonjs/types";
  11702. import { Observable } from "babylonjs/Misc/observable";
  11703. import { Scene } from "babylonjs/scene";
  11704. import { Sprite } from "babylonjs/Sprites/sprite";
  11705. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11706. import { Ray } from "babylonjs/Culling/ray";
  11707. import { Camera } from "babylonjs/Cameras/camera";
  11708. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11709. import { ISceneComponent } from "babylonjs/sceneComponent";
  11710. module "babylonjs/scene" {
  11711. interface Scene {
  11712. /** @hidden */
  11713. _pointerOverSprite: Nullable<Sprite>;
  11714. /** @hidden */
  11715. _pickedDownSprite: Nullable<Sprite>;
  11716. /** @hidden */
  11717. _tempSpritePickingRay: Nullable<Ray>;
  11718. /**
  11719. * All of the sprite managers added to this scene
  11720. * @see http://doc.babylonjs.com/babylon101/sprites
  11721. */
  11722. spriteManagers: Array<ISpriteManager>;
  11723. /**
  11724. * An event triggered when sprites rendering is about to start
  11725. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11726. */
  11727. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11728. /**
  11729. * An event triggered when sprites rendering is done
  11730. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11731. */
  11732. onAfterSpritesRenderingObservable: Observable<Scene>;
  11733. /** @hidden */
  11734. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11735. /** Launch a ray to try to pick a sprite in the scene
  11736. * @param x position on screen
  11737. * @param y position on screen
  11738. * @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
  11739. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11740. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11741. * @returns a PickingInfo
  11742. */
  11743. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11744. /** Use the given ray to pick a sprite in the scene
  11745. * @param ray The ray (in world space) to use to pick meshes
  11746. * @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
  11747. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11748. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11749. * @returns a PickingInfo
  11750. */
  11751. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11752. /** @hidden */
  11753. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11754. /** Launch a ray to try to pick sprites in the scene
  11755. * @param x position on screen
  11756. * @param y position on screen
  11757. * @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
  11758. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11759. * @returns a PickingInfo array
  11760. */
  11761. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11762. /** Use the given ray to pick sprites in the scene
  11763. * @param ray The ray (in world space) to use to pick meshes
  11764. * @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
  11765. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11766. * @returns a PickingInfo array
  11767. */
  11768. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11769. /**
  11770. * Force the sprite under the pointer
  11771. * @param sprite defines the sprite to use
  11772. */
  11773. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11774. /**
  11775. * Gets the sprite under the pointer
  11776. * @returns a Sprite or null if no sprite is under the pointer
  11777. */
  11778. getPointerOverSprite(): Nullable<Sprite>;
  11779. }
  11780. }
  11781. /**
  11782. * Defines the sprite scene component responsible to manage sprites
  11783. * in a given scene.
  11784. */
  11785. export class SpriteSceneComponent implements ISceneComponent {
  11786. /**
  11787. * The component name helpfull to identify the component in the list of scene components.
  11788. */
  11789. readonly name: string;
  11790. /**
  11791. * The scene the component belongs to.
  11792. */
  11793. scene: Scene;
  11794. /** @hidden */
  11795. private _spritePredicate;
  11796. /**
  11797. * Creates a new instance of the component for the given scene
  11798. * @param scene Defines the scene to register the component in
  11799. */
  11800. constructor(scene: Scene);
  11801. /**
  11802. * Registers the component in a given scene
  11803. */
  11804. register(): void;
  11805. /**
  11806. * Rebuilds the elements related to this component in case of
  11807. * context lost for instance.
  11808. */
  11809. rebuild(): void;
  11810. /**
  11811. * Disposes the component and the associated ressources.
  11812. */
  11813. dispose(): void;
  11814. private _pickSpriteButKeepRay;
  11815. private _pointerMove;
  11816. private _pointerDown;
  11817. private _pointerUp;
  11818. }
  11819. }
  11820. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11821. /** @hidden */
  11822. export var fogFragmentDeclaration: {
  11823. name: string;
  11824. shader: string;
  11825. };
  11826. }
  11827. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11828. /** @hidden */
  11829. export var fogFragment: {
  11830. name: string;
  11831. shader: string;
  11832. };
  11833. }
  11834. declare module "babylonjs/Shaders/sprites.fragment" {
  11835. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11836. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11837. /** @hidden */
  11838. export var spritesPixelShader: {
  11839. name: string;
  11840. shader: string;
  11841. };
  11842. }
  11843. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11844. /** @hidden */
  11845. export var fogVertexDeclaration: {
  11846. name: string;
  11847. shader: string;
  11848. };
  11849. }
  11850. declare module "babylonjs/Shaders/sprites.vertex" {
  11851. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11852. /** @hidden */
  11853. export var spritesVertexShader: {
  11854. name: string;
  11855. shader: string;
  11856. };
  11857. }
  11858. declare module "babylonjs/Sprites/spriteManager" {
  11859. import { IDisposable, Scene } from "babylonjs/scene";
  11860. import { Nullable } from "babylonjs/types";
  11861. import { Observable } from "babylonjs/Misc/observable";
  11862. import { Sprite } from "babylonjs/Sprites/sprite";
  11863. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11864. import { Camera } from "babylonjs/Cameras/camera";
  11865. import { Texture } from "babylonjs/Materials/Textures/texture";
  11866. import "babylonjs/Shaders/sprites.fragment";
  11867. import "babylonjs/Shaders/sprites.vertex";
  11868. import { Ray } from "babylonjs/Culling/ray";
  11869. /**
  11870. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11871. */
  11872. export interface ISpriteManager extends IDisposable {
  11873. /**
  11874. * Restricts the camera to viewing objects with the same layerMask.
  11875. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11876. */
  11877. layerMask: number;
  11878. /**
  11879. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11880. */
  11881. isPickable: boolean;
  11882. /**
  11883. * Specifies the rendering group id for this mesh (0 by default)
  11884. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11885. */
  11886. renderingGroupId: number;
  11887. /**
  11888. * Defines the list of sprites managed by the manager.
  11889. */
  11890. sprites: Array<Sprite>;
  11891. /**
  11892. * Tests the intersection of a sprite with a specific ray.
  11893. * @param ray The ray we are sending to test the collision
  11894. * @param camera The camera space we are sending rays in
  11895. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11896. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11897. * @returns picking info or null.
  11898. */
  11899. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11900. /**
  11901. * Intersects the sprites with a ray
  11902. * @param ray defines the ray to intersect with
  11903. * @param camera defines the current active camera
  11904. * @param predicate defines a predicate used to select candidate sprites
  11905. * @returns null if no hit or a PickingInfo array
  11906. */
  11907. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11908. /**
  11909. * Renders the list of sprites on screen.
  11910. */
  11911. render(): void;
  11912. }
  11913. /**
  11914. * Class used to manage multiple sprites on the same spritesheet
  11915. * @see http://doc.babylonjs.com/babylon101/sprites
  11916. */
  11917. export class SpriteManager implements ISpriteManager {
  11918. /** defines the manager's name */
  11919. name: string;
  11920. /** Gets the list of sprites */
  11921. sprites: Sprite[];
  11922. /** Gets or sets the rendering group id (0 by default) */
  11923. renderingGroupId: number;
  11924. /** Gets or sets camera layer mask */
  11925. layerMask: number;
  11926. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11927. fogEnabled: boolean;
  11928. /** Gets or sets a boolean indicating if the sprites are pickable */
  11929. isPickable: boolean;
  11930. /** Defines the default width of a cell in the spritesheet */
  11931. cellWidth: number;
  11932. /** Defines the default height of a cell in the spritesheet */
  11933. cellHeight: number;
  11934. /** Associative array from JSON sprite data file */
  11935. private _cellData;
  11936. /** Array of sprite names from JSON sprite data file */
  11937. private _spriteMap;
  11938. /** True when packed cell data from JSON file is ready*/
  11939. private _packedAndReady;
  11940. /**
  11941. * An event triggered when the manager is disposed.
  11942. */
  11943. onDisposeObservable: Observable<SpriteManager>;
  11944. private _onDisposeObserver;
  11945. /**
  11946. * Callback called when the manager is disposed
  11947. */
  11948. set onDispose(callback: () => void);
  11949. private _capacity;
  11950. private _fromPacked;
  11951. private _spriteTexture;
  11952. private _epsilon;
  11953. private _scene;
  11954. private _vertexData;
  11955. private _buffer;
  11956. private _vertexBuffers;
  11957. private _indexBuffer;
  11958. private _effectBase;
  11959. private _effectFog;
  11960. /**
  11961. * Gets or sets the spritesheet texture
  11962. */
  11963. get texture(): Texture;
  11964. set texture(value: Texture);
  11965. /**
  11966. * Creates a new sprite manager
  11967. * @param name defines the manager's name
  11968. * @param imgUrl defines the sprite sheet url
  11969. * @param capacity defines the maximum allowed number of sprites
  11970. * @param cellSize defines the size of a sprite cell
  11971. * @param scene defines the hosting scene
  11972. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11973. * @param samplingMode defines the smapling mode to use with spritesheet
  11974. * @param fromPacked set to false; do not alter
  11975. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11976. */
  11977. constructor(
  11978. /** defines the manager's name */
  11979. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11980. private _makePacked;
  11981. private _appendSpriteVertex;
  11982. /**
  11983. * Intersects the sprites with a ray
  11984. * @param ray defines the ray to intersect with
  11985. * @param camera defines the current active camera
  11986. * @param predicate defines a predicate used to select candidate sprites
  11987. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11988. * @returns null if no hit or a PickingInfo
  11989. */
  11990. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11991. /**
  11992. * Intersects the sprites with a ray
  11993. * @param ray defines the ray to intersect with
  11994. * @param camera defines the current active camera
  11995. * @param predicate defines a predicate used to select candidate sprites
  11996. * @returns null if no hit or a PickingInfo array
  11997. */
  11998. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11999. /**
  12000. * Render all child sprites
  12001. */
  12002. render(): void;
  12003. /**
  12004. * Release associated resources
  12005. */
  12006. dispose(): void;
  12007. }
  12008. }
  12009. declare module "babylonjs/Sprites/sprite" {
  12010. import { Vector3 } from "babylonjs/Maths/math.vector";
  12011. import { Nullable } from "babylonjs/types";
  12012. import { ActionManager } from "babylonjs/Actions/actionManager";
  12013. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12014. import { Color4 } from "babylonjs/Maths/math.color";
  12015. /**
  12016. * Class used to represent a sprite
  12017. * @see http://doc.babylonjs.com/babylon101/sprites
  12018. */
  12019. export class Sprite {
  12020. /** defines the name */
  12021. name: string;
  12022. /** Gets or sets the current world position */
  12023. position: Vector3;
  12024. /** Gets or sets the main color */
  12025. color: Color4;
  12026. /** Gets or sets the width */
  12027. width: number;
  12028. /** Gets or sets the height */
  12029. height: number;
  12030. /** Gets or sets rotation angle */
  12031. angle: number;
  12032. /** Gets or sets the cell index in the sprite sheet */
  12033. cellIndex: number;
  12034. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  12035. cellRef: string;
  12036. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12037. invertU: number;
  12038. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12039. invertV: number;
  12040. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12041. disposeWhenFinishedAnimating: boolean;
  12042. /** Gets the list of attached animations */
  12043. animations: Animation[];
  12044. /** Gets or sets a boolean indicating if the sprite can be picked */
  12045. isPickable: boolean;
  12046. /**
  12047. * Gets or sets the associated action manager
  12048. */
  12049. actionManager: Nullable<ActionManager>;
  12050. private _animationStarted;
  12051. private _loopAnimation;
  12052. private _fromIndex;
  12053. private _toIndex;
  12054. private _delay;
  12055. private _direction;
  12056. private _manager;
  12057. private _time;
  12058. private _onAnimationEnd;
  12059. /**
  12060. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12061. */
  12062. isVisible: boolean;
  12063. /**
  12064. * Gets or sets the sprite size
  12065. */
  12066. get size(): number;
  12067. set size(value: number);
  12068. /**
  12069. * Creates a new Sprite
  12070. * @param name defines the name
  12071. * @param manager defines the manager
  12072. */
  12073. constructor(
  12074. /** defines the name */
  12075. name: string, manager: ISpriteManager);
  12076. /**
  12077. * Starts an animation
  12078. * @param from defines the initial key
  12079. * @param to defines the end key
  12080. * @param loop defines if the animation must loop
  12081. * @param delay defines the start delay (in ms)
  12082. * @param onAnimationEnd defines a callback to call when animation ends
  12083. */
  12084. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12085. /** Stops current animation (if any) */
  12086. stopAnimation(): void;
  12087. /** @hidden */
  12088. _animate(deltaTime: number): void;
  12089. /** Release associated resources */
  12090. dispose(): void;
  12091. }
  12092. }
  12093. declare module "babylonjs/Collisions/pickingInfo" {
  12094. import { Nullable } from "babylonjs/types";
  12095. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12097. import { Sprite } from "babylonjs/Sprites/sprite";
  12098. import { Ray } from "babylonjs/Culling/ray";
  12099. /**
  12100. * Information about the result of picking within a scene
  12101. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12102. */
  12103. export class PickingInfo {
  12104. /** @hidden */
  12105. _pickingUnavailable: boolean;
  12106. /**
  12107. * If the pick collided with an object
  12108. */
  12109. hit: boolean;
  12110. /**
  12111. * Distance away where the pick collided
  12112. */
  12113. distance: number;
  12114. /**
  12115. * The location of pick collision
  12116. */
  12117. pickedPoint: Nullable<Vector3>;
  12118. /**
  12119. * The mesh corresponding the the pick collision
  12120. */
  12121. pickedMesh: Nullable<AbstractMesh>;
  12122. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  12123. bu: number;
  12124. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  12125. bv: number;
  12126. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12127. faceId: number;
  12128. /** Id of the the submesh that was picked */
  12129. subMeshId: number;
  12130. /** If a sprite was picked, this will be the sprite the pick collided with */
  12131. pickedSprite: Nullable<Sprite>;
  12132. /**
  12133. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12134. */
  12135. originMesh: Nullable<AbstractMesh>;
  12136. /**
  12137. * The ray that was used to perform the picking.
  12138. */
  12139. ray: Nullable<Ray>;
  12140. /**
  12141. * Gets the normal correspodning to the face the pick collided with
  12142. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12143. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12144. * @returns The normal correspodning to the face the pick collided with
  12145. */
  12146. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12147. /**
  12148. * Gets the texture coordinates of where the pick occured
  12149. * @returns the vector containing the coordnates of the texture
  12150. */
  12151. getTextureCoordinates(): Nullable<Vector2>;
  12152. }
  12153. }
  12154. declare module "babylonjs/Events/pointerEvents" {
  12155. import { Nullable } from "babylonjs/types";
  12156. import { Vector2 } from "babylonjs/Maths/math.vector";
  12157. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12158. import { Ray } from "babylonjs/Culling/ray";
  12159. /**
  12160. * Gather the list of pointer event types as constants.
  12161. */
  12162. export class PointerEventTypes {
  12163. /**
  12164. * 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.
  12165. */
  12166. static readonly POINTERDOWN: number;
  12167. /**
  12168. * The pointerup event is fired when a pointer is no longer active.
  12169. */
  12170. static readonly POINTERUP: number;
  12171. /**
  12172. * The pointermove event is fired when a pointer changes coordinates.
  12173. */
  12174. static readonly POINTERMOVE: number;
  12175. /**
  12176. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12177. */
  12178. static readonly POINTERWHEEL: number;
  12179. /**
  12180. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12181. */
  12182. static readonly POINTERPICK: number;
  12183. /**
  12184. * The pointertap event is fired when a the object has been touched and released without drag.
  12185. */
  12186. static readonly POINTERTAP: number;
  12187. /**
  12188. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12189. */
  12190. static readonly POINTERDOUBLETAP: number;
  12191. }
  12192. /**
  12193. * Base class of pointer info types.
  12194. */
  12195. export class PointerInfoBase {
  12196. /**
  12197. * Defines the type of event (PointerEventTypes)
  12198. */
  12199. type: number;
  12200. /**
  12201. * Defines the related dom event
  12202. */
  12203. event: PointerEvent | MouseWheelEvent;
  12204. /**
  12205. * Instantiates the base class of pointers info.
  12206. * @param type Defines the type of event (PointerEventTypes)
  12207. * @param event Defines the related dom event
  12208. */
  12209. constructor(
  12210. /**
  12211. * Defines the type of event (PointerEventTypes)
  12212. */
  12213. type: number,
  12214. /**
  12215. * Defines the related dom event
  12216. */
  12217. event: PointerEvent | MouseWheelEvent);
  12218. }
  12219. /**
  12220. * This class is used to store pointer related info for the onPrePointerObservable event.
  12221. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12222. */
  12223. export class PointerInfoPre extends PointerInfoBase {
  12224. /**
  12225. * Ray from a pointer if availible (eg. 6dof controller)
  12226. */
  12227. ray: Nullable<Ray>;
  12228. /**
  12229. * Defines the local position of the pointer on the canvas.
  12230. */
  12231. localPosition: Vector2;
  12232. /**
  12233. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12234. */
  12235. skipOnPointerObservable: boolean;
  12236. /**
  12237. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12238. * @param type Defines the type of event (PointerEventTypes)
  12239. * @param event Defines the related dom event
  12240. * @param localX Defines the local x coordinates of the pointer when the event occured
  12241. * @param localY Defines the local y coordinates of the pointer when the event occured
  12242. */
  12243. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12244. }
  12245. /**
  12246. * This type contains all the data related to a pointer event in Babylon.js.
  12247. * 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.
  12248. */
  12249. export class PointerInfo extends PointerInfoBase {
  12250. /**
  12251. * Defines the picking info associated to the info (if any)\
  12252. */
  12253. pickInfo: Nullable<PickingInfo>;
  12254. /**
  12255. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12256. * @param type Defines the type of event (PointerEventTypes)
  12257. * @param event Defines the related dom event
  12258. * @param pickInfo Defines the picking info associated to the info (if any)\
  12259. */
  12260. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12261. /**
  12262. * Defines the picking info associated to the info (if any)\
  12263. */
  12264. pickInfo: Nullable<PickingInfo>);
  12265. }
  12266. /**
  12267. * Data relating to a touch event on the screen.
  12268. */
  12269. export interface PointerTouch {
  12270. /**
  12271. * X coordinate of touch.
  12272. */
  12273. x: number;
  12274. /**
  12275. * Y coordinate of touch.
  12276. */
  12277. y: number;
  12278. /**
  12279. * Id of touch. Unique for each finger.
  12280. */
  12281. pointerId: number;
  12282. /**
  12283. * Event type passed from DOM.
  12284. */
  12285. type: any;
  12286. }
  12287. }
  12288. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12289. import { Observable } from "babylonjs/Misc/observable";
  12290. import { Nullable } from "babylonjs/types";
  12291. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12292. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12293. /**
  12294. * Manage the mouse inputs to control the movement of a free camera.
  12295. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12296. */
  12297. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12298. /**
  12299. * Define if touch is enabled in the mouse input
  12300. */
  12301. touchEnabled: boolean;
  12302. /**
  12303. * Defines the camera the input is attached to.
  12304. */
  12305. camera: FreeCamera;
  12306. /**
  12307. * Defines the buttons associated with the input to handle camera move.
  12308. */
  12309. buttons: number[];
  12310. /**
  12311. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12312. */
  12313. angularSensibility: number;
  12314. private _pointerInput;
  12315. private _onMouseMove;
  12316. private _observer;
  12317. private previousPosition;
  12318. /**
  12319. * Observable for when a pointer move event occurs containing the move offset
  12320. */
  12321. onPointerMovedObservable: Observable<{
  12322. offsetX: number;
  12323. offsetY: number;
  12324. }>;
  12325. /**
  12326. * @hidden
  12327. * If the camera should be rotated automatically based on pointer movement
  12328. */
  12329. _allowCameraRotation: boolean;
  12330. /**
  12331. * Manage the mouse inputs to control the movement of a free camera.
  12332. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12333. * @param touchEnabled Defines if touch is enabled or not
  12334. */
  12335. constructor(
  12336. /**
  12337. * Define if touch is enabled in the mouse input
  12338. */
  12339. touchEnabled?: boolean);
  12340. /**
  12341. * Attach the input controls to a specific dom element to get the input from.
  12342. * @param element Defines the element the controls should be listened from
  12343. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12344. */
  12345. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12346. /**
  12347. * Called on JS contextmenu event.
  12348. * Override this method to provide functionality.
  12349. */
  12350. protected onContextMenu(evt: PointerEvent): void;
  12351. /**
  12352. * Detach the current controls from the specified dom element.
  12353. * @param element Defines the element to stop listening the inputs from
  12354. */
  12355. detachControl(element: Nullable<HTMLElement>): void;
  12356. /**
  12357. * Gets the class name of the current intput.
  12358. * @returns the class name
  12359. */
  12360. getClassName(): string;
  12361. /**
  12362. * Get the friendly name associated with the input class.
  12363. * @returns the input friendly name
  12364. */
  12365. getSimpleName(): string;
  12366. }
  12367. }
  12368. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12369. import { Nullable } from "babylonjs/types";
  12370. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12371. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12372. /**
  12373. * Manage the touch inputs to control the movement of a free camera.
  12374. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12375. */
  12376. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12377. /**
  12378. * Defines the camera the input is attached to.
  12379. */
  12380. camera: FreeCamera;
  12381. /**
  12382. * Defines the touch sensibility for rotation.
  12383. * The higher the faster.
  12384. */
  12385. touchAngularSensibility: number;
  12386. /**
  12387. * Defines the touch sensibility for move.
  12388. * The higher the faster.
  12389. */
  12390. touchMoveSensibility: number;
  12391. private _offsetX;
  12392. private _offsetY;
  12393. private _pointerPressed;
  12394. private _pointerInput;
  12395. private _observer;
  12396. private _onLostFocus;
  12397. /**
  12398. * Attach the input controls to a specific dom element to get the input from.
  12399. * @param element Defines the element the controls should be listened from
  12400. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12401. */
  12402. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12403. /**
  12404. * Detach the current controls from the specified dom element.
  12405. * @param element Defines the element to stop listening the inputs from
  12406. */
  12407. detachControl(element: Nullable<HTMLElement>): void;
  12408. /**
  12409. * Update the current camera state depending on the inputs that have been used this frame.
  12410. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12411. */
  12412. checkInputs(): void;
  12413. /**
  12414. * Gets the class name of the current intput.
  12415. * @returns the class name
  12416. */
  12417. getClassName(): string;
  12418. /**
  12419. * Get the friendly name associated with the input class.
  12420. * @returns the input friendly name
  12421. */
  12422. getSimpleName(): string;
  12423. }
  12424. }
  12425. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12426. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12427. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12428. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12429. import { Nullable } from "babylonjs/types";
  12430. /**
  12431. * Default Inputs manager for the FreeCamera.
  12432. * It groups all the default supported inputs for ease of use.
  12433. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12434. */
  12435. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12436. /**
  12437. * @hidden
  12438. */
  12439. _mouseInput: Nullable<FreeCameraMouseInput>;
  12440. /**
  12441. * Instantiates a new FreeCameraInputsManager.
  12442. * @param camera Defines the camera the inputs belong to
  12443. */
  12444. constructor(camera: FreeCamera);
  12445. /**
  12446. * Add keyboard input support to the input manager.
  12447. * @returns the current input manager
  12448. */
  12449. addKeyboard(): FreeCameraInputsManager;
  12450. /**
  12451. * Add mouse input support to the input manager.
  12452. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12453. * @returns the current input manager
  12454. */
  12455. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12456. /**
  12457. * Removes the mouse input support from the manager
  12458. * @returns the current input manager
  12459. */
  12460. removeMouse(): FreeCameraInputsManager;
  12461. /**
  12462. * Add touch input support to the input manager.
  12463. * @returns the current input manager
  12464. */
  12465. addTouch(): FreeCameraInputsManager;
  12466. /**
  12467. * Remove all attached input methods from a camera
  12468. */
  12469. clear(): void;
  12470. }
  12471. }
  12472. declare module "babylonjs/Cameras/freeCamera" {
  12473. import { Vector3 } from "babylonjs/Maths/math.vector";
  12474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12475. import { Scene } from "babylonjs/scene";
  12476. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12477. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12478. /**
  12479. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12480. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12481. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12482. */
  12483. export class FreeCamera extends TargetCamera {
  12484. /**
  12485. * Define the collision ellipsoid of the camera.
  12486. * This is helpful to simulate a camera body like the player body around the camera
  12487. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12488. */
  12489. ellipsoid: Vector3;
  12490. /**
  12491. * Define an offset for the position of the ellipsoid around the camera.
  12492. * This can be helpful to determine the center of the body near the gravity center of the body
  12493. * instead of its head.
  12494. */
  12495. ellipsoidOffset: Vector3;
  12496. /**
  12497. * Enable or disable collisions of the camera with the rest of the scene objects.
  12498. */
  12499. checkCollisions: boolean;
  12500. /**
  12501. * Enable or disable gravity on the camera.
  12502. */
  12503. applyGravity: boolean;
  12504. /**
  12505. * Define the input manager associated to the camera.
  12506. */
  12507. inputs: FreeCameraInputsManager;
  12508. /**
  12509. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12510. * Higher values reduce sensitivity.
  12511. */
  12512. get angularSensibility(): number;
  12513. /**
  12514. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12515. * Higher values reduce sensitivity.
  12516. */
  12517. set angularSensibility(value: number);
  12518. /**
  12519. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12520. */
  12521. get keysUp(): number[];
  12522. set keysUp(value: number[]);
  12523. /**
  12524. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12525. */
  12526. get keysDown(): number[];
  12527. set keysDown(value: number[]);
  12528. /**
  12529. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12530. */
  12531. get keysLeft(): number[];
  12532. set keysLeft(value: number[]);
  12533. /**
  12534. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12535. */
  12536. get keysRight(): number[];
  12537. set keysRight(value: number[]);
  12538. /**
  12539. * Event raised when the camera collide with a mesh in the scene.
  12540. */
  12541. onCollide: (collidedMesh: AbstractMesh) => void;
  12542. private _collider;
  12543. private _needMoveForGravity;
  12544. private _oldPosition;
  12545. private _diffPosition;
  12546. private _newPosition;
  12547. /** @hidden */
  12548. _localDirection: Vector3;
  12549. /** @hidden */
  12550. _transformedDirection: Vector3;
  12551. /**
  12552. * Instantiates a Free Camera.
  12553. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12554. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12555. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12556. * @param name Define the name of the camera in the scene
  12557. * @param position Define the start position of the camera in the scene
  12558. * @param scene Define the scene the camera belongs to
  12559. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12560. */
  12561. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12562. /**
  12563. * Attached controls to the current camera.
  12564. * @param element Defines the element the controls should be listened from
  12565. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12566. */
  12567. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12568. /**
  12569. * Detach the current controls from the camera.
  12570. * The camera will stop reacting to inputs.
  12571. * @param element Defines the element to stop listening the inputs from
  12572. */
  12573. detachControl(element: HTMLElement): void;
  12574. private _collisionMask;
  12575. /**
  12576. * Define a collision mask to limit the list of object the camera can collide with
  12577. */
  12578. get collisionMask(): number;
  12579. set collisionMask(mask: number);
  12580. /** @hidden */
  12581. _collideWithWorld(displacement: Vector3): void;
  12582. private _onCollisionPositionChange;
  12583. /** @hidden */
  12584. _checkInputs(): void;
  12585. /** @hidden */
  12586. _decideIfNeedsToMove(): boolean;
  12587. /** @hidden */
  12588. _updatePosition(): void;
  12589. /**
  12590. * Destroy the camera and release the current resources hold by it.
  12591. */
  12592. dispose(): void;
  12593. /**
  12594. * Gets the current object class name.
  12595. * @return the class name
  12596. */
  12597. getClassName(): string;
  12598. }
  12599. }
  12600. declare module "babylonjs/Gamepads/gamepad" {
  12601. import { Observable } from "babylonjs/Misc/observable";
  12602. /**
  12603. * Represents a gamepad control stick position
  12604. */
  12605. export class StickValues {
  12606. /**
  12607. * The x component of the control stick
  12608. */
  12609. x: number;
  12610. /**
  12611. * The y component of the control stick
  12612. */
  12613. y: number;
  12614. /**
  12615. * Initializes the gamepad x and y control stick values
  12616. * @param x The x component of the gamepad control stick value
  12617. * @param y The y component of the gamepad control stick value
  12618. */
  12619. constructor(
  12620. /**
  12621. * The x component of the control stick
  12622. */
  12623. x: number,
  12624. /**
  12625. * The y component of the control stick
  12626. */
  12627. y: number);
  12628. }
  12629. /**
  12630. * An interface which manages callbacks for gamepad button changes
  12631. */
  12632. export interface GamepadButtonChanges {
  12633. /**
  12634. * Called when a gamepad has been changed
  12635. */
  12636. changed: boolean;
  12637. /**
  12638. * Called when a gamepad press event has been triggered
  12639. */
  12640. pressChanged: boolean;
  12641. /**
  12642. * Called when a touch event has been triggered
  12643. */
  12644. touchChanged: boolean;
  12645. /**
  12646. * Called when a value has changed
  12647. */
  12648. valueChanged: boolean;
  12649. }
  12650. /**
  12651. * Represents a gamepad
  12652. */
  12653. export class Gamepad {
  12654. /**
  12655. * The id of the gamepad
  12656. */
  12657. id: string;
  12658. /**
  12659. * The index of the gamepad
  12660. */
  12661. index: number;
  12662. /**
  12663. * The browser gamepad
  12664. */
  12665. browserGamepad: any;
  12666. /**
  12667. * Specifies what type of gamepad this represents
  12668. */
  12669. type: number;
  12670. private _leftStick;
  12671. private _rightStick;
  12672. /** @hidden */
  12673. _isConnected: boolean;
  12674. private _leftStickAxisX;
  12675. private _leftStickAxisY;
  12676. private _rightStickAxisX;
  12677. private _rightStickAxisY;
  12678. /**
  12679. * Triggered when the left control stick has been changed
  12680. */
  12681. private _onleftstickchanged;
  12682. /**
  12683. * Triggered when the right control stick has been changed
  12684. */
  12685. private _onrightstickchanged;
  12686. /**
  12687. * Represents a gamepad controller
  12688. */
  12689. static GAMEPAD: number;
  12690. /**
  12691. * Represents a generic controller
  12692. */
  12693. static GENERIC: number;
  12694. /**
  12695. * Represents an XBox controller
  12696. */
  12697. static XBOX: number;
  12698. /**
  12699. * Represents a pose-enabled controller
  12700. */
  12701. static POSE_ENABLED: number;
  12702. /**
  12703. * Represents an Dual Shock controller
  12704. */
  12705. static DUALSHOCK: number;
  12706. /**
  12707. * Specifies whether the left control stick should be Y-inverted
  12708. */
  12709. protected _invertLeftStickY: boolean;
  12710. /**
  12711. * Specifies if the gamepad has been connected
  12712. */
  12713. get isConnected(): boolean;
  12714. /**
  12715. * Initializes the gamepad
  12716. * @param id The id of the gamepad
  12717. * @param index The index of the gamepad
  12718. * @param browserGamepad The browser gamepad
  12719. * @param leftStickX The x component of the left joystick
  12720. * @param leftStickY The y component of the left joystick
  12721. * @param rightStickX The x component of the right joystick
  12722. * @param rightStickY The y component of the right joystick
  12723. */
  12724. constructor(
  12725. /**
  12726. * The id of the gamepad
  12727. */
  12728. id: string,
  12729. /**
  12730. * The index of the gamepad
  12731. */
  12732. index: number,
  12733. /**
  12734. * The browser gamepad
  12735. */
  12736. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12737. /**
  12738. * Callback triggered when the left joystick has changed
  12739. * @param callback
  12740. */
  12741. onleftstickchanged(callback: (values: StickValues) => void): void;
  12742. /**
  12743. * Callback triggered when the right joystick has changed
  12744. * @param callback
  12745. */
  12746. onrightstickchanged(callback: (values: StickValues) => void): void;
  12747. /**
  12748. * Gets the left joystick
  12749. */
  12750. get leftStick(): StickValues;
  12751. /**
  12752. * Sets the left joystick values
  12753. */
  12754. set leftStick(newValues: StickValues);
  12755. /**
  12756. * Gets the right joystick
  12757. */
  12758. get rightStick(): StickValues;
  12759. /**
  12760. * Sets the right joystick value
  12761. */
  12762. set rightStick(newValues: StickValues);
  12763. /**
  12764. * Updates the gamepad joystick positions
  12765. */
  12766. update(): void;
  12767. /**
  12768. * Disposes the gamepad
  12769. */
  12770. dispose(): void;
  12771. }
  12772. /**
  12773. * Represents a generic gamepad
  12774. */
  12775. export class GenericPad extends Gamepad {
  12776. private _buttons;
  12777. private _onbuttondown;
  12778. private _onbuttonup;
  12779. /**
  12780. * Observable triggered when a button has been pressed
  12781. */
  12782. onButtonDownObservable: Observable<number>;
  12783. /**
  12784. * Observable triggered when a button has been released
  12785. */
  12786. onButtonUpObservable: Observable<number>;
  12787. /**
  12788. * Callback triggered when a button has been pressed
  12789. * @param callback Called when a button has been pressed
  12790. */
  12791. onbuttondown(callback: (buttonPressed: number) => void): void;
  12792. /**
  12793. * Callback triggered when a button has been released
  12794. * @param callback Called when a button has been released
  12795. */
  12796. onbuttonup(callback: (buttonReleased: number) => void): void;
  12797. /**
  12798. * Initializes the generic gamepad
  12799. * @param id The id of the generic gamepad
  12800. * @param index The index of the generic gamepad
  12801. * @param browserGamepad The browser gamepad
  12802. */
  12803. constructor(id: string, index: number, browserGamepad: any);
  12804. private _setButtonValue;
  12805. /**
  12806. * Updates the generic gamepad
  12807. */
  12808. update(): void;
  12809. /**
  12810. * Disposes the generic gamepad
  12811. */
  12812. dispose(): void;
  12813. }
  12814. }
  12815. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12816. import { Nullable } from "babylonjs/types";
  12817. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12818. import { Scene } from "babylonjs/scene";
  12819. module "babylonjs/Engines/engine" {
  12820. interface Engine {
  12821. /**
  12822. * Creates a raw texture
  12823. * @param data defines the data to store in the texture
  12824. * @param width defines the width of the texture
  12825. * @param height defines the height of the texture
  12826. * @param format defines the format of the data
  12827. * @param generateMipMaps defines if the engine should generate the mip levels
  12828. * @param invertY defines if data must be stored with Y axis inverted
  12829. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12830. * @param compression defines the compression used (null by default)
  12831. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12832. * @returns the raw texture inside an InternalTexture
  12833. */
  12834. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12835. /**
  12836. * Update a raw texture
  12837. * @param texture defines the texture to update
  12838. * @param data defines the data to store in the texture
  12839. * @param format defines the format of the data
  12840. * @param invertY defines if data must be stored with Y axis inverted
  12841. */
  12842. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12843. /**
  12844. * Update a raw texture
  12845. * @param texture defines the texture to update
  12846. * @param data defines the data to store in the texture
  12847. * @param format defines the format of the data
  12848. * @param invertY defines if data must be stored with Y axis inverted
  12849. * @param compression defines the compression used (null by default)
  12850. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12851. */
  12852. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12853. /**
  12854. * Creates a new raw cube texture
  12855. * @param data defines the array of data to use to create each face
  12856. * @param size defines the size of the textures
  12857. * @param format defines the format of the data
  12858. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12859. * @param generateMipMaps defines if the engine should generate the mip levels
  12860. * @param invertY defines if data must be stored with Y axis inverted
  12861. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12862. * @param compression defines the compression used (null by default)
  12863. * @returns the cube texture as an InternalTexture
  12864. */
  12865. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12866. /**
  12867. * Update a raw cube texture
  12868. * @param texture defines the texture to udpdate
  12869. * @param data defines the data to store
  12870. * @param format defines the data format
  12871. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12872. * @param invertY defines if data must be stored with Y axis inverted
  12873. */
  12874. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12875. /**
  12876. * Update a raw cube texture
  12877. * @param texture defines the texture to udpdate
  12878. * @param data defines the data to store
  12879. * @param format defines the data format
  12880. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12881. * @param invertY defines if data must be stored with Y axis inverted
  12882. * @param compression defines the compression used (null by default)
  12883. */
  12884. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12885. /**
  12886. * Update a raw cube texture
  12887. * @param texture defines the texture to udpdate
  12888. * @param data defines the data to store
  12889. * @param format defines the data format
  12890. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12891. * @param invertY defines if data must be stored with Y axis inverted
  12892. * @param compression defines the compression used (null by default)
  12893. * @param level defines which level of the texture to update
  12894. */
  12895. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12896. /**
  12897. * Creates a new raw cube texture from a specified url
  12898. * @param url defines the url where the data is located
  12899. * @param scene defines the current scene
  12900. * @param size defines the size of the textures
  12901. * @param format defines the format of the data
  12902. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12903. * @param noMipmap defines if the engine should avoid generating the mip levels
  12904. * @param callback defines a callback used to extract texture data from loaded data
  12905. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12906. * @param onLoad defines a callback called when texture is loaded
  12907. * @param onError defines a callback called if there is an error
  12908. * @returns the cube texture as an InternalTexture
  12909. */
  12910. 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;
  12911. /**
  12912. * Creates a new raw cube texture from a specified url
  12913. * @param url defines the url where the data is located
  12914. * @param scene defines the current scene
  12915. * @param size defines the size of the textures
  12916. * @param format defines the format of the data
  12917. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12918. * @param noMipmap defines if the engine should avoid generating the mip levels
  12919. * @param callback defines a callback used to extract texture data from loaded data
  12920. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12921. * @param onLoad defines a callback called when texture is loaded
  12922. * @param onError defines a callback called if there is an error
  12923. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12924. * @param invertY defines if data must be stored with Y axis inverted
  12925. * @returns the cube texture as an InternalTexture
  12926. */
  12927. 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;
  12928. /**
  12929. * Creates a new raw 3D texture
  12930. * @param data defines the data used to create the texture
  12931. * @param width defines the width of the texture
  12932. * @param height defines the height of the texture
  12933. * @param depth defines the depth of the texture
  12934. * @param format defines the format of the texture
  12935. * @param generateMipMaps defines if the engine must generate mip levels
  12936. * @param invertY defines if data must be stored with Y axis inverted
  12937. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12938. * @param compression defines the compressed used (can be null)
  12939. * @param textureType defines the compressed used (can be null)
  12940. * @returns a new raw 3D texture (stored in an InternalTexture)
  12941. */
  12942. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12943. /**
  12944. * Update a raw 3D texture
  12945. * @param texture defines the texture to update
  12946. * @param data defines the data to store
  12947. * @param format defines the data format
  12948. * @param invertY defines if data must be stored with Y axis inverted
  12949. */
  12950. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12951. /**
  12952. * Update a raw 3D texture
  12953. * @param texture defines the texture to update
  12954. * @param data defines the data to store
  12955. * @param format defines the data format
  12956. * @param invertY defines if data must be stored with Y axis inverted
  12957. * @param compression defines the used compression (can be null)
  12958. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12959. */
  12960. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12961. /**
  12962. * Creates a new raw 2D array texture
  12963. * @param data defines the data used to create the texture
  12964. * @param width defines the width of the texture
  12965. * @param height defines the height of the texture
  12966. * @param depth defines the number of layers of the texture
  12967. * @param format defines the format of the texture
  12968. * @param generateMipMaps defines if the engine must generate mip levels
  12969. * @param invertY defines if data must be stored with Y axis inverted
  12970. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12971. * @param compression defines the compressed used (can be null)
  12972. * @param textureType defines the compressed used (can be null)
  12973. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12974. */
  12975. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12976. /**
  12977. * Update a raw 2D array texture
  12978. * @param texture defines the texture to update
  12979. * @param data defines the data to store
  12980. * @param format defines the data format
  12981. * @param invertY defines if data must be stored with Y axis inverted
  12982. */
  12983. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12984. /**
  12985. * Update a raw 2D array texture
  12986. * @param texture defines the texture to update
  12987. * @param data defines the data to store
  12988. * @param format defines the data format
  12989. * @param invertY defines if data must be stored with Y axis inverted
  12990. * @param compression defines the used compression (can be null)
  12991. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12992. */
  12993. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12994. }
  12995. }
  12996. }
  12997. declare module "babylonjs/Materials/Textures/rawTexture" {
  12998. import { Scene } from "babylonjs/scene";
  12999. import { Texture } from "babylonjs/Materials/Textures/texture";
  13000. import "babylonjs/Engines/Extensions/engine.rawTexture";
  13001. /**
  13002. * Raw texture can help creating a texture directly from an array of data.
  13003. * This can be super useful if you either get the data from an uncompressed source or
  13004. * if you wish to create your texture pixel by pixel.
  13005. */
  13006. export class RawTexture extends Texture {
  13007. /**
  13008. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13009. */
  13010. format: number;
  13011. private _engine;
  13012. /**
  13013. * Instantiates a new RawTexture.
  13014. * Raw texture can help creating a texture directly from an array of data.
  13015. * This can be super useful if you either get the data from an uncompressed source or
  13016. * if you wish to create your texture pixel by pixel.
  13017. * @param data define the array of data to use to create the texture
  13018. * @param width define the width of the texture
  13019. * @param height define the height of the texture
  13020. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13021. * @param scene define the scene the texture belongs to
  13022. * @param generateMipMaps define whether mip maps should be generated or not
  13023. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13024. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13025. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13026. */
  13027. constructor(data: ArrayBufferView, width: number, height: number,
  13028. /**
  13029. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13030. */
  13031. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  13032. /**
  13033. * Updates the texture underlying data.
  13034. * @param data Define the new data of the texture
  13035. */
  13036. update(data: ArrayBufferView): void;
  13037. /**
  13038. * Creates a luminance texture from some data.
  13039. * @param data Define the texture data
  13040. * @param width Define the width of the texture
  13041. * @param height Define the height of the texture
  13042. * @param scene Define the scene the texture belongs to
  13043. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13044. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13045. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13046. * @returns the luminance texture
  13047. */
  13048. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13049. /**
  13050. * Creates a luminance alpha texture from some data.
  13051. * @param data Define the texture data
  13052. * @param width Define the width of the texture
  13053. * @param height Define the height of the texture
  13054. * @param scene Define the scene the texture belongs to
  13055. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13056. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13057. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13058. * @returns the luminance alpha texture
  13059. */
  13060. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13061. /**
  13062. * Creates an alpha texture from some data.
  13063. * @param data Define the texture data
  13064. * @param width Define the width of the texture
  13065. * @param height Define the height of the texture
  13066. * @param scene Define the scene the texture belongs to
  13067. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13068. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13069. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13070. * @returns the alpha texture
  13071. */
  13072. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13073. /**
  13074. * Creates a RGB texture from some data.
  13075. * @param data Define the texture data
  13076. * @param width Define the width of the texture
  13077. * @param height Define the height of the texture
  13078. * @param scene Define the scene the texture belongs to
  13079. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13080. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13081. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13082. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13083. * @returns the RGB alpha texture
  13084. */
  13085. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13086. /**
  13087. * Creates a RGBA texture from some data.
  13088. * @param data Define the texture data
  13089. * @param width Define the width of the texture
  13090. * @param height Define the height of the texture
  13091. * @param scene Define the scene the texture belongs to
  13092. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13093. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13094. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13095. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13096. * @returns the RGBA texture
  13097. */
  13098. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13099. /**
  13100. * Creates a R texture from some data.
  13101. * @param data Define the texture data
  13102. * @param width Define the width of the texture
  13103. * @param height Define the height of the texture
  13104. * @param scene Define the scene the texture belongs to
  13105. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13106. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13107. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13108. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13109. * @returns the R texture
  13110. */
  13111. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13112. }
  13113. }
  13114. declare module "babylonjs/Maths/math.size" {
  13115. /**
  13116. * Interface for the size containing width and height
  13117. */
  13118. export interface ISize {
  13119. /**
  13120. * Width
  13121. */
  13122. width: number;
  13123. /**
  13124. * Heighht
  13125. */
  13126. height: number;
  13127. }
  13128. /**
  13129. * Size containing widht and height
  13130. */
  13131. export class Size implements ISize {
  13132. /**
  13133. * Width
  13134. */
  13135. width: number;
  13136. /**
  13137. * Height
  13138. */
  13139. height: number;
  13140. /**
  13141. * Creates a Size object from the given width and height (floats).
  13142. * @param width width of the new size
  13143. * @param height height of the new size
  13144. */
  13145. constructor(width: number, height: number);
  13146. /**
  13147. * Returns a string with the Size width and height
  13148. * @returns a string with the Size width and height
  13149. */
  13150. toString(): string;
  13151. /**
  13152. * "Size"
  13153. * @returns the string "Size"
  13154. */
  13155. getClassName(): string;
  13156. /**
  13157. * Returns the Size hash code.
  13158. * @returns a hash code for a unique width and height
  13159. */
  13160. getHashCode(): number;
  13161. /**
  13162. * Updates the current size from the given one.
  13163. * @param src the given size
  13164. */
  13165. copyFrom(src: Size): void;
  13166. /**
  13167. * Updates in place the current Size from the given floats.
  13168. * @param width width of the new size
  13169. * @param height height of the new size
  13170. * @returns the updated Size.
  13171. */
  13172. copyFromFloats(width: number, height: number): Size;
  13173. /**
  13174. * Updates in place the current Size from the given floats.
  13175. * @param width width to set
  13176. * @param height height to set
  13177. * @returns the updated Size.
  13178. */
  13179. set(width: number, height: number): Size;
  13180. /**
  13181. * Multiplies the width and height by numbers
  13182. * @param w factor to multiple the width by
  13183. * @param h factor to multiple the height by
  13184. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  13185. */
  13186. multiplyByFloats(w: number, h: number): Size;
  13187. /**
  13188. * Clones the size
  13189. * @returns a new Size copied from the given one.
  13190. */
  13191. clone(): Size;
  13192. /**
  13193. * True if the current Size and the given one width and height are strictly equal.
  13194. * @param other the other size to compare against
  13195. * @returns True if the current Size and the given one width and height are strictly equal.
  13196. */
  13197. equals(other: Size): boolean;
  13198. /**
  13199. * The surface of the Size : width * height (float).
  13200. */
  13201. get surface(): number;
  13202. /**
  13203. * Create a new size of zero
  13204. * @returns a new Size set to (0.0, 0.0)
  13205. */
  13206. static Zero(): Size;
  13207. /**
  13208. * Sums the width and height of two sizes
  13209. * @param otherSize size to add to this size
  13210. * @returns a new Size set as the addition result of the current Size and the given one.
  13211. */
  13212. add(otherSize: Size): Size;
  13213. /**
  13214. * Subtracts the width and height of two
  13215. * @param otherSize size to subtract to this size
  13216. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13217. */
  13218. subtract(otherSize: Size): Size;
  13219. /**
  13220. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13221. * @param start starting size to lerp between
  13222. * @param end end size to lerp between
  13223. * @param amount amount to lerp between the start and end values
  13224. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13225. */
  13226. static Lerp(start: Size, end: Size, amount: number): Size;
  13227. }
  13228. }
  13229. declare module "babylonjs/Animations/runtimeAnimation" {
  13230. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13231. import { Animatable } from "babylonjs/Animations/animatable";
  13232. import { Scene } from "babylonjs/scene";
  13233. /**
  13234. * Defines a runtime animation
  13235. */
  13236. export class RuntimeAnimation {
  13237. private _events;
  13238. /**
  13239. * The current frame of the runtime animation
  13240. */
  13241. private _currentFrame;
  13242. /**
  13243. * The animation used by the runtime animation
  13244. */
  13245. private _animation;
  13246. /**
  13247. * The target of the runtime animation
  13248. */
  13249. private _target;
  13250. /**
  13251. * The initiating animatable
  13252. */
  13253. private _host;
  13254. /**
  13255. * The original value of the runtime animation
  13256. */
  13257. private _originalValue;
  13258. /**
  13259. * The original blend value of the runtime animation
  13260. */
  13261. private _originalBlendValue;
  13262. /**
  13263. * The offsets cache of the runtime animation
  13264. */
  13265. private _offsetsCache;
  13266. /**
  13267. * The high limits cache of the runtime animation
  13268. */
  13269. private _highLimitsCache;
  13270. /**
  13271. * Specifies if the runtime animation has been stopped
  13272. */
  13273. private _stopped;
  13274. /**
  13275. * The blending factor of the runtime animation
  13276. */
  13277. private _blendingFactor;
  13278. /**
  13279. * The BabylonJS scene
  13280. */
  13281. private _scene;
  13282. /**
  13283. * The current value of the runtime animation
  13284. */
  13285. private _currentValue;
  13286. /** @hidden */
  13287. _animationState: _IAnimationState;
  13288. /**
  13289. * The active target of the runtime animation
  13290. */
  13291. private _activeTargets;
  13292. private _currentActiveTarget;
  13293. private _directTarget;
  13294. /**
  13295. * The target path of the runtime animation
  13296. */
  13297. private _targetPath;
  13298. /**
  13299. * The weight of the runtime animation
  13300. */
  13301. private _weight;
  13302. /**
  13303. * The ratio offset of the runtime animation
  13304. */
  13305. private _ratioOffset;
  13306. /**
  13307. * The previous delay of the runtime animation
  13308. */
  13309. private _previousDelay;
  13310. /**
  13311. * The previous ratio of the runtime animation
  13312. */
  13313. private _previousRatio;
  13314. private _enableBlending;
  13315. private _keys;
  13316. private _minFrame;
  13317. private _maxFrame;
  13318. private _minValue;
  13319. private _maxValue;
  13320. private _targetIsArray;
  13321. /**
  13322. * Gets the current frame of the runtime animation
  13323. */
  13324. get currentFrame(): number;
  13325. /**
  13326. * Gets the weight of the runtime animation
  13327. */
  13328. get weight(): number;
  13329. /**
  13330. * Gets the current value of the runtime animation
  13331. */
  13332. get currentValue(): any;
  13333. /**
  13334. * Gets the target path of the runtime animation
  13335. */
  13336. get targetPath(): string;
  13337. /**
  13338. * Gets the actual target of the runtime animation
  13339. */
  13340. get target(): any;
  13341. /** @hidden */
  13342. _onLoop: () => void;
  13343. /**
  13344. * Create a new RuntimeAnimation object
  13345. * @param target defines the target of the animation
  13346. * @param animation defines the source animation object
  13347. * @param scene defines the hosting scene
  13348. * @param host defines the initiating Animatable
  13349. */
  13350. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13351. private _preparePath;
  13352. /**
  13353. * Gets the animation from the runtime animation
  13354. */
  13355. get animation(): Animation;
  13356. /**
  13357. * Resets the runtime animation to the beginning
  13358. * @param restoreOriginal defines whether to restore the target property to the original value
  13359. */
  13360. reset(restoreOriginal?: boolean): void;
  13361. /**
  13362. * Specifies if the runtime animation is stopped
  13363. * @returns Boolean specifying if the runtime animation is stopped
  13364. */
  13365. isStopped(): boolean;
  13366. /**
  13367. * Disposes of the runtime animation
  13368. */
  13369. dispose(): void;
  13370. /**
  13371. * Apply the interpolated value to the target
  13372. * @param currentValue defines the value computed by the animation
  13373. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13374. */
  13375. setValue(currentValue: any, weight: number): void;
  13376. private _getOriginalValues;
  13377. private _setValue;
  13378. /**
  13379. * Gets the loop pmode of the runtime animation
  13380. * @returns Loop Mode
  13381. */
  13382. private _getCorrectLoopMode;
  13383. /**
  13384. * Move the current animation to a given frame
  13385. * @param frame defines the frame to move to
  13386. */
  13387. goToFrame(frame: number): void;
  13388. /**
  13389. * @hidden Internal use only
  13390. */
  13391. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13392. /**
  13393. * Execute the current animation
  13394. * @param delay defines the delay to add to the current frame
  13395. * @param from defines the lower bound of the animation range
  13396. * @param to defines the upper bound of the animation range
  13397. * @param loop defines if the current animation must loop
  13398. * @param speedRatio defines the current speed ratio
  13399. * @param weight defines the weight of the animation (default is -1 so no weight)
  13400. * @param onLoop optional callback called when animation loops
  13401. * @returns a boolean indicating if the animation is running
  13402. */
  13403. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13404. }
  13405. }
  13406. declare module "babylonjs/Animations/animatable" {
  13407. import { Animation } from "babylonjs/Animations/animation";
  13408. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13409. import { Nullable } from "babylonjs/types";
  13410. import { Observable } from "babylonjs/Misc/observable";
  13411. import { Scene } from "babylonjs/scene";
  13412. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13413. import { Node } from "babylonjs/node";
  13414. /**
  13415. * Class used to store an actual running animation
  13416. */
  13417. export class Animatable {
  13418. /** defines the target object */
  13419. target: any;
  13420. /** defines the starting frame number (default is 0) */
  13421. fromFrame: number;
  13422. /** defines the ending frame number (default is 100) */
  13423. toFrame: number;
  13424. /** defines if the animation must loop (default is false) */
  13425. loopAnimation: boolean;
  13426. /** defines a callback to call when animation ends if it is not looping */
  13427. onAnimationEnd?: (() => void) | null | undefined;
  13428. /** defines a callback to call when animation loops */
  13429. onAnimationLoop?: (() => void) | null | undefined;
  13430. private _localDelayOffset;
  13431. private _pausedDelay;
  13432. private _runtimeAnimations;
  13433. private _paused;
  13434. private _scene;
  13435. private _speedRatio;
  13436. private _weight;
  13437. private _syncRoot;
  13438. /**
  13439. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13440. * This will only apply for non looping animation (default is true)
  13441. */
  13442. disposeOnEnd: boolean;
  13443. /**
  13444. * Gets a boolean indicating if the animation has started
  13445. */
  13446. animationStarted: boolean;
  13447. /**
  13448. * Observer raised when the animation ends
  13449. */
  13450. onAnimationEndObservable: Observable<Animatable>;
  13451. /**
  13452. * Observer raised when the animation loops
  13453. */
  13454. onAnimationLoopObservable: Observable<Animatable>;
  13455. /**
  13456. * Gets the root Animatable used to synchronize and normalize animations
  13457. */
  13458. get syncRoot(): Nullable<Animatable>;
  13459. /**
  13460. * Gets the current frame of the first RuntimeAnimation
  13461. * Used to synchronize Animatables
  13462. */
  13463. get masterFrame(): number;
  13464. /**
  13465. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13466. */
  13467. get weight(): number;
  13468. set weight(value: number);
  13469. /**
  13470. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13471. */
  13472. get speedRatio(): number;
  13473. set speedRatio(value: number);
  13474. /**
  13475. * Creates a new Animatable
  13476. * @param scene defines the hosting scene
  13477. * @param target defines the target object
  13478. * @param fromFrame defines the starting frame number (default is 0)
  13479. * @param toFrame defines the ending frame number (default is 100)
  13480. * @param loopAnimation defines if the animation must loop (default is false)
  13481. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13482. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13483. * @param animations defines a group of animation to add to the new Animatable
  13484. * @param onAnimationLoop defines a callback to call when animation loops
  13485. */
  13486. constructor(scene: Scene,
  13487. /** defines the target object */
  13488. target: any,
  13489. /** defines the starting frame number (default is 0) */
  13490. fromFrame?: number,
  13491. /** defines the ending frame number (default is 100) */
  13492. toFrame?: number,
  13493. /** defines if the animation must loop (default is false) */
  13494. loopAnimation?: boolean, speedRatio?: number,
  13495. /** defines a callback to call when animation ends if it is not looping */
  13496. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13497. /** defines a callback to call when animation loops */
  13498. onAnimationLoop?: (() => void) | null | undefined);
  13499. /**
  13500. * Synchronize and normalize current Animatable with a source Animatable
  13501. * This is useful when using animation weights and when animations are not of the same length
  13502. * @param root defines the root Animatable to synchronize with
  13503. * @returns the current Animatable
  13504. */
  13505. syncWith(root: Animatable): Animatable;
  13506. /**
  13507. * Gets the list of runtime animations
  13508. * @returns an array of RuntimeAnimation
  13509. */
  13510. getAnimations(): RuntimeAnimation[];
  13511. /**
  13512. * Adds more animations to the current animatable
  13513. * @param target defines the target of the animations
  13514. * @param animations defines the new animations to add
  13515. */
  13516. appendAnimations(target: any, animations: Animation[]): void;
  13517. /**
  13518. * Gets the source animation for a specific property
  13519. * @param property defines the propertyu to look for
  13520. * @returns null or the source animation for the given property
  13521. */
  13522. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13523. /**
  13524. * Gets the runtime animation for a specific property
  13525. * @param property defines the propertyu to look for
  13526. * @returns null or the runtime animation for the given property
  13527. */
  13528. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13529. /**
  13530. * Resets the animatable to its original state
  13531. */
  13532. reset(): void;
  13533. /**
  13534. * Allows the animatable to blend with current running animations
  13535. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13536. * @param blendingSpeed defines the blending speed to use
  13537. */
  13538. enableBlending(blendingSpeed: number): void;
  13539. /**
  13540. * Disable animation blending
  13541. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13542. */
  13543. disableBlending(): void;
  13544. /**
  13545. * Jump directly to a given frame
  13546. * @param frame defines the frame to jump to
  13547. */
  13548. goToFrame(frame: number): void;
  13549. /**
  13550. * Pause the animation
  13551. */
  13552. pause(): void;
  13553. /**
  13554. * Restart the animation
  13555. */
  13556. restart(): void;
  13557. private _raiseOnAnimationEnd;
  13558. /**
  13559. * Stop and delete the current animation
  13560. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13561. * @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)
  13562. */
  13563. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13564. /**
  13565. * Wait asynchronously for the animation to end
  13566. * @returns a promise which will be fullfilled when the animation ends
  13567. */
  13568. waitAsync(): Promise<Animatable>;
  13569. /** @hidden */
  13570. _animate(delay: number): boolean;
  13571. }
  13572. module "babylonjs/scene" {
  13573. interface Scene {
  13574. /** @hidden */
  13575. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13576. /** @hidden */
  13577. _processLateAnimationBindingsForMatrices(holder: {
  13578. totalWeight: number;
  13579. animations: RuntimeAnimation[];
  13580. originalValue: Matrix;
  13581. }): any;
  13582. /** @hidden */
  13583. _processLateAnimationBindingsForQuaternions(holder: {
  13584. totalWeight: number;
  13585. animations: RuntimeAnimation[];
  13586. originalValue: Quaternion;
  13587. }, refQuaternion: Quaternion): Quaternion;
  13588. /** @hidden */
  13589. _processLateAnimationBindings(): void;
  13590. /**
  13591. * Will start the animation sequence of a given target
  13592. * @param target defines the target
  13593. * @param from defines from which frame should animation start
  13594. * @param to defines until which frame should animation run.
  13595. * @param weight defines the weight to apply to the animation (1.0 by default)
  13596. * @param loop defines if the animation loops
  13597. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13598. * @param onAnimationEnd defines the function to be executed when the animation ends
  13599. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13600. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13601. * @param onAnimationLoop defines the callback to call when an animation loops
  13602. * @returns the animatable object created for this animation
  13603. */
  13604. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13605. /**
  13606. * Will start the animation sequence of a given target
  13607. * @param target defines the target
  13608. * @param from defines from which frame should animation start
  13609. * @param to defines until which frame should animation run.
  13610. * @param loop defines if the animation loops
  13611. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13612. * @param onAnimationEnd defines the function to be executed when the animation ends
  13613. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13614. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13615. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13616. * @param onAnimationLoop defines the callback to call when an animation loops
  13617. * @returns the animatable object created for this animation
  13618. */
  13619. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13620. /**
  13621. * Will start the animation sequence of a given target and its hierarchy
  13622. * @param target defines the target
  13623. * @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.
  13624. * @param from defines from which frame should animation start
  13625. * @param to defines until which frame should animation run.
  13626. * @param loop defines if the animation loops
  13627. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13628. * @param onAnimationEnd defines the function to be executed when the animation ends
  13629. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13630. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13631. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13632. * @param onAnimationLoop defines the callback to call when an animation loops
  13633. * @returns the list of created animatables
  13634. */
  13635. 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[];
  13636. /**
  13637. * Begin a new animation on a given node
  13638. * @param target defines the target where the animation will take place
  13639. * @param animations defines the list of animations to start
  13640. * @param from defines the initial value
  13641. * @param to defines the final value
  13642. * @param loop defines if you want animation to loop (off by default)
  13643. * @param speedRatio defines the speed ratio to apply to all animations
  13644. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13645. * @param onAnimationLoop defines the callback to call when an animation loops
  13646. * @returns the list of created animatables
  13647. */
  13648. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13649. /**
  13650. * Begin a new animation on a given node and its hierarchy
  13651. * @param target defines the root node where the animation will take place
  13652. * @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.
  13653. * @param animations defines the list of animations to start
  13654. * @param from defines the initial value
  13655. * @param to defines the final value
  13656. * @param loop defines if you want animation to loop (off by default)
  13657. * @param speedRatio defines the speed ratio to apply to all animations
  13658. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13659. * @param onAnimationLoop defines the callback to call when an animation loops
  13660. * @returns the list of animatables created for all nodes
  13661. */
  13662. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13663. /**
  13664. * Gets the animatable associated with a specific target
  13665. * @param target defines the target of the animatable
  13666. * @returns the required animatable if found
  13667. */
  13668. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13669. /**
  13670. * Gets all animatables associated with a given target
  13671. * @param target defines the target to look animatables for
  13672. * @returns an array of Animatables
  13673. */
  13674. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13675. /**
  13676. * Stops and removes all animations that have been applied to the scene
  13677. */
  13678. stopAllAnimations(): void;
  13679. /**
  13680. * Gets the current delta time used by animation engine
  13681. */
  13682. deltaTime: number;
  13683. }
  13684. }
  13685. module "babylonjs/Bones/bone" {
  13686. interface Bone {
  13687. /**
  13688. * Copy an animation range from another bone
  13689. * @param source defines the source bone
  13690. * @param rangeName defines the range name to copy
  13691. * @param frameOffset defines the frame offset
  13692. * @param rescaleAsRequired defines if rescaling must be applied if required
  13693. * @param skelDimensionsRatio defines the scaling ratio
  13694. * @returns true if operation was successful
  13695. */
  13696. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13697. }
  13698. }
  13699. }
  13700. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13701. /**
  13702. * Class used to override all child animations of a given target
  13703. */
  13704. export class AnimationPropertiesOverride {
  13705. /**
  13706. * Gets or sets a value indicating if animation blending must be used
  13707. */
  13708. enableBlending: boolean;
  13709. /**
  13710. * Gets or sets the blending speed to use when enableBlending is true
  13711. */
  13712. blendingSpeed: number;
  13713. /**
  13714. * Gets or sets the default loop mode to use
  13715. */
  13716. loopMode: number;
  13717. }
  13718. }
  13719. declare module "babylonjs/Bones/skeleton" {
  13720. import { Bone } from "babylonjs/Bones/bone";
  13721. import { Observable } from "babylonjs/Misc/observable";
  13722. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13723. import { Scene } from "babylonjs/scene";
  13724. import { Nullable } from "babylonjs/types";
  13725. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13726. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13727. import { Animatable } from "babylonjs/Animations/animatable";
  13728. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13729. import { Animation } from "babylonjs/Animations/animation";
  13730. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13731. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13732. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13733. /**
  13734. * Class used to handle skinning animations
  13735. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13736. */
  13737. export class Skeleton implements IAnimatable {
  13738. /** defines the skeleton name */
  13739. name: string;
  13740. /** defines the skeleton Id */
  13741. id: string;
  13742. /**
  13743. * Defines the list of child bones
  13744. */
  13745. bones: Bone[];
  13746. /**
  13747. * Defines an estimate of the dimension of the skeleton at rest
  13748. */
  13749. dimensionsAtRest: Vector3;
  13750. /**
  13751. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13752. */
  13753. needInitialSkinMatrix: boolean;
  13754. /**
  13755. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13756. */
  13757. overrideMesh: Nullable<AbstractMesh>;
  13758. /**
  13759. * Gets the list of animations attached to this skeleton
  13760. */
  13761. animations: Array<Animation>;
  13762. private _scene;
  13763. private _isDirty;
  13764. private _transformMatrices;
  13765. private _transformMatrixTexture;
  13766. private _meshesWithPoseMatrix;
  13767. private _animatables;
  13768. private _identity;
  13769. private _synchronizedWithMesh;
  13770. private _ranges;
  13771. private _lastAbsoluteTransformsUpdateId;
  13772. private _canUseTextureForBones;
  13773. private _uniqueId;
  13774. /** @hidden */
  13775. _numBonesWithLinkedTransformNode: number;
  13776. /** @hidden */
  13777. _hasWaitingData: Nullable<boolean>;
  13778. /**
  13779. * Specifies if the skeleton should be serialized
  13780. */
  13781. doNotSerialize: boolean;
  13782. private _useTextureToStoreBoneMatrices;
  13783. /**
  13784. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13785. * Please note that this option is not available if the hardware does not support it
  13786. */
  13787. get useTextureToStoreBoneMatrices(): boolean;
  13788. set useTextureToStoreBoneMatrices(value: boolean);
  13789. private _animationPropertiesOverride;
  13790. /**
  13791. * Gets or sets the animation properties override
  13792. */
  13793. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13794. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  13795. /**
  13796. * List of inspectable custom properties (used by the Inspector)
  13797. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13798. */
  13799. inspectableCustomProperties: IInspectable[];
  13800. /**
  13801. * An observable triggered before computing the skeleton's matrices
  13802. */
  13803. onBeforeComputeObservable: Observable<Skeleton>;
  13804. /**
  13805. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13806. */
  13807. get isUsingTextureForMatrices(): boolean;
  13808. /**
  13809. * Gets the unique ID of this skeleton
  13810. */
  13811. get uniqueId(): number;
  13812. /**
  13813. * Creates a new skeleton
  13814. * @param name defines the skeleton name
  13815. * @param id defines the skeleton Id
  13816. * @param scene defines the hosting scene
  13817. */
  13818. constructor(
  13819. /** defines the skeleton name */
  13820. name: string,
  13821. /** defines the skeleton Id */
  13822. id: string, scene: Scene);
  13823. /**
  13824. * Gets the current object class name.
  13825. * @return the class name
  13826. */
  13827. getClassName(): string;
  13828. /**
  13829. * Returns an array containing the root bones
  13830. * @returns an array containing the root bones
  13831. */
  13832. getChildren(): Array<Bone>;
  13833. /**
  13834. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13835. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13836. * @returns a Float32Array containing matrices data
  13837. */
  13838. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13839. /**
  13840. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13841. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13842. * @returns a raw texture containing the data
  13843. */
  13844. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13845. /**
  13846. * Gets the current hosting scene
  13847. * @returns a scene object
  13848. */
  13849. getScene(): Scene;
  13850. /**
  13851. * Gets a string representing the current skeleton data
  13852. * @param fullDetails defines a boolean indicating if we want a verbose version
  13853. * @returns a string representing the current skeleton data
  13854. */
  13855. toString(fullDetails?: boolean): string;
  13856. /**
  13857. * Get bone's index searching by name
  13858. * @param name defines bone's name to search for
  13859. * @return the indice of the bone. Returns -1 if not found
  13860. */
  13861. getBoneIndexByName(name: string): number;
  13862. /**
  13863. * Creater a new animation range
  13864. * @param name defines the name of the range
  13865. * @param from defines the start key
  13866. * @param to defines the end key
  13867. */
  13868. createAnimationRange(name: string, from: number, to: number): void;
  13869. /**
  13870. * Delete a specific animation range
  13871. * @param name defines the name of the range
  13872. * @param deleteFrames defines if frames must be removed as well
  13873. */
  13874. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13875. /**
  13876. * Gets a specific animation range
  13877. * @param name defines the name of the range to look for
  13878. * @returns the requested animation range or null if not found
  13879. */
  13880. getAnimationRange(name: string): Nullable<AnimationRange>;
  13881. /**
  13882. * Gets the list of all animation ranges defined on this skeleton
  13883. * @returns an array
  13884. */
  13885. getAnimationRanges(): Nullable<AnimationRange>[];
  13886. /**
  13887. * Copy animation range from a source skeleton.
  13888. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13889. * @param source defines the source skeleton
  13890. * @param name defines the name of the range to copy
  13891. * @param rescaleAsRequired defines if rescaling must be applied if required
  13892. * @returns true if operation was successful
  13893. */
  13894. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13895. /**
  13896. * Forces the skeleton to go to rest pose
  13897. */
  13898. returnToRest(): void;
  13899. private _getHighestAnimationFrame;
  13900. /**
  13901. * Begin a specific animation range
  13902. * @param name defines the name of the range to start
  13903. * @param loop defines if looping must be turned on (false by default)
  13904. * @param speedRatio defines the speed ratio to apply (1 by default)
  13905. * @param onAnimationEnd defines a callback which will be called when animation will end
  13906. * @returns a new animatable
  13907. */
  13908. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13909. /** @hidden */
  13910. _markAsDirty(): void;
  13911. /** @hidden */
  13912. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13913. /** @hidden */
  13914. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13915. private _computeTransformMatrices;
  13916. /**
  13917. * Build all resources required to render a skeleton
  13918. */
  13919. prepare(): void;
  13920. /**
  13921. * Gets the list of animatables currently running for this skeleton
  13922. * @returns an array of animatables
  13923. */
  13924. getAnimatables(): IAnimatable[];
  13925. /**
  13926. * Clone the current skeleton
  13927. * @param name defines the name of the new skeleton
  13928. * @param id defines the id of the new skeleton
  13929. * @returns the new skeleton
  13930. */
  13931. clone(name: string, id?: string): Skeleton;
  13932. /**
  13933. * Enable animation blending for this skeleton
  13934. * @param blendingSpeed defines the blending speed to apply
  13935. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13936. */
  13937. enableBlending(blendingSpeed?: number): void;
  13938. /**
  13939. * Releases all resources associated with the current skeleton
  13940. */
  13941. dispose(): void;
  13942. /**
  13943. * Serialize the skeleton in a JSON object
  13944. * @returns a JSON object
  13945. */
  13946. serialize(): any;
  13947. /**
  13948. * Creates a new skeleton from serialized data
  13949. * @param parsedSkeleton defines the serialized data
  13950. * @param scene defines the hosting scene
  13951. * @returns a new skeleton
  13952. */
  13953. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13954. /**
  13955. * Compute all node absolute transforms
  13956. * @param forceUpdate defines if computation must be done even if cache is up to date
  13957. */
  13958. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13959. /**
  13960. * Gets the root pose matrix
  13961. * @returns a matrix
  13962. */
  13963. getPoseMatrix(): Nullable<Matrix>;
  13964. /**
  13965. * Sorts bones per internal index
  13966. */
  13967. sortBones(): void;
  13968. private _sortBones;
  13969. }
  13970. }
  13971. declare module "babylonjs/Bones/bone" {
  13972. import { Skeleton } from "babylonjs/Bones/skeleton";
  13973. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13974. import { Nullable } from "babylonjs/types";
  13975. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13976. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13977. import { Node } from "babylonjs/node";
  13978. import { Space } from "babylonjs/Maths/math.axis";
  13979. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13980. /**
  13981. * Class used to store bone information
  13982. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13983. */
  13984. export class Bone extends Node {
  13985. /**
  13986. * defines the bone name
  13987. */
  13988. name: string;
  13989. private static _tmpVecs;
  13990. private static _tmpQuat;
  13991. private static _tmpMats;
  13992. /**
  13993. * Gets the list of child bones
  13994. */
  13995. children: Bone[];
  13996. /** Gets the animations associated with this bone */
  13997. animations: import("babylonjs/Animations/animation").Animation[];
  13998. /**
  13999. * Gets or sets bone length
  14000. */
  14001. length: number;
  14002. /**
  14003. * @hidden Internal only
  14004. * Set this value to map this bone to a different index in the transform matrices
  14005. * Set this value to -1 to exclude the bone from the transform matrices
  14006. */
  14007. _index: Nullable<number>;
  14008. private _skeleton;
  14009. private _localMatrix;
  14010. private _restPose;
  14011. private _baseMatrix;
  14012. private _absoluteTransform;
  14013. private _invertedAbsoluteTransform;
  14014. private _parent;
  14015. private _scalingDeterminant;
  14016. private _worldTransform;
  14017. private _localScaling;
  14018. private _localRotation;
  14019. private _localPosition;
  14020. private _needToDecompose;
  14021. private _needToCompose;
  14022. /** @hidden */
  14023. _linkedTransformNode: Nullable<TransformNode>;
  14024. /** @hidden */
  14025. _waitingTransformNodeId: Nullable<string>;
  14026. /** @hidden */
  14027. get _matrix(): Matrix;
  14028. /** @hidden */
  14029. set _matrix(value: Matrix);
  14030. /**
  14031. * Create a new bone
  14032. * @param name defines the bone name
  14033. * @param skeleton defines the parent skeleton
  14034. * @param parentBone defines the parent (can be null if the bone is the root)
  14035. * @param localMatrix defines the local matrix
  14036. * @param restPose defines the rest pose matrix
  14037. * @param baseMatrix defines the base matrix
  14038. * @param index defines index of the bone in the hiearchy
  14039. */
  14040. constructor(
  14041. /**
  14042. * defines the bone name
  14043. */
  14044. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14045. /**
  14046. * Gets the current object class name.
  14047. * @return the class name
  14048. */
  14049. getClassName(): string;
  14050. /**
  14051. * Gets the parent skeleton
  14052. * @returns a skeleton
  14053. */
  14054. getSkeleton(): Skeleton;
  14055. /**
  14056. * Gets parent bone
  14057. * @returns a bone or null if the bone is the root of the bone hierarchy
  14058. */
  14059. getParent(): Nullable<Bone>;
  14060. /**
  14061. * Returns an array containing the root bones
  14062. * @returns an array containing the root bones
  14063. */
  14064. getChildren(): Array<Bone>;
  14065. /**
  14066. * Gets the node index in matrix array generated for rendering
  14067. * @returns the node index
  14068. */
  14069. getIndex(): number;
  14070. /**
  14071. * Sets the parent bone
  14072. * @param parent defines the parent (can be null if the bone is the root)
  14073. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14074. */
  14075. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14076. /**
  14077. * Gets the local matrix
  14078. * @returns a matrix
  14079. */
  14080. getLocalMatrix(): Matrix;
  14081. /**
  14082. * Gets the base matrix (initial matrix which remains unchanged)
  14083. * @returns a matrix
  14084. */
  14085. getBaseMatrix(): Matrix;
  14086. /**
  14087. * Gets the rest pose matrix
  14088. * @returns a matrix
  14089. */
  14090. getRestPose(): Matrix;
  14091. /**
  14092. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14093. */
  14094. getWorldMatrix(): Matrix;
  14095. /**
  14096. * Sets the local matrix to rest pose matrix
  14097. */
  14098. returnToRest(): void;
  14099. /**
  14100. * Gets the inverse of the absolute transform matrix.
  14101. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14102. * @returns a matrix
  14103. */
  14104. getInvertedAbsoluteTransform(): Matrix;
  14105. /**
  14106. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14107. * @returns a matrix
  14108. */
  14109. getAbsoluteTransform(): Matrix;
  14110. /**
  14111. * Links with the given transform node.
  14112. * The local matrix of this bone is copied from the transform node every frame.
  14113. * @param transformNode defines the transform node to link to
  14114. */
  14115. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14116. /**
  14117. * Gets the node used to drive the bone's transformation
  14118. * @returns a transform node or null
  14119. */
  14120. getTransformNode(): Nullable<TransformNode>;
  14121. /** Gets or sets current position (in local space) */
  14122. get position(): Vector3;
  14123. set position(newPosition: Vector3);
  14124. /** Gets or sets current rotation (in local space) */
  14125. get rotation(): Vector3;
  14126. set rotation(newRotation: Vector3);
  14127. /** Gets or sets current rotation quaternion (in local space) */
  14128. get rotationQuaternion(): Quaternion;
  14129. set rotationQuaternion(newRotation: Quaternion);
  14130. /** Gets or sets current scaling (in local space) */
  14131. get scaling(): Vector3;
  14132. set scaling(newScaling: Vector3);
  14133. /**
  14134. * Gets the animation properties override
  14135. */
  14136. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14137. private _decompose;
  14138. private _compose;
  14139. /**
  14140. * Update the base and local matrices
  14141. * @param matrix defines the new base or local matrix
  14142. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14143. * @param updateLocalMatrix defines if the local matrix should be updated
  14144. */
  14145. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14146. /** @hidden */
  14147. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14148. /**
  14149. * Flag the bone as dirty (Forcing it to update everything)
  14150. */
  14151. markAsDirty(): void;
  14152. /** @hidden */
  14153. _markAsDirtyAndCompose(): void;
  14154. private _markAsDirtyAndDecompose;
  14155. /**
  14156. * Translate the bone in local or world space
  14157. * @param vec The amount to translate the bone
  14158. * @param space The space that the translation is in
  14159. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14160. */
  14161. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14162. /**
  14163. * Set the postion of the bone in local or world space
  14164. * @param position The position to set the bone
  14165. * @param space The space that the position is in
  14166. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14167. */
  14168. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14169. /**
  14170. * Set the absolute position of the bone (world space)
  14171. * @param position The position to set the bone
  14172. * @param mesh The mesh that this bone is attached to
  14173. */
  14174. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14175. /**
  14176. * Scale the bone on the x, y and z axes (in local space)
  14177. * @param x The amount to scale the bone on the x axis
  14178. * @param y The amount to scale the bone on the y axis
  14179. * @param z The amount to scale the bone on the z axis
  14180. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14181. */
  14182. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14183. /**
  14184. * Set the bone scaling in local space
  14185. * @param scale defines the scaling vector
  14186. */
  14187. setScale(scale: Vector3): void;
  14188. /**
  14189. * Gets the current scaling in local space
  14190. * @returns the current scaling vector
  14191. */
  14192. getScale(): Vector3;
  14193. /**
  14194. * Gets the current scaling in local space and stores it in a target vector
  14195. * @param result defines the target vector
  14196. */
  14197. getScaleToRef(result: Vector3): void;
  14198. /**
  14199. * Set the yaw, pitch, and roll of the bone in local or world space
  14200. * @param yaw The rotation of the bone on the y axis
  14201. * @param pitch The rotation of the bone on the x axis
  14202. * @param roll The rotation of the bone on the z axis
  14203. * @param space The space that the axes of rotation are in
  14204. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14205. */
  14206. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14207. /**
  14208. * Add a rotation to the bone on an axis in local or world space
  14209. * @param axis The axis to rotate the bone on
  14210. * @param amount The amount to rotate the bone
  14211. * @param space The space that the axis is in
  14212. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14213. */
  14214. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14215. /**
  14216. * Set the rotation of the bone to a particular axis angle in local or world space
  14217. * @param axis The axis to rotate the bone on
  14218. * @param angle The angle that the bone should be rotated to
  14219. * @param space The space that the axis is in
  14220. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14221. */
  14222. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14223. /**
  14224. * Set the euler rotation of the bone in local of world space
  14225. * @param rotation The euler rotation that the bone should be set to
  14226. * @param space The space that the rotation is in
  14227. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14228. */
  14229. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14230. /**
  14231. * Set the quaternion rotation of the bone in local of world space
  14232. * @param quat The quaternion rotation that the bone should be set to
  14233. * @param space The space that the rotation is in
  14234. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14235. */
  14236. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14237. /**
  14238. * Set the rotation matrix of the bone in local of world space
  14239. * @param rotMat The rotation matrix that the bone should be set to
  14240. * @param space The space that the rotation is in
  14241. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14242. */
  14243. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14244. private _rotateWithMatrix;
  14245. private _getNegativeRotationToRef;
  14246. /**
  14247. * Get the position of the bone in local or world space
  14248. * @param space The space that the returned position is in
  14249. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14250. * @returns The position of the bone
  14251. */
  14252. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14253. /**
  14254. * Copy the position of the bone to a vector3 in local or world space
  14255. * @param space The space that the returned position is in
  14256. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14257. * @param result The vector3 to copy the position to
  14258. */
  14259. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14260. /**
  14261. * Get the absolute position of the bone (world space)
  14262. * @param mesh The mesh that this bone is attached to
  14263. * @returns The absolute position of the bone
  14264. */
  14265. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14266. /**
  14267. * Copy the absolute position of the bone (world space) to the result param
  14268. * @param mesh The mesh that this bone is attached to
  14269. * @param result The vector3 to copy the absolute position to
  14270. */
  14271. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14272. /**
  14273. * Compute the absolute transforms of this bone and its children
  14274. */
  14275. computeAbsoluteTransforms(): void;
  14276. /**
  14277. * Get the world direction from an axis that is in the local space of the bone
  14278. * @param localAxis The local direction that is used to compute the world direction
  14279. * @param mesh The mesh that this bone is attached to
  14280. * @returns The world direction
  14281. */
  14282. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14283. /**
  14284. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14285. * @param localAxis The local direction that is used to compute the world direction
  14286. * @param mesh The mesh that this bone is attached to
  14287. * @param result The vector3 that the world direction will be copied to
  14288. */
  14289. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14290. /**
  14291. * Get the euler rotation of the bone in local or world space
  14292. * @param space The space that the rotation should be in
  14293. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14294. * @returns The euler rotation
  14295. */
  14296. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14297. /**
  14298. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14299. * @param space The space that the rotation should be in
  14300. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14301. * @param result The vector3 that the rotation should be copied to
  14302. */
  14303. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14304. /**
  14305. * Get the quaternion rotation of the bone in either local or world space
  14306. * @param space The space that the rotation should be in
  14307. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14308. * @returns The quaternion rotation
  14309. */
  14310. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14311. /**
  14312. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14313. * @param space The space that the rotation should be in
  14314. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14315. * @param result The quaternion that the rotation should be copied to
  14316. */
  14317. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14318. /**
  14319. * Get the rotation matrix of the bone in local or world space
  14320. * @param space The space that the rotation should be in
  14321. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14322. * @returns The rotation matrix
  14323. */
  14324. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14325. /**
  14326. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14327. * @param space The space that the rotation should be in
  14328. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14329. * @param result The quaternion that the rotation should be copied to
  14330. */
  14331. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14332. /**
  14333. * Get the world position of a point that is in the local space of the bone
  14334. * @param position The local position
  14335. * @param mesh The mesh that this bone is attached to
  14336. * @returns The world position
  14337. */
  14338. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14339. /**
  14340. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14341. * @param position The local position
  14342. * @param mesh The mesh that this bone is attached to
  14343. * @param result The vector3 that the world position should be copied to
  14344. */
  14345. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14346. /**
  14347. * Get the local position of a point that is in world space
  14348. * @param position The world position
  14349. * @param mesh The mesh that this bone is attached to
  14350. * @returns The local position
  14351. */
  14352. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14353. /**
  14354. * Get the local position of a point that is in world space and copy it to the result param
  14355. * @param position The world position
  14356. * @param mesh The mesh that this bone is attached to
  14357. * @param result The vector3 that the local position should be copied to
  14358. */
  14359. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14360. }
  14361. }
  14362. declare module "babylonjs/Meshes/transformNode" {
  14363. import { DeepImmutable } from "babylonjs/types";
  14364. import { Observable } from "babylonjs/Misc/observable";
  14365. import { Nullable } from "babylonjs/types";
  14366. import { Camera } from "babylonjs/Cameras/camera";
  14367. import { Scene } from "babylonjs/scene";
  14368. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14369. import { Node } from "babylonjs/node";
  14370. import { Bone } from "babylonjs/Bones/bone";
  14371. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14372. import { Space } from "babylonjs/Maths/math.axis";
  14373. /**
  14374. * 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.
  14375. * @see https://doc.babylonjs.com/how_to/transformnode
  14376. */
  14377. export class TransformNode extends Node {
  14378. /**
  14379. * Object will not rotate to face the camera
  14380. */
  14381. static BILLBOARDMODE_NONE: number;
  14382. /**
  14383. * Object will rotate to face the camera but only on the x axis
  14384. */
  14385. static BILLBOARDMODE_X: number;
  14386. /**
  14387. * Object will rotate to face the camera but only on the y axis
  14388. */
  14389. static BILLBOARDMODE_Y: number;
  14390. /**
  14391. * Object will rotate to face the camera but only on the z axis
  14392. */
  14393. static BILLBOARDMODE_Z: number;
  14394. /**
  14395. * Object will rotate to face the camera
  14396. */
  14397. static BILLBOARDMODE_ALL: number;
  14398. /**
  14399. * Object will rotate to face the camera's position instead of orientation
  14400. */
  14401. static BILLBOARDMODE_USE_POSITION: number;
  14402. private _forward;
  14403. private _forwardInverted;
  14404. private _up;
  14405. private _right;
  14406. private _rightInverted;
  14407. private _position;
  14408. private _rotation;
  14409. private _rotationQuaternion;
  14410. protected _scaling: Vector3;
  14411. protected _isDirty: boolean;
  14412. private _transformToBoneReferal;
  14413. private _isAbsoluteSynced;
  14414. private _billboardMode;
  14415. /**
  14416. * Gets or sets the billboard mode. Default is 0.
  14417. *
  14418. * | Value | Type | Description |
  14419. * | --- | --- | --- |
  14420. * | 0 | BILLBOARDMODE_NONE | |
  14421. * | 1 | BILLBOARDMODE_X | |
  14422. * | 2 | BILLBOARDMODE_Y | |
  14423. * | 4 | BILLBOARDMODE_Z | |
  14424. * | 7 | BILLBOARDMODE_ALL | |
  14425. *
  14426. */
  14427. get billboardMode(): number;
  14428. set billboardMode(value: number);
  14429. private _preserveParentRotationForBillboard;
  14430. /**
  14431. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14432. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14433. */
  14434. get preserveParentRotationForBillboard(): boolean;
  14435. set preserveParentRotationForBillboard(value: boolean);
  14436. /**
  14437. * 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
  14438. */
  14439. scalingDeterminant: number;
  14440. private _infiniteDistance;
  14441. /**
  14442. * Gets or sets the distance of the object to max, often used by skybox
  14443. */
  14444. get infiniteDistance(): boolean;
  14445. set infiniteDistance(value: boolean);
  14446. /**
  14447. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14448. * By default the system will update normals to compensate
  14449. */
  14450. ignoreNonUniformScaling: boolean;
  14451. /**
  14452. * 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
  14453. */
  14454. reIntegrateRotationIntoRotationQuaternion: boolean;
  14455. /** @hidden */
  14456. _poseMatrix: Nullable<Matrix>;
  14457. /** @hidden */
  14458. _localMatrix: Matrix;
  14459. private _usePivotMatrix;
  14460. private _absolutePosition;
  14461. private _absoluteScaling;
  14462. private _absoluteRotationQuaternion;
  14463. private _pivotMatrix;
  14464. private _pivotMatrixInverse;
  14465. protected _postMultiplyPivotMatrix: boolean;
  14466. protected _isWorldMatrixFrozen: boolean;
  14467. /** @hidden */
  14468. _indexInSceneTransformNodesArray: number;
  14469. /**
  14470. * An event triggered after the world matrix is updated
  14471. */
  14472. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14473. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14474. /**
  14475. * Gets a string identifying the name of the class
  14476. * @returns "TransformNode" string
  14477. */
  14478. getClassName(): string;
  14479. /**
  14480. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14481. */
  14482. get position(): Vector3;
  14483. set position(newPosition: Vector3);
  14484. /**
  14485. * 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)).
  14486. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14487. */
  14488. get rotation(): Vector3;
  14489. set rotation(newRotation: Vector3);
  14490. /**
  14491. * 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)).
  14492. */
  14493. get scaling(): Vector3;
  14494. set scaling(newScaling: Vector3);
  14495. /**
  14496. * 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).
  14497. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14498. */
  14499. get rotationQuaternion(): Nullable<Quaternion>;
  14500. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14501. /**
  14502. * The forward direction of that transform in world space.
  14503. */
  14504. get forward(): Vector3;
  14505. /**
  14506. * The up direction of that transform in world space.
  14507. */
  14508. get up(): Vector3;
  14509. /**
  14510. * The right direction of that transform in world space.
  14511. */
  14512. get right(): Vector3;
  14513. /**
  14514. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14515. * @param matrix the matrix to copy the pose from
  14516. * @returns this TransformNode.
  14517. */
  14518. updatePoseMatrix(matrix: Matrix): TransformNode;
  14519. /**
  14520. * Returns the mesh Pose matrix.
  14521. * @returns the pose matrix
  14522. */
  14523. getPoseMatrix(): Matrix;
  14524. /** @hidden */
  14525. _isSynchronized(): boolean;
  14526. /** @hidden */
  14527. _initCache(): void;
  14528. /**
  14529. * Flag the transform node as dirty (Forcing it to update everything)
  14530. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14531. * @returns this transform node
  14532. */
  14533. markAsDirty(property: string): TransformNode;
  14534. /**
  14535. * Returns the current mesh absolute position.
  14536. * Returns a Vector3.
  14537. */
  14538. get absolutePosition(): Vector3;
  14539. /**
  14540. * Returns the current mesh absolute scaling.
  14541. * Returns a Vector3.
  14542. */
  14543. get absoluteScaling(): Vector3;
  14544. /**
  14545. * Returns the current mesh absolute rotation.
  14546. * Returns a Quaternion.
  14547. */
  14548. get absoluteRotationQuaternion(): Quaternion;
  14549. /**
  14550. * Sets a new matrix to apply before all other transformation
  14551. * @param matrix defines the transform matrix
  14552. * @returns the current TransformNode
  14553. */
  14554. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14555. /**
  14556. * Sets a new pivot matrix to the current node
  14557. * @param matrix defines the new pivot matrix to use
  14558. * @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
  14559. * @returns the current TransformNode
  14560. */
  14561. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14562. /**
  14563. * Returns the mesh pivot matrix.
  14564. * Default : Identity.
  14565. * @returns the matrix
  14566. */
  14567. getPivotMatrix(): Matrix;
  14568. /**
  14569. * Instantiate (when possible) or clone that node with its hierarchy
  14570. * @param newParent defines the new parent to use for the instance (or clone)
  14571. * @param options defines options to configure how copy is done
  14572. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14573. * @returns an instance (or a clone) of the current node with its hiearchy
  14574. */
  14575. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14576. doNotInstantiate: boolean;
  14577. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14578. /**
  14579. * Prevents the World matrix to be computed any longer
  14580. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14581. * @returns the TransformNode.
  14582. */
  14583. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14584. /**
  14585. * Allows back the World matrix computation.
  14586. * @returns the TransformNode.
  14587. */
  14588. unfreezeWorldMatrix(): this;
  14589. /**
  14590. * True if the World matrix has been frozen.
  14591. */
  14592. get isWorldMatrixFrozen(): boolean;
  14593. /**
  14594. * Retuns the mesh absolute position in the World.
  14595. * @returns a Vector3.
  14596. */
  14597. getAbsolutePosition(): Vector3;
  14598. /**
  14599. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14600. * @param absolutePosition the absolute position to set
  14601. * @returns the TransformNode.
  14602. */
  14603. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14604. /**
  14605. * Sets the mesh position in its local space.
  14606. * @param vector3 the position to set in localspace
  14607. * @returns the TransformNode.
  14608. */
  14609. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14610. /**
  14611. * Returns the mesh position in the local space from the current World matrix values.
  14612. * @returns a new Vector3.
  14613. */
  14614. getPositionExpressedInLocalSpace(): Vector3;
  14615. /**
  14616. * Translates the mesh along the passed Vector3 in its local space.
  14617. * @param vector3 the distance to translate in localspace
  14618. * @returns the TransformNode.
  14619. */
  14620. locallyTranslate(vector3: Vector3): TransformNode;
  14621. private static _lookAtVectorCache;
  14622. /**
  14623. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14624. * @param targetPoint the position (must be in same space as current mesh) to look at
  14625. * @param yawCor optional yaw (y-axis) correction in radians
  14626. * @param pitchCor optional pitch (x-axis) correction in radians
  14627. * @param rollCor optional roll (z-axis) correction in radians
  14628. * @param space the choosen space of the target
  14629. * @returns the TransformNode.
  14630. */
  14631. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14632. /**
  14633. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14634. * This Vector3 is expressed in the World space.
  14635. * @param localAxis axis to rotate
  14636. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14637. */
  14638. getDirection(localAxis: Vector3): Vector3;
  14639. /**
  14640. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14641. * localAxis is expressed in the mesh local space.
  14642. * result is computed in the Wordl space from the mesh World matrix.
  14643. * @param localAxis axis to rotate
  14644. * @param result the resulting transformnode
  14645. * @returns this TransformNode.
  14646. */
  14647. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14648. /**
  14649. * Sets this transform node rotation to the given local axis.
  14650. * @param localAxis the axis in local space
  14651. * @param yawCor optional yaw (y-axis) correction in radians
  14652. * @param pitchCor optional pitch (x-axis) correction in radians
  14653. * @param rollCor optional roll (z-axis) correction in radians
  14654. * @returns this TransformNode
  14655. */
  14656. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14657. /**
  14658. * Sets a new pivot point to the current node
  14659. * @param point defines the new pivot point to use
  14660. * @param space defines if the point is in world or local space (local by default)
  14661. * @returns the current TransformNode
  14662. */
  14663. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14664. /**
  14665. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14666. * @returns the pivot point
  14667. */
  14668. getPivotPoint(): Vector3;
  14669. /**
  14670. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14671. * @param result the vector3 to store the result
  14672. * @returns this TransformNode.
  14673. */
  14674. getPivotPointToRef(result: Vector3): TransformNode;
  14675. /**
  14676. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14677. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14678. */
  14679. getAbsolutePivotPoint(): Vector3;
  14680. /**
  14681. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14682. * @param result vector3 to store the result
  14683. * @returns this TransformNode.
  14684. */
  14685. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14686. /**
  14687. * Defines the passed node as the parent of the current node.
  14688. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14689. * @see https://doc.babylonjs.com/how_to/parenting
  14690. * @param node the node ot set as the parent
  14691. * @returns this TransformNode.
  14692. */
  14693. setParent(node: Nullable<Node>): TransformNode;
  14694. private _nonUniformScaling;
  14695. /**
  14696. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14697. */
  14698. get nonUniformScaling(): boolean;
  14699. /** @hidden */
  14700. _updateNonUniformScalingState(value: boolean): boolean;
  14701. /**
  14702. * Attach the current TransformNode to another TransformNode associated with a bone
  14703. * @param bone Bone affecting the TransformNode
  14704. * @param affectedTransformNode TransformNode associated with the bone
  14705. * @returns this object
  14706. */
  14707. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14708. /**
  14709. * Detach the transform node if its associated with a bone
  14710. * @returns this object
  14711. */
  14712. detachFromBone(): TransformNode;
  14713. private static _rotationAxisCache;
  14714. /**
  14715. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14716. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14717. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14718. * The passed axis is also normalized.
  14719. * @param axis the axis to rotate around
  14720. * @param amount the amount to rotate in radians
  14721. * @param space Space to rotate in (Default: local)
  14722. * @returns the TransformNode.
  14723. */
  14724. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14725. /**
  14726. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14727. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14728. * The passed axis is also normalized. .
  14729. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14730. * @param point the point to rotate around
  14731. * @param axis the axis to rotate around
  14732. * @param amount the amount to rotate in radians
  14733. * @returns the TransformNode
  14734. */
  14735. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14736. /**
  14737. * Translates the mesh along the axis vector for the passed distance in the given space.
  14738. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14739. * @param axis the axis to translate in
  14740. * @param distance the distance to translate
  14741. * @param space Space to rotate in (Default: local)
  14742. * @returns the TransformNode.
  14743. */
  14744. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14745. /**
  14746. * Adds a rotation step to the mesh current rotation.
  14747. * x, y, z are Euler angles expressed in radians.
  14748. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14749. * This means this rotation is made in the mesh local space only.
  14750. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14751. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14752. * ```javascript
  14753. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14754. * ```
  14755. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14756. * 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.
  14757. * @param x Rotation to add
  14758. * @param y Rotation to add
  14759. * @param z Rotation to add
  14760. * @returns the TransformNode.
  14761. */
  14762. addRotation(x: number, y: number, z: number): TransformNode;
  14763. /**
  14764. * @hidden
  14765. */
  14766. protected _getEffectiveParent(): Nullable<Node>;
  14767. /**
  14768. * Computes the world matrix of the node
  14769. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14770. * @returns the world matrix
  14771. */
  14772. computeWorldMatrix(force?: boolean): Matrix;
  14773. protected _afterComputeWorldMatrix(): void;
  14774. /**
  14775. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14776. * @param func callback function to add
  14777. *
  14778. * @returns the TransformNode.
  14779. */
  14780. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14781. /**
  14782. * Removes a registered callback function.
  14783. * @param func callback function to remove
  14784. * @returns the TransformNode.
  14785. */
  14786. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14787. /**
  14788. * Gets the position of the current mesh in camera space
  14789. * @param camera defines the camera to use
  14790. * @returns a position
  14791. */
  14792. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14793. /**
  14794. * Returns the distance from the mesh to the active camera
  14795. * @param camera defines the camera to use
  14796. * @returns the distance
  14797. */
  14798. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14799. /**
  14800. * Clone the current transform node
  14801. * @param name Name of the new clone
  14802. * @param newParent New parent for the clone
  14803. * @param doNotCloneChildren Do not clone children hierarchy
  14804. * @returns the new transform node
  14805. */
  14806. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14807. /**
  14808. * Serializes the objects information.
  14809. * @param currentSerializationObject defines the object to serialize in
  14810. * @returns the serialized object
  14811. */
  14812. serialize(currentSerializationObject?: any): any;
  14813. /**
  14814. * Returns a new TransformNode object parsed from the source provided.
  14815. * @param parsedTransformNode is the source.
  14816. * @param scene the scne the object belongs to
  14817. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14818. * @returns a new TransformNode object parsed from the source provided.
  14819. */
  14820. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14821. /**
  14822. * Get all child-transformNodes of this node
  14823. * @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
  14824. * @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
  14825. * @returns an array of TransformNode
  14826. */
  14827. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14828. /**
  14829. * Releases resources associated with this transform node.
  14830. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14831. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14832. */
  14833. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14834. /**
  14835. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14836. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14837. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14838. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14839. * @returns the current mesh
  14840. */
  14841. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14842. private _syncAbsoluteScalingAndRotation;
  14843. }
  14844. }
  14845. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14846. import { Observable } from "babylonjs/Misc/observable";
  14847. import { Nullable } from "babylonjs/types";
  14848. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14849. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14850. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14851. import { Ray } from "babylonjs/Culling/ray";
  14852. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14853. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14854. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14855. /**
  14856. * Defines the types of pose enabled controllers that are supported
  14857. */
  14858. export enum PoseEnabledControllerType {
  14859. /**
  14860. * HTC Vive
  14861. */
  14862. VIVE = 0,
  14863. /**
  14864. * Oculus Rift
  14865. */
  14866. OCULUS = 1,
  14867. /**
  14868. * Windows mixed reality
  14869. */
  14870. WINDOWS = 2,
  14871. /**
  14872. * Samsung gear VR
  14873. */
  14874. GEAR_VR = 3,
  14875. /**
  14876. * Google Daydream
  14877. */
  14878. DAYDREAM = 4,
  14879. /**
  14880. * Generic
  14881. */
  14882. GENERIC = 5
  14883. }
  14884. /**
  14885. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14886. */
  14887. export interface MutableGamepadButton {
  14888. /**
  14889. * Value of the button/trigger
  14890. */
  14891. value: number;
  14892. /**
  14893. * If the button/trigger is currently touched
  14894. */
  14895. touched: boolean;
  14896. /**
  14897. * If the button/trigger is currently pressed
  14898. */
  14899. pressed: boolean;
  14900. }
  14901. /**
  14902. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14903. * @hidden
  14904. */
  14905. export interface ExtendedGamepadButton extends GamepadButton {
  14906. /**
  14907. * If the button/trigger is currently pressed
  14908. */
  14909. readonly pressed: boolean;
  14910. /**
  14911. * If the button/trigger is currently touched
  14912. */
  14913. readonly touched: boolean;
  14914. /**
  14915. * Value of the button/trigger
  14916. */
  14917. readonly value: number;
  14918. }
  14919. /** @hidden */
  14920. export interface _GamePadFactory {
  14921. /**
  14922. * Returns wether or not the current gamepad can be created for this type of controller.
  14923. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14924. * @returns true if it can be created, otherwise false
  14925. */
  14926. canCreate(gamepadInfo: any): boolean;
  14927. /**
  14928. * Creates a new instance of the Gamepad.
  14929. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14930. * @returns the new gamepad instance
  14931. */
  14932. create(gamepadInfo: any): Gamepad;
  14933. }
  14934. /**
  14935. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14936. */
  14937. export class PoseEnabledControllerHelper {
  14938. /** @hidden */
  14939. static _ControllerFactories: _GamePadFactory[];
  14940. /** @hidden */
  14941. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14942. /**
  14943. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14944. * @param vrGamepad the gamepad to initialized
  14945. * @returns a vr controller of the type the gamepad identified as
  14946. */
  14947. static InitiateController(vrGamepad: any): Gamepad;
  14948. }
  14949. /**
  14950. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14951. */
  14952. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14953. /**
  14954. * If the controller is used in a webXR session
  14955. */
  14956. isXR: boolean;
  14957. private _deviceRoomPosition;
  14958. private _deviceRoomRotationQuaternion;
  14959. /**
  14960. * The device position in babylon space
  14961. */
  14962. devicePosition: Vector3;
  14963. /**
  14964. * The device rotation in babylon space
  14965. */
  14966. deviceRotationQuaternion: Quaternion;
  14967. /**
  14968. * The scale factor of the device in babylon space
  14969. */
  14970. deviceScaleFactor: number;
  14971. /**
  14972. * (Likely devicePosition should be used instead) The device position in its room space
  14973. */
  14974. position: Vector3;
  14975. /**
  14976. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14977. */
  14978. rotationQuaternion: Quaternion;
  14979. /**
  14980. * The type of controller (Eg. Windows mixed reality)
  14981. */
  14982. controllerType: PoseEnabledControllerType;
  14983. protected _calculatedPosition: Vector3;
  14984. private _calculatedRotation;
  14985. /**
  14986. * The raw pose from the device
  14987. */
  14988. rawPose: DevicePose;
  14989. private _trackPosition;
  14990. private _maxRotationDistFromHeadset;
  14991. private _draggedRoomRotation;
  14992. /**
  14993. * @hidden
  14994. */
  14995. _disableTrackPosition(fixedPosition: Vector3): void;
  14996. /**
  14997. * Internal, the mesh attached to the controller
  14998. * @hidden
  14999. */
  15000. _mesh: Nullable<AbstractMesh>;
  15001. private _poseControlledCamera;
  15002. private _leftHandSystemQuaternion;
  15003. /**
  15004. * Internal, matrix used to convert room space to babylon space
  15005. * @hidden
  15006. */
  15007. _deviceToWorld: Matrix;
  15008. /**
  15009. * Node to be used when casting a ray from the controller
  15010. * @hidden
  15011. */
  15012. _pointingPoseNode: Nullable<TransformNode>;
  15013. /**
  15014. * Name of the child mesh that can be used to cast a ray from the controller
  15015. */
  15016. static readonly POINTING_POSE: string;
  15017. /**
  15018. * Creates a new PoseEnabledController from a gamepad
  15019. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  15020. */
  15021. constructor(browserGamepad: any);
  15022. private _workingMatrix;
  15023. /**
  15024. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  15025. */
  15026. update(): void;
  15027. /**
  15028. * Updates only the pose device and mesh without doing any button event checking
  15029. */
  15030. protected _updatePoseAndMesh(): void;
  15031. /**
  15032. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  15033. * @param poseData raw pose fromthe device
  15034. */
  15035. updateFromDevice(poseData: DevicePose): void;
  15036. /**
  15037. * @hidden
  15038. */
  15039. _meshAttachedObservable: Observable<AbstractMesh>;
  15040. /**
  15041. * Attaches a mesh to the controller
  15042. * @param mesh the mesh to be attached
  15043. */
  15044. attachToMesh(mesh: AbstractMesh): void;
  15045. /**
  15046. * Attaches the controllers mesh to a camera
  15047. * @param camera the camera the mesh should be attached to
  15048. */
  15049. attachToPoseControlledCamera(camera: TargetCamera): void;
  15050. /**
  15051. * Disposes of the controller
  15052. */
  15053. dispose(): void;
  15054. /**
  15055. * The mesh that is attached to the controller
  15056. */
  15057. get mesh(): Nullable<AbstractMesh>;
  15058. /**
  15059. * Gets the ray of the controller in the direction the controller is pointing
  15060. * @param length the length the resulting ray should be
  15061. * @returns a ray in the direction the controller is pointing
  15062. */
  15063. getForwardRay(length?: number): Ray;
  15064. }
  15065. }
  15066. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  15067. import { Observable } from "babylonjs/Misc/observable";
  15068. import { Scene } from "babylonjs/scene";
  15069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15070. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  15071. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  15072. import { Nullable } from "babylonjs/types";
  15073. /**
  15074. * Defines the WebVRController object that represents controllers tracked in 3D space
  15075. */
  15076. export abstract class WebVRController extends PoseEnabledController {
  15077. /**
  15078. * Internal, the default controller model for the controller
  15079. */
  15080. protected _defaultModel: Nullable<AbstractMesh>;
  15081. /**
  15082. * Fired when the trigger state has changed
  15083. */
  15084. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  15085. /**
  15086. * Fired when the main button state has changed
  15087. */
  15088. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  15089. /**
  15090. * Fired when the secondary button state has changed
  15091. */
  15092. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  15093. /**
  15094. * Fired when the pad state has changed
  15095. */
  15096. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  15097. /**
  15098. * Fired when controllers stick values have changed
  15099. */
  15100. onPadValuesChangedObservable: Observable<StickValues>;
  15101. /**
  15102. * Array of button availible on the controller
  15103. */
  15104. protected _buttons: Array<MutableGamepadButton>;
  15105. private _onButtonStateChange;
  15106. /**
  15107. * Fired when a controller button's state has changed
  15108. * @param callback the callback containing the button that was modified
  15109. */
  15110. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  15111. /**
  15112. * X and Y axis corresponding to the controllers joystick
  15113. */
  15114. pad: StickValues;
  15115. /**
  15116. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  15117. */
  15118. hand: string;
  15119. /**
  15120. * The default controller model for the controller
  15121. */
  15122. get defaultModel(): Nullable<AbstractMesh>;
  15123. /**
  15124. * Creates a new WebVRController from a gamepad
  15125. * @param vrGamepad the gamepad that the WebVRController should be created from
  15126. */
  15127. constructor(vrGamepad: any);
  15128. /**
  15129. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  15130. */
  15131. update(): void;
  15132. /**
  15133. * Function to be called when a button is modified
  15134. */
  15135. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  15136. /**
  15137. * Loads a mesh and attaches it to the controller
  15138. * @param scene the scene the mesh should be added to
  15139. * @param meshLoaded callback for when the mesh has been loaded
  15140. */
  15141. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  15142. private _setButtonValue;
  15143. private _changes;
  15144. private _checkChanges;
  15145. /**
  15146. * Disposes of th webVRCOntroller
  15147. */
  15148. dispose(): void;
  15149. }
  15150. }
  15151. declare module "babylonjs/Lights/hemisphericLight" {
  15152. import { Nullable } from "babylonjs/types";
  15153. import { Scene } from "babylonjs/scene";
  15154. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15155. import { Color3 } from "babylonjs/Maths/math.color";
  15156. import { Effect } from "babylonjs/Materials/effect";
  15157. import { Light } from "babylonjs/Lights/light";
  15158. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  15159. /**
  15160. * The HemisphericLight simulates the ambient environment light,
  15161. * so the passed direction is the light reflection direction, not the incoming direction.
  15162. */
  15163. export class HemisphericLight extends Light {
  15164. /**
  15165. * The groundColor is the light in the opposite direction to the one specified during creation.
  15166. * 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.
  15167. */
  15168. groundColor: Color3;
  15169. /**
  15170. * The light reflection direction, not the incoming direction.
  15171. */
  15172. direction: Vector3;
  15173. /**
  15174. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15175. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15176. * The HemisphericLight can't cast shadows.
  15177. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15178. * @param name The friendly name of the light
  15179. * @param direction The direction of the light reflection
  15180. * @param scene The scene the light belongs to
  15181. */
  15182. constructor(name: string, direction: Vector3, scene: Scene);
  15183. protected _buildUniformLayout(): void;
  15184. /**
  15185. * Returns the string "HemisphericLight".
  15186. * @return The class name
  15187. */
  15188. getClassName(): string;
  15189. /**
  15190. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15191. * Returns the updated direction.
  15192. * @param target The target the direction should point to
  15193. * @return The computed direction
  15194. */
  15195. setDirectionToTarget(target: Vector3): Vector3;
  15196. /**
  15197. * Returns the shadow generator associated to the light.
  15198. * @returns Always null for hemispheric lights because it does not support shadows.
  15199. */
  15200. getShadowGenerator(): Nullable<IShadowGenerator>;
  15201. /**
  15202. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15203. * @param effect The effect to update
  15204. * @param lightIndex The index of the light in the effect to update
  15205. * @returns The hemispheric light
  15206. */
  15207. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15208. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  15209. /**
  15210. * Computes the world matrix of the node
  15211. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15212. * @param useWasUpdatedFlag defines a reserved property
  15213. * @returns the world matrix
  15214. */
  15215. computeWorldMatrix(): Matrix;
  15216. /**
  15217. * Returns the integer 3.
  15218. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15219. */
  15220. getTypeID(): number;
  15221. /**
  15222. * Prepares the list of defines specific to the light type.
  15223. * @param defines the list of defines
  15224. * @param lightIndex defines the index of the light for the effect
  15225. */
  15226. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15227. }
  15228. }
  15229. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  15230. /** @hidden */
  15231. export var vrMultiviewToSingleviewPixelShader: {
  15232. name: string;
  15233. shader: string;
  15234. };
  15235. }
  15236. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15237. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15238. import { Scene } from "babylonjs/scene";
  15239. /**
  15240. * Renders to multiple views with a single draw call
  15241. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15242. */
  15243. export class MultiviewRenderTarget extends RenderTargetTexture {
  15244. /**
  15245. * Creates a multiview render target
  15246. * @param scene scene used with the render target
  15247. * @param size the size of the render target (used for each view)
  15248. */
  15249. constructor(scene: Scene, size?: number | {
  15250. width: number;
  15251. height: number;
  15252. } | {
  15253. ratio: number;
  15254. });
  15255. /**
  15256. * @hidden
  15257. * @param faceIndex the face index, if its a cube texture
  15258. */
  15259. _bindFrameBuffer(faceIndex?: number): void;
  15260. /**
  15261. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15262. * @returns the view count
  15263. */
  15264. getViewCount(): number;
  15265. }
  15266. }
  15267. declare module "babylonjs/Maths/math.frustum" {
  15268. import { Matrix } from "babylonjs/Maths/math.vector";
  15269. import { DeepImmutable } from "babylonjs/types";
  15270. import { Plane } from "babylonjs/Maths/math.plane";
  15271. /**
  15272. * Represents a camera frustum
  15273. */
  15274. export class Frustum {
  15275. /**
  15276. * Gets the planes representing the frustum
  15277. * @param transform matrix to be applied to the returned planes
  15278. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15279. */
  15280. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15281. /**
  15282. * Gets the near frustum plane transformed by the transform matrix
  15283. * @param transform transformation matrix to be applied to the resulting frustum plane
  15284. * @param frustumPlane the resuling frustum plane
  15285. */
  15286. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15287. /**
  15288. * Gets the far frustum plane transformed by the transform matrix
  15289. * @param transform transformation matrix to be applied to the resulting frustum plane
  15290. * @param frustumPlane the resuling frustum plane
  15291. */
  15292. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15293. /**
  15294. * Gets the left frustum plane transformed by the transform matrix
  15295. * @param transform transformation matrix to be applied to the resulting frustum plane
  15296. * @param frustumPlane the resuling frustum plane
  15297. */
  15298. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15299. /**
  15300. * Gets the right frustum plane transformed by the transform matrix
  15301. * @param transform transformation matrix to be applied to the resulting frustum plane
  15302. * @param frustumPlane the resuling frustum plane
  15303. */
  15304. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15305. /**
  15306. * Gets the top frustum plane transformed by the transform matrix
  15307. * @param transform transformation matrix to be applied to the resulting frustum plane
  15308. * @param frustumPlane the resuling frustum plane
  15309. */
  15310. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15311. /**
  15312. * Gets the bottom frustum plane transformed by the transform matrix
  15313. * @param transform transformation matrix to be applied to the resulting frustum plane
  15314. * @param frustumPlane the resuling frustum plane
  15315. */
  15316. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15317. /**
  15318. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15319. * @param transform transformation matrix to be applied to the resulting frustum planes
  15320. * @param frustumPlanes the resuling frustum planes
  15321. */
  15322. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15323. }
  15324. }
  15325. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15326. import { Camera } from "babylonjs/Cameras/camera";
  15327. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15328. import { Nullable } from "babylonjs/types";
  15329. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15330. import { Matrix } from "babylonjs/Maths/math.vector";
  15331. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15332. module "babylonjs/Engines/engine" {
  15333. interface Engine {
  15334. /**
  15335. * Creates a new multiview render target
  15336. * @param width defines the width of the texture
  15337. * @param height defines the height of the texture
  15338. * @returns the created multiview texture
  15339. */
  15340. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15341. /**
  15342. * Binds a multiview framebuffer to be drawn to
  15343. * @param multiviewTexture texture to bind
  15344. */
  15345. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15346. }
  15347. }
  15348. module "babylonjs/Cameras/camera" {
  15349. interface Camera {
  15350. /**
  15351. * @hidden
  15352. * 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)
  15353. */
  15354. _useMultiviewToSingleView: boolean;
  15355. /**
  15356. * @hidden
  15357. * 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)
  15358. */
  15359. _multiviewTexture: Nullable<RenderTargetTexture>;
  15360. /**
  15361. * @hidden
  15362. * ensures the multiview texture of the camera exists and has the specified width/height
  15363. * @param width height to set on the multiview texture
  15364. * @param height width to set on the multiview texture
  15365. */
  15366. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15367. }
  15368. }
  15369. module "babylonjs/scene" {
  15370. interface Scene {
  15371. /** @hidden */
  15372. _transformMatrixR: Matrix;
  15373. /** @hidden */
  15374. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15375. /** @hidden */
  15376. _createMultiviewUbo(): void;
  15377. /** @hidden */
  15378. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15379. /** @hidden */
  15380. _renderMultiviewToSingleView(camera: Camera): void;
  15381. }
  15382. }
  15383. }
  15384. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15385. import { Camera } from "babylonjs/Cameras/camera";
  15386. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15387. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15388. import "babylonjs/Engines/Extensions/engine.multiview";
  15389. /**
  15390. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15391. * This will not be used for webXR as it supports displaying texture arrays directly
  15392. */
  15393. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15394. /**
  15395. * Initializes a VRMultiviewToSingleview
  15396. * @param name name of the post process
  15397. * @param camera camera to be applied to
  15398. * @param scaleFactor scaling factor to the size of the output texture
  15399. */
  15400. constructor(name: string, camera: Camera, scaleFactor: number);
  15401. }
  15402. }
  15403. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15404. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15405. import { Nullable } from "babylonjs/types";
  15406. import { Size } from "babylonjs/Maths/math.size";
  15407. import { Observable } from "babylonjs/Misc/observable";
  15408. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  15409. /**
  15410. * Interface used to define additional presentation attributes
  15411. */
  15412. export interface IVRPresentationAttributes {
  15413. /**
  15414. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15415. */
  15416. highRefreshRate: boolean;
  15417. /**
  15418. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15419. */
  15420. foveationLevel: number;
  15421. }
  15422. module "babylonjs/Engines/engine" {
  15423. interface Engine {
  15424. /** @hidden */
  15425. _vrDisplay: any;
  15426. /** @hidden */
  15427. _vrSupported: boolean;
  15428. /** @hidden */
  15429. _oldSize: Size;
  15430. /** @hidden */
  15431. _oldHardwareScaleFactor: number;
  15432. /** @hidden */
  15433. _vrExclusivePointerMode: boolean;
  15434. /** @hidden */
  15435. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15436. /** @hidden */
  15437. _onVRDisplayPointerRestricted: () => void;
  15438. /** @hidden */
  15439. _onVRDisplayPointerUnrestricted: () => void;
  15440. /** @hidden */
  15441. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15442. /** @hidden */
  15443. _onVrDisplayDisconnect: Nullable<() => void>;
  15444. /** @hidden */
  15445. _onVrDisplayPresentChange: Nullable<() => void>;
  15446. /**
  15447. * Observable signaled when VR display mode changes
  15448. */
  15449. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15450. /**
  15451. * Observable signaled when VR request present is complete
  15452. */
  15453. onVRRequestPresentComplete: Observable<boolean>;
  15454. /**
  15455. * Observable signaled when VR request present starts
  15456. */
  15457. onVRRequestPresentStart: Observable<Engine>;
  15458. /**
  15459. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15460. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15461. */
  15462. isInVRExclusivePointerMode: boolean;
  15463. /**
  15464. * Gets a boolean indicating if a webVR device was detected
  15465. * @returns true if a webVR device was detected
  15466. */
  15467. isVRDevicePresent(): boolean;
  15468. /**
  15469. * Gets the current webVR device
  15470. * @returns the current webVR device (or null)
  15471. */
  15472. getVRDevice(): any;
  15473. /**
  15474. * Initializes a webVR display and starts listening to display change events
  15475. * The onVRDisplayChangedObservable will be notified upon these changes
  15476. * @returns A promise containing a VRDisplay and if vr is supported
  15477. */
  15478. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15479. /** @hidden */
  15480. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15481. /**
  15482. * Gets or sets the presentation attributes used to configure VR rendering
  15483. */
  15484. vrPresentationAttributes?: IVRPresentationAttributes;
  15485. /**
  15486. * Call this function to switch to webVR mode
  15487. * Will do nothing if webVR is not supported or if there is no webVR device
  15488. * @param options the webvr options provided to the camera. mainly used for multiview
  15489. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15490. */
  15491. enableVR(options: WebVROptions): void;
  15492. /** @hidden */
  15493. _onVRFullScreenTriggered(): void;
  15494. }
  15495. }
  15496. }
  15497. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15498. import { Nullable } from "babylonjs/types";
  15499. import { Observable } from "babylonjs/Misc/observable";
  15500. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15501. import { Scene } from "babylonjs/scene";
  15502. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15503. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15504. import { Node } from "babylonjs/node";
  15505. import { Ray } from "babylonjs/Culling/ray";
  15506. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15507. import "babylonjs/Engines/Extensions/engine.webVR";
  15508. /**
  15509. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15510. * IMPORTANT!! The data is right-hand data.
  15511. * @export
  15512. * @interface DevicePose
  15513. */
  15514. export interface DevicePose {
  15515. /**
  15516. * The position of the device, values in array are [x,y,z].
  15517. */
  15518. readonly position: Nullable<Float32Array>;
  15519. /**
  15520. * The linearVelocity of the device, values in array are [x,y,z].
  15521. */
  15522. readonly linearVelocity: Nullable<Float32Array>;
  15523. /**
  15524. * The linearAcceleration of the device, values in array are [x,y,z].
  15525. */
  15526. readonly linearAcceleration: Nullable<Float32Array>;
  15527. /**
  15528. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15529. */
  15530. readonly orientation: Nullable<Float32Array>;
  15531. /**
  15532. * The angularVelocity of the device, values in array are [x,y,z].
  15533. */
  15534. readonly angularVelocity: Nullable<Float32Array>;
  15535. /**
  15536. * The angularAcceleration of the device, values in array are [x,y,z].
  15537. */
  15538. readonly angularAcceleration: Nullable<Float32Array>;
  15539. }
  15540. /**
  15541. * Interface representing a pose controlled object in Babylon.
  15542. * A pose controlled object has both regular pose values as well as pose values
  15543. * from an external device such as a VR head mounted display
  15544. */
  15545. export interface PoseControlled {
  15546. /**
  15547. * The position of the object in babylon space.
  15548. */
  15549. position: Vector3;
  15550. /**
  15551. * The rotation quaternion of the object in babylon space.
  15552. */
  15553. rotationQuaternion: Quaternion;
  15554. /**
  15555. * The position of the device in babylon space.
  15556. */
  15557. devicePosition?: Vector3;
  15558. /**
  15559. * The rotation quaternion of the device in babylon space.
  15560. */
  15561. deviceRotationQuaternion: Quaternion;
  15562. /**
  15563. * The raw pose coming from the device.
  15564. */
  15565. rawPose: Nullable<DevicePose>;
  15566. /**
  15567. * The scale of the device to be used when translating from device space to babylon space.
  15568. */
  15569. deviceScaleFactor: number;
  15570. /**
  15571. * Updates the poseControlled values based on the input device pose.
  15572. * @param poseData the pose data to update the object with
  15573. */
  15574. updateFromDevice(poseData: DevicePose): void;
  15575. }
  15576. /**
  15577. * Set of options to customize the webVRCamera
  15578. */
  15579. export interface WebVROptions {
  15580. /**
  15581. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15582. */
  15583. trackPosition?: boolean;
  15584. /**
  15585. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15586. */
  15587. positionScale?: number;
  15588. /**
  15589. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15590. */
  15591. displayName?: string;
  15592. /**
  15593. * Should the native controller meshes be initialized. (default: true)
  15594. */
  15595. controllerMeshes?: boolean;
  15596. /**
  15597. * Creating a default HemiLight only on controllers. (default: true)
  15598. */
  15599. defaultLightingOnControllers?: boolean;
  15600. /**
  15601. * If you don't want to use the default VR button of the helper. (default: false)
  15602. */
  15603. useCustomVRButton?: boolean;
  15604. /**
  15605. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15606. */
  15607. customVRButton?: HTMLButtonElement;
  15608. /**
  15609. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15610. */
  15611. rayLength?: number;
  15612. /**
  15613. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15614. */
  15615. defaultHeight?: number;
  15616. /**
  15617. * If multiview should be used if availible (default: false)
  15618. */
  15619. useMultiview?: boolean;
  15620. }
  15621. /**
  15622. * This represents a WebVR camera.
  15623. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15624. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15625. */
  15626. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15627. private webVROptions;
  15628. /**
  15629. * @hidden
  15630. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15631. */
  15632. _vrDevice: any;
  15633. /**
  15634. * The rawPose of the vrDevice.
  15635. */
  15636. rawPose: Nullable<DevicePose>;
  15637. private _onVREnabled;
  15638. private _specsVersion;
  15639. private _attached;
  15640. private _frameData;
  15641. protected _descendants: Array<Node>;
  15642. private _deviceRoomPosition;
  15643. /** @hidden */
  15644. _deviceRoomRotationQuaternion: Quaternion;
  15645. private _standingMatrix;
  15646. /**
  15647. * Represents device position in babylon space.
  15648. */
  15649. devicePosition: Vector3;
  15650. /**
  15651. * Represents device rotation in babylon space.
  15652. */
  15653. deviceRotationQuaternion: Quaternion;
  15654. /**
  15655. * The scale of the device to be used when translating from device space to babylon space.
  15656. */
  15657. deviceScaleFactor: number;
  15658. private _deviceToWorld;
  15659. private _worldToDevice;
  15660. /**
  15661. * References to the webVR controllers for the vrDevice.
  15662. */
  15663. controllers: Array<WebVRController>;
  15664. /**
  15665. * Emits an event when a controller is attached.
  15666. */
  15667. onControllersAttachedObservable: Observable<WebVRController[]>;
  15668. /**
  15669. * Emits an event when a controller's mesh has been loaded;
  15670. */
  15671. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15672. /**
  15673. * Emits an event when the HMD's pose has been updated.
  15674. */
  15675. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15676. private _poseSet;
  15677. /**
  15678. * If the rig cameras be used as parent instead of this camera.
  15679. */
  15680. rigParenting: boolean;
  15681. private _lightOnControllers;
  15682. private _defaultHeight?;
  15683. /**
  15684. * Instantiates a WebVRFreeCamera.
  15685. * @param name The name of the WebVRFreeCamera
  15686. * @param position The starting anchor position for the camera
  15687. * @param scene The scene the camera belongs to
  15688. * @param webVROptions a set of customizable options for the webVRCamera
  15689. */
  15690. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15691. /**
  15692. * Gets the device distance from the ground in meters.
  15693. * @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.
  15694. */
  15695. deviceDistanceToRoomGround(): number;
  15696. /**
  15697. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15698. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15699. */
  15700. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15701. /**
  15702. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15703. * @returns A promise with a boolean set to if the standing matrix is supported.
  15704. */
  15705. useStandingMatrixAsync(): Promise<boolean>;
  15706. /**
  15707. * Disposes the camera
  15708. */
  15709. dispose(): void;
  15710. /**
  15711. * Gets a vrController by name.
  15712. * @param name The name of the controller to retreive
  15713. * @returns the controller matching the name specified or null if not found
  15714. */
  15715. getControllerByName(name: string): Nullable<WebVRController>;
  15716. private _leftController;
  15717. /**
  15718. * The controller corresponding to the users left hand.
  15719. */
  15720. get leftController(): Nullable<WebVRController>;
  15721. private _rightController;
  15722. /**
  15723. * The controller corresponding to the users right hand.
  15724. */
  15725. get rightController(): Nullable<WebVRController>;
  15726. /**
  15727. * Casts a ray forward from the vrCamera's gaze.
  15728. * @param length Length of the ray (default: 100)
  15729. * @returns the ray corresponding to the gaze
  15730. */
  15731. getForwardRay(length?: number): Ray;
  15732. /**
  15733. * @hidden
  15734. * Updates the camera based on device's frame data
  15735. */
  15736. _checkInputs(): void;
  15737. /**
  15738. * Updates the poseControlled values based on the input device pose.
  15739. * @param poseData Pose coming from the device
  15740. */
  15741. updateFromDevice(poseData: DevicePose): void;
  15742. private _htmlElementAttached;
  15743. private _detachIfAttached;
  15744. /**
  15745. * WebVR's attach control will start broadcasting frames to the device.
  15746. * Note that in certain browsers (chrome for example) this function must be called
  15747. * within a user-interaction callback. Example:
  15748. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15749. *
  15750. * @param element html element to attach the vrDevice to
  15751. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15752. */
  15753. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15754. /**
  15755. * Detaches the camera from the html element and disables VR
  15756. *
  15757. * @param element html element to detach from
  15758. */
  15759. detachControl(element: HTMLElement): void;
  15760. /**
  15761. * @returns the name of this class
  15762. */
  15763. getClassName(): string;
  15764. /**
  15765. * Calls resetPose on the vrDisplay
  15766. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15767. */
  15768. resetToCurrentRotation(): void;
  15769. /**
  15770. * @hidden
  15771. * Updates the rig cameras (left and right eye)
  15772. */
  15773. _updateRigCameras(): void;
  15774. private _workingVector;
  15775. private _oneVector;
  15776. private _workingMatrix;
  15777. private updateCacheCalled;
  15778. private _correctPositionIfNotTrackPosition;
  15779. /**
  15780. * @hidden
  15781. * Updates the cached values of the camera
  15782. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15783. */
  15784. _updateCache(ignoreParentClass?: boolean): void;
  15785. /**
  15786. * @hidden
  15787. * Get current device position in babylon world
  15788. */
  15789. _computeDevicePosition(): void;
  15790. /**
  15791. * Updates the current device position and rotation in the babylon world
  15792. */
  15793. update(): void;
  15794. /**
  15795. * @hidden
  15796. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15797. * @returns an identity matrix
  15798. */
  15799. _getViewMatrix(): Matrix;
  15800. private _tmpMatrix;
  15801. /**
  15802. * This function is called by the two RIG cameras.
  15803. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15804. * @hidden
  15805. */
  15806. _getWebVRViewMatrix(): Matrix;
  15807. /** @hidden */
  15808. _getWebVRProjectionMatrix(): Matrix;
  15809. private _onGamepadConnectedObserver;
  15810. private _onGamepadDisconnectedObserver;
  15811. private _updateCacheWhenTrackingDisabledObserver;
  15812. /**
  15813. * Initializes the controllers and their meshes
  15814. */
  15815. initControllers(): void;
  15816. }
  15817. }
  15818. declare module "babylonjs/PostProcesses/postProcess" {
  15819. import { Nullable } from "babylonjs/types";
  15820. import { SmartArray } from "babylonjs/Misc/smartArray";
  15821. import { Observable } from "babylonjs/Misc/observable";
  15822. import { Vector2 } from "babylonjs/Maths/math.vector";
  15823. import { Camera } from "babylonjs/Cameras/camera";
  15824. import { Effect } from "babylonjs/Materials/effect";
  15825. import "babylonjs/Shaders/postprocess.vertex";
  15826. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15827. import { Engine } from "babylonjs/Engines/engine";
  15828. import { Color4 } from "babylonjs/Maths/math.color";
  15829. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15830. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15831. /**
  15832. * Size options for a post process
  15833. */
  15834. export type PostProcessOptions = {
  15835. width: number;
  15836. height: number;
  15837. };
  15838. /**
  15839. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15840. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15841. */
  15842. export class PostProcess {
  15843. /** Name of the PostProcess. */
  15844. name: string;
  15845. /**
  15846. * Gets or sets the unique id of the post process
  15847. */
  15848. uniqueId: number;
  15849. /**
  15850. * Width of the texture to apply the post process on
  15851. */
  15852. width: number;
  15853. /**
  15854. * Height of the texture to apply the post process on
  15855. */
  15856. height: number;
  15857. /**
  15858. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15859. * @hidden
  15860. */
  15861. _outputTexture: Nullable<InternalTexture>;
  15862. /**
  15863. * Sampling mode used by the shader
  15864. * See https://doc.babylonjs.com/classes/3.1/texture
  15865. */
  15866. renderTargetSamplingMode: number;
  15867. /**
  15868. * Clear color to use when screen clearing
  15869. */
  15870. clearColor: Color4;
  15871. /**
  15872. * If the buffer needs to be cleared before applying the post process. (default: true)
  15873. * Should be set to false if shader will overwrite all previous pixels.
  15874. */
  15875. autoClear: boolean;
  15876. /**
  15877. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15878. */
  15879. alphaMode: number;
  15880. /**
  15881. * Sets the setAlphaBlendConstants of the babylon engine
  15882. */
  15883. alphaConstants: Color4;
  15884. /**
  15885. * Animations to be used for the post processing
  15886. */
  15887. animations: import("babylonjs/Animations/animation").Animation[];
  15888. /**
  15889. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15890. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15891. */
  15892. enablePixelPerfectMode: boolean;
  15893. /**
  15894. * Force the postprocess to be applied without taking in account viewport
  15895. */
  15896. forceFullscreenViewport: boolean;
  15897. /**
  15898. * List of inspectable custom properties (used by the Inspector)
  15899. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15900. */
  15901. inspectableCustomProperties: IInspectable[];
  15902. /**
  15903. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15904. *
  15905. * | Value | Type | Description |
  15906. * | ----- | ----------------------------------- | ----------- |
  15907. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15908. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15909. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15910. *
  15911. */
  15912. scaleMode: number;
  15913. /**
  15914. * Force textures to be a power of two (default: false)
  15915. */
  15916. alwaysForcePOT: boolean;
  15917. private _samples;
  15918. /**
  15919. * Number of sample textures (default: 1)
  15920. */
  15921. get samples(): number;
  15922. set samples(n: number);
  15923. /**
  15924. * Modify the scale of the post process to be the same as the viewport (default: false)
  15925. */
  15926. adaptScaleToCurrentViewport: boolean;
  15927. private _camera;
  15928. private _scene;
  15929. private _engine;
  15930. private _options;
  15931. private _reusable;
  15932. private _textureType;
  15933. /**
  15934. * Smart array of input and output textures for the post process.
  15935. * @hidden
  15936. */
  15937. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15938. /**
  15939. * The index in _textures that corresponds to the output texture.
  15940. * @hidden
  15941. */
  15942. _currentRenderTextureInd: number;
  15943. private _effect;
  15944. private _samplers;
  15945. private _fragmentUrl;
  15946. private _vertexUrl;
  15947. private _parameters;
  15948. private _scaleRatio;
  15949. protected _indexParameters: any;
  15950. private _shareOutputWithPostProcess;
  15951. private _texelSize;
  15952. private _forcedOutputTexture;
  15953. /**
  15954. * Returns the fragment url or shader name used in the post process.
  15955. * @returns the fragment url or name in the shader store.
  15956. */
  15957. getEffectName(): string;
  15958. /**
  15959. * An event triggered when the postprocess is activated.
  15960. */
  15961. onActivateObservable: Observable<Camera>;
  15962. private _onActivateObserver;
  15963. /**
  15964. * A function that is added to the onActivateObservable
  15965. */
  15966. set onActivate(callback: Nullable<(camera: Camera) => void>);
  15967. /**
  15968. * An event triggered when the postprocess changes its size.
  15969. */
  15970. onSizeChangedObservable: Observable<PostProcess>;
  15971. private _onSizeChangedObserver;
  15972. /**
  15973. * A function that is added to the onSizeChangedObservable
  15974. */
  15975. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  15976. /**
  15977. * An event triggered when the postprocess applies its effect.
  15978. */
  15979. onApplyObservable: Observable<Effect>;
  15980. private _onApplyObserver;
  15981. /**
  15982. * A function that is added to the onApplyObservable
  15983. */
  15984. set onApply(callback: (effect: Effect) => void);
  15985. /**
  15986. * An event triggered before rendering the postprocess
  15987. */
  15988. onBeforeRenderObservable: Observable<Effect>;
  15989. private _onBeforeRenderObserver;
  15990. /**
  15991. * A function that is added to the onBeforeRenderObservable
  15992. */
  15993. set onBeforeRender(callback: (effect: Effect) => void);
  15994. /**
  15995. * An event triggered after rendering the postprocess
  15996. */
  15997. onAfterRenderObservable: Observable<Effect>;
  15998. private _onAfterRenderObserver;
  15999. /**
  16000. * A function that is added to the onAfterRenderObservable
  16001. */
  16002. set onAfterRender(callback: (efect: Effect) => void);
  16003. /**
  16004. * 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
  16005. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  16006. */
  16007. get inputTexture(): InternalTexture;
  16008. set inputTexture(value: InternalTexture);
  16009. /**
  16010. * Gets the camera which post process is applied to.
  16011. * @returns The camera the post process is applied to.
  16012. */
  16013. getCamera(): Camera;
  16014. /**
  16015. * Gets the texel size of the postprocess.
  16016. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  16017. */
  16018. get texelSize(): Vector2;
  16019. /**
  16020. * Creates a new instance PostProcess
  16021. * @param name The name of the PostProcess.
  16022. * @param fragmentUrl The url of the fragment shader to be used.
  16023. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  16024. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  16025. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16026. * @param camera The camera to apply the render pass to.
  16027. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16028. * @param engine The engine which the post process will be applied. (default: current engine)
  16029. * @param reusable If the post process can be reused on the same frame. (default: false)
  16030. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  16031. * @param textureType Type of textures used when performing the post process. (default: 0)
  16032. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  16033. * @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
  16034. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  16035. */
  16036. constructor(
  16037. /** Name of the PostProcess. */
  16038. 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);
  16039. /**
  16040. * Gets a string idenfifying the name of the class
  16041. * @returns "PostProcess" string
  16042. */
  16043. getClassName(): string;
  16044. /**
  16045. * Gets the engine which this post process belongs to.
  16046. * @returns The engine the post process was enabled with.
  16047. */
  16048. getEngine(): Engine;
  16049. /**
  16050. * The effect that is created when initializing the post process.
  16051. * @returns The created effect corresponding the the postprocess.
  16052. */
  16053. getEffect(): Effect;
  16054. /**
  16055. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  16056. * @param postProcess The post process to share the output with.
  16057. * @returns This post process.
  16058. */
  16059. shareOutputWith(postProcess: PostProcess): PostProcess;
  16060. /**
  16061. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  16062. * This should be called if the post process that shares output with this post process is disabled/disposed.
  16063. */
  16064. useOwnOutput(): void;
  16065. /**
  16066. * Updates the effect with the current post process compile time values and recompiles the shader.
  16067. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16068. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16069. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16070. * @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
  16071. * @param onCompiled Called when the shader has been compiled.
  16072. * @param onError Called if there is an error when compiling a shader.
  16073. */
  16074. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16075. /**
  16076. * The post process is reusable if it can be used multiple times within one frame.
  16077. * @returns If the post process is reusable
  16078. */
  16079. isReusable(): boolean;
  16080. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  16081. markTextureDirty(): void;
  16082. /**
  16083. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  16084. * 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.
  16085. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  16086. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  16087. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  16088. * @returns The target texture that was bound to be written to.
  16089. */
  16090. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  16091. /**
  16092. * If the post process is supported.
  16093. */
  16094. get isSupported(): boolean;
  16095. /**
  16096. * The aspect ratio of the output texture.
  16097. */
  16098. get aspectRatio(): number;
  16099. /**
  16100. * Get a value indicating if the post-process is ready to be used
  16101. * @returns true if the post-process is ready (shader is compiled)
  16102. */
  16103. isReady(): boolean;
  16104. /**
  16105. * Binds all textures and uniforms to the shader, this will be run on every pass.
  16106. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  16107. */
  16108. apply(): Nullable<Effect>;
  16109. private _disposeTextures;
  16110. /**
  16111. * Disposes the post process.
  16112. * @param camera The camera to dispose the post process on.
  16113. */
  16114. dispose(camera?: Camera): void;
  16115. }
  16116. }
  16117. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  16118. /** @hidden */
  16119. export var kernelBlurVaryingDeclaration: {
  16120. name: string;
  16121. shader: string;
  16122. };
  16123. }
  16124. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  16125. /** @hidden */
  16126. export var kernelBlurFragment: {
  16127. name: string;
  16128. shader: string;
  16129. };
  16130. }
  16131. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  16132. /** @hidden */
  16133. export var kernelBlurFragment2: {
  16134. name: string;
  16135. shader: string;
  16136. };
  16137. }
  16138. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  16139. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16140. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  16141. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  16142. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  16143. /** @hidden */
  16144. export var kernelBlurPixelShader: {
  16145. name: string;
  16146. shader: string;
  16147. };
  16148. }
  16149. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  16150. /** @hidden */
  16151. export var kernelBlurVertex: {
  16152. name: string;
  16153. shader: string;
  16154. };
  16155. }
  16156. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  16157. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16158. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  16159. /** @hidden */
  16160. export var kernelBlurVertexShader: {
  16161. name: string;
  16162. shader: string;
  16163. };
  16164. }
  16165. declare module "babylonjs/PostProcesses/blurPostProcess" {
  16166. import { Vector2 } from "babylonjs/Maths/math.vector";
  16167. import { Nullable } from "babylonjs/types";
  16168. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  16169. import { Camera } from "babylonjs/Cameras/camera";
  16170. import { Effect } from "babylonjs/Materials/effect";
  16171. import { Engine } from "babylonjs/Engines/engine";
  16172. import "babylonjs/Shaders/kernelBlur.fragment";
  16173. import "babylonjs/Shaders/kernelBlur.vertex";
  16174. /**
  16175. * The Blur Post Process which blurs an image based on a kernel and direction.
  16176. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  16177. */
  16178. export class BlurPostProcess extends PostProcess {
  16179. /** The direction in which to blur the image. */
  16180. direction: Vector2;
  16181. private blockCompilation;
  16182. protected _kernel: number;
  16183. protected _idealKernel: number;
  16184. protected _packedFloat: boolean;
  16185. private _staticDefines;
  16186. /**
  16187. * Sets the length in pixels of the blur sample region
  16188. */
  16189. set kernel(v: number);
  16190. /**
  16191. * Gets the length in pixels of the blur sample region
  16192. */
  16193. get kernel(): number;
  16194. /**
  16195. * Sets wether or not the blur needs to unpack/repack floats
  16196. */
  16197. set packedFloat(v: boolean);
  16198. /**
  16199. * Gets wether or not the blur is unpacking/repacking floats
  16200. */
  16201. get packedFloat(): boolean;
  16202. /**
  16203. * Creates a new instance BlurPostProcess
  16204. * @param name The name of the effect.
  16205. * @param direction The direction in which to blur the image.
  16206. * @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.
  16207. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16208. * @param camera The camera to apply the render pass to.
  16209. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16210. * @param engine The engine which the post process will be applied. (default: current engine)
  16211. * @param reusable If the post process can be reused on the same frame. (default: false)
  16212. * @param textureType Type of textures used when performing the post process. (default: 0)
  16213. * @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)
  16214. */
  16215. constructor(name: string,
  16216. /** The direction in which to blur the image. */
  16217. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  16218. /**
  16219. * Updates the effect with the current post process compile time values and recompiles the shader.
  16220. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16221. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16222. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16223. * @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
  16224. * @param onCompiled Called when the shader has been compiled.
  16225. * @param onError Called if there is an error when compiling a shader.
  16226. */
  16227. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16228. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16229. /**
  16230. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  16231. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  16232. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  16233. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  16234. * The gaps between physical kernels are compensated for in the weighting of the samples
  16235. * @param idealKernel Ideal blur kernel.
  16236. * @return Nearest best kernel.
  16237. */
  16238. protected _nearestBestKernel(idealKernel: number): number;
  16239. /**
  16240. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  16241. * @param x The point on the Gaussian distribution to sample.
  16242. * @return the value of the Gaussian function at x.
  16243. */
  16244. protected _gaussianWeight(x: number): number;
  16245. /**
  16246. * Generates a string that can be used as a floating point number in GLSL.
  16247. * @param x Value to print.
  16248. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  16249. * @return GLSL float string.
  16250. */
  16251. protected _glslFloat(x: number, decimalFigures?: number): string;
  16252. }
  16253. }
  16254. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16255. import { Scene } from "babylonjs/scene";
  16256. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16257. import { Plane } from "babylonjs/Maths/math.plane";
  16258. /**
  16259. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16260. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16261. * You can then easily use it as a reflectionTexture on a flat surface.
  16262. * In case the surface is not a plane, please consider relying on reflection probes.
  16263. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16264. */
  16265. export class MirrorTexture extends RenderTargetTexture {
  16266. private scene;
  16267. /**
  16268. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16269. * 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.
  16270. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16271. */
  16272. mirrorPlane: Plane;
  16273. /**
  16274. * Define the blur ratio used to blur the reflection if needed.
  16275. */
  16276. set blurRatio(value: number);
  16277. get blurRatio(): number;
  16278. /**
  16279. * Define the adaptive blur kernel used to blur the reflection if needed.
  16280. * This will autocompute the closest best match for the `blurKernel`
  16281. */
  16282. set adaptiveBlurKernel(value: number);
  16283. /**
  16284. * Define the blur kernel used to blur the reflection if needed.
  16285. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16286. */
  16287. set blurKernel(value: number);
  16288. /**
  16289. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16290. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16291. */
  16292. set blurKernelX(value: number);
  16293. get blurKernelX(): number;
  16294. /**
  16295. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16296. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16297. */
  16298. set blurKernelY(value: number);
  16299. get blurKernelY(): number;
  16300. private _autoComputeBlurKernel;
  16301. protected _onRatioRescale(): void;
  16302. private _updateGammaSpace;
  16303. private _imageProcessingConfigChangeObserver;
  16304. private _transformMatrix;
  16305. private _mirrorMatrix;
  16306. private _savedViewMatrix;
  16307. private _blurX;
  16308. private _blurY;
  16309. private _adaptiveBlurKernel;
  16310. private _blurKernelX;
  16311. private _blurKernelY;
  16312. private _blurRatio;
  16313. /**
  16314. * Instantiates a Mirror Texture.
  16315. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16316. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16317. * You can then easily use it as a reflectionTexture on a flat surface.
  16318. * In case the surface is not a plane, please consider relying on reflection probes.
  16319. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16320. * @param name
  16321. * @param size
  16322. * @param scene
  16323. * @param generateMipMaps
  16324. * @param type
  16325. * @param samplingMode
  16326. * @param generateDepthBuffer
  16327. */
  16328. constructor(name: string, size: number | {
  16329. width: number;
  16330. height: number;
  16331. } | {
  16332. ratio: number;
  16333. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16334. private _preparePostProcesses;
  16335. /**
  16336. * Clone the mirror texture.
  16337. * @returns the cloned texture
  16338. */
  16339. clone(): MirrorTexture;
  16340. /**
  16341. * Serialize the texture to a JSON representation you could use in Parse later on
  16342. * @returns the serialized JSON representation
  16343. */
  16344. serialize(): any;
  16345. /**
  16346. * Dispose the texture and release its associated resources.
  16347. */
  16348. dispose(): void;
  16349. }
  16350. }
  16351. declare module "babylonjs/Materials/Textures/texture" {
  16352. import { Observable } from "babylonjs/Misc/observable";
  16353. import { Nullable } from "babylonjs/types";
  16354. import { Matrix } from "babylonjs/Maths/math.vector";
  16355. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16356. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16357. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16358. import { Scene } from "babylonjs/scene";
  16359. /**
  16360. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16361. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16362. */
  16363. export class Texture extends BaseTexture {
  16364. /**
  16365. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16366. */
  16367. static SerializeBuffers: boolean;
  16368. /** @hidden */
  16369. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16370. /** @hidden */
  16371. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16372. /** @hidden */
  16373. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16374. /** nearest is mag = nearest and min = nearest and mip = linear */
  16375. static readonly NEAREST_SAMPLINGMODE: number;
  16376. /** nearest is mag = nearest and min = nearest and mip = linear */
  16377. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16378. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16379. static readonly BILINEAR_SAMPLINGMODE: number;
  16380. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16381. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16382. /** Trilinear is mag = linear and min = linear and mip = linear */
  16383. static readonly TRILINEAR_SAMPLINGMODE: number;
  16384. /** Trilinear is mag = linear and min = linear and mip = linear */
  16385. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16386. /** mag = nearest and min = nearest and mip = nearest */
  16387. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16388. /** mag = nearest and min = linear and mip = nearest */
  16389. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16390. /** mag = nearest and min = linear and mip = linear */
  16391. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16392. /** mag = nearest and min = linear and mip = none */
  16393. static readonly NEAREST_LINEAR: number;
  16394. /** mag = nearest and min = nearest and mip = none */
  16395. static readonly NEAREST_NEAREST: number;
  16396. /** mag = linear and min = nearest and mip = nearest */
  16397. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16398. /** mag = linear and min = nearest and mip = linear */
  16399. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16400. /** mag = linear and min = linear and mip = none */
  16401. static readonly LINEAR_LINEAR: number;
  16402. /** mag = linear and min = nearest and mip = none */
  16403. static readonly LINEAR_NEAREST: number;
  16404. /** Explicit coordinates mode */
  16405. static readonly EXPLICIT_MODE: number;
  16406. /** Spherical coordinates mode */
  16407. static readonly SPHERICAL_MODE: number;
  16408. /** Planar coordinates mode */
  16409. static readonly PLANAR_MODE: number;
  16410. /** Cubic coordinates mode */
  16411. static readonly CUBIC_MODE: number;
  16412. /** Projection coordinates mode */
  16413. static readonly PROJECTION_MODE: number;
  16414. /** Inverse Cubic coordinates mode */
  16415. static readonly SKYBOX_MODE: number;
  16416. /** Inverse Cubic coordinates mode */
  16417. static readonly INVCUBIC_MODE: number;
  16418. /** Equirectangular coordinates mode */
  16419. static readonly EQUIRECTANGULAR_MODE: number;
  16420. /** Equirectangular Fixed coordinates mode */
  16421. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16422. /** Equirectangular Fixed Mirrored coordinates mode */
  16423. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16424. /** Texture is not repeating outside of 0..1 UVs */
  16425. static readonly CLAMP_ADDRESSMODE: number;
  16426. /** Texture is repeating outside of 0..1 UVs */
  16427. static readonly WRAP_ADDRESSMODE: number;
  16428. /** Texture is repeating and mirrored */
  16429. static readonly MIRROR_ADDRESSMODE: number;
  16430. /**
  16431. * 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
  16432. */
  16433. static UseSerializedUrlIfAny: boolean;
  16434. /**
  16435. * Define the url of the texture.
  16436. */
  16437. url: Nullable<string>;
  16438. /**
  16439. * Define an offset on the texture to offset the u coordinates of the UVs
  16440. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16441. */
  16442. uOffset: number;
  16443. /**
  16444. * Define an offset on the texture to offset the v coordinates of the UVs
  16445. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16446. */
  16447. vOffset: number;
  16448. /**
  16449. * Define an offset on the texture to scale the u coordinates of the UVs
  16450. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16451. */
  16452. uScale: number;
  16453. /**
  16454. * Define an offset on the texture to scale the v coordinates of the UVs
  16455. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16456. */
  16457. vScale: number;
  16458. /**
  16459. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16460. * @see http://doc.babylonjs.com/how_to/more_materials
  16461. */
  16462. uAng: number;
  16463. /**
  16464. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16465. * @see http://doc.babylonjs.com/how_to/more_materials
  16466. */
  16467. vAng: number;
  16468. /**
  16469. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16470. * @see http://doc.babylonjs.com/how_to/more_materials
  16471. */
  16472. wAng: number;
  16473. /**
  16474. * Defines the center of rotation (U)
  16475. */
  16476. uRotationCenter: number;
  16477. /**
  16478. * Defines the center of rotation (V)
  16479. */
  16480. vRotationCenter: number;
  16481. /**
  16482. * Defines the center of rotation (W)
  16483. */
  16484. wRotationCenter: number;
  16485. /**
  16486. * Are mip maps generated for this texture or not.
  16487. */
  16488. get noMipmap(): boolean;
  16489. /**
  16490. * List of inspectable custom properties (used by the Inspector)
  16491. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16492. */
  16493. inspectableCustomProperties: Nullable<IInspectable[]>;
  16494. private _noMipmap;
  16495. /** @hidden */
  16496. _invertY: boolean;
  16497. private _rowGenerationMatrix;
  16498. private _cachedTextureMatrix;
  16499. private _projectionModeMatrix;
  16500. private _t0;
  16501. private _t1;
  16502. private _t2;
  16503. private _cachedUOffset;
  16504. private _cachedVOffset;
  16505. private _cachedUScale;
  16506. private _cachedVScale;
  16507. private _cachedUAng;
  16508. private _cachedVAng;
  16509. private _cachedWAng;
  16510. private _cachedProjectionMatrixId;
  16511. private _cachedCoordinatesMode;
  16512. /** @hidden */
  16513. protected _initialSamplingMode: number;
  16514. /** @hidden */
  16515. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16516. private _deleteBuffer;
  16517. protected _format: Nullable<number>;
  16518. private _delayedOnLoad;
  16519. private _delayedOnError;
  16520. private _mimeType?;
  16521. /**
  16522. * Observable triggered once the texture has been loaded.
  16523. */
  16524. onLoadObservable: Observable<Texture>;
  16525. protected _isBlocking: boolean;
  16526. /**
  16527. * Is the texture preventing material to render while loading.
  16528. * If false, a default texture will be used instead of the loading one during the preparation step.
  16529. */
  16530. set isBlocking(value: boolean);
  16531. get isBlocking(): boolean;
  16532. /**
  16533. * Get the current sampling mode associated with the texture.
  16534. */
  16535. get samplingMode(): number;
  16536. /**
  16537. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16538. */
  16539. get invertY(): boolean;
  16540. /**
  16541. * Instantiates a new texture.
  16542. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16543. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16544. * @param url defines the url of the picture to load as a texture
  16545. * @param scene defines the scene or engine the texture will belong to
  16546. * @param noMipmap defines if the texture will require mip maps or not
  16547. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16548. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16549. * @param onLoad defines a callback triggered when the texture has been loaded
  16550. * @param onError defines a callback triggered when an error occurred during the loading session
  16551. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16552. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16553. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16554. * @param mimeType defines an optional mime type information
  16555. */
  16556. 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 | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  16557. /**
  16558. * Update the url (and optional buffer) of this texture if url was null during construction.
  16559. * @param url the url of the texture
  16560. * @param buffer the buffer of the texture (defaults to null)
  16561. * @param onLoad callback called when the texture is loaded (defaults to null)
  16562. */
  16563. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16564. /**
  16565. * Finish the loading sequence of a texture flagged as delayed load.
  16566. * @hidden
  16567. */
  16568. delayLoad(): void;
  16569. private _prepareRowForTextureGeneration;
  16570. /**
  16571. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16572. * @returns the transform matrix of the texture.
  16573. */
  16574. getTextureMatrix(uBase?: number): Matrix;
  16575. /**
  16576. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16577. * @returns The reflection texture transform
  16578. */
  16579. getReflectionTextureMatrix(): Matrix;
  16580. /**
  16581. * Clones the texture.
  16582. * @returns the cloned texture
  16583. */
  16584. clone(): Texture;
  16585. /**
  16586. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16587. * @returns The JSON representation of the texture
  16588. */
  16589. serialize(): any;
  16590. /**
  16591. * Get the current class name of the texture useful for serialization or dynamic coding.
  16592. * @returns "Texture"
  16593. */
  16594. getClassName(): string;
  16595. /**
  16596. * Dispose the texture and release its associated resources.
  16597. */
  16598. dispose(): void;
  16599. /**
  16600. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16601. * @param parsedTexture Define the JSON representation of the texture
  16602. * @param scene Define the scene the parsed texture should be instantiated in
  16603. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16604. * @returns The parsed texture if successful
  16605. */
  16606. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16607. /**
  16608. * Creates a texture from its base 64 representation.
  16609. * @param data Define the base64 payload without the data: prefix
  16610. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16611. * @param scene Define the scene the texture should belong to
  16612. * @param noMipmap Forces the texture to not create mip map information if true
  16613. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16614. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16615. * @param onLoad define a callback triggered when the texture has been loaded
  16616. * @param onError define a callback triggered when an error occurred during the loading session
  16617. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16618. * @returns the created texture
  16619. */
  16620. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16621. /**
  16622. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16623. * @param data Define the base64 payload without the data: prefix
  16624. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16625. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16626. * @param scene Define the scene the texture should belong to
  16627. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16628. * @param noMipmap Forces the texture to not create mip map information if true
  16629. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16630. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16631. * @param onLoad define a callback triggered when the texture has been loaded
  16632. * @param onError define a callback triggered when an error occurred during the loading session
  16633. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16634. * @returns the created texture
  16635. */
  16636. 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;
  16637. }
  16638. }
  16639. declare module "babylonjs/PostProcesses/postProcessManager" {
  16640. import { Nullable } from "babylonjs/types";
  16641. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16642. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16643. import { Scene } from "babylonjs/scene";
  16644. /**
  16645. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16646. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16647. */
  16648. export class PostProcessManager {
  16649. private _scene;
  16650. private _indexBuffer;
  16651. private _vertexBuffers;
  16652. /**
  16653. * Creates a new instance PostProcess
  16654. * @param scene The scene that the post process is associated with.
  16655. */
  16656. constructor(scene: Scene);
  16657. private _prepareBuffers;
  16658. private _buildIndexBuffer;
  16659. /**
  16660. * Rebuilds the vertex buffers of the manager.
  16661. * @hidden
  16662. */
  16663. _rebuild(): void;
  16664. /**
  16665. * Prepares a frame to be run through a post process.
  16666. * @param sourceTexture The input texture to the post procesess. (default: null)
  16667. * @param postProcesses An array of post processes to be run. (default: null)
  16668. * @returns True if the post processes were able to be run.
  16669. * @hidden
  16670. */
  16671. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16672. /**
  16673. * Manually render a set of post processes to a texture.
  16674. * @param postProcesses An array of post processes to be run.
  16675. * @param targetTexture The target texture to render to.
  16676. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16677. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16678. * @param lodLevel defines which lod of the texture to render to
  16679. */
  16680. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16681. /**
  16682. * Finalize the result of the output of the postprocesses.
  16683. * @param doNotPresent If true the result will not be displayed to the screen.
  16684. * @param targetTexture The target texture to render to.
  16685. * @param faceIndex The index of the face to bind the target texture to.
  16686. * @param postProcesses The array of post processes to render.
  16687. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16688. * @hidden
  16689. */
  16690. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16691. /**
  16692. * Disposes of the post process manager.
  16693. */
  16694. dispose(): void;
  16695. }
  16696. }
  16697. declare module "babylonjs/Misc/gradients" {
  16698. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16699. /** Interface used by value gradients (color, factor, ...) */
  16700. export interface IValueGradient {
  16701. /**
  16702. * Gets or sets the gradient value (between 0 and 1)
  16703. */
  16704. gradient: number;
  16705. }
  16706. /** Class used to store color4 gradient */
  16707. export class ColorGradient implements IValueGradient {
  16708. /**
  16709. * Gets or sets the gradient value (between 0 and 1)
  16710. */
  16711. gradient: number;
  16712. /**
  16713. * Gets or sets first associated color
  16714. */
  16715. color1: Color4;
  16716. /**
  16717. * Gets or sets second associated color
  16718. */
  16719. color2?: Color4;
  16720. /**
  16721. * Will get a color picked randomly between color1 and color2.
  16722. * If color2 is undefined then color1 will be used
  16723. * @param result defines the target Color4 to store the result in
  16724. */
  16725. getColorToRef(result: Color4): void;
  16726. }
  16727. /** Class used to store color 3 gradient */
  16728. export class Color3Gradient implements IValueGradient {
  16729. /**
  16730. * Gets or sets the gradient value (between 0 and 1)
  16731. */
  16732. gradient: number;
  16733. /**
  16734. * Gets or sets the associated color
  16735. */
  16736. color: Color3;
  16737. }
  16738. /** Class used to store factor gradient */
  16739. export class FactorGradient implements IValueGradient {
  16740. /**
  16741. * Gets or sets the gradient value (between 0 and 1)
  16742. */
  16743. gradient: number;
  16744. /**
  16745. * Gets or sets first associated factor
  16746. */
  16747. factor1: number;
  16748. /**
  16749. * Gets or sets second associated factor
  16750. */
  16751. factor2?: number;
  16752. /**
  16753. * Will get a number picked randomly between factor1 and factor2.
  16754. * If factor2 is undefined then factor1 will be used
  16755. * @returns the picked number
  16756. */
  16757. getFactor(): number;
  16758. }
  16759. /**
  16760. * Helper used to simplify some generic gradient tasks
  16761. */
  16762. export class GradientHelper {
  16763. /**
  16764. * Gets the current gradient from an array of IValueGradient
  16765. * @param ratio defines the current ratio to get
  16766. * @param gradients defines the array of IValueGradient
  16767. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16768. */
  16769. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16770. }
  16771. }
  16772. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16773. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16774. import { Nullable } from "babylonjs/types";
  16775. module "babylonjs/Engines/thinEngine" {
  16776. interface ThinEngine {
  16777. /**
  16778. * Creates a dynamic texture
  16779. * @param width defines the width of the texture
  16780. * @param height defines the height of the texture
  16781. * @param generateMipMaps defines if the engine should generate the mip levels
  16782. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16783. * @returns the dynamic texture inside an InternalTexture
  16784. */
  16785. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16786. /**
  16787. * Update the content of a dynamic texture
  16788. * @param texture defines the texture to update
  16789. * @param canvas defines the canvas containing the source
  16790. * @param invertY defines if data must be stored with Y axis inverted
  16791. * @param premulAlpha defines if alpha is stored as premultiplied
  16792. * @param format defines the format of the data
  16793. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16794. */
  16795. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16796. }
  16797. }
  16798. }
  16799. declare module "babylonjs/Misc/canvasGenerator" {
  16800. /**
  16801. * Helper class used to generate a canvas to manipulate images
  16802. */
  16803. export class CanvasGenerator {
  16804. /**
  16805. * Create a new canvas (or offscreen canvas depending on the context)
  16806. * @param width defines the expected width
  16807. * @param height defines the expected height
  16808. * @return a new canvas or offscreen canvas
  16809. */
  16810. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16811. }
  16812. }
  16813. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16814. import { Scene } from "babylonjs/scene";
  16815. import { Texture } from "babylonjs/Materials/Textures/texture";
  16816. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16817. /**
  16818. * A class extending Texture allowing drawing on a texture
  16819. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16820. */
  16821. export class DynamicTexture extends Texture {
  16822. private _generateMipMaps;
  16823. private _canvas;
  16824. private _context;
  16825. private _engine;
  16826. /**
  16827. * Creates a DynamicTexture
  16828. * @param name defines the name of the texture
  16829. * @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
  16830. * @param scene defines the scene where you want the texture
  16831. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16832. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16833. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16834. */
  16835. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16836. /**
  16837. * Get the current class name of the texture useful for serialization or dynamic coding.
  16838. * @returns "DynamicTexture"
  16839. */
  16840. getClassName(): string;
  16841. /**
  16842. * Gets the current state of canRescale
  16843. */
  16844. get canRescale(): boolean;
  16845. private _recreate;
  16846. /**
  16847. * Scales the texture
  16848. * @param ratio the scale factor to apply to both width and height
  16849. */
  16850. scale(ratio: number): void;
  16851. /**
  16852. * Resizes the texture
  16853. * @param width the new width
  16854. * @param height the new height
  16855. */
  16856. scaleTo(width: number, height: number): void;
  16857. /**
  16858. * Gets the context of the canvas used by the texture
  16859. * @returns the canvas context of the dynamic texture
  16860. */
  16861. getContext(): CanvasRenderingContext2D;
  16862. /**
  16863. * Clears the texture
  16864. */
  16865. clear(): void;
  16866. /**
  16867. * Updates the texture
  16868. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16869. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16870. */
  16871. update(invertY?: boolean, premulAlpha?: boolean): void;
  16872. /**
  16873. * Draws text onto the texture
  16874. * @param text defines the text to be drawn
  16875. * @param x defines the placement of the text from the left
  16876. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16877. * @param font defines the font to be used with font-style, font-size, font-name
  16878. * @param color defines the color used for the text
  16879. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16880. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16881. * @param update defines whether texture is immediately update (default is true)
  16882. */
  16883. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16884. /**
  16885. * Clones the texture
  16886. * @returns the clone of the texture.
  16887. */
  16888. clone(): DynamicTexture;
  16889. /**
  16890. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16891. * @returns a serialized dynamic texture object
  16892. */
  16893. serialize(): any;
  16894. /** @hidden */
  16895. _rebuild(): void;
  16896. }
  16897. }
  16898. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16899. import { Scene } from "babylonjs/scene";
  16900. import { ISceneComponent } from "babylonjs/sceneComponent";
  16901. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16902. module "babylonjs/abstractScene" {
  16903. interface AbstractScene {
  16904. /**
  16905. * The list of procedural textures added to the scene
  16906. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16907. */
  16908. proceduralTextures: Array<ProceduralTexture>;
  16909. }
  16910. }
  16911. /**
  16912. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16913. * in a given scene.
  16914. */
  16915. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16916. /**
  16917. * The component name helpfull to identify the component in the list of scene components.
  16918. */
  16919. readonly name: string;
  16920. /**
  16921. * The scene the component belongs to.
  16922. */
  16923. scene: Scene;
  16924. /**
  16925. * Creates a new instance of the component for the given scene
  16926. * @param scene Defines the scene to register the component in
  16927. */
  16928. constructor(scene: Scene);
  16929. /**
  16930. * Registers the component in a given scene
  16931. */
  16932. register(): void;
  16933. /**
  16934. * Rebuilds the elements related to this component in case of
  16935. * context lost for instance.
  16936. */
  16937. rebuild(): void;
  16938. /**
  16939. * Disposes the component and the associated ressources.
  16940. */
  16941. dispose(): void;
  16942. private _beforeClear;
  16943. }
  16944. }
  16945. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16946. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16947. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16948. module "babylonjs/Engines/thinEngine" {
  16949. interface ThinEngine {
  16950. /**
  16951. * Creates a new render target cube texture
  16952. * @param size defines the size of the texture
  16953. * @param options defines the options used to create the texture
  16954. * @returns a new render target cube texture stored in an InternalTexture
  16955. */
  16956. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16957. }
  16958. }
  16959. }
  16960. declare module "babylonjs/Shaders/procedural.vertex" {
  16961. /** @hidden */
  16962. export var proceduralVertexShader: {
  16963. name: string;
  16964. shader: string;
  16965. };
  16966. }
  16967. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16968. import { Observable } from "babylonjs/Misc/observable";
  16969. import { Nullable } from "babylonjs/types";
  16970. import { Scene } from "babylonjs/scene";
  16971. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16972. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16973. import { Effect } from "babylonjs/Materials/effect";
  16974. import { Texture } from "babylonjs/Materials/Textures/texture";
  16975. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16976. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16977. import "babylonjs/Shaders/procedural.vertex";
  16978. /**
  16979. * 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.
  16980. * This is the base class of any Procedural texture and contains most of the shareable code.
  16981. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16982. */
  16983. export class ProceduralTexture extends Texture {
  16984. isCube: boolean;
  16985. /**
  16986. * Define if the texture is enabled or not (disabled texture will not render)
  16987. */
  16988. isEnabled: boolean;
  16989. /**
  16990. * Define if the texture must be cleared before rendering (default is true)
  16991. */
  16992. autoClear: boolean;
  16993. /**
  16994. * Callback called when the texture is generated
  16995. */
  16996. onGenerated: () => void;
  16997. /**
  16998. * Event raised when the texture is generated
  16999. */
  17000. onGeneratedObservable: Observable<ProceduralTexture>;
  17001. /** @hidden */
  17002. _generateMipMaps: boolean;
  17003. /** @hidden **/
  17004. _effect: Effect;
  17005. /** @hidden */
  17006. _textures: {
  17007. [key: string]: Texture;
  17008. };
  17009. private _size;
  17010. private _currentRefreshId;
  17011. private _frameId;
  17012. private _refreshRate;
  17013. private _vertexBuffers;
  17014. private _indexBuffer;
  17015. private _uniforms;
  17016. private _samplers;
  17017. private _fragment;
  17018. private _floats;
  17019. private _ints;
  17020. private _floatsArrays;
  17021. private _colors3;
  17022. private _colors4;
  17023. private _vectors2;
  17024. private _vectors3;
  17025. private _matrices;
  17026. private _fallbackTexture;
  17027. private _fallbackTextureUsed;
  17028. private _engine;
  17029. private _cachedDefines;
  17030. private _contentUpdateId;
  17031. private _contentData;
  17032. /**
  17033. * Instantiates a new procedural texture.
  17034. * 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.
  17035. * This is the base class of any Procedural texture and contains most of the shareable code.
  17036. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  17037. * @param name Define the name of the texture
  17038. * @param size Define the size of the texture to create
  17039. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  17040. * @param scene Define the scene the texture belongs to
  17041. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  17042. * @param generateMipMaps Define if the texture should creates mip maps or not
  17043. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  17044. */
  17045. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  17046. /**
  17047. * The effect that is created when initializing the post process.
  17048. * @returns The created effect corresponding the the postprocess.
  17049. */
  17050. getEffect(): Effect;
  17051. /**
  17052. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  17053. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  17054. */
  17055. getContent(): Nullable<ArrayBufferView>;
  17056. private _createIndexBuffer;
  17057. /** @hidden */
  17058. _rebuild(): void;
  17059. /**
  17060. * Resets the texture in order to recreate its associated resources.
  17061. * This can be called in case of context loss
  17062. */
  17063. reset(): void;
  17064. protected _getDefines(): string;
  17065. /**
  17066. * Is the texture ready to be used ? (rendered at least once)
  17067. * @returns true if ready, otherwise, false.
  17068. */
  17069. isReady(): boolean;
  17070. /**
  17071. * Resets the refresh counter of the texture and start bak from scratch.
  17072. * Could be useful to regenerate the texture if it is setup to render only once.
  17073. */
  17074. resetRefreshCounter(): void;
  17075. /**
  17076. * Set the fragment shader to use in order to render the texture.
  17077. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  17078. */
  17079. setFragment(fragment: any): void;
  17080. /**
  17081. * Define the refresh rate of the texture or the rendering frequency.
  17082. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17083. */
  17084. get refreshRate(): number;
  17085. set refreshRate(value: number);
  17086. /** @hidden */
  17087. _shouldRender(): boolean;
  17088. /**
  17089. * Get the size the texture is rendering at.
  17090. * @returns the size (texture is always squared)
  17091. */
  17092. getRenderSize(): number;
  17093. /**
  17094. * Resize the texture to new value.
  17095. * @param size Define the new size the texture should have
  17096. * @param generateMipMaps Define whether the new texture should create mip maps
  17097. */
  17098. resize(size: number, generateMipMaps: boolean): void;
  17099. private _checkUniform;
  17100. /**
  17101. * Set a texture in the shader program used to render.
  17102. * @param name Define the name of the uniform samplers as defined in the shader
  17103. * @param texture Define the texture to bind to this sampler
  17104. * @return the texture itself allowing "fluent" like uniform updates
  17105. */
  17106. setTexture(name: string, texture: Texture): ProceduralTexture;
  17107. /**
  17108. * Set a float in the shader.
  17109. * @param name Define the name of the uniform as defined in the shader
  17110. * @param value Define the value to give to the uniform
  17111. * @return the texture itself allowing "fluent" like uniform updates
  17112. */
  17113. setFloat(name: string, value: number): ProceduralTexture;
  17114. /**
  17115. * Set a int in the shader.
  17116. * @param name Define the name of the uniform as defined in the shader
  17117. * @param value Define the value to give to the uniform
  17118. * @return the texture itself allowing "fluent" like uniform updates
  17119. */
  17120. setInt(name: string, value: number): ProceduralTexture;
  17121. /**
  17122. * Set an array of floats in the shader.
  17123. * @param name Define the name of the uniform as defined in the shader
  17124. * @param value Define the value to give to the uniform
  17125. * @return the texture itself allowing "fluent" like uniform updates
  17126. */
  17127. setFloats(name: string, value: number[]): ProceduralTexture;
  17128. /**
  17129. * Set a vec3 in the shader from a Color3.
  17130. * @param name Define the name of the uniform as defined in the shader
  17131. * @param value Define the value to give to the uniform
  17132. * @return the texture itself allowing "fluent" like uniform updates
  17133. */
  17134. setColor3(name: string, value: Color3): ProceduralTexture;
  17135. /**
  17136. * Set a vec4 in the shader from a Color4.
  17137. * @param name Define the name of the uniform as defined in the shader
  17138. * @param value Define the value to give to the uniform
  17139. * @return the texture itself allowing "fluent" like uniform updates
  17140. */
  17141. setColor4(name: string, value: Color4): ProceduralTexture;
  17142. /**
  17143. * Set a vec2 in the shader from a Vector2.
  17144. * @param name Define the name of the uniform as defined in the shader
  17145. * @param value Define the value to give to the uniform
  17146. * @return the texture itself allowing "fluent" like uniform updates
  17147. */
  17148. setVector2(name: string, value: Vector2): ProceduralTexture;
  17149. /**
  17150. * Set a vec3 in the shader from a Vector3.
  17151. * @param name Define the name of the uniform as defined in the shader
  17152. * @param value Define the value to give to the uniform
  17153. * @return the texture itself allowing "fluent" like uniform updates
  17154. */
  17155. setVector3(name: string, value: Vector3): ProceduralTexture;
  17156. /**
  17157. * Set a mat4 in the shader from a MAtrix.
  17158. * @param name Define the name of the uniform as defined in the shader
  17159. * @param value Define the value to give to the uniform
  17160. * @return the texture itself allowing "fluent" like uniform updates
  17161. */
  17162. setMatrix(name: string, value: Matrix): ProceduralTexture;
  17163. /**
  17164. * Render the texture to its associated render target.
  17165. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  17166. */
  17167. render(useCameraPostProcess?: boolean): void;
  17168. /**
  17169. * Clone the texture.
  17170. * @returns the cloned texture
  17171. */
  17172. clone(): ProceduralTexture;
  17173. /**
  17174. * Dispose the texture and release its asoociated resources.
  17175. */
  17176. dispose(): void;
  17177. }
  17178. }
  17179. declare module "babylonjs/Particles/baseParticleSystem" {
  17180. import { Nullable } from "babylonjs/types";
  17181. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  17182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17183. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17184. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17185. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  17186. import { Scene } from "babylonjs/scene";
  17187. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  17188. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17189. import { Texture } from "babylonjs/Materials/Textures/texture";
  17190. import { Color4 } from "babylonjs/Maths/math.color";
  17191. import { Animation } from "babylonjs/Animations/animation";
  17192. /**
  17193. * This represents the base class for particle system in Babylon.
  17194. * 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.
  17195. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17196. * @example https://doc.babylonjs.com/babylon101/particles
  17197. */
  17198. export class BaseParticleSystem {
  17199. /**
  17200. * Source color is added to the destination color without alpha affecting the result
  17201. */
  17202. static BLENDMODE_ONEONE: number;
  17203. /**
  17204. * Blend current color and particle color using particle’s alpha
  17205. */
  17206. static BLENDMODE_STANDARD: number;
  17207. /**
  17208. * Add current color and particle color multiplied by particle’s alpha
  17209. */
  17210. static BLENDMODE_ADD: number;
  17211. /**
  17212. * Multiply current color with particle color
  17213. */
  17214. static BLENDMODE_MULTIPLY: number;
  17215. /**
  17216. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  17217. */
  17218. static BLENDMODE_MULTIPLYADD: number;
  17219. /**
  17220. * List of animations used by the particle system.
  17221. */
  17222. animations: Animation[];
  17223. /**
  17224. * The id of the Particle system.
  17225. */
  17226. id: string;
  17227. /**
  17228. * The friendly name of the Particle system.
  17229. */
  17230. name: string;
  17231. /**
  17232. * The rendering group used by the Particle system to chose when to render.
  17233. */
  17234. renderingGroupId: number;
  17235. /**
  17236. * The emitter represents the Mesh or position we are attaching the particle system to.
  17237. */
  17238. emitter: Nullable<AbstractMesh | Vector3>;
  17239. /**
  17240. * The maximum number of particles to emit per frame
  17241. */
  17242. emitRate: number;
  17243. /**
  17244. * If you want to launch only a few particles at once, that can be done, as well.
  17245. */
  17246. manualEmitCount: number;
  17247. /**
  17248. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17249. */
  17250. updateSpeed: number;
  17251. /**
  17252. * The amount of time the particle system is running (depends of the overall update speed).
  17253. */
  17254. targetStopDuration: number;
  17255. /**
  17256. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17257. */
  17258. disposeOnStop: boolean;
  17259. /**
  17260. * Minimum power of emitting particles.
  17261. */
  17262. minEmitPower: number;
  17263. /**
  17264. * Maximum power of emitting particles.
  17265. */
  17266. maxEmitPower: number;
  17267. /**
  17268. * Minimum life time of emitting particles.
  17269. */
  17270. minLifeTime: number;
  17271. /**
  17272. * Maximum life time of emitting particles.
  17273. */
  17274. maxLifeTime: number;
  17275. /**
  17276. * Minimum Size of emitting particles.
  17277. */
  17278. minSize: number;
  17279. /**
  17280. * Maximum Size of emitting particles.
  17281. */
  17282. maxSize: number;
  17283. /**
  17284. * Minimum scale of emitting particles on X axis.
  17285. */
  17286. minScaleX: number;
  17287. /**
  17288. * Maximum scale of emitting particles on X axis.
  17289. */
  17290. maxScaleX: number;
  17291. /**
  17292. * Minimum scale of emitting particles on Y axis.
  17293. */
  17294. minScaleY: number;
  17295. /**
  17296. * Maximum scale of emitting particles on Y axis.
  17297. */
  17298. maxScaleY: number;
  17299. /**
  17300. * Gets or sets the minimal initial rotation in radians.
  17301. */
  17302. minInitialRotation: number;
  17303. /**
  17304. * Gets or sets the maximal initial rotation in radians.
  17305. */
  17306. maxInitialRotation: number;
  17307. /**
  17308. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17309. */
  17310. minAngularSpeed: number;
  17311. /**
  17312. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17313. */
  17314. maxAngularSpeed: number;
  17315. /**
  17316. * The texture used to render each particle. (this can be a spritesheet)
  17317. */
  17318. particleTexture: Nullable<Texture>;
  17319. /**
  17320. * The layer mask we are rendering the particles through.
  17321. */
  17322. layerMask: number;
  17323. /**
  17324. * This can help using your own shader to render the particle system.
  17325. * The according effect will be created
  17326. */
  17327. customShader: any;
  17328. /**
  17329. * By default particle system starts as soon as they are created. This prevents the
  17330. * automatic start to happen and let you decide when to start emitting particles.
  17331. */
  17332. preventAutoStart: boolean;
  17333. private _noiseTexture;
  17334. /**
  17335. * Gets or sets a texture used to add random noise to particle positions
  17336. */
  17337. get noiseTexture(): Nullable<ProceduralTexture>;
  17338. set noiseTexture(value: Nullable<ProceduralTexture>);
  17339. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17340. noiseStrength: Vector3;
  17341. /**
  17342. * Callback triggered when the particle animation is ending.
  17343. */
  17344. onAnimationEnd: Nullable<() => void>;
  17345. /**
  17346. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17347. */
  17348. blendMode: number;
  17349. /**
  17350. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17351. * to override the particles.
  17352. */
  17353. forceDepthWrite: boolean;
  17354. /** 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 */
  17355. preWarmCycles: number;
  17356. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17357. preWarmStepOffset: number;
  17358. /**
  17359. * 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)
  17360. */
  17361. spriteCellChangeSpeed: number;
  17362. /**
  17363. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17364. */
  17365. startSpriteCellID: number;
  17366. /**
  17367. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17368. */
  17369. endSpriteCellID: number;
  17370. /**
  17371. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17372. */
  17373. spriteCellWidth: number;
  17374. /**
  17375. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17376. */
  17377. spriteCellHeight: number;
  17378. /**
  17379. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17380. */
  17381. spriteRandomStartCell: boolean;
  17382. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17383. translationPivot: Vector2;
  17384. /** @hidden */
  17385. protected _isAnimationSheetEnabled: boolean;
  17386. /**
  17387. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17388. */
  17389. beginAnimationOnStart: boolean;
  17390. /**
  17391. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17392. */
  17393. beginAnimationFrom: number;
  17394. /**
  17395. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17396. */
  17397. beginAnimationTo: number;
  17398. /**
  17399. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17400. */
  17401. beginAnimationLoop: boolean;
  17402. /**
  17403. * Gets or sets a world offset applied to all particles
  17404. */
  17405. worldOffset: Vector3;
  17406. /**
  17407. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17408. */
  17409. get isAnimationSheetEnabled(): boolean;
  17410. set isAnimationSheetEnabled(value: boolean);
  17411. /**
  17412. * Get hosting scene
  17413. * @returns the scene
  17414. */
  17415. getScene(): Scene;
  17416. /**
  17417. * You can use gravity if you want to give an orientation to your particles.
  17418. */
  17419. gravity: Vector3;
  17420. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17421. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17422. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17423. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17424. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17425. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17426. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17427. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17428. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17429. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17430. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17431. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17432. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17433. /**
  17434. * Defines the delay in milliseconds before starting the system (0 by default)
  17435. */
  17436. startDelay: number;
  17437. /**
  17438. * Gets the current list of drag gradients.
  17439. * You must use addDragGradient and removeDragGradient to udpate this list
  17440. * @returns the list of drag gradients
  17441. */
  17442. getDragGradients(): Nullable<Array<FactorGradient>>;
  17443. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17444. limitVelocityDamping: number;
  17445. /**
  17446. * Gets the current list of limit velocity gradients.
  17447. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17448. * @returns the list of limit velocity gradients
  17449. */
  17450. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17451. /**
  17452. * Gets the current list of color gradients.
  17453. * You must use addColorGradient and removeColorGradient to udpate this list
  17454. * @returns the list of color gradients
  17455. */
  17456. getColorGradients(): Nullable<Array<ColorGradient>>;
  17457. /**
  17458. * Gets the current list of size gradients.
  17459. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17460. * @returns the list of size gradients
  17461. */
  17462. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17463. /**
  17464. * Gets the current list of color remap gradients.
  17465. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17466. * @returns the list of color remap gradients
  17467. */
  17468. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17469. /**
  17470. * Gets the current list of alpha remap gradients.
  17471. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17472. * @returns the list of alpha remap gradients
  17473. */
  17474. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17475. /**
  17476. * Gets the current list of life time gradients.
  17477. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17478. * @returns the list of life time gradients
  17479. */
  17480. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17481. /**
  17482. * Gets the current list of angular speed gradients.
  17483. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17484. * @returns the list of angular speed gradients
  17485. */
  17486. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17487. /**
  17488. * Gets the current list of velocity gradients.
  17489. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17490. * @returns the list of velocity gradients
  17491. */
  17492. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17493. /**
  17494. * Gets the current list of start size gradients.
  17495. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17496. * @returns the list of start size gradients
  17497. */
  17498. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17499. /**
  17500. * Gets the current list of emit rate gradients.
  17501. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17502. * @returns the list of emit rate gradients
  17503. */
  17504. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17505. /**
  17506. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17507. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17508. */
  17509. get direction1(): Vector3;
  17510. set direction1(value: Vector3);
  17511. /**
  17512. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17513. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17514. */
  17515. get direction2(): Vector3;
  17516. set direction2(value: Vector3);
  17517. /**
  17518. * 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.
  17519. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17520. */
  17521. get minEmitBox(): Vector3;
  17522. set minEmitBox(value: Vector3);
  17523. /**
  17524. * 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.
  17525. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17526. */
  17527. get maxEmitBox(): Vector3;
  17528. set maxEmitBox(value: Vector3);
  17529. /**
  17530. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17531. */
  17532. color1: Color4;
  17533. /**
  17534. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17535. */
  17536. color2: Color4;
  17537. /**
  17538. * Color the particle will have at the end of its lifetime
  17539. */
  17540. colorDead: Color4;
  17541. /**
  17542. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17543. */
  17544. textureMask: Color4;
  17545. /**
  17546. * The particle emitter type defines the emitter used by the particle system.
  17547. * It can be for example box, sphere, or cone...
  17548. */
  17549. particleEmitterType: IParticleEmitterType;
  17550. /** @hidden */
  17551. _isSubEmitter: boolean;
  17552. /**
  17553. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17554. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17555. */
  17556. billboardMode: number;
  17557. protected _isBillboardBased: boolean;
  17558. /**
  17559. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17560. */
  17561. get isBillboardBased(): boolean;
  17562. set isBillboardBased(value: boolean);
  17563. /**
  17564. * The scene the particle system belongs to.
  17565. */
  17566. protected _scene: Scene;
  17567. /**
  17568. * Local cache of defines for image processing.
  17569. */
  17570. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17571. /**
  17572. * Default configuration related to image processing available in the standard Material.
  17573. */
  17574. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17575. /**
  17576. * Gets the image processing configuration used either in this material.
  17577. */
  17578. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17579. /**
  17580. * Sets the Default image processing configuration used either in the this material.
  17581. *
  17582. * If sets to null, the scene one is in use.
  17583. */
  17584. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17585. /**
  17586. * Attaches a new image processing configuration to the Standard Material.
  17587. * @param configuration
  17588. */
  17589. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17590. /** @hidden */
  17591. protected _reset(): void;
  17592. /** @hidden */
  17593. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17594. /**
  17595. * Instantiates a particle system.
  17596. * 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.
  17597. * @param name The name of the particle system
  17598. */
  17599. constructor(name: string);
  17600. /**
  17601. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17602. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17603. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17604. * @returns the emitter
  17605. */
  17606. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17607. /**
  17608. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17609. * @param radius The radius of the hemisphere to emit from
  17610. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17611. * @returns the emitter
  17612. */
  17613. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17614. /**
  17615. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17616. * @param radius The radius of the sphere to emit from
  17617. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17618. * @returns the emitter
  17619. */
  17620. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17621. /**
  17622. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17623. * @param radius The radius of the sphere to emit from
  17624. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17625. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17626. * @returns the emitter
  17627. */
  17628. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17629. /**
  17630. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17631. * @param radius The radius of the emission cylinder
  17632. * @param height The height of the emission cylinder
  17633. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17634. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17635. * @returns the emitter
  17636. */
  17637. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17638. /**
  17639. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17640. * @param radius The radius of the cylinder to emit from
  17641. * @param height The height of the emission cylinder
  17642. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17643. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17644. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17645. * @returns the emitter
  17646. */
  17647. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17648. /**
  17649. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17650. * @param radius The radius of the cone to emit from
  17651. * @param angle The base angle of the cone
  17652. * @returns the emitter
  17653. */
  17654. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17655. /**
  17656. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17657. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17658. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17659. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17660. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17661. * @returns the emitter
  17662. */
  17663. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17664. }
  17665. }
  17666. declare module "babylonjs/Particles/subEmitter" {
  17667. import { Scene } from "babylonjs/scene";
  17668. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17669. /**
  17670. * Type of sub emitter
  17671. */
  17672. export enum SubEmitterType {
  17673. /**
  17674. * Attached to the particle over it's lifetime
  17675. */
  17676. ATTACHED = 0,
  17677. /**
  17678. * Created when the particle dies
  17679. */
  17680. END = 1
  17681. }
  17682. /**
  17683. * Sub emitter class used to emit particles from an existing particle
  17684. */
  17685. export class SubEmitter {
  17686. /**
  17687. * the particle system to be used by the sub emitter
  17688. */
  17689. particleSystem: ParticleSystem;
  17690. /**
  17691. * Type of the submitter (Default: END)
  17692. */
  17693. type: SubEmitterType;
  17694. /**
  17695. * 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)
  17696. * Note: This only is supported when using an emitter of type Mesh
  17697. */
  17698. inheritDirection: boolean;
  17699. /**
  17700. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17701. */
  17702. inheritedVelocityAmount: number;
  17703. /**
  17704. * Creates a sub emitter
  17705. * @param particleSystem the particle system to be used by the sub emitter
  17706. */
  17707. constructor(
  17708. /**
  17709. * the particle system to be used by the sub emitter
  17710. */
  17711. particleSystem: ParticleSystem);
  17712. /**
  17713. * Clones the sub emitter
  17714. * @returns the cloned sub emitter
  17715. */
  17716. clone(): SubEmitter;
  17717. /**
  17718. * Serialize current object to a JSON object
  17719. * @returns the serialized object
  17720. */
  17721. serialize(): any;
  17722. /** @hidden */
  17723. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17724. /**
  17725. * Creates a new SubEmitter from a serialized JSON version
  17726. * @param serializationObject defines the JSON object to read from
  17727. * @param scene defines the hosting scene
  17728. * @param rootUrl defines the rootUrl for data loading
  17729. * @returns a new SubEmitter
  17730. */
  17731. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17732. /** Release associated resources */
  17733. dispose(): void;
  17734. }
  17735. }
  17736. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17737. /** @hidden */
  17738. export var clipPlaneFragmentDeclaration: {
  17739. name: string;
  17740. shader: string;
  17741. };
  17742. }
  17743. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17744. /** @hidden */
  17745. export var imageProcessingDeclaration: {
  17746. name: string;
  17747. shader: string;
  17748. };
  17749. }
  17750. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17751. /** @hidden */
  17752. export var imageProcessingFunctions: {
  17753. name: string;
  17754. shader: string;
  17755. };
  17756. }
  17757. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17758. /** @hidden */
  17759. export var clipPlaneFragment: {
  17760. name: string;
  17761. shader: string;
  17762. };
  17763. }
  17764. declare module "babylonjs/Shaders/particles.fragment" {
  17765. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17766. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17767. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17768. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17769. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17770. /** @hidden */
  17771. export var particlesPixelShader: {
  17772. name: string;
  17773. shader: string;
  17774. };
  17775. }
  17776. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17777. /** @hidden */
  17778. export var clipPlaneVertexDeclaration: {
  17779. name: string;
  17780. shader: string;
  17781. };
  17782. }
  17783. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17784. /** @hidden */
  17785. export var clipPlaneVertex: {
  17786. name: string;
  17787. shader: string;
  17788. };
  17789. }
  17790. declare module "babylonjs/Shaders/particles.vertex" {
  17791. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17792. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17793. /** @hidden */
  17794. export var particlesVertexShader: {
  17795. name: string;
  17796. shader: string;
  17797. };
  17798. }
  17799. declare module "babylonjs/Particles/particleSystem" {
  17800. import { Nullable } from "babylonjs/types";
  17801. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17802. import { Observable } from "babylonjs/Misc/observable";
  17803. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17804. import { Effect } from "babylonjs/Materials/effect";
  17805. import { Scene, IDisposable } from "babylonjs/scene";
  17806. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17807. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17808. import { Particle } from "babylonjs/Particles/particle";
  17809. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17810. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17811. import "babylonjs/Shaders/particles.fragment";
  17812. import "babylonjs/Shaders/particles.vertex";
  17813. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17814. /**
  17815. * This represents a particle system in Babylon.
  17816. * 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.
  17817. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17818. * @example https://doc.babylonjs.com/babylon101/particles
  17819. */
  17820. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17821. /**
  17822. * Billboard mode will only apply to Y axis
  17823. */
  17824. static readonly BILLBOARDMODE_Y: number;
  17825. /**
  17826. * Billboard mode will apply to all axes
  17827. */
  17828. static readonly BILLBOARDMODE_ALL: number;
  17829. /**
  17830. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17831. */
  17832. static readonly BILLBOARDMODE_STRETCHED: number;
  17833. /**
  17834. * This function can be defined to provide custom update for active particles.
  17835. * This function will be called instead of regular update (age, position, color, etc.).
  17836. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17837. */
  17838. updateFunction: (particles: Particle[]) => void;
  17839. private _emitterWorldMatrix;
  17840. /**
  17841. * This function can be defined to specify initial direction for every new particle.
  17842. * It by default use the emitterType defined function
  17843. */
  17844. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17845. /**
  17846. * This function can be defined to specify initial position for every new particle.
  17847. * It by default use the emitterType defined function
  17848. */
  17849. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17850. /**
  17851. * @hidden
  17852. */
  17853. _inheritedVelocityOffset: Vector3;
  17854. /**
  17855. * An event triggered when the system is disposed
  17856. */
  17857. onDisposeObservable: Observable<ParticleSystem>;
  17858. private _onDisposeObserver;
  17859. /**
  17860. * Sets a callback that will be triggered when the system is disposed
  17861. */
  17862. set onDispose(callback: () => void);
  17863. private _particles;
  17864. private _epsilon;
  17865. private _capacity;
  17866. private _stockParticles;
  17867. private _newPartsExcess;
  17868. private _vertexData;
  17869. private _vertexBuffer;
  17870. private _vertexBuffers;
  17871. private _spriteBuffer;
  17872. private _indexBuffer;
  17873. private _effect;
  17874. private _customEffect;
  17875. private _cachedDefines;
  17876. private _scaledColorStep;
  17877. private _colorDiff;
  17878. private _scaledDirection;
  17879. private _scaledGravity;
  17880. private _currentRenderId;
  17881. private _alive;
  17882. private _useInstancing;
  17883. private _started;
  17884. private _stopped;
  17885. private _actualFrame;
  17886. private _scaledUpdateSpeed;
  17887. private _vertexBufferSize;
  17888. /** @hidden */
  17889. _currentEmitRateGradient: Nullable<FactorGradient>;
  17890. /** @hidden */
  17891. _currentEmitRate1: number;
  17892. /** @hidden */
  17893. _currentEmitRate2: number;
  17894. /** @hidden */
  17895. _currentStartSizeGradient: Nullable<FactorGradient>;
  17896. /** @hidden */
  17897. _currentStartSize1: number;
  17898. /** @hidden */
  17899. _currentStartSize2: number;
  17900. private readonly _rawTextureWidth;
  17901. private _rampGradientsTexture;
  17902. private _useRampGradients;
  17903. /** Gets or sets a boolean indicating that ramp gradients must be used
  17904. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17905. */
  17906. get useRampGradients(): boolean;
  17907. set useRampGradients(value: boolean);
  17908. /**
  17909. * 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.
  17910. * 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: [])
  17911. */
  17912. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17913. private _subEmitters;
  17914. /**
  17915. * @hidden
  17916. * If the particle systems emitter should be disposed when the particle system is disposed
  17917. */
  17918. _disposeEmitterOnDispose: boolean;
  17919. /**
  17920. * The current active Sub-systems, this property is used by the root particle system only.
  17921. */
  17922. activeSubSystems: Array<ParticleSystem>;
  17923. private _rootParticleSystem;
  17924. /**
  17925. * Gets the current list of active particles
  17926. */
  17927. get particles(): Particle[];
  17928. /**
  17929. * Returns the string "ParticleSystem"
  17930. * @returns a string containing the class name
  17931. */
  17932. getClassName(): string;
  17933. /**
  17934. * Instantiates a particle system.
  17935. * 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.
  17936. * @param name The name of the particle system
  17937. * @param capacity The max number of particles alive at the same time
  17938. * @param scene The scene the particle system belongs to
  17939. * @param customEffect a custom effect used to change the way particles are rendered by default
  17940. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17941. * @param epsilon Offset used to render the particles
  17942. */
  17943. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17944. private _addFactorGradient;
  17945. private _removeFactorGradient;
  17946. /**
  17947. * Adds a new life time gradient
  17948. * @param gradient defines the gradient to use (between 0 and 1)
  17949. * @param factor defines the life time factor to affect to the specified gradient
  17950. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17951. * @returns the current particle system
  17952. */
  17953. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17954. /**
  17955. * Remove a specific life time gradient
  17956. * @param gradient defines the gradient to remove
  17957. * @returns the current particle system
  17958. */
  17959. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17960. /**
  17961. * Adds a new size gradient
  17962. * @param gradient defines the gradient to use (between 0 and 1)
  17963. * @param factor defines the size factor to affect to the specified gradient
  17964. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17965. * @returns the current particle system
  17966. */
  17967. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17968. /**
  17969. * Remove a specific size gradient
  17970. * @param gradient defines the gradient to remove
  17971. * @returns the current particle system
  17972. */
  17973. removeSizeGradient(gradient: number): IParticleSystem;
  17974. /**
  17975. * Adds a new color remap gradient
  17976. * @param gradient defines the gradient to use (between 0 and 1)
  17977. * @param min defines the color remap minimal range
  17978. * @param max defines the color remap maximal range
  17979. * @returns the current particle system
  17980. */
  17981. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17982. /**
  17983. * Remove a specific color remap gradient
  17984. * @param gradient defines the gradient to remove
  17985. * @returns the current particle system
  17986. */
  17987. removeColorRemapGradient(gradient: number): IParticleSystem;
  17988. /**
  17989. * Adds a new alpha remap gradient
  17990. * @param gradient defines the gradient to use (between 0 and 1)
  17991. * @param min defines the alpha remap minimal range
  17992. * @param max defines the alpha remap maximal range
  17993. * @returns the current particle system
  17994. */
  17995. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17996. /**
  17997. * Remove a specific alpha remap gradient
  17998. * @param gradient defines the gradient to remove
  17999. * @returns the current particle system
  18000. */
  18001. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  18002. /**
  18003. * Adds a new angular speed gradient
  18004. * @param gradient defines the gradient to use (between 0 and 1)
  18005. * @param factor defines the angular speed to affect to the specified gradient
  18006. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18007. * @returns the current particle system
  18008. */
  18009. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18010. /**
  18011. * Remove a specific angular speed gradient
  18012. * @param gradient defines the gradient to remove
  18013. * @returns the current particle system
  18014. */
  18015. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18016. /**
  18017. * Adds a new velocity gradient
  18018. * @param gradient defines the gradient to use (between 0 and 1)
  18019. * @param factor defines the velocity to affect to the specified gradient
  18020. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18021. * @returns the current particle system
  18022. */
  18023. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18024. /**
  18025. * Remove a specific velocity gradient
  18026. * @param gradient defines the gradient to remove
  18027. * @returns the current particle system
  18028. */
  18029. removeVelocityGradient(gradient: number): IParticleSystem;
  18030. /**
  18031. * Adds a new limit velocity gradient
  18032. * @param gradient defines the gradient to use (between 0 and 1)
  18033. * @param factor defines the limit velocity value to affect to the specified gradient
  18034. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18035. * @returns the current particle system
  18036. */
  18037. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18038. /**
  18039. * Remove a specific limit velocity gradient
  18040. * @param gradient defines the gradient to remove
  18041. * @returns the current particle system
  18042. */
  18043. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18044. /**
  18045. * Adds a new drag gradient
  18046. * @param gradient defines the gradient to use (between 0 and 1)
  18047. * @param factor defines the drag value to affect to the specified gradient
  18048. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18049. * @returns the current particle system
  18050. */
  18051. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18052. /**
  18053. * Remove a specific drag gradient
  18054. * @param gradient defines the gradient to remove
  18055. * @returns the current particle system
  18056. */
  18057. removeDragGradient(gradient: number): IParticleSystem;
  18058. /**
  18059. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18060. * @param gradient defines the gradient to use (between 0 and 1)
  18061. * @param factor defines the emit rate value to affect to the specified gradient
  18062. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18063. * @returns the current particle system
  18064. */
  18065. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18066. /**
  18067. * Remove a specific emit rate gradient
  18068. * @param gradient defines the gradient to remove
  18069. * @returns the current particle system
  18070. */
  18071. removeEmitRateGradient(gradient: number): IParticleSystem;
  18072. /**
  18073. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18074. * @param gradient defines the gradient to use (between 0 and 1)
  18075. * @param factor defines the start size value to affect to the specified gradient
  18076. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18077. * @returns the current particle system
  18078. */
  18079. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18080. /**
  18081. * Remove a specific start size gradient
  18082. * @param gradient defines the gradient to remove
  18083. * @returns the current particle system
  18084. */
  18085. removeStartSizeGradient(gradient: number): IParticleSystem;
  18086. private _createRampGradientTexture;
  18087. /**
  18088. * Gets the current list of ramp gradients.
  18089. * You must use addRampGradient and removeRampGradient to udpate this list
  18090. * @returns the list of ramp gradients
  18091. */
  18092. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18093. /**
  18094. * Adds a new ramp gradient used to remap particle colors
  18095. * @param gradient defines the gradient to use (between 0 and 1)
  18096. * @param color defines the color to affect to the specified gradient
  18097. * @returns the current particle system
  18098. */
  18099. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  18100. /**
  18101. * Remove a specific ramp gradient
  18102. * @param gradient defines the gradient to remove
  18103. * @returns the current particle system
  18104. */
  18105. removeRampGradient(gradient: number): ParticleSystem;
  18106. /**
  18107. * Adds a new color gradient
  18108. * @param gradient defines the gradient to use (between 0 and 1)
  18109. * @param color1 defines the color to affect to the specified gradient
  18110. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18111. * @returns this particle system
  18112. */
  18113. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18114. /**
  18115. * Remove a specific color gradient
  18116. * @param gradient defines the gradient to remove
  18117. * @returns this particle system
  18118. */
  18119. removeColorGradient(gradient: number): IParticleSystem;
  18120. private _fetchR;
  18121. protected _reset(): void;
  18122. private _resetEffect;
  18123. private _createVertexBuffers;
  18124. private _createIndexBuffer;
  18125. /**
  18126. * Gets the maximum number of particles active at the same time.
  18127. * @returns The max number of active particles.
  18128. */
  18129. getCapacity(): number;
  18130. /**
  18131. * Gets whether there are still active particles in the system.
  18132. * @returns True if it is alive, otherwise false.
  18133. */
  18134. isAlive(): boolean;
  18135. /**
  18136. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18137. * @returns True if it has been started, otherwise false.
  18138. */
  18139. isStarted(): boolean;
  18140. private _prepareSubEmitterInternalArray;
  18141. /**
  18142. * Starts the particle system and begins to emit
  18143. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  18144. */
  18145. start(delay?: number): void;
  18146. /**
  18147. * Stops the particle system.
  18148. * @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.
  18149. */
  18150. stop(stopSubEmitters?: boolean): void;
  18151. /**
  18152. * Remove all active particles
  18153. */
  18154. reset(): void;
  18155. /**
  18156. * @hidden (for internal use only)
  18157. */
  18158. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18159. /**
  18160. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18161. * Its lifetime will start back at 0.
  18162. */
  18163. recycleParticle: (particle: Particle) => void;
  18164. private _stopSubEmitters;
  18165. private _createParticle;
  18166. private _removeFromRoot;
  18167. private _emitFromParticle;
  18168. private _update;
  18169. /** @hidden */
  18170. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  18171. /** @hidden */
  18172. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  18173. /** @hidden */
  18174. private _getEffect;
  18175. /**
  18176. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18177. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  18178. */
  18179. animate(preWarmOnly?: boolean): void;
  18180. private _appendParticleVertices;
  18181. /**
  18182. * Rebuilds the particle system.
  18183. */
  18184. rebuild(): void;
  18185. /**
  18186. * Is this system ready to be used/rendered
  18187. * @return true if the system is ready
  18188. */
  18189. isReady(): boolean;
  18190. private _render;
  18191. /**
  18192. * Renders the particle system in its current state.
  18193. * @returns the current number of particles
  18194. */
  18195. render(): number;
  18196. /**
  18197. * Disposes the particle system and free the associated resources
  18198. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18199. */
  18200. dispose(disposeTexture?: boolean): void;
  18201. /**
  18202. * Clones the particle system.
  18203. * @param name The name of the cloned object
  18204. * @param newEmitter The new emitter to use
  18205. * @returns the cloned particle system
  18206. */
  18207. clone(name: string, newEmitter: any): ParticleSystem;
  18208. /**
  18209. * Serializes the particle system to a JSON object.
  18210. * @returns the JSON object
  18211. */
  18212. serialize(): any;
  18213. /** @hidden */
  18214. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  18215. /** @hidden */
  18216. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  18217. /**
  18218. * Parses a JSON object to create a particle system.
  18219. * @param parsedParticleSystem The JSON object to parse
  18220. * @param scene The scene to create the particle system in
  18221. * @param rootUrl The root url to use to load external dependencies like texture
  18222. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  18223. * @returns the Parsed particle system
  18224. */
  18225. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  18226. }
  18227. }
  18228. declare module "babylonjs/Particles/particle" {
  18229. import { Nullable } from "babylonjs/types";
  18230. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  18231. import { Color4 } from "babylonjs/Maths/math.color";
  18232. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  18233. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  18234. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  18235. /**
  18236. * A particle represents one of the element emitted by a particle system.
  18237. * This is mainly define by its coordinates, direction, velocity and age.
  18238. */
  18239. export class Particle {
  18240. /**
  18241. * The particle system the particle belongs to.
  18242. */
  18243. particleSystem: ParticleSystem;
  18244. private static _Count;
  18245. /**
  18246. * Unique ID of the particle
  18247. */
  18248. id: number;
  18249. /**
  18250. * The world position of the particle in the scene.
  18251. */
  18252. position: Vector3;
  18253. /**
  18254. * The world direction of the particle in the scene.
  18255. */
  18256. direction: Vector3;
  18257. /**
  18258. * The color of the particle.
  18259. */
  18260. color: Color4;
  18261. /**
  18262. * The color change of the particle per step.
  18263. */
  18264. colorStep: Color4;
  18265. /**
  18266. * Defines how long will the life of the particle be.
  18267. */
  18268. lifeTime: number;
  18269. /**
  18270. * The current age of the particle.
  18271. */
  18272. age: number;
  18273. /**
  18274. * The current size of the particle.
  18275. */
  18276. size: number;
  18277. /**
  18278. * The current scale of the particle.
  18279. */
  18280. scale: Vector2;
  18281. /**
  18282. * The current angle of the particle.
  18283. */
  18284. angle: number;
  18285. /**
  18286. * Defines how fast is the angle changing.
  18287. */
  18288. angularSpeed: number;
  18289. /**
  18290. * Defines the cell index used by the particle to be rendered from a sprite.
  18291. */
  18292. cellIndex: number;
  18293. /**
  18294. * The information required to support color remapping
  18295. */
  18296. remapData: Vector4;
  18297. /** @hidden */
  18298. _randomCellOffset?: number;
  18299. /** @hidden */
  18300. _initialDirection: Nullable<Vector3>;
  18301. /** @hidden */
  18302. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18303. /** @hidden */
  18304. _initialStartSpriteCellID: number;
  18305. /** @hidden */
  18306. _initialEndSpriteCellID: number;
  18307. /** @hidden */
  18308. _currentColorGradient: Nullable<ColorGradient>;
  18309. /** @hidden */
  18310. _currentColor1: Color4;
  18311. /** @hidden */
  18312. _currentColor2: Color4;
  18313. /** @hidden */
  18314. _currentSizeGradient: Nullable<FactorGradient>;
  18315. /** @hidden */
  18316. _currentSize1: number;
  18317. /** @hidden */
  18318. _currentSize2: number;
  18319. /** @hidden */
  18320. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18321. /** @hidden */
  18322. _currentAngularSpeed1: number;
  18323. /** @hidden */
  18324. _currentAngularSpeed2: number;
  18325. /** @hidden */
  18326. _currentVelocityGradient: Nullable<FactorGradient>;
  18327. /** @hidden */
  18328. _currentVelocity1: number;
  18329. /** @hidden */
  18330. _currentVelocity2: number;
  18331. /** @hidden */
  18332. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18333. /** @hidden */
  18334. _currentLimitVelocity1: number;
  18335. /** @hidden */
  18336. _currentLimitVelocity2: number;
  18337. /** @hidden */
  18338. _currentDragGradient: Nullable<FactorGradient>;
  18339. /** @hidden */
  18340. _currentDrag1: number;
  18341. /** @hidden */
  18342. _currentDrag2: number;
  18343. /** @hidden */
  18344. _randomNoiseCoordinates1: Vector3;
  18345. /** @hidden */
  18346. _randomNoiseCoordinates2: Vector3;
  18347. /**
  18348. * Creates a new instance Particle
  18349. * @param particleSystem the particle system the particle belongs to
  18350. */
  18351. constructor(
  18352. /**
  18353. * The particle system the particle belongs to.
  18354. */
  18355. particleSystem: ParticleSystem);
  18356. private updateCellInfoFromSystem;
  18357. /**
  18358. * Defines how the sprite cell index is updated for the particle
  18359. */
  18360. updateCellIndex(): void;
  18361. /** @hidden */
  18362. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18363. /** @hidden */
  18364. _inheritParticleInfoToSubEmitters(): void;
  18365. /** @hidden */
  18366. _reset(): void;
  18367. /**
  18368. * Copy the properties of particle to another one.
  18369. * @param other the particle to copy the information to.
  18370. */
  18371. copyTo(other: Particle): void;
  18372. }
  18373. }
  18374. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18375. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18376. import { Effect } from "babylonjs/Materials/effect";
  18377. import { Particle } from "babylonjs/Particles/particle";
  18378. /**
  18379. * Particle emitter represents a volume emitting particles.
  18380. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18381. */
  18382. export interface IParticleEmitterType {
  18383. /**
  18384. * Called by the particle System when the direction is computed for the created particle.
  18385. * @param worldMatrix is the world matrix of the particle system
  18386. * @param directionToUpdate is the direction vector to update with the result
  18387. * @param particle is the particle we are computed the direction for
  18388. */
  18389. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18390. /**
  18391. * Called by the particle System when the position is computed for the created particle.
  18392. * @param worldMatrix is the world matrix of the particle system
  18393. * @param positionToUpdate is the position vector to update with the result
  18394. * @param particle is the particle we are computed the position for
  18395. */
  18396. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18397. /**
  18398. * Clones the current emitter and returns a copy of it
  18399. * @returns the new emitter
  18400. */
  18401. clone(): IParticleEmitterType;
  18402. /**
  18403. * Called by the GPUParticleSystem to setup the update shader
  18404. * @param effect defines the update shader
  18405. */
  18406. applyToShader(effect: Effect): void;
  18407. /**
  18408. * Returns a string to use to update the GPU particles update shader
  18409. * @returns the effect defines string
  18410. */
  18411. getEffectDefines(): string;
  18412. /**
  18413. * Returns a string representing the class name
  18414. * @returns a string containing the class name
  18415. */
  18416. getClassName(): string;
  18417. /**
  18418. * Serializes the particle system to a JSON object.
  18419. * @returns the JSON object
  18420. */
  18421. serialize(): any;
  18422. /**
  18423. * Parse properties from a JSON object
  18424. * @param serializationObject defines the JSON object
  18425. */
  18426. parse(serializationObject: any): void;
  18427. }
  18428. }
  18429. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18430. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18431. import { Effect } from "babylonjs/Materials/effect";
  18432. import { Particle } from "babylonjs/Particles/particle";
  18433. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18434. /**
  18435. * Particle emitter emitting particles from the inside of a box.
  18436. * It emits the particles randomly between 2 given directions.
  18437. */
  18438. export class BoxParticleEmitter implements IParticleEmitterType {
  18439. /**
  18440. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18441. */
  18442. direction1: Vector3;
  18443. /**
  18444. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18445. */
  18446. direction2: Vector3;
  18447. /**
  18448. * 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.
  18449. */
  18450. minEmitBox: Vector3;
  18451. /**
  18452. * 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.
  18453. */
  18454. maxEmitBox: Vector3;
  18455. /**
  18456. * Creates a new instance BoxParticleEmitter
  18457. */
  18458. constructor();
  18459. /**
  18460. * Called by the particle System when the direction is computed for the created particle.
  18461. * @param worldMatrix is the world matrix of the particle system
  18462. * @param directionToUpdate is the direction vector to update with the result
  18463. * @param particle is the particle we are computed the direction for
  18464. */
  18465. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18466. /**
  18467. * Called by the particle System when the position is computed for the created particle.
  18468. * @param worldMatrix is the world matrix of the particle system
  18469. * @param positionToUpdate is the position vector to update with the result
  18470. * @param particle is the particle we are computed the position for
  18471. */
  18472. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18473. /**
  18474. * Clones the current emitter and returns a copy of it
  18475. * @returns the new emitter
  18476. */
  18477. clone(): BoxParticleEmitter;
  18478. /**
  18479. * Called by the GPUParticleSystem to setup the update shader
  18480. * @param effect defines the update shader
  18481. */
  18482. applyToShader(effect: Effect): void;
  18483. /**
  18484. * Returns a string to use to update the GPU particles update shader
  18485. * @returns a string containng the defines string
  18486. */
  18487. getEffectDefines(): string;
  18488. /**
  18489. * Returns the string "BoxParticleEmitter"
  18490. * @returns a string containing the class name
  18491. */
  18492. getClassName(): string;
  18493. /**
  18494. * Serializes the particle system to a JSON object.
  18495. * @returns the JSON object
  18496. */
  18497. serialize(): any;
  18498. /**
  18499. * Parse properties from a JSON object
  18500. * @param serializationObject defines the JSON object
  18501. */
  18502. parse(serializationObject: any): void;
  18503. }
  18504. }
  18505. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18506. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18507. import { Effect } from "babylonjs/Materials/effect";
  18508. import { Particle } from "babylonjs/Particles/particle";
  18509. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18510. /**
  18511. * Particle emitter emitting particles from the inside of a cone.
  18512. * It emits the particles alongside the cone volume from the base to the particle.
  18513. * The emission direction might be randomized.
  18514. */
  18515. export class ConeParticleEmitter implements IParticleEmitterType {
  18516. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18517. directionRandomizer: number;
  18518. private _radius;
  18519. private _angle;
  18520. private _height;
  18521. /**
  18522. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18523. */
  18524. radiusRange: number;
  18525. /**
  18526. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18527. */
  18528. heightRange: number;
  18529. /**
  18530. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18531. */
  18532. emitFromSpawnPointOnly: boolean;
  18533. /**
  18534. * Gets or sets the radius of the emission cone
  18535. */
  18536. get radius(): number;
  18537. set radius(value: number);
  18538. /**
  18539. * Gets or sets the angle of the emission cone
  18540. */
  18541. get angle(): number;
  18542. set angle(value: number);
  18543. private _buildHeight;
  18544. /**
  18545. * Creates a new instance ConeParticleEmitter
  18546. * @param radius the radius of the emission cone (1 by default)
  18547. * @param angle the cone base angle (PI by default)
  18548. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18549. */
  18550. constructor(radius?: number, angle?: number,
  18551. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18552. directionRandomizer?: number);
  18553. /**
  18554. * Called by the particle System when the direction is computed for the created particle.
  18555. * @param worldMatrix is the world matrix of the particle system
  18556. * @param directionToUpdate is the direction vector to update with the result
  18557. * @param particle is the particle we are computed the direction for
  18558. */
  18559. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18560. /**
  18561. * Called by the particle System when the position is computed for the created particle.
  18562. * @param worldMatrix is the world matrix of the particle system
  18563. * @param positionToUpdate is the position vector to update with the result
  18564. * @param particle is the particle we are computed the position for
  18565. */
  18566. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18567. /**
  18568. * Clones the current emitter and returns a copy of it
  18569. * @returns the new emitter
  18570. */
  18571. clone(): ConeParticleEmitter;
  18572. /**
  18573. * Called by the GPUParticleSystem to setup the update shader
  18574. * @param effect defines the update shader
  18575. */
  18576. applyToShader(effect: Effect): void;
  18577. /**
  18578. * Returns a string to use to update the GPU particles update shader
  18579. * @returns a string containng the defines string
  18580. */
  18581. getEffectDefines(): string;
  18582. /**
  18583. * Returns the string "ConeParticleEmitter"
  18584. * @returns a string containing the class name
  18585. */
  18586. getClassName(): string;
  18587. /**
  18588. * Serializes the particle system to a JSON object.
  18589. * @returns the JSON object
  18590. */
  18591. serialize(): any;
  18592. /**
  18593. * Parse properties from a JSON object
  18594. * @param serializationObject defines the JSON object
  18595. */
  18596. parse(serializationObject: any): void;
  18597. }
  18598. }
  18599. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18600. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18601. import { Effect } from "babylonjs/Materials/effect";
  18602. import { Particle } from "babylonjs/Particles/particle";
  18603. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18604. /**
  18605. * Particle emitter emitting particles from the inside of a cylinder.
  18606. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18607. */
  18608. export class CylinderParticleEmitter implements IParticleEmitterType {
  18609. /**
  18610. * The radius of the emission cylinder.
  18611. */
  18612. radius: number;
  18613. /**
  18614. * The height of the emission cylinder.
  18615. */
  18616. height: number;
  18617. /**
  18618. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18619. */
  18620. radiusRange: number;
  18621. /**
  18622. * How much to randomize the particle direction [0-1].
  18623. */
  18624. directionRandomizer: number;
  18625. /**
  18626. * Creates a new instance CylinderParticleEmitter
  18627. * @param radius the radius of the emission cylinder (1 by default)
  18628. * @param height the height of the emission cylinder (1 by default)
  18629. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18630. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18631. */
  18632. constructor(
  18633. /**
  18634. * The radius of the emission cylinder.
  18635. */
  18636. radius?: number,
  18637. /**
  18638. * The height of the emission cylinder.
  18639. */
  18640. height?: number,
  18641. /**
  18642. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18643. */
  18644. radiusRange?: number,
  18645. /**
  18646. * How much to randomize the particle direction [0-1].
  18647. */
  18648. directionRandomizer?: number);
  18649. /**
  18650. * Called by the particle System when the direction is computed for the created particle.
  18651. * @param worldMatrix is the world matrix of the particle system
  18652. * @param directionToUpdate is the direction vector to update with the result
  18653. * @param particle is the particle we are computed the direction for
  18654. */
  18655. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18656. /**
  18657. * Called by the particle System when the position is computed for the created particle.
  18658. * @param worldMatrix is the world matrix of the particle system
  18659. * @param positionToUpdate is the position vector to update with the result
  18660. * @param particle is the particle we are computed the position for
  18661. */
  18662. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18663. /**
  18664. * Clones the current emitter and returns a copy of it
  18665. * @returns the new emitter
  18666. */
  18667. clone(): CylinderParticleEmitter;
  18668. /**
  18669. * Called by the GPUParticleSystem to setup the update shader
  18670. * @param effect defines the update shader
  18671. */
  18672. applyToShader(effect: Effect): void;
  18673. /**
  18674. * Returns a string to use to update the GPU particles update shader
  18675. * @returns a string containng the defines string
  18676. */
  18677. getEffectDefines(): string;
  18678. /**
  18679. * Returns the string "CylinderParticleEmitter"
  18680. * @returns a string containing the class name
  18681. */
  18682. getClassName(): string;
  18683. /**
  18684. * Serializes the particle system to a JSON object.
  18685. * @returns the JSON object
  18686. */
  18687. serialize(): any;
  18688. /**
  18689. * Parse properties from a JSON object
  18690. * @param serializationObject defines the JSON object
  18691. */
  18692. parse(serializationObject: any): void;
  18693. }
  18694. /**
  18695. * Particle emitter emitting particles from the inside of a cylinder.
  18696. * It emits the particles randomly between two vectors.
  18697. */
  18698. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18699. /**
  18700. * The min limit of the emission direction.
  18701. */
  18702. direction1: Vector3;
  18703. /**
  18704. * The max limit of the emission direction.
  18705. */
  18706. direction2: Vector3;
  18707. /**
  18708. * Creates a new instance CylinderDirectedParticleEmitter
  18709. * @param radius the radius of the emission cylinder (1 by default)
  18710. * @param height the height of the emission cylinder (1 by default)
  18711. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18712. * @param direction1 the min limit of the emission direction (up vector by default)
  18713. * @param direction2 the max limit of the emission direction (up vector by default)
  18714. */
  18715. constructor(radius?: number, height?: number, radiusRange?: number,
  18716. /**
  18717. * The min limit of the emission direction.
  18718. */
  18719. direction1?: Vector3,
  18720. /**
  18721. * The max limit of the emission direction.
  18722. */
  18723. direction2?: Vector3);
  18724. /**
  18725. * Called by the particle System when the direction is computed for the created particle.
  18726. * @param worldMatrix is the world matrix of the particle system
  18727. * @param directionToUpdate is the direction vector to update with the result
  18728. * @param particle is the particle we are computed the direction for
  18729. */
  18730. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18731. /**
  18732. * Clones the current emitter and returns a copy of it
  18733. * @returns the new emitter
  18734. */
  18735. clone(): CylinderDirectedParticleEmitter;
  18736. /**
  18737. * Called by the GPUParticleSystem to setup the update shader
  18738. * @param effect defines the update shader
  18739. */
  18740. applyToShader(effect: Effect): void;
  18741. /**
  18742. * Returns a string to use to update the GPU particles update shader
  18743. * @returns a string containng the defines string
  18744. */
  18745. getEffectDefines(): string;
  18746. /**
  18747. * Returns the string "CylinderDirectedParticleEmitter"
  18748. * @returns a string containing the class name
  18749. */
  18750. getClassName(): string;
  18751. /**
  18752. * Serializes the particle system to a JSON object.
  18753. * @returns the JSON object
  18754. */
  18755. serialize(): any;
  18756. /**
  18757. * Parse properties from a JSON object
  18758. * @param serializationObject defines the JSON object
  18759. */
  18760. parse(serializationObject: any): void;
  18761. }
  18762. }
  18763. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18764. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18765. import { Effect } from "babylonjs/Materials/effect";
  18766. import { Particle } from "babylonjs/Particles/particle";
  18767. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18768. /**
  18769. * Particle emitter emitting particles from the inside of a hemisphere.
  18770. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18771. */
  18772. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18773. /**
  18774. * The radius of the emission hemisphere.
  18775. */
  18776. radius: number;
  18777. /**
  18778. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18779. */
  18780. radiusRange: number;
  18781. /**
  18782. * How much to randomize the particle direction [0-1].
  18783. */
  18784. directionRandomizer: number;
  18785. /**
  18786. * Creates a new instance HemisphericParticleEmitter
  18787. * @param radius the radius of the emission hemisphere (1 by default)
  18788. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18789. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18790. */
  18791. constructor(
  18792. /**
  18793. * The radius of the emission hemisphere.
  18794. */
  18795. radius?: number,
  18796. /**
  18797. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18798. */
  18799. radiusRange?: number,
  18800. /**
  18801. * How much to randomize the particle direction [0-1].
  18802. */
  18803. directionRandomizer?: number);
  18804. /**
  18805. * Called by the particle System when the direction is computed for the created particle.
  18806. * @param worldMatrix is the world matrix of the particle system
  18807. * @param directionToUpdate is the direction vector to update with the result
  18808. * @param particle is the particle we are computed the direction for
  18809. */
  18810. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18811. /**
  18812. * Called by the particle System when the position is computed for the created particle.
  18813. * @param worldMatrix is the world matrix of the particle system
  18814. * @param positionToUpdate is the position vector to update with the result
  18815. * @param particle is the particle we are computed the position for
  18816. */
  18817. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18818. /**
  18819. * Clones the current emitter and returns a copy of it
  18820. * @returns the new emitter
  18821. */
  18822. clone(): HemisphericParticleEmitter;
  18823. /**
  18824. * Called by the GPUParticleSystem to setup the update shader
  18825. * @param effect defines the update shader
  18826. */
  18827. applyToShader(effect: Effect): void;
  18828. /**
  18829. * Returns a string to use to update the GPU particles update shader
  18830. * @returns a string containng the defines string
  18831. */
  18832. getEffectDefines(): string;
  18833. /**
  18834. * Returns the string "HemisphericParticleEmitter"
  18835. * @returns a string containing the class name
  18836. */
  18837. getClassName(): string;
  18838. /**
  18839. * Serializes the particle system to a JSON object.
  18840. * @returns the JSON object
  18841. */
  18842. serialize(): any;
  18843. /**
  18844. * Parse properties from a JSON object
  18845. * @param serializationObject defines the JSON object
  18846. */
  18847. parse(serializationObject: any): void;
  18848. }
  18849. }
  18850. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18851. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18852. import { Effect } from "babylonjs/Materials/effect";
  18853. import { Particle } from "babylonjs/Particles/particle";
  18854. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18855. /**
  18856. * Particle emitter emitting particles from a point.
  18857. * It emits the particles randomly between 2 given directions.
  18858. */
  18859. export class PointParticleEmitter implements IParticleEmitterType {
  18860. /**
  18861. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18862. */
  18863. direction1: Vector3;
  18864. /**
  18865. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18866. */
  18867. direction2: Vector3;
  18868. /**
  18869. * Creates a new instance PointParticleEmitter
  18870. */
  18871. constructor();
  18872. /**
  18873. * Called by the particle System when the direction is computed for the created particle.
  18874. * @param worldMatrix is the world matrix of the particle system
  18875. * @param directionToUpdate is the direction vector to update with the result
  18876. * @param particle is the particle we are computed the direction for
  18877. */
  18878. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18879. /**
  18880. * Called by the particle System when the position is computed for the created particle.
  18881. * @param worldMatrix is the world matrix of the particle system
  18882. * @param positionToUpdate is the position vector to update with the result
  18883. * @param particle is the particle we are computed the position for
  18884. */
  18885. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18886. /**
  18887. * Clones the current emitter and returns a copy of it
  18888. * @returns the new emitter
  18889. */
  18890. clone(): PointParticleEmitter;
  18891. /**
  18892. * Called by the GPUParticleSystem to setup the update shader
  18893. * @param effect defines the update shader
  18894. */
  18895. applyToShader(effect: Effect): void;
  18896. /**
  18897. * Returns a string to use to update the GPU particles update shader
  18898. * @returns a string containng the defines string
  18899. */
  18900. getEffectDefines(): string;
  18901. /**
  18902. * Returns the string "PointParticleEmitter"
  18903. * @returns a string containing the class name
  18904. */
  18905. getClassName(): string;
  18906. /**
  18907. * Serializes the particle system to a JSON object.
  18908. * @returns the JSON object
  18909. */
  18910. serialize(): any;
  18911. /**
  18912. * Parse properties from a JSON object
  18913. * @param serializationObject defines the JSON object
  18914. */
  18915. parse(serializationObject: any): void;
  18916. }
  18917. }
  18918. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18919. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18920. import { Effect } from "babylonjs/Materials/effect";
  18921. import { Particle } from "babylonjs/Particles/particle";
  18922. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18923. /**
  18924. * Particle emitter emitting particles from the inside of a sphere.
  18925. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18926. */
  18927. export class SphereParticleEmitter implements IParticleEmitterType {
  18928. /**
  18929. * The radius of the emission sphere.
  18930. */
  18931. radius: number;
  18932. /**
  18933. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18934. */
  18935. radiusRange: number;
  18936. /**
  18937. * How much to randomize the particle direction [0-1].
  18938. */
  18939. directionRandomizer: number;
  18940. /**
  18941. * Creates a new instance SphereParticleEmitter
  18942. * @param radius the radius of the emission sphere (1 by default)
  18943. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18944. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18945. */
  18946. constructor(
  18947. /**
  18948. * The radius of the emission sphere.
  18949. */
  18950. radius?: number,
  18951. /**
  18952. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18953. */
  18954. radiusRange?: number,
  18955. /**
  18956. * How much to randomize the particle direction [0-1].
  18957. */
  18958. directionRandomizer?: number);
  18959. /**
  18960. * Called by the particle System when the direction is computed for the created particle.
  18961. * @param worldMatrix is the world matrix of the particle system
  18962. * @param directionToUpdate is the direction vector to update with the result
  18963. * @param particle is the particle we are computed the direction for
  18964. */
  18965. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18966. /**
  18967. * Called by the particle System when the position is computed for the created particle.
  18968. * @param worldMatrix is the world matrix of the particle system
  18969. * @param positionToUpdate is the position vector to update with the result
  18970. * @param particle is the particle we are computed the position for
  18971. */
  18972. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18973. /**
  18974. * Clones the current emitter and returns a copy of it
  18975. * @returns the new emitter
  18976. */
  18977. clone(): SphereParticleEmitter;
  18978. /**
  18979. * Called by the GPUParticleSystem to setup the update shader
  18980. * @param effect defines the update shader
  18981. */
  18982. applyToShader(effect: Effect): void;
  18983. /**
  18984. * Returns a string to use to update the GPU particles update shader
  18985. * @returns a string containng the defines string
  18986. */
  18987. getEffectDefines(): string;
  18988. /**
  18989. * Returns the string "SphereParticleEmitter"
  18990. * @returns a string containing the class name
  18991. */
  18992. getClassName(): string;
  18993. /**
  18994. * Serializes the particle system to a JSON object.
  18995. * @returns the JSON object
  18996. */
  18997. serialize(): any;
  18998. /**
  18999. * Parse properties from a JSON object
  19000. * @param serializationObject defines the JSON object
  19001. */
  19002. parse(serializationObject: any): void;
  19003. }
  19004. /**
  19005. * Particle emitter emitting particles from the inside of a sphere.
  19006. * It emits the particles randomly between two vectors.
  19007. */
  19008. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  19009. /**
  19010. * The min limit of the emission direction.
  19011. */
  19012. direction1: Vector3;
  19013. /**
  19014. * The max limit of the emission direction.
  19015. */
  19016. direction2: Vector3;
  19017. /**
  19018. * Creates a new instance SphereDirectedParticleEmitter
  19019. * @param radius the radius of the emission sphere (1 by default)
  19020. * @param direction1 the min limit of the emission direction (up vector by default)
  19021. * @param direction2 the max limit of the emission direction (up vector by default)
  19022. */
  19023. constructor(radius?: number,
  19024. /**
  19025. * The min limit of the emission direction.
  19026. */
  19027. direction1?: Vector3,
  19028. /**
  19029. * The max limit of the emission direction.
  19030. */
  19031. direction2?: Vector3);
  19032. /**
  19033. * Called by the particle System when the direction is computed for the created particle.
  19034. * @param worldMatrix is the world matrix of the particle system
  19035. * @param directionToUpdate is the direction vector to update with the result
  19036. * @param particle is the particle we are computed the direction for
  19037. */
  19038. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19039. /**
  19040. * Clones the current emitter and returns a copy of it
  19041. * @returns the new emitter
  19042. */
  19043. clone(): SphereDirectedParticleEmitter;
  19044. /**
  19045. * Called by the GPUParticleSystem to setup the update shader
  19046. * @param effect defines the update shader
  19047. */
  19048. applyToShader(effect: Effect): void;
  19049. /**
  19050. * Returns a string to use to update the GPU particles update shader
  19051. * @returns a string containng the defines string
  19052. */
  19053. getEffectDefines(): string;
  19054. /**
  19055. * Returns the string "SphereDirectedParticleEmitter"
  19056. * @returns a string containing the class name
  19057. */
  19058. getClassName(): string;
  19059. /**
  19060. * Serializes the particle system to a JSON object.
  19061. * @returns the JSON object
  19062. */
  19063. serialize(): any;
  19064. /**
  19065. * Parse properties from a JSON object
  19066. * @param serializationObject defines the JSON object
  19067. */
  19068. parse(serializationObject: any): void;
  19069. }
  19070. }
  19071. declare module "babylonjs/Particles/EmitterTypes/index" {
  19072. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  19073. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  19074. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  19075. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  19076. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  19077. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  19078. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  19079. }
  19080. declare module "babylonjs/Particles/IParticleSystem" {
  19081. import { Nullable } from "babylonjs/types";
  19082. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  19083. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19085. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19086. import { Texture } from "babylonjs/Materials/Textures/texture";
  19087. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  19088. import { Scene } from "babylonjs/scene";
  19089. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  19090. import { Animation } from "babylonjs/Animations/animation";
  19091. /**
  19092. * Interface representing a particle system in Babylon.js.
  19093. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  19094. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  19095. */
  19096. export interface IParticleSystem {
  19097. /**
  19098. * List of animations used by the particle system.
  19099. */
  19100. animations: Animation[];
  19101. /**
  19102. * The id of the Particle system.
  19103. */
  19104. id: string;
  19105. /**
  19106. * The name of the Particle system.
  19107. */
  19108. name: string;
  19109. /**
  19110. * The emitter represents the Mesh or position we are attaching the particle system to.
  19111. */
  19112. emitter: Nullable<AbstractMesh | Vector3>;
  19113. /**
  19114. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19115. */
  19116. isBillboardBased: boolean;
  19117. /**
  19118. * The rendering group used by the Particle system to chose when to render.
  19119. */
  19120. renderingGroupId: number;
  19121. /**
  19122. * The layer mask we are rendering the particles through.
  19123. */
  19124. layerMask: number;
  19125. /**
  19126. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19127. */
  19128. updateSpeed: number;
  19129. /**
  19130. * The amount of time the particle system is running (depends of the overall update speed).
  19131. */
  19132. targetStopDuration: number;
  19133. /**
  19134. * The texture used to render each particle. (this can be a spritesheet)
  19135. */
  19136. particleTexture: Nullable<Texture>;
  19137. /**
  19138. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  19139. */
  19140. blendMode: number;
  19141. /**
  19142. * Minimum life time of emitting particles.
  19143. */
  19144. minLifeTime: number;
  19145. /**
  19146. * Maximum life time of emitting particles.
  19147. */
  19148. maxLifeTime: number;
  19149. /**
  19150. * Minimum Size of emitting particles.
  19151. */
  19152. minSize: number;
  19153. /**
  19154. * Maximum Size of emitting particles.
  19155. */
  19156. maxSize: number;
  19157. /**
  19158. * Minimum scale of emitting particles on X axis.
  19159. */
  19160. minScaleX: number;
  19161. /**
  19162. * Maximum scale of emitting particles on X axis.
  19163. */
  19164. maxScaleX: number;
  19165. /**
  19166. * Minimum scale of emitting particles on Y axis.
  19167. */
  19168. minScaleY: number;
  19169. /**
  19170. * Maximum scale of emitting particles on Y axis.
  19171. */
  19172. maxScaleY: number;
  19173. /**
  19174. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19175. */
  19176. color1: Color4;
  19177. /**
  19178. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19179. */
  19180. color2: Color4;
  19181. /**
  19182. * Color the particle will have at the end of its lifetime.
  19183. */
  19184. colorDead: Color4;
  19185. /**
  19186. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19187. */
  19188. emitRate: number;
  19189. /**
  19190. * You can use gravity if you want to give an orientation to your particles.
  19191. */
  19192. gravity: Vector3;
  19193. /**
  19194. * Minimum power of emitting particles.
  19195. */
  19196. minEmitPower: number;
  19197. /**
  19198. * Maximum power of emitting particles.
  19199. */
  19200. maxEmitPower: number;
  19201. /**
  19202. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19203. */
  19204. minAngularSpeed: number;
  19205. /**
  19206. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19207. */
  19208. maxAngularSpeed: number;
  19209. /**
  19210. * Gets or sets the minimal initial rotation in radians.
  19211. */
  19212. minInitialRotation: number;
  19213. /**
  19214. * Gets or sets the maximal initial rotation in radians.
  19215. */
  19216. maxInitialRotation: number;
  19217. /**
  19218. * The particle emitter type defines the emitter used by the particle system.
  19219. * It can be for example box, sphere, or cone...
  19220. */
  19221. particleEmitterType: Nullable<IParticleEmitterType>;
  19222. /**
  19223. * Defines the delay in milliseconds before starting the system (0 by default)
  19224. */
  19225. startDelay: number;
  19226. /**
  19227. * 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
  19228. */
  19229. preWarmCycles: number;
  19230. /**
  19231. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  19232. */
  19233. preWarmStepOffset: number;
  19234. /**
  19235. * 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)
  19236. */
  19237. spriteCellChangeSpeed: number;
  19238. /**
  19239. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19240. */
  19241. startSpriteCellID: number;
  19242. /**
  19243. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19244. */
  19245. endSpriteCellID: number;
  19246. /**
  19247. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19248. */
  19249. spriteCellWidth: number;
  19250. /**
  19251. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19252. */
  19253. spriteCellHeight: number;
  19254. /**
  19255. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19256. */
  19257. spriteRandomStartCell: boolean;
  19258. /**
  19259. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  19260. */
  19261. isAnimationSheetEnabled: boolean;
  19262. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19263. translationPivot: Vector2;
  19264. /**
  19265. * Gets or sets a texture used to add random noise to particle positions
  19266. */
  19267. noiseTexture: Nullable<BaseTexture>;
  19268. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19269. noiseStrength: Vector3;
  19270. /**
  19271. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19272. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19273. */
  19274. billboardMode: number;
  19275. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19276. limitVelocityDamping: number;
  19277. /**
  19278. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19279. */
  19280. beginAnimationOnStart: boolean;
  19281. /**
  19282. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19283. */
  19284. beginAnimationFrom: number;
  19285. /**
  19286. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19287. */
  19288. beginAnimationTo: number;
  19289. /**
  19290. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19291. */
  19292. beginAnimationLoop: boolean;
  19293. /**
  19294. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19295. */
  19296. disposeOnStop: boolean;
  19297. /**
  19298. * Gets the maximum number of particles active at the same time.
  19299. * @returns The max number of active particles.
  19300. */
  19301. getCapacity(): number;
  19302. /**
  19303. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19304. * @returns True if it has been started, otherwise false.
  19305. */
  19306. isStarted(): boolean;
  19307. /**
  19308. * Animates the particle system for this frame.
  19309. */
  19310. animate(): void;
  19311. /**
  19312. * Renders the particle system in its current state.
  19313. * @returns the current number of particles
  19314. */
  19315. render(): number;
  19316. /**
  19317. * Dispose the particle system and frees its associated resources.
  19318. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19319. */
  19320. dispose(disposeTexture?: boolean): void;
  19321. /**
  19322. * Clones the particle system.
  19323. * @param name The name of the cloned object
  19324. * @param newEmitter The new emitter to use
  19325. * @returns the cloned particle system
  19326. */
  19327. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19328. /**
  19329. * Serializes the particle system to a JSON object.
  19330. * @returns the JSON object
  19331. */
  19332. serialize(): any;
  19333. /**
  19334. * Rebuild the particle system
  19335. */
  19336. rebuild(): void;
  19337. /**
  19338. * Starts the particle system and begins to emit
  19339. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19340. */
  19341. start(delay?: number): void;
  19342. /**
  19343. * Stops the particle system.
  19344. */
  19345. stop(): void;
  19346. /**
  19347. * Remove all active particles
  19348. */
  19349. reset(): void;
  19350. /**
  19351. * Is this system ready to be used/rendered
  19352. * @return true if the system is ready
  19353. */
  19354. isReady(): boolean;
  19355. /**
  19356. * Adds a new color gradient
  19357. * @param gradient defines the gradient to use (between 0 and 1)
  19358. * @param color1 defines the color to affect to the specified gradient
  19359. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19360. * @returns the current particle system
  19361. */
  19362. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19363. /**
  19364. * Remove a specific color gradient
  19365. * @param gradient defines the gradient to remove
  19366. * @returns the current particle system
  19367. */
  19368. removeColorGradient(gradient: number): IParticleSystem;
  19369. /**
  19370. * Adds a new size gradient
  19371. * @param gradient defines the gradient to use (between 0 and 1)
  19372. * @param factor defines the size factor to affect to the specified gradient
  19373. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19374. * @returns the current particle system
  19375. */
  19376. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19377. /**
  19378. * Remove a specific size gradient
  19379. * @param gradient defines the gradient to remove
  19380. * @returns the current particle system
  19381. */
  19382. removeSizeGradient(gradient: number): IParticleSystem;
  19383. /**
  19384. * Gets the current list of color gradients.
  19385. * You must use addColorGradient and removeColorGradient to udpate this list
  19386. * @returns the list of color gradients
  19387. */
  19388. getColorGradients(): Nullable<Array<ColorGradient>>;
  19389. /**
  19390. * Gets the current list of size gradients.
  19391. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19392. * @returns the list of size gradients
  19393. */
  19394. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19395. /**
  19396. * Gets the current list of angular speed gradients.
  19397. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19398. * @returns the list of angular speed gradients
  19399. */
  19400. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19401. /**
  19402. * Adds a new angular speed gradient
  19403. * @param gradient defines the gradient to use (between 0 and 1)
  19404. * @param factor defines the angular speed to affect to the specified gradient
  19405. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19406. * @returns the current particle system
  19407. */
  19408. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19409. /**
  19410. * Remove a specific angular speed gradient
  19411. * @param gradient defines the gradient to remove
  19412. * @returns the current particle system
  19413. */
  19414. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19415. /**
  19416. * Gets the current list of velocity gradients.
  19417. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19418. * @returns the list of velocity gradients
  19419. */
  19420. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19421. /**
  19422. * Adds a new velocity gradient
  19423. * @param gradient defines the gradient to use (between 0 and 1)
  19424. * @param factor defines the velocity to affect to the specified gradient
  19425. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19426. * @returns the current particle system
  19427. */
  19428. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19429. /**
  19430. * Remove a specific velocity gradient
  19431. * @param gradient defines the gradient to remove
  19432. * @returns the current particle system
  19433. */
  19434. removeVelocityGradient(gradient: number): IParticleSystem;
  19435. /**
  19436. * Gets the current list of limit velocity gradients.
  19437. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19438. * @returns the list of limit velocity gradients
  19439. */
  19440. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19441. /**
  19442. * Adds a new limit velocity gradient
  19443. * @param gradient defines the gradient to use (between 0 and 1)
  19444. * @param factor defines the limit velocity to affect to the specified gradient
  19445. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19446. * @returns the current particle system
  19447. */
  19448. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19449. /**
  19450. * Remove a specific limit velocity gradient
  19451. * @param gradient defines the gradient to remove
  19452. * @returns the current particle system
  19453. */
  19454. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19455. /**
  19456. * Adds a new drag gradient
  19457. * @param gradient defines the gradient to use (between 0 and 1)
  19458. * @param factor defines the drag to affect to the specified gradient
  19459. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19460. * @returns the current particle system
  19461. */
  19462. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19463. /**
  19464. * Remove a specific drag gradient
  19465. * @param gradient defines the gradient to remove
  19466. * @returns the current particle system
  19467. */
  19468. removeDragGradient(gradient: number): IParticleSystem;
  19469. /**
  19470. * Gets the current list of drag gradients.
  19471. * You must use addDragGradient and removeDragGradient to udpate this list
  19472. * @returns the list of drag gradients
  19473. */
  19474. getDragGradients(): Nullable<Array<FactorGradient>>;
  19475. /**
  19476. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19477. * @param gradient defines the gradient to use (between 0 and 1)
  19478. * @param factor defines the emit rate to affect to the specified gradient
  19479. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19480. * @returns the current particle system
  19481. */
  19482. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19483. /**
  19484. * Remove a specific emit rate gradient
  19485. * @param gradient defines the gradient to remove
  19486. * @returns the current particle system
  19487. */
  19488. removeEmitRateGradient(gradient: number): IParticleSystem;
  19489. /**
  19490. * Gets the current list of emit rate gradients.
  19491. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19492. * @returns the list of emit rate gradients
  19493. */
  19494. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19495. /**
  19496. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19497. * @param gradient defines the gradient to use (between 0 and 1)
  19498. * @param factor defines the start size to affect to the specified gradient
  19499. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19500. * @returns the current particle system
  19501. */
  19502. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19503. /**
  19504. * Remove a specific start size gradient
  19505. * @param gradient defines the gradient to remove
  19506. * @returns the current particle system
  19507. */
  19508. removeStartSizeGradient(gradient: number): IParticleSystem;
  19509. /**
  19510. * Gets the current list of start size gradients.
  19511. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19512. * @returns the list of start size gradients
  19513. */
  19514. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19515. /**
  19516. * Adds a new life time gradient
  19517. * @param gradient defines the gradient to use (between 0 and 1)
  19518. * @param factor defines the life time factor to affect to the specified gradient
  19519. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19520. * @returns the current particle system
  19521. */
  19522. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19523. /**
  19524. * Remove a specific life time gradient
  19525. * @param gradient defines the gradient to remove
  19526. * @returns the current particle system
  19527. */
  19528. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19529. /**
  19530. * Gets the current list of life time gradients.
  19531. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19532. * @returns the list of life time gradients
  19533. */
  19534. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19535. /**
  19536. * Gets the current list of color gradients.
  19537. * You must use addColorGradient and removeColorGradient to udpate this list
  19538. * @returns the list of color gradients
  19539. */
  19540. getColorGradients(): Nullable<Array<ColorGradient>>;
  19541. /**
  19542. * Adds a new ramp gradient used to remap particle colors
  19543. * @param gradient defines the gradient to use (between 0 and 1)
  19544. * @param color defines the color to affect to the specified gradient
  19545. * @returns the current particle system
  19546. */
  19547. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19548. /**
  19549. * Gets the current list of ramp gradients.
  19550. * You must use addRampGradient and removeRampGradient to udpate this list
  19551. * @returns the list of ramp gradients
  19552. */
  19553. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19554. /** Gets or sets a boolean indicating that ramp gradients must be used
  19555. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19556. */
  19557. useRampGradients: boolean;
  19558. /**
  19559. * Adds a new color remap gradient
  19560. * @param gradient defines the gradient to use (between 0 and 1)
  19561. * @param min defines the color remap minimal range
  19562. * @param max defines the color remap maximal range
  19563. * @returns the current particle system
  19564. */
  19565. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19566. /**
  19567. * Gets the current list of color remap gradients.
  19568. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19569. * @returns the list of color remap gradients
  19570. */
  19571. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19572. /**
  19573. * Adds a new alpha remap gradient
  19574. * @param gradient defines the gradient to use (between 0 and 1)
  19575. * @param min defines the alpha remap minimal range
  19576. * @param max defines the alpha remap maximal range
  19577. * @returns the current particle system
  19578. */
  19579. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19580. /**
  19581. * Gets the current list of alpha remap gradients.
  19582. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19583. * @returns the list of alpha remap gradients
  19584. */
  19585. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19586. /**
  19587. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19588. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19589. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19590. * @returns the emitter
  19591. */
  19592. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19593. /**
  19594. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19595. * @param radius The radius of the hemisphere to emit from
  19596. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19597. * @returns the emitter
  19598. */
  19599. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19600. /**
  19601. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19602. * @param radius The radius of the sphere to emit from
  19603. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19604. * @returns the emitter
  19605. */
  19606. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19607. /**
  19608. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19609. * @param radius The radius of the sphere to emit from
  19610. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19611. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19612. * @returns the emitter
  19613. */
  19614. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19615. /**
  19616. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19617. * @param radius The radius of the emission cylinder
  19618. * @param height The height of the emission cylinder
  19619. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19620. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19621. * @returns the emitter
  19622. */
  19623. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19624. /**
  19625. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19626. * @param radius The radius of the cylinder to emit from
  19627. * @param height The height of the emission cylinder
  19628. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19629. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19630. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19631. * @returns the emitter
  19632. */
  19633. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19634. /**
  19635. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19636. * @param radius The radius of the cone to emit from
  19637. * @param angle The base angle of the cone
  19638. * @returns the emitter
  19639. */
  19640. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19641. /**
  19642. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19643. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19644. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19645. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19646. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19647. * @returns the emitter
  19648. */
  19649. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19650. /**
  19651. * Get hosting scene
  19652. * @returns the scene
  19653. */
  19654. getScene(): Scene;
  19655. }
  19656. }
  19657. declare module "babylonjs/Meshes/instancedMesh" {
  19658. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19659. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19660. import { Camera } from "babylonjs/Cameras/camera";
  19661. import { Node } from "babylonjs/node";
  19662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19663. import { Mesh } from "babylonjs/Meshes/mesh";
  19664. import { Material } from "babylonjs/Materials/material";
  19665. import { Skeleton } from "babylonjs/Bones/skeleton";
  19666. import { Light } from "babylonjs/Lights/light";
  19667. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19668. /**
  19669. * Creates an instance based on a source mesh.
  19670. */
  19671. export class InstancedMesh extends AbstractMesh {
  19672. private _sourceMesh;
  19673. private _currentLOD;
  19674. /** @hidden */
  19675. _indexInSourceMeshInstanceArray: number;
  19676. constructor(name: string, source: Mesh);
  19677. /**
  19678. * Returns the string "InstancedMesh".
  19679. */
  19680. getClassName(): string;
  19681. /** Gets the list of lights affecting that mesh */
  19682. get lightSources(): Light[];
  19683. _resyncLightSources(): void;
  19684. _resyncLightSource(light: Light): void;
  19685. _removeLightSource(light: Light, dispose: boolean): void;
  19686. /**
  19687. * If the source mesh receives shadows
  19688. */
  19689. get receiveShadows(): boolean;
  19690. /**
  19691. * The material of the source mesh
  19692. */
  19693. get material(): Nullable<Material>;
  19694. /**
  19695. * Visibility of the source mesh
  19696. */
  19697. get visibility(): number;
  19698. /**
  19699. * Skeleton of the source mesh
  19700. */
  19701. get skeleton(): Nullable<Skeleton>;
  19702. /**
  19703. * Rendering ground id of the source mesh
  19704. */
  19705. get renderingGroupId(): number;
  19706. set renderingGroupId(value: number);
  19707. /**
  19708. * Returns the total number of vertices (integer).
  19709. */
  19710. getTotalVertices(): number;
  19711. /**
  19712. * Returns a positive integer : the total number of indices in this mesh geometry.
  19713. * @returns the numner of indices or zero if the mesh has no geometry.
  19714. */
  19715. getTotalIndices(): number;
  19716. /**
  19717. * The source mesh of the instance
  19718. */
  19719. get sourceMesh(): Mesh;
  19720. /**
  19721. * Is this node ready to be used/rendered
  19722. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19723. * @return {boolean} is it ready
  19724. */
  19725. isReady(completeCheck?: boolean): boolean;
  19726. /**
  19727. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19728. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19729. * @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.
  19730. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19731. */
  19732. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19733. /**
  19734. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19735. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19736. * The `data` are either a numeric array either a Float32Array.
  19737. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19738. * 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).
  19739. * Note that a new underlying VertexBuffer object is created each call.
  19740. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19741. *
  19742. * Possible `kind` values :
  19743. * - VertexBuffer.PositionKind
  19744. * - VertexBuffer.UVKind
  19745. * - VertexBuffer.UV2Kind
  19746. * - VertexBuffer.UV3Kind
  19747. * - VertexBuffer.UV4Kind
  19748. * - VertexBuffer.UV5Kind
  19749. * - VertexBuffer.UV6Kind
  19750. * - VertexBuffer.ColorKind
  19751. * - VertexBuffer.MatricesIndicesKind
  19752. * - VertexBuffer.MatricesIndicesExtraKind
  19753. * - VertexBuffer.MatricesWeightsKind
  19754. * - VertexBuffer.MatricesWeightsExtraKind
  19755. *
  19756. * Returns the Mesh.
  19757. */
  19758. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19759. /**
  19760. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19761. * If the mesh has no geometry, it is simply returned as it is.
  19762. * The `data` are either a numeric array either a Float32Array.
  19763. * No new underlying VertexBuffer object is created.
  19764. * 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.
  19765. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19766. *
  19767. * Possible `kind` values :
  19768. * - VertexBuffer.PositionKind
  19769. * - VertexBuffer.UVKind
  19770. * - VertexBuffer.UV2Kind
  19771. * - VertexBuffer.UV3Kind
  19772. * - VertexBuffer.UV4Kind
  19773. * - VertexBuffer.UV5Kind
  19774. * - VertexBuffer.UV6Kind
  19775. * - VertexBuffer.ColorKind
  19776. * - VertexBuffer.MatricesIndicesKind
  19777. * - VertexBuffer.MatricesIndicesExtraKind
  19778. * - VertexBuffer.MatricesWeightsKind
  19779. * - VertexBuffer.MatricesWeightsExtraKind
  19780. *
  19781. * Returns the Mesh.
  19782. */
  19783. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19784. /**
  19785. * Sets the mesh indices.
  19786. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19787. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19788. * This method creates a new index buffer each call.
  19789. * Returns the Mesh.
  19790. */
  19791. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19792. /**
  19793. * Boolean : True if the mesh owns the requested kind of data.
  19794. */
  19795. isVerticesDataPresent(kind: string): boolean;
  19796. /**
  19797. * Returns an array of indices (IndicesArray).
  19798. */
  19799. getIndices(): Nullable<IndicesArray>;
  19800. get _positions(): Nullable<Vector3[]>;
  19801. /**
  19802. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19803. * This means the mesh underlying bounding box and sphere are recomputed.
  19804. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19805. * @returns the current mesh
  19806. */
  19807. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19808. /** @hidden */
  19809. _preActivate(): InstancedMesh;
  19810. /** @hidden */
  19811. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19812. /** @hidden */
  19813. _postActivate(): void;
  19814. getWorldMatrix(): Matrix;
  19815. get isAnInstance(): boolean;
  19816. /**
  19817. * Returns the current associated LOD AbstractMesh.
  19818. */
  19819. getLOD(camera: Camera): AbstractMesh;
  19820. /** @hidden */
  19821. _syncSubMeshes(): InstancedMesh;
  19822. /** @hidden */
  19823. _generatePointsArray(): boolean;
  19824. /**
  19825. * Creates a new InstancedMesh from the current mesh.
  19826. * - name (string) : the cloned mesh name
  19827. * - newParent (optional Node) : the optional Node to parent the clone to.
  19828. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19829. *
  19830. * Returns the clone.
  19831. */
  19832. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19833. /**
  19834. * Disposes the InstancedMesh.
  19835. * Returns nothing.
  19836. */
  19837. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19838. }
  19839. module "babylonjs/Meshes/mesh" {
  19840. interface Mesh {
  19841. /**
  19842. * Register a custom buffer that will be instanced
  19843. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19844. * @param kind defines the buffer kind
  19845. * @param stride defines the stride in floats
  19846. */
  19847. registerInstancedBuffer(kind: string, stride: number): void;
  19848. /** @hidden */
  19849. _userInstancedBuffersStorage: {
  19850. data: {
  19851. [key: string]: Float32Array;
  19852. };
  19853. sizes: {
  19854. [key: string]: number;
  19855. };
  19856. vertexBuffers: {
  19857. [key: string]: Nullable<VertexBuffer>;
  19858. };
  19859. strides: {
  19860. [key: string]: number;
  19861. };
  19862. };
  19863. }
  19864. }
  19865. module "babylonjs/Meshes/abstractMesh" {
  19866. interface AbstractMesh {
  19867. /**
  19868. * Object used to store instanced buffers defined by user
  19869. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19870. */
  19871. instancedBuffers: {
  19872. [key: string]: any;
  19873. };
  19874. }
  19875. }
  19876. }
  19877. declare module "babylonjs/Materials/shaderMaterial" {
  19878. import { Scene } from "babylonjs/scene";
  19879. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19880. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19881. import { Mesh } from "babylonjs/Meshes/mesh";
  19882. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19883. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19884. import { Texture } from "babylonjs/Materials/Textures/texture";
  19885. import { Material } from "babylonjs/Materials/material";
  19886. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19887. /**
  19888. * Defines the options associated with the creation of a shader material.
  19889. */
  19890. export interface IShaderMaterialOptions {
  19891. /**
  19892. * Does the material work in alpha blend mode
  19893. */
  19894. needAlphaBlending: boolean;
  19895. /**
  19896. * Does the material work in alpha test mode
  19897. */
  19898. needAlphaTesting: boolean;
  19899. /**
  19900. * The list of attribute names used in the shader
  19901. */
  19902. attributes: string[];
  19903. /**
  19904. * The list of unifrom names used in the shader
  19905. */
  19906. uniforms: string[];
  19907. /**
  19908. * The list of UBO names used in the shader
  19909. */
  19910. uniformBuffers: string[];
  19911. /**
  19912. * The list of sampler names used in the shader
  19913. */
  19914. samplers: string[];
  19915. /**
  19916. * The list of defines used in the shader
  19917. */
  19918. defines: string[];
  19919. }
  19920. /**
  19921. * 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.
  19922. *
  19923. * This returned material effects how the mesh will look based on the code in the shaders.
  19924. *
  19925. * @see http://doc.babylonjs.com/how_to/shader_material
  19926. */
  19927. export class ShaderMaterial extends Material {
  19928. private _shaderPath;
  19929. private _options;
  19930. private _textures;
  19931. private _textureArrays;
  19932. private _floats;
  19933. private _ints;
  19934. private _floatsArrays;
  19935. private _colors3;
  19936. private _colors3Arrays;
  19937. private _colors4;
  19938. private _colors4Arrays;
  19939. private _vectors2;
  19940. private _vectors3;
  19941. private _vectors4;
  19942. private _matrices;
  19943. private _matrixArrays;
  19944. private _matrices3x3;
  19945. private _matrices2x2;
  19946. private _vectors2Arrays;
  19947. private _vectors3Arrays;
  19948. private _vectors4Arrays;
  19949. private _cachedWorldViewMatrix;
  19950. private _cachedWorldViewProjectionMatrix;
  19951. private _renderId;
  19952. private _multiview;
  19953. /**
  19954. * Instantiate a new shader material.
  19955. * 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.
  19956. * This returned material effects how the mesh will look based on the code in the shaders.
  19957. * @see http://doc.babylonjs.com/how_to/shader_material
  19958. * @param name Define the name of the material in the scene
  19959. * @param scene Define the scene the material belongs to
  19960. * @param shaderPath Defines the route to the shader code in one of three ways:
  19961. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19962. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19963. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19964. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19965. * @param options Define the options used to create the shader
  19966. */
  19967. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19968. /**
  19969. * Gets the shader path used to define the shader code
  19970. * It can be modified to trigger a new compilation
  19971. */
  19972. get shaderPath(): any;
  19973. /**
  19974. * Sets the shader path used to define the shader code
  19975. * It can be modified to trigger a new compilation
  19976. */
  19977. set shaderPath(shaderPath: any);
  19978. /**
  19979. * Gets the options used to compile the shader.
  19980. * They can be modified to trigger a new compilation
  19981. */
  19982. get options(): IShaderMaterialOptions;
  19983. /**
  19984. * Gets the current class name of the material e.g. "ShaderMaterial"
  19985. * Mainly use in serialization.
  19986. * @returns the class name
  19987. */
  19988. getClassName(): string;
  19989. /**
  19990. * Specifies if the material will require alpha blending
  19991. * @returns a boolean specifying if alpha blending is needed
  19992. */
  19993. needAlphaBlending(): boolean;
  19994. /**
  19995. * Specifies if this material should be rendered in alpha test mode
  19996. * @returns a boolean specifying if an alpha test is needed.
  19997. */
  19998. needAlphaTesting(): boolean;
  19999. private _checkUniform;
  20000. /**
  20001. * Set a texture in the shader.
  20002. * @param name Define the name of the uniform samplers as defined in the shader
  20003. * @param texture Define the texture to bind to this sampler
  20004. * @return the material itself allowing "fluent" like uniform updates
  20005. */
  20006. setTexture(name: string, texture: Texture): ShaderMaterial;
  20007. /**
  20008. * Set a texture array in the shader.
  20009. * @param name Define the name of the uniform sampler array as defined in the shader
  20010. * @param textures Define the list of textures to bind to this sampler
  20011. * @return the material itself allowing "fluent" like uniform updates
  20012. */
  20013. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  20014. /**
  20015. * Set a float in the shader.
  20016. * @param name Define the name of the uniform as defined in the shader
  20017. * @param value Define the value to give to the uniform
  20018. * @return the material itself allowing "fluent" like uniform updates
  20019. */
  20020. setFloat(name: string, value: number): ShaderMaterial;
  20021. /**
  20022. * Set a int in the shader.
  20023. * @param name Define the name of the uniform as defined in the shader
  20024. * @param value Define the value to give to the uniform
  20025. * @return the material itself allowing "fluent" like uniform updates
  20026. */
  20027. setInt(name: string, value: number): ShaderMaterial;
  20028. /**
  20029. * Set an array of floats in the shader.
  20030. * @param name Define the name of the uniform as defined in the shader
  20031. * @param value Define the value to give to the uniform
  20032. * @return the material itself allowing "fluent" like uniform updates
  20033. */
  20034. setFloats(name: string, value: number[]): ShaderMaterial;
  20035. /**
  20036. * Set a vec3 in the shader from a Color3.
  20037. * @param name Define the name of the uniform as defined in the shader
  20038. * @param value Define the value to give to the uniform
  20039. * @return the material itself allowing "fluent" like uniform updates
  20040. */
  20041. setColor3(name: string, value: Color3): ShaderMaterial;
  20042. /**
  20043. * Set a vec3 array in the shader from a Color3 array.
  20044. * @param name Define the name of the uniform as defined in the shader
  20045. * @param value Define the value to give to the uniform
  20046. * @return the material itself allowing "fluent" like uniform updates
  20047. */
  20048. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  20049. /**
  20050. * Set a vec4 in the shader from a Color4.
  20051. * @param name Define the name of the uniform as defined in the shader
  20052. * @param value Define the value to give to the uniform
  20053. * @return the material itself allowing "fluent" like uniform updates
  20054. */
  20055. setColor4(name: string, value: Color4): ShaderMaterial;
  20056. /**
  20057. * Set a vec4 array in the shader from a Color4 array.
  20058. * @param name Define the name of the uniform as defined in the shader
  20059. * @param value Define the value to give to the uniform
  20060. * @return the material itself allowing "fluent" like uniform updates
  20061. */
  20062. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  20063. /**
  20064. * Set a vec2 in the shader from a Vector2.
  20065. * @param name Define the name of the uniform as defined in the shader
  20066. * @param value Define the value to give to the uniform
  20067. * @return the material itself allowing "fluent" like uniform updates
  20068. */
  20069. setVector2(name: string, value: Vector2): ShaderMaterial;
  20070. /**
  20071. * Set a vec3 in the shader from a Vector3.
  20072. * @param name Define the name of the uniform as defined in the shader
  20073. * @param value Define the value to give to the uniform
  20074. * @return the material itself allowing "fluent" like uniform updates
  20075. */
  20076. setVector3(name: string, value: Vector3): ShaderMaterial;
  20077. /**
  20078. * Set a vec4 in the shader from a Vector4.
  20079. * @param name Define the name of the uniform as defined in the shader
  20080. * @param value Define the value to give to the uniform
  20081. * @return the material itself allowing "fluent" like uniform updates
  20082. */
  20083. setVector4(name: string, value: Vector4): ShaderMaterial;
  20084. /**
  20085. * Set a mat4 in the shader from a Matrix.
  20086. * @param name Define the name of the uniform as defined in the shader
  20087. * @param value Define the value to give to the uniform
  20088. * @return the material itself allowing "fluent" like uniform updates
  20089. */
  20090. setMatrix(name: string, value: Matrix): ShaderMaterial;
  20091. /**
  20092. * Set a float32Array in the shader from a matrix array.
  20093. * @param name Define the name of the uniform as defined in the shader
  20094. * @param value Define the value to give to the uniform
  20095. * @return the material itself allowing "fluent" like uniform updates
  20096. */
  20097. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  20098. /**
  20099. * Set a mat3 in the shader from a Float32Array.
  20100. * @param name Define the name of the uniform as defined in the shader
  20101. * @param value Define the value to give to the uniform
  20102. * @return the material itself allowing "fluent" like uniform updates
  20103. */
  20104. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  20105. /**
  20106. * Set a mat2 in the shader from a Float32Array.
  20107. * @param name Define the name of the uniform as defined in the shader
  20108. * @param value Define the value to give to the uniform
  20109. * @return the material itself allowing "fluent" like uniform updates
  20110. */
  20111. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  20112. /**
  20113. * Set a vec2 array in the shader from a number array.
  20114. * @param name Define the name of the uniform as defined in the shader
  20115. * @param value Define the value to give to the uniform
  20116. * @return the material itself allowing "fluent" like uniform updates
  20117. */
  20118. setArray2(name: string, value: number[]): ShaderMaterial;
  20119. /**
  20120. * Set a vec3 array in the shader from a number array.
  20121. * @param name Define the name of the uniform as defined in the shader
  20122. * @param value Define the value to give to the uniform
  20123. * @return the material itself allowing "fluent" like uniform updates
  20124. */
  20125. setArray3(name: string, value: number[]): ShaderMaterial;
  20126. /**
  20127. * Set a vec4 array in the shader from a number array.
  20128. * @param name Define the name of the uniform as defined in the shader
  20129. * @param value Define the value to give to the uniform
  20130. * @return the material itself allowing "fluent" like uniform updates
  20131. */
  20132. setArray4(name: string, value: number[]): ShaderMaterial;
  20133. private _checkCache;
  20134. /**
  20135. * Specifies that the submesh is ready to be used
  20136. * @param mesh defines the mesh to check
  20137. * @param subMesh defines which submesh to check
  20138. * @param useInstances specifies that instances should be used
  20139. * @returns a boolean indicating that the submesh is ready or not
  20140. */
  20141. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20142. /**
  20143. * Checks if the material is ready to render the requested mesh
  20144. * @param mesh Define the mesh to render
  20145. * @param useInstances Define whether or not the material is used with instances
  20146. * @returns true if ready, otherwise false
  20147. */
  20148. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20149. /**
  20150. * Binds the world matrix to the material
  20151. * @param world defines the world transformation matrix
  20152. */
  20153. bindOnlyWorldMatrix(world: Matrix): void;
  20154. /**
  20155. * Binds the material to the mesh
  20156. * @param world defines the world transformation matrix
  20157. * @param mesh defines the mesh to bind the material to
  20158. */
  20159. bind(world: Matrix, mesh?: Mesh): void;
  20160. /**
  20161. * Gets the active textures from the material
  20162. * @returns an array of textures
  20163. */
  20164. getActiveTextures(): BaseTexture[];
  20165. /**
  20166. * Specifies if the material uses a texture
  20167. * @param texture defines the texture to check against the material
  20168. * @returns a boolean specifying if the material uses the texture
  20169. */
  20170. hasTexture(texture: BaseTexture): boolean;
  20171. /**
  20172. * Makes a duplicate of the material, and gives it a new name
  20173. * @param name defines the new name for the duplicated material
  20174. * @returns the cloned material
  20175. */
  20176. clone(name: string): ShaderMaterial;
  20177. /**
  20178. * Disposes the material
  20179. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20180. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20181. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20182. */
  20183. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20184. /**
  20185. * Serializes this material in a JSON representation
  20186. * @returns the serialized material object
  20187. */
  20188. serialize(): any;
  20189. /**
  20190. * Creates a shader material from parsed shader material data
  20191. * @param source defines the JSON represnetation of the material
  20192. * @param scene defines the hosting scene
  20193. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20194. * @returns a new material
  20195. */
  20196. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  20197. }
  20198. }
  20199. declare module "babylonjs/Shaders/color.fragment" {
  20200. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20201. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20202. /** @hidden */
  20203. export var colorPixelShader: {
  20204. name: string;
  20205. shader: string;
  20206. };
  20207. }
  20208. declare module "babylonjs/Shaders/color.vertex" {
  20209. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  20210. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20211. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  20212. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  20213. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  20214. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20215. /** @hidden */
  20216. export var colorVertexShader: {
  20217. name: string;
  20218. shader: string;
  20219. };
  20220. }
  20221. declare module "babylonjs/Meshes/linesMesh" {
  20222. import { Nullable } from "babylonjs/types";
  20223. import { Scene } from "babylonjs/scene";
  20224. import { Color3 } from "babylonjs/Maths/math.color";
  20225. import { Node } from "babylonjs/node";
  20226. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20227. import { Mesh } from "babylonjs/Meshes/mesh";
  20228. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20229. import { Effect } from "babylonjs/Materials/effect";
  20230. import { Material } from "babylonjs/Materials/material";
  20231. import "babylonjs/Shaders/color.fragment";
  20232. import "babylonjs/Shaders/color.vertex";
  20233. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20234. /**
  20235. * Line mesh
  20236. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  20237. */
  20238. export class LinesMesh extends Mesh {
  20239. /**
  20240. * If vertex color should be applied to the mesh
  20241. */
  20242. readonly useVertexColor?: boolean | undefined;
  20243. /**
  20244. * If vertex alpha should be applied to the mesh
  20245. */
  20246. readonly useVertexAlpha?: boolean | undefined;
  20247. /**
  20248. * Color of the line (Default: White)
  20249. */
  20250. color: Color3;
  20251. /**
  20252. * Alpha of the line (Default: 1)
  20253. */
  20254. alpha: number;
  20255. /**
  20256. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20257. * This margin is expressed in world space coordinates, so its value may vary.
  20258. * Default value is 0.1
  20259. */
  20260. intersectionThreshold: number;
  20261. private _colorShader;
  20262. private color4;
  20263. /**
  20264. * Creates a new LinesMesh
  20265. * @param name defines the name
  20266. * @param scene defines the hosting scene
  20267. * @param parent defines the parent mesh if any
  20268. * @param source defines the optional source LinesMesh used to clone data from
  20269. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20270. * When false, achieved by calling a clone(), also passing False.
  20271. * This will make creation of children, recursive.
  20272. * @param useVertexColor defines if this LinesMesh supports vertex color
  20273. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  20274. */
  20275. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  20276. /**
  20277. * If vertex color should be applied to the mesh
  20278. */
  20279. useVertexColor?: boolean | undefined,
  20280. /**
  20281. * If vertex alpha should be applied to the mesh
  20282. */
  20283. useVertexAlpha?: boolean | undefined);
  20284. private _addClipPlaneDefine;
  20285. private _removeClipPlaneDefine;
  20286. isReady(): boolean;
  20287. /**
  20288. * Returns the string "LineMesh"
  20289. */
  20290. getClassName(): string;
  20291. /**
  20292. * @hidden
  20293. */
  20294. get material(): Material;
  20295. /**
  20296. * @hidden
  20297. */
  20298. set material(value: Material);
  20299. /**
  20300. * @hidden
  20301. */
  20302. get checkCollisions(): boolean;
  20303. /** @hidden */
  20304. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20305. /** @hidden */
  20306. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20307. /**
  20308. * Disposes of the line mesh
  20309. * @param doNotRecurse If children should be disposed
  20310. */
  20311. dispose(doNotRecurse?: boolean): void;
  20312. /**
  20313. * Returns a new LineMesh object cloned from the current one.
  20314. */
  20315. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20316. /**
  20317. * Creates a new InstancedLinesMesh object from the mesh model.
  20318. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20319. * @param name defines the name of the new instance
  20320. * @returns a new InstancedLinesMesh
  20321. */
  20322. createInstance(name: string): InstancedLinesMesh;
  20323. }
  20324. /**
  20325. * Creates an instance based on a source LinesMesh
  20326. */
  20327. export class InstancedLinesMesh extends InstancedMesh {
  20328. /**
  20329. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20330. * This margin is expressed in world space coordinates, so its value may vary.
  20331. * Initilized with the intersectionThreshold value of the source LinesMesh
  20332. */
  20333. intersectionThreshold: number;
  20334. constructor(name: string, source: LinesMesh);
  20335. /**
  20336. * Returns the string "InstancedLinesMesh".
  20337. */
  20338. getClassName(): string;
  20339. }
  20340. }
  20341. declare module "babylonjs/Shaders/line.fragment" {
  20342. /** @hidden */
  20343. export var linePixelShader: {
  20344. name: string;
  20345. shader: string;
  20346. };
  20347. }
  20348. declare module "babylonjs/Shaders/line.vertex" {
  20349. /** @hidden */
  20350. export var lineVertexShader: {
  20351. name: string;
  20352. shader: string;
  20353. };
  20354. }
  20355. declare module "babylonjs/Rendering/edgesRenderer" {
  20356. import { Nullable } from "babylonjs/types";
  20357. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20358. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20359. import { Vector3 } from "babylonjs/Maths/math.vector";
  20360. import { IDisposable } from "babylonjs/scene";
  20361. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20362. import "babylonjs/Shaders/line.fragment";
  20363. import "babylonjs/Shaders/line.vertex";
  20364. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20365. module "babylonjs/Meshes/abstractMesh" {
  20366. interface AbstractMesh {
  20367. /**
  20368. * Gets the edgesRenderer associated with the mesh
  20369. */
  20370. edgesRenderer: Nullable<EdgesRenderer>;
  20371. }
  20372. }
  20373. module "babylonjs/Meshes/linesMesh" {
  20374. interface LinesMesh {
  20375. /**
  20376. * Enables the edge rendering mode on the mesh.
  20377. * This mode makes the mesh edges visible
  20378. * @param epsilon defines the maximal distance between two angles to detect a face
  20379. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20380. * @returns the currentAbstractMesh
  20381. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20382. */
  20383. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20384. }
  20385. }
  20386. module "babylonjs/Meshes/linesMesh" {
  20387. interface InstancedLinesMesh {
  20388. /**
  20389. * Enables the edge rendering mode on the mesh.
  20390. * This mode makes the mesh edges visible
  20391. * @param epsilon defines the maximal distance between two angles to detect a face
  20392. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20393. * @returns the current InstancedLinesMesh
  20394. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20395. */
  20396. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20397. }
  20398. }
  20399. /**
  20400. * Defines the minimum contract an Edges renderer should follow.
  20401. */
  20402. export interface IEdgesRenderer extends IDisposable {
  20403. /**
  20404. * Gets or sets a boolean indicating if the edgesRenderer is active
  20405. */
  20406. isEnabled: boolean;
  20407. /**
  20408. * Renders the edges of the attached mesh,
  20409. */
  20410. render(): void;
  20411. /**
  20412. * Checks wether or not the edges renderer is ready to render.
  20413. * @return true if ready, otherwise false.
  20414. */
  20415. isReady(): boolean;
  20416. }
  20417. /**
  20418. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20419. */
  20420. export class EdgesRenderer implements IEdgesRenderer {
  20421. /**
  20422. * Define the size of the edges with an orthographic camera
  20423. */
  20424. edgesWidthScalerForOrthographic: number;
  20425. /**
  20426. * Define the size of the edges with a perspective camera
  20427. */
  20428. edgesWidthScalerForPerspective: number;
  20429. protected _source: AbstractMesh;
  20430. protected _linesPositions: number[];
  20431. protected _linesNormals: number[];
  20432. protected _linesIndices: number[];
  20433. protected _epsilon: number;
  20434. protected _indicesCount: number;
  20435. protected _lineShader: ShaderMaterial;
  20436. protected _ib: DataBuffer;
  20437. protected _buffers: {
  20438. [key: string]: Nullable<VertexBuffer>;
  20439. };
  20440. protected _checkVerticesInsteadOfIndices: boolean;
  20441. private _meshRebuildObserver;
  20442. private _meshDisposeObserver;
  20443. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20444. isEnabled: boolean;
  20445. /**
  20446. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20447. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20448. * @param source Mesh used to create edges
  20449. * @param epsilon sum of angles in adjacency to check for edge
  20450. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20451. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20452. */
  20453. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20454. protected _prepareRessources(): void;
  20455. /** @hidden */
  20456. _rebuild(): void;
  20457. /**
  20458. * Releases the required resources for the edges renderer
  20459. */
  20460. dispose(): void;
  20461. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20462. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20463. /**
  20464. * Checks if the pair of p0 and p1 is en edge
  20465. * @param faceIndex
  20466. * @param edge
  20467. * @param faceNormals
  20468. * @param p0
  20469. * @param p1
  20470. * @private
  20471. */
  20472. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20473. /**
  20474. * push line into the position, normal and index buffer
  20475. * @protected
  20476. */
  20477. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20478. /**
  20479. * Generates lines edges from adjacencjes
  20480. * @private
  20481. */
  20482. _generateEdgesLines(): void;
  20483. /**
  20484. * Checks wether or not the edges renderer is ready to render.
  20485. * @return true if ready, otherwise false.
  20486. */
  20487. isReady(): boolean;
  20488. /**
  20489. * Renders the edges of the attached mesh,
  20490. */
  20491. render(): void;
  20492. }
  20493. /**
  20494. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20495. */
  20496. export class LineEdgesRenderer extends EdgesRenderer {
  20497. /**
  20498. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20499. * @param source LineMesh used to generate edges
  20500. * @param epsilon not important (specified angle for edge detection)
  20501. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20502. */
  20503. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20504. /**
  20505. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20506. */
  20507. _generateEdgesLines(): void;
  20508. }
  20509. }
  20510. declare module "babylonjs/Rendering/renderingGroup" {
  20511. import { SmartArray } from "babylonjs/Misc/smartArray";
  20512. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20513. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20514. import { Nullable } from "babylonjs/types";
  20515. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20516. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20517. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20518. import { Material } from "babylonjs/Materials/material";
  20519. import { Scene } from "babylonjs/scene";
  20520. /**
  20521. * This represents the object necessary to create a rendering group.
  20522. * This is exclusively used and created by the rendering manager.
  20523. * To modify the behavior, you use the available helpers in your scene or meshes.
  20524. * @hidden
  20525. */
  20526. export class RenderingGroup {
  20527. index: number;
  20528. private static _zeroVector;
  20529. private _scene;
  20530. private _opaqueSubMeshes;
  20531. private _transparentSubMeshes;
  20532. private _alphaTestSubMeshes;
  20533. private _depthOnlySubMeshes;
  20534. private _particleSystems;
  20535. private _spriteManagers;
  20536. private _opaqueSortCompareFn;
  20537. private _alphaTestSortCompareFn;
  20538. private _transparentSortCompareFn;
  20539. private _renderOpaque;
  20540. private _renderAlphaTest;
  20541. private _renderTransparent;
  20542. /** @hidden */
  20543. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20544. onBeforeTransparentRendering: () => void;
  20545. /**
  20546. * Set the opaque sort comparison function.
  20547. * If null the sub meshes will be render in the order they were created
  20548. */
  20549. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20550. /**
  20551. * Set the alpha test sort comparison function.
  20552. * If null the sub meshes will be render in the order they were created
  20553. */
  20554. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20555. /**
  20556. * Set the transparent sort comparison function.
  20557. * If null the sub meshes will be render in the order they were created
  20558. */
  20559. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20560. /**
  20561. * Creates a new rendering group.
  20562. * @param index The rendering group index
  20563. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20564. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20565. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20566. */
  20567. 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>);
  20568. /**
  20569. * Render all the sub meshes contained in the group.
  20570. * @param customRenderFunction Used to override the default render behaviour of the group.
  20571. * @returns true if rendered some submeshes.
  20572. */
  20573. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20574. /**
  20575. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20576. * @param subMeshes The submeshes to render
  20577. */
  20578. private renderOpaqueSorted;
  20579. /**
  20580. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20581. * @param subMeshes The submeshes to render
  20582. */
  20583. private renderAlphaTestSorted;
  20584. /**
  20585. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20586. * @param subMeshes The submeshes to render
  20587. */
  20588. private renderTransparentSorted;
  20589. /**
  20590. * Renders the submeshes in a specified order.
  20591. * @param subMeshes The submeshes to sort before render
  20592. * @param sortCompareFn The comparison function use to sort
  20593. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20594. * @param transparent Specifies to activate blending if true
  20595. */
  20596. private static renderSorted;
  20597. /**
  20598. * Renders the submeshes in the order they were dispatched (no sort applied).
  20599. * @param subMeshes The submeshes to render
  20600. */
  20601. private static renderUnsorted;
  20602. /**
  20603. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20604. * are rendered back to front if in the same alpha index.
  20605. *
  20606. * @param a The first submesh
  20607. * @param b The second submesh
  20608. * @returns The result of the comparison
  20609. */
  20610. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20611. /**
  20612. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20613. * are rendered back to front.
  20614. *
  20615. * @param a The first submesh
  20616. * @param b The second submesh
  20617. * @returns The result of the comparison
  20618. */
  20619. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20620. /**
  20621. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20622. * are rendered front to back (prevent overdraw).
  20623. *
  20624. * @param a The first submesh
  20625. * @param b The second submesh
  20626. * @returns The result of the comparison
  20627. */
  20628. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20629. /**
  20630. * Resets the different lists of submeshes to prepare a new frame.
  20631. */
  20632. prepare(): void;
  20633. dispose(): void;
  20634. /**
  20635. * Inserts the submesh in its correct queue depending on its material.
  20636. * @param subMesh The submesh to dispatch
  20637. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20638. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20639. */
  20640. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20641. dispatchSprites(spriteManager: ISpriteManager): void;
  20642. dispatchParticles(particleSystem: IParticleSystem): void;
  20643. private _renderParticles;
  20644. private _renderSprites;
  20645. }
  20646. }
  20647. declare module "babylonjs/Rendering/renderingManager" {
  20648. import { Nullable } from "babylonjs/types";
  20649. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20650. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20651. import { SmartArray } from "babylonjs/Misc/smartArray";
  20652. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20653. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20654. import { Material } from "babylonjs/Materials/material";
  20655. import { Scene } from "babylonjs/scene";
  20656. import { Camera } from "babylonjs/Cameras/camera";
  20657. /**
  20658. * Interface describing the different options available in the rendering manager
  20659. * regarding Auto Clear between groups.
  20660. */
  20661. export interface IRenderingManagerAutoClearSetup {
  20662. /**
  20663. * Defines whether or not autoclear is enable.
  20664. */
  20665. autoClear: boolean;
  20666. /**
  20667. * Defines whether or not to autoclear the depth buffer.
  20668. */
  20669. depth: boolean;
  20670. /**
  20671. * Defines whether or not to autoclear the stencil buffer.
  20672. */
  20673. stencil: boolean;
  20674. }
  20675. /**
  20676. * This class is used by the onRenderingGroupObservable
  20677. */
  20678. export class RenderingGroupInfo {
  20679. /**
  20680. * The Scene that being rendered
  20681. */
  20682. scene: Scene;
  20683. /**
  20684. * The camera currently used for the rendering pass
  20685. */
  20686. camera: Nullable<Camera>;
  20687. /**
  20688. * The ID of the renderingGroup being processed
  20689. */
  20690. renderingGroupId: number;
  20691. }
  20692. /**
  20693. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20694. * It is enable to manage the different groups as well as the different necessary sort functions.
  20695. * This should not be used directly aside of the few static configurations
  20696. */
  20697. export class RenderingManager {
  20698. /**
  20699. * The max id used for rendering groups (not included)
  20700. */
  20701. static MAX_RENDERINGGROUPS: number;
  20702. /**
  20703. * The min id used for rendering groups (included)
  20704. */
  20705. static MIN_RENDERINGGROUPS: number;
  20706. /**
  20707. * Used to globally prevent autoclearing scenes.
  20708. */
  20709. static AUTOCLEAR: boolean;
  20710. /**
  20711. * @hidden
  20712. */
  20713. _useSceneAutoClearSetup: boolean;
  20714. private _scene;
  20715. private _renderingGroups;
  20716. private _depthStencilBufferAlreadyCleaned;
  20717. private _autoClearDepthStencil;
  20718. private _customOpaqueSortCompareFn;
  20719. private _customAlphaTestSortCompareFn;
  20720. private _customTransparentSortCompareFn;
  20721. private _renderingGroupInfo;
  20722. /**
  20723. * Instantiates a new rendering group for a particular scene
  20724. * @param scene Defines the scene the groups belongs to
  20725. */
  20726. constructor(scene: Scene);
  20727. private _clearDepthStencilBuffer;
  20728. /**
  20729. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20730. * @hidden
  20731. */
  20732. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20733. /**
  20734. * Resets the different information of the group to prepare a new frame
  20735. * @hidden
  20736. */
  20737. reset(): void;
  20738. /**
  20739. * Dispose and release the group and its associated resources.
  20740. * @hidden
  20741. */
  20742. dispose(): void;
  20743. /**
  20744. * Clear the info related to rendering groups preventing retention points during dispose.
  20745. */
  20746. freeRenderingGroups(): void;
  20747. private _prepareRenderingGroup;
  20748. /**
  20749. * Add a sprite manager to the rendering manager in order to render it this frame.
  20750. * @param spriteManager Define the sprite manager to render
  20751. */
  20752. dispatchSprites(spriteManager: ISpriteManager): void;
  20753. /**
  20754. * Add a particle system to the rendering manager in order to render it this frame.
  20755. * @param particleSystem Define the particle system to render
  20756. */
  20757. dispatchParticles(particleSystem: IParticleSystem): void;
  20758. /**
  20759. * Add a submesh to the manager in order to render it this frame
  20760. * @param subMesh The submesh to dispatch
  20761. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20762. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20763. */
  20764. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20765. /**
  20766. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20767. * This allowed control for front to back rendering or reversly depending of the special needs.
  20768. *
  20769. * @param renderingGroupId The rendering group id corresponding to its index
  20770. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20771. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20772. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20773. */
  20774. 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;
  20775. /**
  20776. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20777. *
  20778. * @param renderingGroupId The rendering group id corresponding to its index
  20779. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20780. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20781. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20782. */
  20783. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20784. /**
  20785. * Gets the current auto clear configuration for one rendering group of the rendering
  20786. * manager.
  20787. * @param index the rendering group index to get the information for
  20788. * @returns The auto clear setup for the requested rendering group
  20789. */
  20790. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20791. }
  20792. }
  20793. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20794. import { Observable } from "babylonjs/Misc/observable";
  20795. import { SmartArray } from "babylonjs/Misc/smartArray";
  20796. import { Nullable } from "babylonjs/types";
  20797. import { Camera } from "babylonjs/Cameras/camera";
  20798. import { Scene } from "babylonjs/scene";
  20799. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20800. import { Color4 } from "babylonjs/Maths/math.color";
  20801. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20802. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20803. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20804. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20805. import { Texture } from "babylonjs/Materials/Textures/texture";
  20806. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20807. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20808. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20809. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20810. import { Engine } from "babylonjs/Engines/engine";
  20811. /**
  20812. * This Helps creating a texture that will be created from a camera in your scene.
  20813. * It is basically a dynamic texture that could be used to create special effects for instance.
  20814. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20815. */
  20816. export class RenderTargetTexture extends Texture {
  20817. isCube: boolean;
  20818. /**
  20819. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20820. */
  20821. static readonly REFRESHRATE_RENDER_ONCE: number;
  20822. /**
  20823. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20824. */
  20825. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20826. /**
  20827. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20828. * the central point of your effect and can save a lot of performances.
  20829. */
  20830. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20831. /**
  20832. * Use this predicate to dynamically define the list of mesh you want to render.
  20833. * If set, the renderList property will be overwritten.
  20834. */
  20835. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20836. private _renderList;
  20837. /**
  20838. * Use this list to define the list of mesh you want to render.
  20839. */
  20840. get renderList(): Nullable<Array<AbstractMesh>>;
  20841. set renderList(value: Nullable<Array<AbstractMesh>>);
  20842. private _hookArray;
  20843. /**
  20844. * Define if particles should be rendered in your texture.
  20845. */
  20846. renderParticles: boolean;
  20847. /**
  20848. * Define if sprites should be rendered in your texture.
  20849. */
  20850. renderSprites: boolean;
  20851. /**
  20852. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20853. */
  20854. coordinatesMode: number;
  20855. /**
  20856. * Define the camera used to render the texture.
  20857. */
  20858. activeCamera: Nullable<Camera>;
  20859. /**
  20860. * Override the render function of the texture with your own one.
  20861. */
  20862. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20863. /**
  20864. * Define if camera post processes should be use while rendering the texture.
  20865. */
  20866. useCameraPostProcesses: boolean;
  20867. /**
  20868. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20869. */
  20870. ignoreCameraViewport: boolean;
  20871. private _postProcessManager;
  20872. private _postProcesses;
  20873. private _resizeObserver;
  20874. /**
  20875. * An event triggered when the texture is unbind.
  20876. */
  20877. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20878. /**
  20879. * An event triggered when the texture is unbind.
  20880. */
  20881. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20882. private _onAfterUnbindObserver;
  20883. /**
  20884. * Set a after unbind callback in the texture.
  20885. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20886. */
  20887. set onAfterUnbind(callback: () => void);
  20888. /**
  20889. * An event triggered before rendering the texture
  20890. */
  20891. onBeforeRenderObservable: Observable<number>;
  20892. private _onBeforeRenderObserver;
  20893. /**
  20894. * Set a before render callback in the texture.
  20895. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20896. */
  20897. set onBeforeRender(callback: (faceIndex: number) => void);
  20898. /**
  20899. * An event triggered after rendering the texture
  20900. */
  20901. onAfterRenderObservable: Observable<number>;
  20902. private _onAfterRenderObserver;
  20903. /**
  20904. * Set a after render callback in the texture.
  20905. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20906. */
  20907. set onAfterRender(callback: (faceIndex: number) => void);
  20908. /**
  20909. * An event triggered after the texture clear
  20910. */
  20911. onClearObservable: Observable<Engine>;
  20912. private _onClearObserver;
  20913. /**
  20914. * Set a clear callback in the texture.
  20915. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20916. */
  20917. set onClear(callback: (Engine: Engine) => void);
  20918. /**
  20919. * An event triggered when the texture is resized.
  20920. */
  20921. onResizeObservable: Observable<RenderTargetTexture>;
  20922. /**
  20923. * Define the clear color of the Render Target if it should be different from the scene.
  20924. */
  20925. clearColor: Color4;
  20926. protected _size: number | {
  20927. width: number;
  20928. height: number;
  20929. };
  20930. protected _initialSizeParameter: number | {
  20931. width: number;
  20932. height: number;
  20933. } | {
  20934. ratio: number;
  20935. };
  20936. protected _sizeRatio: Nullable<number>;
  20937. /** @hidden */
  20938. _generateMipMaps: boolean;
  20939. protected _renderingManager: RenderingManager;
  20940. /** @hidden */
  20941. _waitingRenderList: string[];
  20942. protected _doNotChangeAspectRatio: boolean;
  20943. protected _currentRefreshId: number;
  20944. protected _refreshRate: number;
  20945. protected _textureMatrix: Matrix;
  20946. protected _samples: number;
  20947. protected _renderTargetOptions: RenderTargetCreationOptions;
  20948. /**
  20949. * Gets render target creation options that were used.
  20950. */
  20951. get renderTargetOptions(): RenderTargetCreationOptions;
  20952. protected _engine: Engine;
  20953. protected _onRatioRescale(): void;
  20954. /**
  20955. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20956. * It must define where the camera used to render the texture is set
  20957. */
  20958. boundingBoxPosition: Vector3;
  20959. private _boundingBoxSize;
  20960. /**
  20961. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20962. * When defined, the cubemap will switch to local mode
  20963. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20964. * @example https://www.babylonjs-playground.com/#RNASML
  20965. */
  20966. set boundingBoxSize(value: Vector3);
  20967. get boundingBoxSize(): Vector3;
  20968. /**
  20969. * In case the RTT has been created with a depth texture, get the associated
  20970. * depth texture.
  20971. * Otherwise, return null.
  20972. */
  20973. depthStencilTexture: Nullable<InternalTexture>;
  20974. /**
  20975. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20976. * or used a shadow, depth texture...
  20977. * @param name The friendly name of the texture
  20978. * @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)
  20979. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20980. * @param generateMipMaps True if mip maps need to be generated after render.
  20981. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20982. * @param type The type of the buffer in the RTT (int, half float, float...)
  20983. * @param isCube True if a cube texture needs to be created
  20984. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20985. * @param generateDepthBuffer True to generate a depth buffer
  20986. * @param generateStencilBuffer True to generate a stencil buffer
  20987. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20988. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20989. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20990. */
  20991. constructor(name: string, size: number | {
  20992. width: number;
  20993. height: number;
  20994. } | {
  20995. ratio: number;
  20996. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20997. /**
  20998. * Creates a depth stencil texture.
  20999. * This is only available in WebGL 2 or with the depth texture extension available.
  21000. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21001. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21002. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21003. */
  21004. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21005. private _processSizeParameter;
  21006. /**
  21007. * Define the number of samples to use in case of MSAA.
  21008. * It defaults to one meaning no MSAA has been enabled.
  21009. */
  21010. get samples(): number;
  21011. set samples(value: number);
  21012. /**
  21013. * Resets the refresh counter of the texture and start bak from scratch.
  21014. * Could be useful to regenerate the texture if it is setup to render only once.
  21015. */
  21016. resetRefreshCounter(): void;
  21017. /**
  21018. * Define the refresh rate of the texture or the rendering frequency.
  21019. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21020. */
  21021. get refreshRate(): number;
  21022. set refreshRate(value: number);
  21023. /**
  21024. * Adds a post process to the render target rendering passes.
  21025. * @param postProcess define the post process to add
  21026. */
  21027. addPostProcess(postProcess: PostProcess): void;
  21028. /**
  21029. * Clear all the post processes attached to the render target
  21030. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21031. */
  21032. clearPostProcesses(dispose?: boolean): void;
  21033. /**
  21034. * Remove one of the post process from the list of attached post processes to the texture
  21035. * @param postProcess define the post process to remove from the list
  21036. */
  21037. removePostProcess(postProcess: PostProcess): void;
  21038. /** @hidden */
  21039. _shouldRender(): boolean;
  21040. /**
  21041. * Gets the actual render size of the texture.
  21042. * @returns the width of the render size
  21043. */
  21044. getRenderSize(): number;
  21045. /**
  21046. * Gets the actual render width of the texture.
  21047. * @returns the width of the render size
  21048. */
  21049. getRenderWidth(): number;
  21050. /**
  21051. * Gets the actual render height of the texture.
  21052. * @returns the height of the render size
  21053. */
  21054. getRenderHeight(): number;
  21055. /**
  21056. * Get if the texture can be rescaled or not.
  21057. */
  21058. get canRescale(): boolean;
  21059. /**
  21060. * Resize the texture using a ratio.
  21061. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21062. */
  21063. scale(ratio: number): void;
  21064. /**
  21065. * Get the texture reflection matrix used to rotate/transform the reflection.
  21066. * @returns the reflection matrix
  21067. */
  21068. getReflectionTextureMatrix(): Matrix;
  21069. /**
  21070. * Resize the texture to a new desired size.
  21071. * Be carrefull as it will recreate all the data in the new texture.
  21072. * @param size Define the new size. It can be:
  21073. * - a number for squared texture,
  21074. * - an object containing { width: number, height: number }
  21075. * - or an object containing a ratio { ratio: number }
  21076. */
  21077. resize(size: number | {
  21078. width: number;
  21079. height: number;
  21080. } | {
  21081. ratio: number;
  21082. }): void;
  21083. /**
  21084. * Renders all the objects from the render list into the texture.
  21085. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21086. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21087. */
  21088. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21089. private _bestReflectionRenderTargetDimension;
  21090. /**
  21091. * @hidden
  21092. * @param faceIndex face index to bind to if this is a cubetexture
  21093. */
  21094. _bindFrameBuffer(faceIndex?: number): void;
  21095. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21096. private renderToTarget;
  21097. /**
  21098. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21099. * This allowed control for front to back rendering or reversly depending of the special needs.
  21100. *
  21101. * @param renderingGroupId The rendering group id corresponding to its index
  21102. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21103. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21104. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21105. */
  21106. 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;
  21107. /**
  21108. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21109. *
  21110. * @param renderingGroupId The rendering group id corresponding to its index
  21111. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21112. */
  21113. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21114. /**
  21115. * Clones the texture.
  21116. * @returns the cloned texture
  21117. */
  21118. clone(): RenderTargetTexture;
  21119. /**
  21120. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21121. * @returns The JSON representation of the texture
  21122. */
  21123. serialize(): any;
  21124. /**
  21125. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21126. */
  21127. disposeFramebufferObjects(): void;
  21128. /**
  21129. * Dispose the texture and release its associated resources.
  21130. */
  21131. dispose(): void;
  21132. /** @hidden */
  21133. _rebuild(): void;
  21134. /**
  21135. * Clear the info related to rendering groups preventing retention point in material dispose.
  21136. */
  21137. freeRenderingGroups(): void;
  21138. /**
  21139. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21140. * @returns the view count
  21141. */
  21142. getViewCount(): number;
  21143. }
  21144. }
  21145. declare module "babylonjs/Materials/material" {
  21146. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21147. import { SmartArray } from "babylonjs/Misc/smartArray";
  21148. import { Observable } from "babylonjs/Misc/observable";
  21149. import { Nullable } from "babylonjs/types";
  21150. import { Scene } from "babylonjs/scene";
  21151. import { Matrix } from "babylonjs/Maths/math.vector";
  21152. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21153. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21154. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21155. import { Effect } from "babylonjs/Materials/effect";
  21156. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21157. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21158. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21159. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21160. import { Mesh } from "babylonjs/Meshes/mesh";
  21161. import { Animation } from "babylonjs/Animations/animation";
  21162. /**
  21163. * Options for compiling materials.
  21164. */
  21165. export interface IMaterialCompilationOptions {
  21166. /**
  21167. * Defines whether clip planes are enabled.
  21168. */
  21169. clipPlane: boolean;
  21170. /**
  21171. * Defines whether instances are enabled.
  21172. */
  21173. useInstances: boolean;
  21174. }
  21175. /**
  21176. * Base class for the main features of a material in Babylon.js
  21177. */
  21178. export class Material implements IAnimatable {
  21179. /**
  21180. * Returns the triangle fill mode
  21181. */
  21182. static readonly TriangleFillMode: number;
  21183. /**
  21184. * Returns the wireframe mode
  21185. */
  21186. static readonly WireFrameFillMode: number;
  21187. /**
  21188. * Returns the point fill mode
  21189. */
  21190. static readonly PointFillMode: number;
  21191. /**
  21192. * Returns the point list draw mode
  21193. */
  21194. static readonly PointListDrawMode: number;
  21195. /**
  21196. * Returns the line list draw mode
  21197. */
  21198. static readonly LineListDrawMode: number;
  21199. /**
  21200. * Returns the line loop draw mode
  21201. */
  21202. static readonly LineLoopDrawMode: number;
  21203. /**
  21204. * Returns the line strip draw mode
  21205. */
  21206. static readonly LineStripDrawMode: number;
  21207. /**
  21208. * Returns the triangle strip draw mode
  21209. */
  21210. static readonly TriangleStripDrawMode: number;
  21211. /**
  21212. * Returns the triangle fan draw mode
  21213. */
  21214. static readonly TriangleFanDrawMode: number;
  21215. /**
  21216. * Stores the clock-wise side orientation
  21217. */
  21218. static readonly ClockWiseSideOrientation: number;
  21219. /**
  21220. * Stores the counter clock-wise side orientation
  21221. */
  21222. static readonly CounterClockWiseSideOrientation: number;
  21223. /**
  21224. * The dirty texture flag value
  21225. */
  21226. static readonly TextureDirtyFlag: number;
  21227. /**
  21228. * The dirty light flag value
  21229. */
  21230. static readonly LightDirtyFlag: number;
  21231. /**
  21232. * The dirty fresnel flag value
  21233. */
  21234. static readonly FresnelDirtyFlag: number;
  21235. /**
  21236. * The dirty attribute flag value
  21237. */
  21238. static readonly AttributesDirtyFlag: number;
  21239. /**
  21240. * The dirty misc flag value
  21241. */
  21242. static readonly MiscDirtyFlag: number;
  21243. /**
  21244. * The all dirty flag value
  21245. */
  21246. static readonly AllDirtyFlag: number;
  21247. /**
  21248. * The ID of the material
  21249. */
  21250. id: string;
  21251. /**
  21252. * Gets or sets the unique id of the material
  21253. */
  21254. uniqueId: number;
  21255. /**
  21256. * The name of the material
  21257. */
  21258. name: string;
  21259. /**
  21260. * Gets or sets user defined metadata
  21261. */
  21262. metadata: any;
  21263. /**
  21264. * For internal use only. Please do not use.
  21265. */
  21266. reservedDataStore: any;
  21267. /**
  21268. * Specifies if the ready state should be checked on each call
  21269. */
  21270. checkReadyOnEveryCall: boolean;
  21271. /**
  21272. * Specifies if the ready state should be checked once
  21273. */
  21274. checkReadyOnlyOnce: boolean;
  21275. /**
  21276. * The state of the material
  21277. */
  21278. state: string;
  21279. /**
  21280. * The alpha value of the material
  21281. */
  21282. protected _alpha: number;
  21283. /**
  21284. * List of inspectable custom properties (used by the Inspector)
  21285. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21286. */
  21287. inspectableCustomProperties: IInspectable[];
  21288. /**
  21289. * Sets the alpha value of the material
  21290. */
  21291. set alpha(value: number);
  21292. /**
  21293. * Gets the alpha value of the material
  21294. */
  21295. get alpha(): number;
  21296. /**
  21297. * Specifies if back face culling is enabled
  21298. */
  21299. protected _backFaceCulling: boolean;
  21300. /**
  21301. * Sets the back-face culling state
  21302. */
  21303. set backFaceCulling(value: boolean);
  21304. /**
  21305. * Gets the back-face culling state
  21306. */
  21307. get backFaceCulling(): boolean;
  21308. /**
  21309. * Stores the value for side orientation
  21310. */
  21311. sideOrientation: number;
  21312. /**
  21313. * Callback triggered when the material is compiled
  21314. */
  21315. onCompiled: Nullable<(effect: Effect) => void>;
  21316. /**
  21317. * Callback triggered when an error occurs
  21318. */
  21319. onError: Nullable<(effect: Effect, errors: string) => void>;
  21320. /**
  21321. * Callback triggered to get the render target textures
  21322. */
  21323. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21324. /**
  21325. * Gets a boolean indicating that current material needs to register RTT
  21326. */
  21327. get hasRenderTargetTextures(): boolean;
  21328. /**
  21329. * Specifies if the material should be serialized
  21330. */
  21331. doNotSerialize: boolean;
  21332. /**
  21333. * @hidden
  21334. */
  21335. _storeEffectOnSubMeshes: boolean;
  21336. /**
  21337. * Stores the animations for the material
  21338. */
  21339. animations: Nullable<Array<Animation>>;
  21340. /**
  21341. * An event triggered when the material is disposed
  21342. */
  21343. onDisposeObservable: Observable<Material>;
  21344. /**
  21345. * An observer which watches for dispose events
  21346. */
  21347. private _onDisposeObserver;
  21348. private _onUnBindObservable;
  21349. /**
  21350. * Called during a dispose event
  21351. */
  21352. set onDispose(callback: () => void);
  21353. private _onBindObservable;
  21354. /**
  21355. * An event triggered when the material is bound
  21356. */
  21357. get onBindObservable(): Observable<AbstractMesh>;
  21358. /**
  21359. * An observer which watches for bind events
  21360. */
  21361. private _onBindObserver;
  21362. /**
  21363. * Called during a bind event
  21364. */
  21365. set onBind(callback: (Mesh: AbstractMesh) => void);
  21366. /**
  21367. * An event triggered when the material is unbound
  21368. */
  21369. get onUnBindObservable(): Observable<Material>;
  21370. /**
  21371. * Stores the value of the alpha mode
  21372. */
  21373. private _alphaMode;
  21374. /**
  21375. * Sets the value of the alpha mode.
  21376. *
  21377. * | Value | Type | Description |
  21378. * | --- | --- | --- |
  21379. * | 0 | ALPHA_DISABLE | |
  21380. * | 1 | ALPHA_ADD | |
  21381. * | 2 | ALPHA_COMBINE | |
  21382. * | 3 | ALPHA_SUBTRACT | |
  21383. * | 4 | ALPHA_MULTIPLY | |
  21384. * | 5 | ALPHA_MAXIMIZED | |
  21385. * | 6 | ALPHA_ONEONE | |
  21386. * | 7 | ALPHA_PREMULTIPLIED | |
  21387. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21388. * | 9 | ALPHA_INTERPOLATE | |
  21389. * | 10 | ALPHA_SCREENMODE | |
  21390. *
  21391. */
  21392. set alphaMode(value: number);
  21393. /**
  21394. * Gets the value of the alpha mode
  21395. */
  21396. get alphaMode(): number;
  21397. /**
  21398. * Stores the state of the need depth pre-pass value
  21399. */
  21400. private _needDepthPrePass;
  21401. /**
  21402. * Sets the need depth pre-pass value
  21403. */
  21404. set needDepthPrePass(value: boolean);
  21405. /**
  21406. * Gets the depth pre-pass value
  21407. */
  21408. get needDepthPrePass(): boolean;
  21409. /**
  21410. * Specifies if depth writing should be disabled
  21411. */
  21412. disableDepthWrite: boolean;
  21413. /**
  21414. * Specifies if depth writing should be forced
  21415. */
  21416. forceDepthWrite: boolean;
  21417. /**
  21418. * Specifies the depth function that should be used. 0 means the default engine function
  21419. */
  21420. depthFunction: number;
  21421. /**
  21422. * Specifies if there should be a separate pass for culling
  21423. */
  21424. separateCullingPass: boolean;
  21425. /**
  21426. * Stores the state specifing if fog should be enabled
  21427. */
  21428. private _fogEnabled;
  21429. /**
  21430. * Sets the state for enabling fog
  21431. */
  21432. set fogEnabled(value: boolean);
  21433. /**
  21434. * Gets the value of the fog enabled state
  21435. */
  21436. get fogEnabled(): boolean;
  21437. /**
  21438. * Stores the size of points
  21439. */
  21440. pointSize: number;
  21441. /**
  21442. * Stores the z offset value
  21443. */
  21444. zOffset: number;
  21445. /**
  21446. * Gets a value specifying if wireframe mode is enabled
  21447. */
  21448. get wireframe(): boolean;
  21449. /**
  21450. * Sets the state of wireframe mode
  21451. */
  21452. set wireframe(value: boolean);
  21453. /**
  21454. * Gets the value specifying if point clouds are enabled
  21455. */
  21456. get pointsCloud(): boolean;
  21457. /**
  21458. * Sets the state of point cloud mode
  21459. */
  21460. set pointsCloud(value: boolean);
  21461. /**
  21462. * Gets the material fill mode
  21463. */
  21464. get fillMode(): number;
  21465. /**
  21466. * Sets the material fill mode
  21467. */
  21468. set fillMode(value: number);
  21469. /**
  21470. * @hidden
  21471. * Stores the effects for the material
  21472. */
  21473. _effect: Nullable<Effect>;
  21474. /**
  21475. * @hidden
  21476. * Specifies if the material was previously ready
  21477. */
  21478. _wasPreviouslyReady: boolean;
  21479. /**
  21480. * Specifies if uniform buffers should be used
  21481. */
  21482. private _useUBO;
  21483. /**
  21484. * Stores a reference to the scene
  21485. */
  21486. private _scene;
  21487. /**
  21488. * Stores the fill mode state
  21489. */
  21490. private _fillMode;
  21491. /**
  21492. * Specifies if the depth write state should be cached
  21493. */
  21494. private _cachedDepthWriteState;
  21495. /**
  21496. * Specifies if the depth function state should be cached
  21497. */
  21498. private _cachedDepthFunctionState;
  21499. /**
  21500. * Stores the uniform buffer
  21501. */
  21502. protected _uniformBuffer: UniformBuffer;
  21503. /** @hidden */
  21504. _indexInSceneMaterialArray: number;
  21505. /** @hidden */
  21506. meshMap: Nullable<{
  21507. [id: string]: AbstractMesh | undefined;
  21508. }>;
  21509. /**
  21510. * Creates a material instance
  21511. * @param name defines the name of the material
  21512. * @param scene defines the scene to reference
  21513. * @param doNotAdd specifies if the material should be added to the scene
  21514. */
  21515. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21516. /**
  21517. * Returns a string representation of the current material
  21518. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21519. * @returns a string with material information
  21520. */
  21521. toString(fullDetails?: boolean): string;
  21522. /**
  21523. * Gets the class name of the material
  21524. * @returns a string with the class name of the material
  21525. */
  21526. getClassName(): string;
  21527. /**
  21528. * Specifies if updates for the material been locked
  21529. */
  21530. get isFrozen(): boolean;
  21531. /**
  21532. * Locks updates for the material
  21533. */
  21534. freeze(): void;
  21535. /**
  21536. * Unlocks updates for the material
  21537. */
  21538. unfreeze(): void;
  21539. /**
  21540. * Specifies if the material is ready to be used
  21541. * @param mesh defines the mesh to check
  21542. * @param useInstances specifies if instances should be used
  21543. * @returns a boolean indicating if the material is ready to be used
  21544. */
  21545. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21546. /**
  21547. * Specifies that the submesh is ready to be used
  21548. * @param mesh defines the mesh to check
  21549. * @param subMesh defines which submesh to check
  21550. * @param useInstances specifies that instances should be used
  21551. * @returns a boolean indicating that the submesh is ready or not
  21552. */
  21553. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21554. /**
  21555. * Returns the material effect
  21556. * @returns the effect associated with the material
  21557. */
  21558. getEffect(): Nullable<Effect>;
  21559. /**
  21560. * Returns the current scene
  21561. * @returns a Scene
  21562. */
  21563. getScene(): Scene;
  21564. /**
  21565. * Specifies if the material will require alpha blending
  21566. * @returns a boolean specifying if alpha blending is needed
  21567. */
  21568. needAlphaBlending(): boolean;
  21569. /**
  21570. * Specifies if the mesh will require alpha blending
  21571. * @param mesh defines the mesh to check
  21572. * @returns a boolean specifying if alpha blending is needed for the mesh
  21573. */
  21574. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21575. /**
  21576. * Specifies if this material should be rendered in alpha test mode
  21577. * @returns a boolean specifying if an alpha test is needed.
  21578. */
  21579. needAlphaTesting(): boolean;
  21580. /**
  21581. * Gets the texture used for the alpha test
  21582. * @returns the texture to use for alpha testing
  21583. */
  21584. getAlphaTestTexture(): Nullable<BaseTexture>;
  21585. /**
  21586. * Marks the material to indicate that it needs to be re-calculated
  21587. */
  21588. markDirty(): void;
  21589. /** @hidden */
  21590. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21591. /**
  21592. * Binds the material to the mesh
  21593. * @param world defines the world transformation matrix
  21594. * @param mesh defines the mesh to bind the material to
  21595. */
  21596. bind(world: Matrix, mesh?: Mesh): void;
  21597. /**
  21598. * Binds the submesh to the material
  21599. * @param world defines the world transformation matrix
  21600. * @param mesh defines the mesh containing the submesh
  21601. * @param subMesh defines the submesh to bind the material to
  21602. */
  21603. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21604. /**
  21605. * Binds the world matrix to the material
  21606. * @param world defines the world transformation matrix
  21607. */
  21608. bindOnlyWorldMatrix(world: Matrix): void;
  21609. /**
  21610. * Binds the scene's uniform buffer to the effect.
  21611. * @param effect defines the effect to bind to the scene uniform buffer
  21612. * @param sceneUbo defines the uniform buffer storing scene data
  21613. */
  21614. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21615. /**
  21616. * Binds the view matrix to the effect
  21617. * @param effect defines the effect to bind the view matrix to
  21618. */
  21619. bindView(effect: Effect): void;
  21620. /**
  21621. * Binds the view projection matrix to the effect
  21622. * @param effect defines the effect to bind the view projection matrix to
  21623. */
  21624. bindViewProjection(effect: Effect): void;
  21625. /**
  21626. * Specifies if material alpha testing should be turned on for the mesh
  21627. * @param mesh defines the mesh to check
  21628. */
  21629. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21630. /**
  21631. * Processes to execute after binding the material to a mesh
  21632. * @param mesh defines the rendered mesh
  21633. */
  21634. protected _afterBind(mesh?: Mesh): void;
  21635. /**
  21636. * Unbinds the material from the mesh
  21637. */
  21638. unbind(): void;
  21639. /**
  21640. * Gets the active textures from the material
  21641. * @returns an array of textures
  21642. */
  21643. getActiveTextures(): BaseTexture[];
  21644. /**
  21645. * Specifies if the material uses a texture
  21646. * @param texture defines the texture to check against the material
  21647. * @returns a boolean specifying if the material uses the texture
  21648. */
  21649. hasTexture(texture: BaseTexture): boolean;
  21650. /**
  21651. * Makes a duplicate of the material, and gives it a new name
  21652. * @param name defines the new name for the duplicated material
  21653. * @returns the cloned material
  21654. */
  21655. clone(name: string): Nullable<Material>;
  21656. /**
  21657. * Gets the meshes bound to the material
  21658. * @returns an array of meshes bound to the material
  21659. */
  21660. getBindedMeshes(): AbstractMesh[];
  21661. /**
  21662. * Force shader compilation
  21663. * @param mesh defines the mesh associated with this material
  21664. * @param onCompiled defines a function to execute once the material is compiled
  21665. * @param options defines the options to configure the compilation
  21666. * @param onError defines a function to execute if the material fails compiling
  21667. */
  21668. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21669. /**
  21670. * Force shader compilation
  21671. * @param mesh defines the mesh that will use this material
  21672. * @param options defines additional options for compiling the shaders
  21673. * @returns a promise that resolves when the compilation completes
  21674. */
  21675. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21676. private static readonly _AllDirtyCallBack;
  21677. private static readonly _ImageProcessingDirtyCallBack;
  21678. private static readonly _TextureDirtyCallBack;
  21679. private static readonly _FresnelDirtyCallBack;
  21680. private static readonly _MiscDirtyCallBack;
  21681. private static readonly _LightsDirtyCallBack;
  21682. private static readonly _AttributeDirtyCallBack;
  21683. private static _FresnelAndMiscDirtyCallBack;
  21684. private static _TextureAndMiscDirtyCallBack;
  21685. private static readonly _DirtyCallbackArray;
  21686. private static readonly _RunDirtyCallBacks;
  21687. /**
  21688. * Marks a define in the material to indicate that it needs to be re-computed
  21689. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21690. */
  21691. markAsDirty(flag: number): void;
  21692. /**
  21693. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21694. * @param func defines a function which checks material defines against the submeshes
  21695. */
  21696. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21697. /**
  21698. * Indicates that we need to re-calculated for all submeshes
  21699. */
  21700. protected _markAllSubMeshesAsAllDirty(): void;
  21701. /**
  21702. * Indicates that image processing needs to be re-calculated for all submeshes
  21703. */
  21704. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21705. /**
  21706. * Indicates that textures need to be re-calculated for all submeshes
  21707. */
  21708. protected _markAllSubMeshesAsTexturesDirty(): void;
  21709. /**
  21710. * Indicates that fresnel needs to be re-calculated for all submeshes
  21711. */
  21712. protected _markAllSubMeshesAsFresnelDirty(): void;
  21713. /**
  21714. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21715. */
  21716. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21717. /**
  21718. * Indicates that lights need to be re-calculated for all submeshes
  21719. */
  21720. protected _markAllSubMeshesAsLightsDirty(): void;
  21721. /**
  21722. * Indicates that attributes need to be re-calculated for all submeshes
  21723. */
  21724. protected _markAllSubMeshesAsAttributesDirty(): void;
  21725. /**
  21726. * Indicates that misc needs to be re-calculated for all submeshes
  21727. */
  21728. protected _markAllSubMeshesAsMiscDirty(): void;
  21729. /**
  21730. * Indicates that textures and misc need to be re-calculated for all submeshes
  21731. */
  21732. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21733. /**
  21734. * Disposes the material
  21735. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21736. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21737. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21738. */
  21739. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21740. /** @hidden */
  21741. private releaseVertexArrayObject;
  21742. /**
  21743. * Serializes this material
  21744. * @returns the serialized material object
  21745. */
  21746. serialize(): any;
  21747. /**
  21748. * Creates a material from parsed material data
  21749. * @param parsedMaterial defines parsed material data
  21750. * @param scene defines the hosting scene
  21751. * @param rootUrl defines the root URL to use to load textures
  21752. * @returns a new material
  21753. */
  21754. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21755. }
  21756. }
  21757. declare module "babylonjs/Materials/multiMaterial" {
  21758. import { Nullable } from "babylonjs/types";
  21759. import { Scene } from "babylonjs/scene";
  21760. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21761. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21762. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21763. import { Material } from "babylonjs/Materials/material";
  21764. /**
  21765. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21766. * separate meshes. This can be use to improve performances.
  21767. * @see http://doc.babylonjs.com/how_to/multi_materials
  21768. */
  21769. export class MultiMaterial extends Material {
  21770. private _subMaterials;
  21771. /**
  21772. * Gets or Sets the list of Materials used within the multi material.
  21773. * They need to be ordered according to the submeshes order in the associated mesh
  21774. */
  21775. get subMaterials(): Nullable<Material>[];
  21776. set subMaterials(value: Nullable<Material>[]);
  21777. /**
  21778. * Function used to align with Node.getChildren()
  21779. * @returns the list of Materials used within the multi material
  21780. */
  21781. getChildren(): Nullable<Material>[];
  21782. /**
  21783. * Instantiates a new Multi Material
  21784. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21785. * separate meshes. This can be use to improve performances.
  21786. * @see http://doc.babylonjs.com/how_to/multi_materials
  21787. * @param name Define the name in the scene
  21788. * @param scene Define the scene the material belongs to
  21789. */
  21790. constructor(name: string, scene: Scene);
  21791. private _hookArray;
  21792. /**
  21793. * Get one of the submaterial by its index in the submaterials array
  21794. * @param index The index to look the sub material at
  21795. * @returns The Material if the index has been defined
  21796. */
  21797. getSubMaterial(index: number): Nullable<Material>;
  21798. /**
  21799. * Get the list of active textures for the whole sub materials list.
  21800. * @returns All the textures that will be used during the rendering
  21801. */
  21802. getActiveTextures(): BaseTexture[];
  21803. /**
  21804. * Gets the current class name of the material e.g. "MultiMaterial"
  21805. * Mainly use in serialization.
  21806. * @returns the class name
  21807. */
  21808. getClassName(): string;
  21809. /**
  21810. * Checks if the material is ready to render the requested sub mesh
  21811. * @param mesh Define the mesh the submesh belongs to
  21812. * @param subMesh Define the sub mesh to look readyness for
  21813. * @param useInstances Define whether or not the material is used with instances
  21814. * @returns true if ready, otherwise false
  21815. */
  21816. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21817. /**
  21818. * Clones the current material and its related sub materials
  21819. * @param name Define the name of the newly cloned material
  21820. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21821. * @returns the cloned material
  21822. */
  21823. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21824. /**
  21825. * Serializes the materials into a JSON representation.
  21826. * @returns the JSON representation
  21827. */
  21828. serialize(): any;
  21829. /**
  21830. * Dispose the material and release its associated resources
  21831. * @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)
  21832. * @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)
  21833. * @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)
  21834. */
  21835. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21836. /**
  21837. * Creates a MultiMaterial from parsed MultiMaterial data.
  21838. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21839. * @param scene defines the hosting scene
  21840. * @returns a new MultiMaterial
  21841. */
  21842. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21843. }
  21844. }
  21845. declare module "babylonjs/Meshes/subMesh" {
  21846. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21847. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21848. import { Engine } from "babylonjs/Engines/engine";
  21849. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21850. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21851. import { Effect } from "babylonjs/Materials/effect";
  21852. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21853. import { Plane } from "babylonjs/Maths/math.plane";
  21854. import { Collider } from "babylonjs/Collisions/collider";
  21855. import { Material } from "babylonjs/Materials/material";
  21856. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21857. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21858. import { Mesh } from "babylonjs/Meshes/mesh";
  21859. import { Ray } from "babylonjs/Culling/ray";
  21860. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21861. /**
  21862. * Base class for submeshes
  21863. */
  21864. export class BaseSubMesh {
  21865. /** @hidden */
  21866. _materialDefines: Nullable<MaterialDefines>;
  21867. /** @hidden */
  21868. _materialEffect: Nullable<Effect>;
  21869. /**
  21870. * Gets material defines used by the effect associated to the sub mesh
  21871. */
  21872. get materialDefines(): Nullable<MaterialDefines>;
  21873. /**
  21874. * Sets material defines used by the effect associated to the sub mesh
  21875. */
  21876. set materialDefines(defines: Nullable<MaterialDefines>);
  21877. /**
  21878. * Gets associated effect
  21879. */
  21880. get effect(): Nullable<Effect>;
  21881. /**
  21882. * Sets associated effect (effect used to render this submesh)
  21883. * @param effect defines the effect to associate with
  21884. * @param defines defines the set of defines used to compile this effect
  21885. */
  21886. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21887. }
  21888. /**
  21889. * Defines a subdivision inside a mesh
  21890. */
  21891. export class SubMesh extends BaseSubMesh implements ICullable {
  21892. /** the material index to use */
  21893. materialIndex: number;
  21894. /** vertex index start */
  21895. verticesStart: number;
  21896. /** vertices count */
  21897. verticesCount: number;
  21898. /** index start */
  21899. indexStart: number;
  21900. /** indices count */
  21901. indexCount: number;
  21902. /** @hidden */
  21903. _linesIndexCount: number;
  21904. private _mesh;
  21905. private _renderingMesh;
  21906. private _boundingInfo;
  21907. private _linesIndexBuffer;
  21908. /** @hidden */
  21909. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21910. /** @hidden */
  21911. _trianglePlanes: Plane[];
  21912. /** @hidden */
  21913. _lastColliderTransformMatrix: Nullable<Matrix>;
  21914. /** @hidden */
  21915. _renderId: number;
  21916. /** @hidden */
  21917. _alphaIndex: number;
  21918. /** @hidden */
  21919. _distanceToCamera: number;
  21920. /** @hidden */
  21921. _id: number;
  21922. private _currentMaterial;
  21923. /**
  21924. * Add a new submesh to a mesh
  21925. * @param materialIndex defines the material index to use
  21926. * @param verticesStart defines vertex index start
  21927. * @param verticesCount defines vertices count
  21928. * @param indexStart defines index start
  21929. * @param indexCount defines indices count
  21930. * @param mesh defines the parent mesh
  21931. * @param renderingMesh defines an optional rendering mesh
  21932. * @param createBoundingBox defines if bounding box should be created for this submesh
  21933. * @returns the new submesh
  21934. */
  21935. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21936. /**
  21937. * Creates a new submesh
  21938. * @param materialIndex defines the material index to use
  21939. * @param verticesStart defines vertex index start
  21940. * @param verticesCount defines vertices count
  21941. * @param indexStart defines index start
  21942. * @param indexCount defines indices count
  21943. * @param mesh defines the parent mesh
  21944. * @param renderingMesh defines an optional rendering mesh
  21945. * @param createBoundingBox defines if bounding box should be created for this submesh
  21946. */
  21947. constructor(
  21948. /** the material index to use */
  21949. materialIndex: number,
  21950. /** vertex index start */
  21951. verticesStart: number,
  21952. /** vertices count */
  21953. verticesCount: number,
  21954. /** index start */
  21955. indexStart: number,
  21956. /** indices count */
  21957. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21958. /**
  21959. * Returns true if this submesh covers the entire parent mesh
  21960. * @ignorenaming
  21961. */
  21962. get IsGlobal(): boolean;
  21963. /**
  21964. * Returns the submesh BoudingInfo object
  21965. * @returns current bounding info (or mesh's one if the submesh is global)
  21966. */
  21967. getBoundingInfo(): BoundingInfo;
  21968. /**
  21969. * Sets the submesh BoundingInfo
  21970. * @param boundingInfo defines the new bounding info to use
  21971. * @returns the SubMesh
  21972. */
  21973. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21974. /**
  21975. * Returns the mesh of the current submesh
  21976. * @return the parent mesh
  21977. */
  21978. getMesh(): AbstractMesh;
  21979. /**
  21980. * Returns the rendering mesh of the submesh
  21981. * @returns the rendering mesh (could be different from parent mesh)
  21982. */
  21983. getRenderingMesh(): Mesh;
  21984. /**
  21985. * Returns the submesh material
  21986. * @returns null or the current material
  21987. */
  21988. getMaterial(): Nullable<Material>;
  21989. /**
  21990. * Sets a new updated BoundingInfo object to the submesh
  21991. * @param data defines an optional position array to use to determine the bounding info
  21992. * @returns the SubMesh
  21993. */
  21994. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21995. /** @hidden */
  21996. _checkCollision(collider: Collider): boolean;
  21997. /**
  21998. * Updates the submesh BoundingInfo
  21999. * @param world defines the world matrix to use to update the bounding info
  22000. * @returns the submesh
  22001. */
  22002. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22003. /**
  22004. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22005. * @param frustumPlanes defines the frustum planes
  22006. * @returns true if the submesh is intersecting with the frustum
  22007. */
  22008. isInFrustum(frustumPlanes: Plane[]): boolean;
  22009. /**
  22010. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22011. * @param frustumPlanes defines the frustum planes
  22012. * @returns true if the submesh is inside the frustum
  22013. */
  22014. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22015. /**
  22016. * Renders the submesh
  22017. * @param enableAlphaMode defines if alpha needs to be used
  22018. * @returns the submesh
  22019. */
  22020. render(enableAlphaMode: boolean): SubMesh;
  22021. /**
  22022. * @hidden
  22023. */
  22024. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22025. /**
  22026. * Checks if the submesh intersects with a ray
  22027. * @param ray defines the ray to test
  22028. * @returns true is the passed ray intersects the submesh bounding box
  22029. */
  22030. canIntersects(ray: Ray): boolean;
  22031. /**
  22032. * Intersects current submesh with a ray
  22033. * @param ray defines the ray to test
  22034. * @param positions defines mesh's positions array
  22035. * @param indices defines mesh's indices array
  22036. * @param fastCheck defines if only bounding info should be used
  22037. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22038. * @returns intersection info or null if no intersection
  22039. */
  22040. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22041. /** @hidden */
  22042. private _intersectLines;
  22043. /** @hidden */
  22044. private _intersectUnIndexedLines;
  22045. /** @hidden */
  22046. private _intersectTriangles;
  22047. /** @hidden */
  22048. private _intersectUnIndexedTriangles;
  22049. /** @hidden */
  22050. _rebuild(): void;
  22051. /**
  22052. * Creates a new submesh from the passed mesh
  22053. * @param newMesh defines the new hosting mesh
  22054. * @param newRenderingMesh defines an optional rendering mesh
  22055. * @returns the new submesh
  22056. */
  22057. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22058. /**
  22059. * Release associated resources
  22060. */
  22061. dispose(): void;
  22062. /**
  22063. * Gets the class name
  22064. * @returns the string "SubMesh".
  22065. */
  22066. getClassName(): string;
  22067. /**
  22068. * Creates a new submesh from indices data
  22069. * @param materialIndex the index of the main mesh material
  22070. * @param startIndex the index where to start the copy in the mesh indices array
  22071. * @param indexCount the number of indices to copy then from the startIndex
  22072. * @param mesh the main mesh to create the submesh from
  22073. * @param renderingMesh the optional rendering mesh
  22074. * @returns a new submesh
  22075. */
  22076. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22077. }
  22078. }
  22079. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22080. /**
  22081. * Class used to represent data loading progression
  22082. */
  22083. export class SceneLoaderFlags {
  22084. private static _ForceFullSceneLoadingForIncremental;
  22085. private static _ShowLoadingScreen;
  22086. private static _CleanBoneMatrixWeights;
  22087. private static _loggingLevel;
  22088. /**
  22089. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22090. */
  22091. static get ForceFullSceneLoadingForIncremental(): boolean;
  22092. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22093. /**
  22094. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22095. */
  22096. static get ShowLoadingScreen(): boolean;
  22097. static set ShowLoadingScreen(value: boolean);
  22098. /**
  22099. * Defines the current logging level (while loading the scene)
  22100. * @ignorenaming
  22101. */
  22102. static get loggingLevel(): number;
  22103. static set loggingLevel(value: number);
  22104. /**
  22105. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22106. */
  22107. static get CleanBoneMatrixWeights(): boolean;
  22108. static set CleanBoneMatrixWeights(value: boolean);
  22109. }
  22110. }
  22111. declare module "babylonjs/Meshes/geometry" {
  22112. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22113. import { Scene } from "babylonjs/scene";
  22114. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22115. import { Engine } from "babylonjs/Engines/engine";
  22116. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22117. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22118. import { Effect } from "babylonjs/Materials/effect";
  22119. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22120. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22121. import { Mesh } from "babylonjs/Meshes/mesh";
  22122. /**
  22123. * Class used to store geometry data (vertex buffers + index buffer)
  22124. */
  22125. export class Geometry implements IGetSetVerticesData {
  22126. /**
  22127. * Gets or sets the ID of the geometry
  22128. */
  22129. id: string;
  22130. /**
  22131. * Gets or sets the unique ID of the geometry
  22132. */
  22133. uniqueId: number;
  22134. /**
  22135. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22136. */
  22137. delayLoadState: number;
  22138. /**
  22139. * Gets the file containing the data to load when running in delay load state
  22140. */
  22141. delayLoadingFile: Nullable<string>;
  22142. /**
  22143. * Callback called when the geometry is updated
  22144. */
  22145. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22146. private _scene;
  22147. private _engine;
  22148. private _meshes;
  22149. private _totalVertices;
  22150. /** @hidden */
  22151. _indices: IndicesArray;
  22152. /** @hidden */
  22153. _vertexBuffers: {
  22154. [key: string]: VertexBuffer;
  22155. };
  22156. private _isDisposed;
  22157. private _extend;
  22158. private _boundingBias;
  22159. /** @hidden */
  22160. _delayInfo: Array<string>;
  22161. private _indexBuffer;
  22162. private _indexBufferIsUpdatable;
  22163. /** @hidden */
  22164. _boundingInfo: Nullable<BoundingInfo>;
  22165. /** @hidden */
  22166. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22167. /** @hidden */
  22168. _softwareSkinningFrameId: number;
  22169. private _vertexArrayObjects;
  22170. private _updatable;
  22171. /** @hidden */
  22172. _positions: Nullable<Vector3[]>;
  22173. /**
  22174. * 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
  22175. */
  22176. get boundingBias(): Vector2;
  22177. /**
  22178. * 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
  22179. */
  22180. set boundingBias(value: Vector2);
  22181. /**
  22182. * Static function used to attach a new empty geometry to a mesh
  22183. * @param mesh defines the mesh to attach the geometry to
  22184. * @returns the new Geometry
  22185. */
  22186. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22187. /**
  22188. * Creates a new geometry
  22189. * @param id defines the unique ID
  22190. * @param scene defines the hosting scene
  22191. * @param vertexData defines the VertexData used to get geometry data
  22192. * @param updatable defines if geometry must be updatable (false by default)
  22193. * @param mesh defines the mesh that will be associated with the geometry
  22194. */
  22195. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22196. /**
  22197. * Gets the current extend of the geometry
  22198. */
  22199. get extend(): {
  22200. minimum: Vector3;
  22201. maximum: Vector3;
  22202. };
  22203. /**
  22204. * Gets the hosting scene
  22205. * @returns the hosting Scene
  22206. */
  22207. getScene(): Scene;
  22208. /**
  22209. * Gets the hosting engine
  22210. * @returns the hosting Engine
  22211. */
  22212. getEngine(): Engine;
  22213. /**
  22214. * Defines if the geometry is ready to use
  22215. * @returns true if the geometry is ready to be used
  22216. */
  22217. isReady(): boolean;
  22218. /**
  22219. * Gets a value indicating that the geometry should not be serialized
  22220. */
  22221. get doNotSerialize(): boolean;
  22222. /** @hidden */
  22223. _rebuild(): void;
  22224. /**
  22225. * Affects all geometry data in one call
  22226. * @param vertexData defines the geometry data
  22227. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22228. */
  22229. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22230. /**
  22231. * Set specific vertex data
  22232. * @param kind defines the data kind (Position, normal, etc...)
  22233. * @param data defines the vertex data to use
  22234. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22235. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22236. */
  22237. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22238. /**
  22239. * Removes a specific vertex data
  22240. * @param kind defines the data kind (Position, normal, etc...)
  22241. */
  22242. removeVerticesData(kind: string): void;
  22243. /**
  22244. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22245. * @param buffer defines the vertex buffer to use
  22246. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22247. */
  22248. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22249. /**
  22250. * Update a specific vertex buffer
  22251. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22252. * It will do nothing if the buffer is not updatable
  22253. * @param kind defines the data kind (Position, normal, etc...)
  22254. * @param data defines the data to use
  22255. * @param offset defines the offset in the target buffer where to store the data
  22256. * @param useBytes set to true if the offset is in bytes
  22257. */
  22258. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22259. /**
  22260. * Update a specific vertex buffer
  22261. * This function will create a new buffer if the current one is not updatable
  22262. * @param kind defines the data kind (Position, normal, etc...)
  22263. * @param data defines the data to use
  22264. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22265. */
  22266. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22267. private _updateBoundingInfo;
  22268. /** @hidden */
  22269. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22270. /**
  22271. * Gets total number of vertices
  22272. * @returns the total number of vertices
  22273. */
  22274. getTotalVertices(): number;
  22275. /**
  22276. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22277. * @param kind defines the data kind (Position, normal, etc...)
  22278. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22279. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22280. * @returns a float array containing vertex data
  22281. */
  22282. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22283. /**
  22284. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22285. * @param kind defines the data kind (Position, normal, etc...)
  22286. * @returns true if the vertex buffer with the specified kind is updatable
  22287. */
  22288. isVertexBufferUpdatable(kind: string): boolean;
  22289. /**
  22290. * Gets a specific vertex buffer
  22291. * @param kind defines the data kind (Position, normal, etc...)
  22292. * @returns a VertexBuffer
  22293. */
  22294. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22295. /**
  22296. * Returns all vertex buffers
  22297. * @return an object holding all vertex buffers indexed by kind
  22298. */
  22299. getVertexBuffers(): Nullable<{
  22300. [key: string]: VertexBuffer;
  22301. }>;
  22302. /**
  22303. * Gets a boolean indicating if specific vertex buffer is present
  22304. * @param kind defines the data kind (Position, normal, etc...)
  22305. * @returns true if data is present
  22306. */
  22307. isVerticesDataPresent(kind: string): boolean;
  22308. /**
  22309. * Gets a list of all attached data kinds (Position, normal, etc...)
  22310. * @returns a list of string containing all kinds
  22311. */
  22312. getVerticesDataKinds(): string[];
  22313. /**
  22314. * Update index buffer
  22315. * @param indices defines the indices to store in the index buffer
  22316. * @param offset defines the offset in the target buffer where to store the data
  22317. * @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)
  22318. */
  22319. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22320. /**
  22321. * Creates a new index buffer
  22322. * @param indices defines the indices to store in the index buffer
  22323. * @param totalVertices defines the total number of vertices (could be null)
  22324. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22325. */
  22326. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22327. /**
  22328. * Return the total number of indices
  22329. * @returns the total number of indices
  22330. */
  22331. getTotalIndices(): number;
  22332. /**
  22333. * Gets the index buffer array
  22334. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22335. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22336. * @returns the index buffer array
  22337. */
  22338. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22339. /**
  22340. * Gets the index buffer
  22341. * @return the index buffer
  22342. */
  22343. getIndexBuffer(): Nullable<DataBuffer>;
  22344. /** @hidden */
  22345. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22346. /**
  22347. * Release the associated resources for a specific mesh
  22348. * @param mesh defines the source mesh
  22349. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22350. */
  22351. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22352. /**
  22353. * Apply current geometry to a given mesh
  22354. * @param mesh defines the mesh to apply geometry to
  22355. */
  22356. applyToMesh(mesh: Mesh): void;
  22357. private _updateExtend;
  22358. private _applyToMesh;
  22359. private notifyUpdate;
  22360. /**
  22361. * Load the geometry if it was flagged as delay loaded
  22362. * @param scene defines the hosting scene
  22363. * @param onLoaded defines a callback called when the geometry is loaded
  22364. */
  22365. load(scene: Scene, onLoaded?: () => void): void;
  22366. private _queueLoad;
  22367. /**
  22368. * Invert the geometry to move from a right handed system to a left handed one.
  22369. */
  22370. toLeftHanded(): void;
  22371. /** @hidden */
  22372. _resetPointsArrayCache(): void;
  22373. /** @hidden */
  22374. _generatePointsArray(): boolean;
  22375. /**
  22376. * Gets a value indicating if the geometry is disposed
  22377. * @returns true if the geometry was disposed
  22378. */
  22379. isDisposed(): boolean;
  22380. private _disposeVertexArrayObjects;
  22381. /**
  22382. * Free all associated resources
  22383. */
  22384. dispose(): void;
  22385. /**
  22386. * Clone the current geometry into a new geometry
  22387. * @param id defines the unique ID of the new geometry
  22388. * @returns a new geometry object
  22389. */
  22390. copy(id: string): Geometry;
  22391. /**
  22392. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22393. * @return a JSON representation of the current geometry data (without the vertices data)
  22394. */
  22395. serialize(): any;
  22396. private toNumberArray;
  22397. /**
  22398. * Serialize all vertices data into a JSON oject
  22399. * @returns a JSON representation of the current geometry data
  22400. */
  22401. serializeVerticeData(): any;
  22402. /**
  22403. * Extracts a clone of a mesh geometry
  22404. * @param mesh defines the source mesh
  22405. * @param id defines the unique ID of the new geometry object
  22406. * @returns the new geometry object
  22407. */
  22408. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22409. /**
  22410. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22411. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22412. * Be aware Math.random() could cause collisions, but:
  22413. * "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"
  22414. * @returns a string containing a new GUID
  22415. */
  22416. static RandomId(): string;
  22417. /** @hidden */
  22418. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22419. private static _CleanMatricesWeights;
  22420. /**
  22421. * Create a new geometry from persisted data (Using .babylon file format)
  22422. * @param parsedVertexData defines the persisted data
  22423. * @param scene defines the hosting scene
  22424. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22425. * @returns the new geometry object
  22426. */
  22427. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22428. }
  22429. }
  22430. declare module "babylonjs/Meshes/mesh.vertexData" {
  22431. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22432. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22433. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22434. import { Geometry } from "babylonjs/Meshes/geometry";
  22435. import { Mesh } from "babylonjs/Meshes/mesh";
  22436. /**
  22437. * Define an interface for all classes that will get and set the data on vertices
  22438. */
  22439. export interface IGetSetVerticesData {
  22440. /**
  22441. * Gets a boolean indicating if specific vertex data is present
  22442. * @param kind defines the vertex data kind to use
  22443. * @returns true is data kind is present
  22444. */
  22445. isVerticesDataPresent(kind: string): boolean;
  22446. /**
  22447. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22448. * @param kind defines the data kind (Position, normal, etc...)
  22449. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22450. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22451. * @returns a float array containing vertex data
  22452. */
  22453. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22454. /**
  22455. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22456. * @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.
  22457. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22458. * @returns the indices array or an empty array if the mesh has no geometry
  22459. */
  22460. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22461. /**
  22462. * Set specific vertex data
  22463. * @param kind defines the data kind (Position, normal, etc...)
  22464. * @param data defines the vertex data to use
  22465. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22466. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22467. */
  22468. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22469. /**
  22470. * Update a specific associated vertex buffer
  22471. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22472. * - VertexBuffer.PositionKind
  22473. * - VertexBuffer.UVKind
  22474. * - VertexBuffer.UV2Kind
  22475. * - VertexBuffer.UV3Kind
  22476. * - VertexBuffer.UV4Kind
  22477. * - VertexBuffer.UV5Kind
  22478. * - VertexBuffer.UV6Kind
  22479. * - VertexBuffer.ColorKind
  22480. * - VertexBuffer.MatricesIndicesKind
  22481. * - VertexBuffer.MatricesIndicesExtraKind
  22482. * - VertexBuffer.MatricesWeightsKind
  22483. * - VertexBuffer.MatricesWeightsExtraKind
  22484. * @param data defines the data source
  22485. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22486. * @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)
  22487. */
  22488. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22489. /**
  22490. * Creates a new index buffer
  22491. * @param indices defines the indices to store in the index buffer
  22492. * @param totalVertices defines the total number of vertices (could be null)
  22493. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22494. */
  22495. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22496. }
  22497. /**
  22498. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22499. */
  22500. export class VertexData {
  22501. /**
  22502. * Mesh side orientation : usually the external or front surface
  22503. */
  22504. static readonly FRONTSIDE: number;
  22505. /**
  22506. * Mesh side orientation : usually the internal or back surface
  22507. */
  22508. static readonly BACKSIDE: number;
  22509. /**
  22510. * Mesh side orientation : both internal and external or front and back surfaces
  22511. */
  22512. static readonly DOUBLESIDE: number;
  22513. /**
  22514. * Mesh side orientation : by default, `FRONTSIDE`
  22515. */
  22516. static readonly DEFAULTSIDE: number;
  22517. /**
  22518. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22519. */
  22520. positions: Nullable<FloatArray>;
  22521. /**
  22522. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22523. */
  22524. normals: Nullable<FloatArray>;
  22525. /**
  22526. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22527. */
  22528. tangents: Nullable<FloatArray>;
  22529. /**
  22530. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22531. */
  22532. uvs: Nullable<FloatArray>;
  22533. /**
  22534. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22535. */
  22536. uvs2: Nullable<FloatArray>;
  22537. /**
  22538. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22539. */
  22540. uvs3: Nullable<FloatArray>;
  22541. /**
  22542. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22543. */
  22544. uvs4: Nullable<FloatArray>;
  22545. /**
  22546. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22547. */
  22548. uvs5: Nullable<FloatArray>;
  22549. /**
  22550. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22551. */
  22552. uvs6: Nullable<FloatArray>;
  22553. /**
  22554. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22555. */
  22556. colors: Nullable<FloatArray>;
  22557. /**
  22558. * 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).
  22559. */
  22560. matricesIndices: Nullable<FloatArray>;
  22561. /**
  22562. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22563. */
  22564. matricesWeights: Nullable<FloatArray>;
  22565. /**
  22566. * An array extending the number of possible indices
  22567. */
  22568. matricesIndicesExtra: Nullable<FloatArray>;
  22569. /**
  22570. * An array extending the number of possible weights when the number of indices is extended
  22571. */
  22572. matricesWeightsExtra: Nullable<FloatArray>;
  22573. /**
  22574. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22575. */
  22576. indices: Nullable<IndicesArray>;
  22577. /**
  22578. * Uses the passed data array to set the set the values for the specified kind of data
  22579. * @param data a linear array of floating numbers
  22580. * @param kind the type of data that is being set, eg positions, colors etc
  22581. */
  22582. set(data: FloatArray, kind: string): void;
  22583. /**
  22584. * Associates the vertexData to the passed Mesh.
  22585. * Sets it as updatable or not (default `false`)
  22586. * @param mesh the mesh the vertexData is applied to
  22587. * @param updatable when used and having the value true allows new data to update the vertexData
  22588. * @returns the VertexData
  22589. */
  22590. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22591. /**
  22592. * Associates the vertexData to the passed Geometry.
  22593. * Sets it as updatable or not (default `false`)
  22594. * @param geometry the geometry the vertexData is applied to
  22595. * @param updatable when used and having the value true allows new data to update the vertexData
  22596. * @returns VertexData
  22597. */
  22598. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22599. /**
  22600. * Updates the associated mesh
  22601. * @param mesh the mesh to be updated
  22602. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22603. * @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
  22604. * @returns VertexData
  22605. */
  22606. updateMesh(mesh: Mesh): VertexData;
  22607. /**
  22608. * Updates the associated geometry
  22609. * @param geometry the geometry to be updated
  22610. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22611. * @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
  22612. * @returns VertexData.
  22613. */
  22614. updateGeometry(geometry: Geometry): VertexData;
  22615. private _applyTo;
  22616. private _update;
  22617. /**
  22618. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22619. * @param matrix the transforming matrix
  22620. * @returns the VertexData
  22621. */
  22622. transform(matrix: Matrix): VertexData;
  22623. /**
  22624. * Merges the passed VertexData into the current one
  22625. * @param other the VertexData to be merged into the current one
  22626. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22627. * @returns the modified VertexData
  22628. */
  22629. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22630. private _mergeElement;
  22631. private _validate;
  22632. /**
  22633. * Serializes the VertexData
  22634. * @returns a serialized object
  22635. */
  22636. serialize(): any;
  22637. /**
  22638. * Extracts the vertexData from a mesh
  22639. * @param mesh the mesh from which to extract the VertexData
  22640. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22641. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22642. * @returns the object VertexData associated to the passed mesh
  22643. */
  22644. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22645. /**
  22646. * Extracts the vertexData from the geometry
  22647. * @param geometry the geometry from which to extract the VertexData
  22648. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22649. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22650. * @returns the object VertexData associated to the passed mesh
  22651. */
  22652. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22653. private static _ExtractFrom;
  22654. /**
  22655. * Creates the VertexData for a Ribbon
  22656. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22657. * * pathArray array of paths, each of which an array of successive Vector3
  22658. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22659. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22660. * * 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
  22661. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22662. * * 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)
  22663. * * 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)
  22664. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22665. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22666. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22667. * @returns the VertexData of the ribbon
  22668. */
  22669. static CreateRibbon(options: {
  22670. pathArray: Vector3[][];
  22671. closeArray?: boolean;
  22672. closePath?: boolean;
  22673. offset?: number;
  22674. sideOrientation?: number;
  22675. frontUVs?: Vector4;
  22676. backUVs?: Vector4;
  22677. invertUV?: boolean;
  22678. uvs?: Vector2[];
  22679. colors?: Color4[];
  22680. }): VertexData;
  22681. /**
  22682. * Creates the VertexData for a box
  22683. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22684. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22685. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22686. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22687. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22688. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22689. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22690. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22691. * * 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)
  22692. * * 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)
  22693. * @returns the VertexData of the box
  22694. */
  22695. static CreateBox(options: {
  22696. size?: number;
  22697. width?: number;
  22698. height?: number;
  22699. depth?: number;
  22700. faceUV?: Vector4[];
  22701. faceColors?: Color4[];
  22702. sideOrientation?: number;
  22703. frontUVs?: Vector4;
  22704. backUVs?: Vector4;
  22705. }): VertexData;
  22706. /**
  22707. * Creates the VertexData for a tiled box
  22708. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22709. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22710. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22711. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22712. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22713. * @returns the VertexData of the box
  22714. */
  22715. static CreateTiledBox(options: {
  22716. pattern?: number;
  22717. width?: number;
  22718. height?: number;
  22719. depth?: number;
  22720. tileSize?: number;
  22721. tileWidth?: number;
  22722. tileHeight?: number;
  22723. alignHorizontal?: number;
  22724. alignVertical?: number;
  22725. faceUV?: Vector4[];
  22726. faceColors?: Color4[];
  22727. sideOrientation?: number;
  22728. }): VertexData;
  22729. /**
  22730. * Creates the VertexData for a tiled plane
  22731. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22732. * * pattern a limited pattern arrangement depending on the number
  22733. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22734. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22735. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22736. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22737. * * 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)
  22738. * * 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)
  22739. * @returns the VertexData of the tiled plane
  22740. */
  22741. static CreateTiledPlane(options: {
  22742. pattern?: number;
  22743. tileSize?: number;
  22744. tileWidth?: number;
  22745. tileHeight?: number;
  22746. size?: number;
  22747. width?: number;
  22748. height?: number;
  22749. alignHorizontal?: number;
  22750. alignVertical?: number;
  22751. sideOrientation?: number;
  22752. frontUVs?: Vector4;
  22753. backUVs?: Vector4;
  22754. }): VertexData;
  22755. /**
  22756. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22757. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22758. * * segments sets the number of horizontal strips optional, default 32
  22759. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22760. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22761. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22762. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22763. * * 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
  22764. * * 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
  22765. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22766. * * 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)
  22767. * * 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)
  22768. * @returns the VertexData of the ellipsoid
  22769. */
  22770. static CreateSphere(options: {
  22771. segments?: number;
  22772. diameter?: number;
  22773. diameterX?: number;
  22774. diameterY?: number;
  22775. diameterZ?: number;
  22776. arc?: number;
  22777. slice?: number;
  22778. sideOrientation?: number;
  22779. frontUVs?: Vector4;
  22780. backUVs?: Vector4;
  22781. }): VertexData;
  22782. /**
  22783. * Creates the VertexData for a cylinder, cone or prism
  22784. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22785. * * height sets the height (y direction) of the cylinder, optional, default 2
  22786. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22787. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22788. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22789. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22790. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22791. * * 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
  22792. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22793. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22794. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22795. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22796. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22797. * * 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)
  22798. * * 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)
  22799. * @returns the VertexData of the cylinder, cone or prism
  22800. */
  22801. static CreateCylinder(options: {
  22802. height?: number;
  22803. diameterTop?: number;
  22804. diameterBottom?: number;
  22805. diameter?: number;
  22806. tessellation?: number;
  22807. subdivisions?: number;
  22808. arc?: number;
  22809. faceColors?: Color4[];
  22810. faceUV?: Vector4[];
  22811. hasRings?: boolean;
  22812. enclose?: boolean;
  22813. sideOrientation?: number;
  22814. frontUVs?: Vector4;
  22815. backUVs?: Vector4;
  22816. }): VertexData;
  22817. /**
  22818. * Creates the VertexData for a torus
  22819. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22820. * * diameter the diameter of the torus, optional default 1
  22821. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22822. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22823. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22824. * * 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)
  22825. * * 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)
  22826. * @returns the VertexData of the torus
  22827. */
  22828. static CreateTorus(options: {
  22829. diameter?: number;
  22830. thickness?: number;
  22831. tessellation?: number;
  22832. sideOrientation?: number;
  22833. frontUVs?: Vector4;
  22834. backUVs?: Vector4;
  22835. }): VertexData;
  22836. /**
  22837. * Creates the VertexData of the LineSystem
  22838. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22839. * - lines an array of lines, each line being an array of successive Vector3
  22840. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22841. * @returns the VertexData of the LineSystem
  22842. */
  22843. static CreateLineSystem(options: {
  22844. lines: Vector3[][];
  22845. colors?: Nullable<Color4[][]>;
  22846. }): VertexData;
  22847. /**
  22848. * Create the VertexData for a DashedLines
  22849. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22850. * - points an array successive Vector3
  22851. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22852. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22853. * - dashNb the intended total number of dashes, optional, default 200
  22854. * @returns the VertexData for the DashedLines
  22855. */
  22856. static CreateDashedLines(options: {
  22857. points: Vector3[];
  22858. dashSize?: number;
  22859. gapSize?: number;
  22860. dashNb?: number;
  22861. }): VertexData;
  22862. /**
  22863. * Creates the VertexData for a Ground
  22864. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22865. * - width the width (x direction) of the ground, optional, default 1
  22866. * - height the height (z direction) of the ground, optional, default 1
  22867. * - subdivisions the number of subdivisions per side, optional, default 1
  22868. * @returns the VertexData of the Ground
  22869. */
  22870. static CreateGround(options: {
  22871. width?: number;
  22872. height?: number;
  22873. subdivisions?: number;
  22874. subdivisionsX?: number;
  22875. subdivisionsY?: number;
  22876. }): VertexData;
  22877. /**
  22878. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22879. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22880. * * xmin the ground minimum X coordinate, optional, default -1
  22881. * * zmin the ground minimum Z coordinate, optional, default -1
  22882. * * xmax the ground maximum X coordinate, optional, default 1
  22883. * * zmax the ground maximum Z coordinate, optional, default 1
  22884. * * 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}
  22885. * * 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}
  22886. * @returns the VertexData of the TiledGround
  22887. */
  22888. static CreateTiledGround(options: {
  22889. xmin: number;
  22890. zmin: number;
  22891. xmax: number;
  22892. zmax: number;
  22893. subdivisions?: {
  22894. w: number;
  22895. h: number;
  22896. };
  22897. precision?: {
  22898. w: number;
  22899. h: number;
  22900. };
  22901. }): VertexData;
  22902. /**
  22903. * Creates the VertexData of the Ground designed from a heightmap
  22904. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22905. * * width the width (x direction) of the ground
  22906. * * height the height (z direction) of the ground
  22907. * * subdivisions the number of subdivisions per side
  22908. * * minHeight the minimum altitude on the ground, optional, default 0
  22909. * * maxHeight the maximum altitude on the ground, optional default 1
  22910. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22911. * * buffer the array holding the image color data
  22912. * * bufferWidth the width of image
  22913. * * bufferHeight the height of image
  22914. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22915. * @returns the VertexData of the Ground designed from a heightmap
  22916. */
  22917. static CreateGroundFromHeightMap(options: {
  22918. width: number;
  22919. height: number;
  22920. subdivisions: number;
  22921. minHeight: number;
  22922. maxHeight: number;
  22923. colorFilter: Color3;
  22924. buffer: Uint8Array;
  22925. bufferWidth: number;
  22926. bufferHeight: number;
  22927. alphaFilter: number;
  22928. }): VertexData;
  22929. /**
  22930. * Creates the VertexData for a Plane
  22931. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22932. * * size sets the width and height of the plane to the value of size, optional default 1
  22933. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22934. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22935. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22936. * * 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)
  22937. * * 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)
  22938. * @returns the VertexData of the box
  22939. */
  22940. static CreatePlane(options: {
  22941. size?: number;
  22942. width?: number;
  22943. height?: number;
  22944. sideOrientation?: number;
  22945. frontUVs?: Vector4;
  22946. backUVs?: Vector4;
  22947. }): VertexData;
  22948. /**
  22949. * Creates the VertexData of the Disc or regular Polygon
  22950. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22951. * * radius the radius of the disc, optional default 0.5
  22952. * * tessellation the number of polygon sides, optional, default 64
  22953. * * 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
  22954. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22955. * * 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)
  22956. * * 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)
  22957. * @returns the VertexData of the box
  22958. */
  22959. static CreateDisc(options: {
  22960. radius?: number;
  22961. tessellation?: number;
  22962. arc?: number;
  22963. sideOrientation?: number;
  22964. frontUVs?: Vector4;
  22965. backUVs?: Vector4;
  22966. }): VertexData;
  22967. /**
  22968. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22969. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22970. * @param polygon a mesh built from polygonTriangulation.build()
  22971. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22972. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22973. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22974. * @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)
  22975. * @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)
  22976. * @returns the VertexData of the Polygon
  22977. */
  22978. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22979. /**
  22980. * Creates the VertexData of the IcoSphere
  22981. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22982. * * radius the radius of the IcoSphere, optional default 1
  22983. * * radiusX allows stretching in the x direction, optional, default radius
  22984. * * radiusY allows stretching in the y direction, optional, default radius
  22985. * * radiusZ allows stretching in the z direction, optional, default radius
  22986. * * flat when true creates a flat shaded mesh, optional, default true
  22987. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22988. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22989. * * 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)
  22990. * * 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)
  22991. * @returns the VertexData of the IcoSphere
  22992. */
  22993. static CreateIcoSphere(options: {
  22994. radius?: number;
  22995. radiusX?: number;
  22996. radiusY?: number;
  22997. radiusZ?: number;
  22998. flat?: boolean;
  22999. subdivisions?: number;
  23000. sideOrientation?: number;
  23001. frontUVs?: Vector4;
  23002. backUVs?: Vector4;
  23003. }): VertexData;
  23004. /**
  23005. * Creates the VertexData for a Polyhedron
  23006. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23007. * * type provided types are:
  23008. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23009. * * 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)
  23010. * * size the size of the IcoSphere, optional default 1
  23011. * * sizeX allows stretching in the x direction, optional, default size
  23012. * * sizeY allows stretching in the y direction, optional, default size
  23013. * * sizeZ allows stretching in the z direction, optional, default size
  23014. * * 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
  23015. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23016. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23017. * * flat when true creates a flat shaded mesh, optional, default true
  23018. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23019. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23020. * * 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)
  23021. * * 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)
  23022. * @returns the VertexData of the Polyhedron
  23023. */
  23024. static CreatePolyhedron(options: {
  23025. type?: number;
  23026. size?: number;
  23027. sizeX?: number;
  23028. sizeY?: number;
  23029. sizeZ?: number;
  23030. custom?: any;
  23031. faceUV?: Vector4[];
  23032. faceColors?: Color4[];
  23033. flat?: boolean;
  23034. sideOrientation?: number;
  23035. frontUVs?: Vector4;
  23036. backUVs?: Vector4;
  23037. }): VertexData;
  23038. /**
  23039. * Creates the VertexData for a TorusKnot
  23040. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23041. * * radius the radius of the torus knot, optional, default 2
  23042. * * tube the thickness of the tube, optional, default 0.5
  23043. * * radialSegments the number of sides on each tube segments, optional, default 32
  23044. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23045. * * p the number of windings around the z axis, optional, default 2
  23046. * * q the number of windings around the x axis, optional, default 3
  23047. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23048. * * 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)
  23049. * * 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)
  23050. * @returns the VertexData of the Torus Knot
  23051. */
  23052. static CreateTorusKnot(options: {
  23053. radius?: number;
  23054. tube?: number;
  23055. radialSegments?: number;
  23056. tubularSegments?: number;
  23057. p?: number;
  23058. q?: number;
  23059. sideOrientation?: number;
  23060. frontUVs?: Vector4;
  23061. backUVs?: Vector4;
  23062. }): VertexData;
  23063. /**
  23064. * Compute normals for given positions and indices
  23065. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23066. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23067. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23068. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23069. * * facetNormals : optional array of facet normals (vector3)
  23070. * * facetPositions : optional array of facet positions (vector3)
  23071. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23072. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23073. * * bInfo : optional bounding info, required for facetPartitioning computation
  23074. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23075. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23076. * * useRightHandedSystem: optional boolean to for right handed system computation
  23077. * * depthSort : optional boolean to enable the facet depth sort computation
  23078. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23079. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23080. */
  23081. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23082. facetNormals?: any;
  23083. facetPositions?: any;
  23084. facetPartitioning?: any;
  23085. ratio?: number;
  23086. bInfo?: any;
  23087. bbSize?: Vector3;
  23088. subDiv?: any;
  23089. useRightHandedSystem?: boolean;
  23090. depthSort?: boolean;
  23091. distanceTo?: Vector3;
  23092. depthSortedFacets?: any;
  23093. }): void;
  23094. /** @hidden */
  23095. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23096. /**
  23097. * Applies VertexData created from the imported parameters to the geometry
  23098. * @param parsedVertexData the parsed data from an imported file
  23099. * @param geometry the geometry to apply the VertexData to
  23100. */
  23101. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23102. }
  23103. }
  23104. declare module "babylonjs/Morph/morphTarget" {
  23105. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23106. import { Observable } from "babylonjs/Misc/observable";
  23107. import { Nullable, FloatArray } from "babylonjs/types";
  23108. import { Scene } from "babylonjs/scene";
  23109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23110. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23111. /**
  23112. * Defines a target to use with MorphTargetManager
  23113. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23114. */
  23115. export class MorphTarget implements IAnimatable {
  23116. /** defines the name of the target */
  23117. name: string;
  23118. /**
  23119. * Gets or sets the list of animations
  23120. */
  23121. animations: import("babylonjs/Animations/animation").Animation[];
  23122. private _scene;
  23123. private _positions;
  23124. private _normals;
  23125. private _tangents;
  23126. private _uvs;
  23127. private _influence;
  23128. private _uniqueId;
  23129. /**
  23130. * Observable raised when the influence changes
  23131. */
  23132. onInfluenceChanged: Observable<boolean>;
  23133. /** @hidden */
  23134. _onDataLayoutChanged: Observable<void>;
  23135. /**
  23136. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23137. */
  23138. get influence(): number;
  23139. set influence(influence: number);
  23140. /**
  23141. * Gets or sets the id of the morph Target
  23142. */
  23143. id: string;
  23144. private _animationPropertiesOverride;
  23145. /**
  23146. * Gets or sets the animation properties override
  23147. */
  23148. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23149. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23150. /**
  23151. * Creates a new MorphTarget
  23152. * @param name defines the name of the target
  23153. * @param influence defines the influence to use
  23154. * @param scene defines the scene the morphtarget belongs to
  23155. */
  23156. constructor(
  23157. /** defines the name of the target */
  23158. name: string, influence?: number, scene?: Nullable<Scene>);
  23159. /**
  23160. * Gets the unique ID of this manager
  23161. */
  23162. get uniqueId(): number;
  23163. /**
  23164. * Gets a boolean defining if the target contains position data
  23165. */
  23166. get hasPositions(): boolean;
  23167. /**
  23168. * Gets a boolean defining if the target contains normal data
  23169. */
  23170. get hasNormals(): boolean;
  23171. /**
  23172. * Gets a boolean defining if the target contains tangent data
  23173. */
  23174. get hasTangents(): boolean;
  23175. /**
  23176. * Gets a boolean defining if the target contains texture coordinates data
  23177. */
  23178. get hasUVs(): boolean;
  23179. /**
  23180. * Affects position data to this target
  23181. * @param data defines the position data to use
  23182. */
  23183. setPositions(data: Nullable<FloatArray>): void;
  23184. /**
  23185. * Gets the position data stored in this target
  23186. * @returns a FloatArray containing the position data (or null if not present)
  23187. */
  23188. getPositions(): Nullable<FloatArray>;
  23189. /**
  23190. * Affects normal data to this target
  23191. * @param data defines the normal data to use
  23192. */
  23193. setNormals(data: Nullable<FloatArray>): void;
  23194. /**
  23195. * Gets the normal data stored in this target
  23196. * @returns a FloatArray containing the normal data (or null if not present)
  23197. */
  23198. getNormals(): Nullable<FloatArray>;
  23199. /**
  23200. * Affects tangent data to this target
  23201. * @param data defines the tangent data to use
  23202. */
  23203. setTangents(data: Nullable<FloatArray>): void;
  23204. /**
  23205. * Gets the tangent data stored in this target
  23206. * @returns a FloatArray containing the tangent data (or null if not present)
  23207. */
  23208. getTangents(): Nullable<FloatArray>;
  23209. /**
  23210. * Affects texture coordinates data to this target
  23211. * @param data defines the texture coordinates data to use
  23212. */
  23213. setUVs(data: Nullable<FloatArray>): void;
  23214. /**
  23215. * Gets the texture coordinates data stored in this target
  23216. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23217. */
  23218. getUVs(): Nullable<FloatArray>;
  23219. /**
  23220. * Clone the current target
  23221. * @returns a new MorphTarget
  23222. */
  23223. clone(): MorphTarget;
  23224. /**
  23225. * Serializes the current target into a Serialization object
  23226. * @returns the serialized object
  23227. */
  23228. serialize(): any;
  23229. /**
  23230. * Returns the string "MorphTarget"
  23231. * @returns "MorphTarget"
  23232. */
  23233. getClassName(): string;
  23234. /**
  23235. * Creates a new target from serialized data
  23236. * @param serializationObject defines the serialized data to use
  23237. * @returns a new MorphTarget
  23238. */
  23239. static Parse(serializationObject: any): MorphTarget;
  23240. /**
  23241. * Creates a MorphTarget from mesh data
  23242. * @param mesh defines the source mesh
  23243. * @param name defines the name to use for the new target
  23244. * @param influence defines the influence to attach to the target
  23245. * @returns a new MorphTarget
  23246. */
  23247. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23248. }
  23249. }
  23250. declare module "babylonjs/Morph/morphTargetManager" {
  23251. import { Nullable } from "babylonjs/types";
  23252. import { Scene } from "babylonjs/scene";
  23253. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23254. /**
  23255. * This class is used to deform meshes using morphing between different targets
  23256. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23257. */
  23258. export class MorphTargetManager {
  23259. private _targets;
  23260. private _targetInfluenceChangedObservers;
  23261. private _targetDataLayoutChangedObservers;
  23262. private _activeTargets;
  23263. private _scene;
  23264. private _influences;
  23265. private _supportsNormals;
  23266. private _supportsTangents;
  23267. private _supportsUVs;
  23268. private _vertexCount;
  23269. private _uniqueId;
  23270. private _tempInfluences;
  23271. /**
  23272. * Gets or sets a boolean indicating if normals must be morphed
  23273. */
  23274. enableNormalMorphing: boolean;
  23275. /**
  23276. * Gets or sets a boolean indicating if tangents must be morphed
  23277. */
  23278. enableTangentMorphing: boolean;
  23279. /**
  23280. * Gets or sets a boolean indicating if UV must be morphed
  23281. */
  23282. enableUVMorphing: boolean;
  23283. /**
  23284. * Creates a new MorphTargetManager
  23285. * @param scene defines the current scene
  23286. */
  23287. constructor(scene?: Nullable<Scene>);
  23288. /**
  23289. * Gets the unique ID of this manager
  23290. */
  23291. get uniqueId(): number;
  23292. /**
  23293. * Gets the number of vertices handled by this manager
  23294. */
  23295. get vertexCount(): number;
  23296. /**
  23297. * Gets a boolean indicating if this manager supports morphing of normals
  23298. */
  23299. get supportsNormals(): boolean;
  23300. /**
  23301. * Gets a boolean indicating if this manager supports morphing of tangents
  23302. */
  23303. get supportsTangents(): boolean;
  23304. /**
  23305. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23306. */
  23307. get supportsUVs(): boolean;
  23308. /**
  23309. * Gets the number of targets stored in this manager
  23310. */
  23311. get numTargets(): number;
  23312. /**
  23313. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23314. */
  23315. get numInfluencers(): number;
  23316. /**
  23317. * Gets the list of influences (one per target)
  23318. */
  23319. get influences(): Float32Array;
  23320. /**
  23321. * Gets the active target at specified index. An active target is a target with an influence > 0
  23322. * @param index defines the index to check
  23323. * @returns the requested target
  23324. */
  23325. getActiveTarget(index: number): MorphTarget;
  23326. /**
  23327. * Gets the target at specified index
  23328. * @param index defines the index to check
  23329. * @returns the requested target
  23330. */
  23331. getTarget(index: number): MorphTarget;
  23332. /**
  23333. * Add a new target to this manager
  23334. * @param target defines the target to add
  23335. */
  23336. addTarget(target: MorphTarget): void;
  23337. /**
  23338. * Removes a target from the manager
  23339. * @param target defines the target to remove
  23340. */
  23341. removeTarget(target: MorphTarget): void;
  23342. /**
  23343. * Clone the current manager
  23344. * @returns a new MorphTargetManager
  23345. */
  23346. clone(): MorphTargetManager;
  23347. /**
  23348. * Serializes the current manager into a Serialization object
  23349. * @returns the serialized object
  23350. */
  23351. serialize(): any;
  23352. private _syncActiveTargets;
  23353. /**
  23354. * Syncrhonize the targets with all the meshes using this morph target manager
  23355. */
  23356. synchronize(): void;
  23357. /**
  23358. * Creates a new MorphTargetManager from serialized data
  23359. * @param serializationObject defines the serialized data
  23360. * @param scene defines the hosting scene
  23361. * @returns the new MorphTargetManager
  23362. */
  23363. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23364. }
  23365. }
  23366. declare module "babylonjs/Meshes/meshLODLevel" {
  23367. import { Mesh } from "babylonjs/Meshes/mesh";
  23368. import { Nullable } from "babylonjs/types";
  23369. /**
  23370. * Class used to represent a specific level of detail of a mesh
  23371. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23372. */
  23373. export class MeshLODLevel {
  23374. /** Defines the distance where this level should start being displayed */
  23375. distance: number;
  23376. /** Defines the mesh to use to render this level */
  23377. mesh: Nullable<Mesh>;
  23378. /**
  23379. * Creates a new LOD level
  23380. * @param distance defines the distance where this level should star being displayed
  23381. * @param mesh defines the mesh to use to render this level
  23382. */
  23383. constructor(
  23384. /** Defines the distance where this level should start being displayed */
  23385. distance: number,
  23386. /** Defines the mesh to use to render this level */
  23387. mesh: Nullable<Mesh>);
  23388. }
  23389. }
  23390. declare module "babylonjs/Meshes/groundMesh" {
  23391. import { Scene } from "babylonjs/scene";
  23392. import { Vector3 } from "babylonjs/Maths/math.vector";
  23393. import { Mesh } from "babylonjs/Meshes/mesh";
  23394. /**
  23395. * Mesh representing the gorund
  23396. */
  23397. export class GroundMesh extends Mesh {
  23398. /** If octree should be generated */
  23399. generateOctree: boolean;
  23400. private _heightQuads;
  23401. /** @hidden */
  23402. _subdivisionsX: number;
  23403. /** @hidden */
  23404. _subdivisionsY: number;
  23405. /** @hidden */
  23406. _width: number;
  23407. /** @hidden */
  23408. _height: number;
  23409. /** @hidden */
  23410. _minX: number;
  23411. /** @hidden */
  23412. _maxX: number;
  23413. /** @hidden */
  23414. _minZ: number;
  23415. /** @hidden */
  23416. _maxZ: number;
  23417. constructor(name: string, scene: Scene);
  23418. /**
  23419. * "GroundMesh"
  23420. * @returns "GroundMesh"
  23421. */
  23422. getClassName(): string;
  23423. /**
  23424. * The minimum of x and y subdivisions
  23425. */
  23426. get subdivisions(): number;
  23427. /**
  23428. * X subdivisions
  23429. */
  23430. get subdivisionsX(): number;
  23431. /**
  23432. * Y subdivisions
  23433. */
  23434. get subdivisionsY(): number;
  23435. /**
  23436. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23437. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23438. * @param chunksCount the number of subdivisions for x and y
  23439. * @param octreeBlocksSize (Default: 32)
  23440. */
  23441. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23442. /**
  23443. * Returns a height (y) value in the Worl system :
  23444. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23445. * @param x x coordinate
  23446. * @param z z coordinate
  23447. * @returns the ground y position if (x, z) are outside the ground surface.
  23448. */
  23449. getHeightAtCoordinates(x: number, z: number): number;
  23450. /**
  23451. * Returns a normalized vector (Vector3) orthogonal to the ground
  23452. * at the ground coordinates (x, z) expressed in the World system.
  23453. * @param x x coordinate
  23454. * @param z z coordinate
  23455. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23456. */
  23457. getNormalAtCoordinates(x: number, z: number): Vector3;
  23458. /**
  23459. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23460. * at the ground coordinates (x, z) expressed in the World system.
  23461. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23462. * @param x x coordinate
  23463. * @param z z coordinate
  23464. * @param ref vector to store the result
  23465. * @returns the GroundMesh.
  23466. */
  23467. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23468. /**
  23469. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23470. * if the ground has been updated.
  23471. * This can be used in the render loop.
  23472. * @returns the GroundMesh.
  23473. */
  23474. updateCoordinateHeights(): GroundMesh;
  23475. private _getFacetAt;
  23476. private _initHeightQuads;
  23477. private _computeHeightQuads;
  23478. /**
  23479. * Serializes this ground mesh
  23480. * @param serializationObject object to write serialization to
  23481. */
  23482. serialize(serializationObject: any): void;
  23483. /**
  23484. * Parses a serialized ground mesh
  23485. * @param parsedMesh the serialized mesh
  23486. * @param scene the scene to create the ground mesh in
  23487. * @returns the created ground mesh
  23488. */
  23489. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23490. }
  23491. }
  23492. declare module "babylonjs/Physics/physicsJoint" {
  23493. import { Vector3 } from "babylonjs/Maths/math.vector";
  23494. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23495. /**
  23496. * Interface for Physics-Joint data
  23497. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23498. */
  23499. export interface PhysicsJointData {
  23500. /**
  23501. * The main pivot of the joint
  23502. */
  23503. mainPivot?: Vector3;
  23504. /**
  23505. * The connected pivot of the joint
  23506. */
  23507. connectedPivot?: Vector3;
  23508. /**
  23509. * The main axis of the joint
  23510. */
  23511. mainAxis?: Vector3;
  23512. /**
  23513. * The connected axis of the joint
  23514. */
  23515. connectedAxis?: Vector3;
  23516. /**
  23517. * The collision of the joint
  23518. */
  23519. collision?: boolean;
  23520. /**
  23521. * Native Oimo/Cannon/Energy data
  23522. */
  23523. nativeParams?: any;
  23524. }
  23525. /**
  23526. * This is a holder class for the physics joint created by the physics plugin
  23527. * It holds a set of functions to control the underlying joint
  23528. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23529. */
  23530. export class PhysicsJoint {
  23531. /**
  23532. * The type of the physics joint
  23533. */
  23534. type: number;
  23535. /**
  23536. * The data for the physics joint
  23537. */
  23538. jointData: PhysicsJointData;
  23539. private _physicsJoint;
  23540. protected _physicsPlugin: IPhysicsEnginePlugin;
  23541. /**
  23542. * Initializes the physics joint
  23543. * @param type The type of the physics joint
  23544. * @param jointData The data for the physics joint
  23545. */
  23546. constructor(
  23547. /**
  23548. * The type of the physics joint
  23549. */
  23550. type: number,
  23551. /**
  23552. * The data for the physics joint
  23553. */
  23554. jointData: PhysicsJointData);
  23555. /**
  23556. * Gets the physics joint
  23557. */
  23558. get physicsJoint(): any;
  23559. /**
  23560. * Sets the physics joint
  23561. */
  23562. set physicsJoint(newJoint: any);
  23563. /**
  23564. * Sets the physics plugin
  23565. */
  23566. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23567. /**
  23568. * Execute a function that is physics-plugin specific.
  23569. * @param {Function} func the function that will be executed.
  23570. * It accepts two parameters: the physics world and the physics joint
  23571. */
  23572. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23573. /**
  23574. * Distance-Joint type
  23575. */
  23576. static DistanceJoint: number;
  23577. /**
  23578. * Hinge-Joint type
  23579. */
  23580. static HingeJoint: number;
  23581. /**
  23582. * Ball-and-Socket joint type
  23583. */
  23584. static BallAndSocketJoint: number;
  23585. /**
  23586. * Wheel-Joint type
  23587. */
  23588. static WheelJoint: number;
  23589. /**
  23590. * Slider-Joint type
  23591. */
  23592. static SliderJoint: number;
  23593. /**
  23594. * Prismatic-Joint type
  23595. */
  23596. static PrismaticJoint: number;
  23597. /**
  23598. * Universal-Joint type
  23599. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23600. */
  23601. static UniversalJoint: number;
  23602. /**
  23603. * Hinge-Joint 2 type
  23604. */
  23605. static Hinge2Joint: number;
  23606. /**
  23607. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23608. */
  23609. static PointToPointJoint: number;
  23610. /**
  23611. * Spring-Joint type
  23612. */
  23613. static SpringJoint: number;
  23614. /**
  23615. * Lock-Joint type
  23616. */
  23617. static LockJoint: number;
  23618. }
  23619. /**
  23620. * A class representing a physics distance joint
  23621. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23622. */
  23623. export class DistanceJoint extends PhysicsJoint {
  23624. /**
  23625. *
  23626. * @param jointData The data for the Distance-Joint
  23627. */
  23628. constructor(jointData: DistanceJointData);
  23629. /**
  23630. * Update the predefined distance.
  23631. * @param maxDistance The maximum preferred distance
  23632. * @param minDistance The minimum preferred distance
  23633. */
  23634. updateDistance(maxDistance: number, minDistance?: number): void;
  23635. }
  23636. /**
  23637. * Represents a Motor-Enabled Joint
  23638. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23639. */
  23640. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23641. /**
  23642. * Initializes the Motor-Enabled Joint
  23643. * @param type The type of the joint
  23644. * @param jointData The physica joint data for the joint
  23645. */
  23646. constructor(type: number, jointData: PhysicsJointData);
  23647. /**
  23648. * Set the motor values.
  23649. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23650. * @param force the force to apply
  23651. * @param maxForce max force for this motor.
  23652. */
  23653. setMotor(force?: number, maxForce?: number): void;
  23654. /**
  23655. * Set the motor's limits.
  23656. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23657. * @param upperLimit The upper limit of the motor
  23658. * @param lowerLimit The lower limit of the motor
  23659. */
  23660. setLimit(upperLimit: number, lowerLimit?: number): void;
  23661. }
  23662. /**
  23663. * This class represents a single physics Hinge-Joint
  23664. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23665. */
  23666. export class HingeJoint extends MotorEnabledJoint {
  23667. /**
  23668. * Initializes the Hinge-Joint
  23669. * @param jointData The joint data for the Hinge-Joint
  23670. */
  23671. constructor(jointData: PhysicsJointData);
  23672. /**
  23673. * Set the motor values.
  23674. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23675. * @param {number} force the force to apply
  23676. * @param {number} maxForce max force for this motor.
  23677. */
  23678. setMotor(force?: number, maxForce?: number): void;
  23679. /**
  23680. * Set the motor's limits.
  23681. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23682. * @param upperLimit The upper limit of the motor
  23683. * @param lowerLimit The lower limit of the motor
  23684. */
  23685. setLimit(upperLimit: number, lowerLimit?: number): void;
  23686. }
  23687. /**
  23688. * This class represents a dual hinge physics joint (same as wheel joint)
  23689. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23690. */
  23691. export class Hinge2Joint extends MotorEnabledJoint {
  23692. /**
  23693. * Initializes the Hinge2-Joint
  23694. * @param jointData The joint data for the Hinge2-Joint
  23695. */
  23696. constructor(jointData: PhysicsJointData);
  23697. /**
  23698. * Set the motor values.
  23699. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23700. * @param {number} targetSpeed the speed the motor is to reach
  23701. * @param {number} maxForce max force for this motor.
  23702. * @param {motorIndex} the motor's index, 0 or 1.
  23703. */
  23704. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23705. /**
  23706. * Set the motor limits.
  23707. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23708. * @param {number} upperLimit the upper limit
  23709. * @param {number} lowerLimit lower limit
  23710. * @param {motorIndex} the motor's index, 0 or 1.
  23711. */
  23712. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23713. }
  23714. /**
  23715. * Interface for a motor enabled joint
  23716. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23717. */
  23718. export interface IMotorEnabledJoint {
  23719. /**
  23720. * Physics joint
  23721. */
  23722. physicsJoint: any;
  23723. /**
  23724. * Sets the motor of the motor-enabled joint
  23725. * @param force The force of the motor
  23726. * @param maxForce The maximum force of the motor
  23727. * @param motorIndex The index of the motor
  23728. */
  23729. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23730. /**
  23731. * Sets the limit of the motor
  23732. * @param upperLimit The upper limit of the motor
  23733. * @param lowerLimit The lower limit of the motor
  23734. * @param motorIndex The index of the motor
  23735. */
  23736. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23737. }
  23738. /**
  23739. * Joint data for a Distance-Joint
  23740. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23741. */
  23742. export interface DistanceJointData extends PhysicsJointData {
  23743. /**
  23744. * Max distance the 2 joint objects can be apart
  23745. */
  23746. maxDistance: number;
  23747. }
  23748. /**
  23749. * Joint data from a spring joint
  23750. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23751. */
  23752. export interface SpringJointData extends PhysicsJointData {
  23753. /**
  23754. * Length of the spring
  23755. */
  23756. length: number;
  23757. /**
  23758. * Stiffness of the spring
  23759. */
  23760. stiffness: number;
  23761. /**
  23762. * Damping of the spring
  23763. */
  23764. damping: number;
  23765. /** this callback will be called when applying the force to the impostors. */
  23766. forceApplicationCallback: () => void;
  23767. }
  23768. }
  23769. declare module "babylonjs/Physics/physicsRaycastResult" {
  23770. import { Vector3 } from "babylonjs/Maths/math.vector";
  23771. /**
  23772. * Holds the data for the raycast result
  23773. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23774. */
  23775. export class PhysicsRaycastResult {
  23776. private _hasHit;
  23777. private _hitDistance;
  23778. private _hitNormalWorld;
  23779. private _hitPointWorld;
  23780. private _rayFromWorld;
  23781. private _rayToWorld;
  23782. /**
  23783. * Gets if there was a hit
  23784. */
  23785. get hasHit(): boolean;
  23786. /**
  23787. * Gets the distance from the hit
  23788. */
  23789. get hitDistance(): number;
  23790. /**
  23791. * Gets the hit normal/direction in the world
  23792. */
  23793. get hitNormalWorld(): Vector3;
  23794. /**
  23795. * Gets the hit point in the world
  23796. */
  23797. get hitPointWorld(): Vector3;
  23798. /**
  23799. * Gets the ray "start point" of the ray in the world
  23800. */
  23801. get rayFromWorld(): Vector3;
  23802. /**
  23803. * Gets the ray "end point" of the ray in the world
  23804. */
  23805. get rayToWorld(): Vector3;
  23806. /**
  23807. * Sets the hit data (normal & point in world space)
  23808. * @param hitNormalWorld defines the normal in world space
  23809. * @param hitPointWorld defines the point in world space
  23810. */
  23811. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23812. /**
  23813. * Sets the distance from the start point to the hit point
  23814. * @param distance
  23815. */
  23816. setHitDistance(distance: number): void;
  23817. /**
  23818. * Calculates the distance manually
  23819. */
  23820. calculateHitDistance(): void;
  23821. /**
  23822. * Resets all the values to default
  23823. * @param from The from point on world space
  23824. * @param to The to point on world space
  23825. */
  23826. reset(from?: Vector3, to?: Vector3): void;
  23827. }
  23828. /**
  23829. * Interface for the size containing width and height
  23830. */
  23831. interface IXYZ {
  23832. /**
  23833. * X
  23834. */
  23835. x: number;
  23836. /**
  23837. * Y
  23838. */
  23839. y: number;
  23840. /**
  23841. * Z
  23842. */
  23843. z: number;
  23844. }
  23845. }
  23846. declare module "babylonjs/Physics/IPhysicsEngine" {
  23847. import { Nullable } from "babylonjs/types";
  23848. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23850. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23851. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23852. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23853. /**
  23854. * Interface used to describe a physics joint
  23855. */
  23856. export interface PhysicsImpostorJoint {
  23857. /** Defines the main impostor to which the joint is linked */
  23858. mainImpostor: PhysicsImpostor;
  23859. /** Defines the impostor that is connected to the main impostor using this joint */
  23860. connectedImpostor: PhysicsImpostor;
  23861. /** Defines the joint itself */
  23862. joint: PhysicsJoint;
  23863. }
  23864. /** @hidden */
  23865. export interface IPhysicsEnginePlugin {
  23866. world: any;
  23867. name: string;
  23868. setGravity(gravity: Vector3): void;
  23869. setTimeStep(timeStep: number): void;
  23870. getTimeStep(): number;
  23871. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23872. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23873. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23874. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23875. removePhysicsBody(impostor: PhysicsImpostor): void;
  23876. generateJoint(joint: PhysicsImpostorJoint): void;
  23877. removeJoint(joint: PhysicsImpostorJoint): void;
  23878. isSupported(): boolean;
  23879. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23880. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23881. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23882. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23883. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23884. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23885. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23886. getBodyMass(impostor: PhysicsImpostor): number;
  23887. getBodyFriction(impostor: PhysicsImpostor): number;
  23888. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23889. getBodyRestitution(impostor: PhysicsImpostor): number;
  23890. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23891. getBodyPressure?(impostor: PhysicsImpostor): number;
  23892. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23893. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23894. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23895. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23896. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23897. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23898. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23899. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23900. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23901. sleepBody(impostor: PhysicsImpostor): void;
  23902. wakeUpBody(impostor: PhysicsImpostor): void;
  23903. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23904. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23905. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23906. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23907. getRadius(impostor: PhysicsImpostor): number;
  23908. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23909. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23910. dispose(): void;
  23911. }
  23912. /**
  23913. * Interface used to define a physics engine
  23914. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23915. */
  23916. export interface IPhysicsEngine {
  23917. /**
  23918. * Gets the gravity vector used by the simulation
  23919. */
  23920. gravity: Vector3;
  23921. /**
  23922. * Sets the gravity vector used by the simulation
  23923. * @param gravity defines the gravity vector to use
  23924. */
  23925. setGravity(gravity: Vector3): void;
  23926. /**
  23927. * Set the time step of the physics engine.
  23928. * Default is 1/60.
  23929. * To slow it down, enter 1/600 for example.
  23930. * To speed it up, 1/30
  23931. * @param newTimeStep the new timestep to apply to this world.
  23932. */
  23933. setTimeStep(newTimeStep: number): void;
  23934. /**
  23935. * Get the time step of the physics engine.
  23936. * @returns the current time step
  23937. */
  23938. getTimeStep(): number;
  23939. /**
  23940. * Set the sub time step of the physics engine.
  23941. * Default is 0 meaning there is no sub steps
  23942. * To increase physics resolution precision, set a small value (like 1 ms)
  23943. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23944. */
  23945. setSubTimeStep(subTimeStep: number): void;
  23946. /**
  23947. * Get the sub time step of the physics engine.
  23948. * @returns the current sub time step
  23949. */
  23950. getSubTimeStep(): number;
  23951. /**
  23952. * Release all resources
  23953. */
  23954. dispose(): void;
  23955. /**
  23956. * Gets the name of the current physics plugin
  23957. * @returns the name of the plugin
  23958. */
  23959. getPhysicsPluginName(): string;
  23960. /**
  23961. * Adding a new impostor for the impostor tracking.
  23962. * This will be done by the impostor itself.
  23963. * @param impostor the impostor to add
  23964. */
  23965. addImpostor(impostor: PhysicsImpostor): void;
  23966. /**
  23967. * Remove an impostor from the engine.
  23968. * This impostor and its mesh will not longer be updated by the physics engine.
  23969. * @param impostor the impostor to remove
  23970. */
  23971. removeImpostor(impostor: PhysicsImpostor): void;
  23972. /**
  23973. * Add a joint to the physics engine
  23974. * @param mainImpostor defines the main impostor to which the joint is added.
  23975. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23976. * @param joint defines the joint that will connect both impostors.
  23977. */
  23978. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23979. /**
  23980. * Removes a joint from the simulation
  23981. * @param mainImpostor defines the impostor used with the joint
  23982. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23983. * @param joint defines the joint to remove
  23984. */
  23985. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23986. /**
  23987. * Gets the current plugin used to run the simulation
  23988. * @returns current plugin
  23989. */
  23990. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23991. /**
  23992. * Gets the list of physic impostors
  23993. * @returns an array of PhysicsImpostor
  23994. */
  23995. getImpostors(): Array<PhysicsImpostor>;
  23996. /**
  23997. * Gets the impostor for a physics enabled object
  23998. * @param object defines the object impersonated by the impostor
  23999. * @returns the PhysicsImpostor or null if not found
  24000. */
  24001. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24002. /**
  24003. * Gets the impostor for a physics body object
  24004. * @param body defines physics body used by the impostor
  24005. * @returns the PhysicsImpostor or null if not found
  24006. */
  24007. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24008. /**
  24009. * Does a raycast in the physics world
  24010. * @param from when should the ray start?
  24011. * @param to when should the ray end?
  24012. * @returns PhysicsRaycastResult
  24013. */
  24014. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24015. /**
  24016. * Called by the scene. No need to call it.
  24017. * @param delta defines the timespam between frames
  24018. */
  24019. _step(delta: number): void;
  24020. }
  24021. }
  24022. declare module "babylonjs/Physics/physicsImpostor" {
  24023. import { Nullable, IndicesArray } from "babylonjs/types";
  24024. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24025. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24026. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24027. import { Scene } from "babylonjs/scene";
  24028. import { Bone } from "babylonjs/Bones/bone";
  24029. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24030. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24031. import { Space } from "babylonjs/Maths/math.axis";
  24032. /**
  24033. * The interface for the physics imposter parameters
  24034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24035. */
  24036. export interface PhysicsImpostorParameters {
  24037. /**
  24038. * The mass of the physics imposter
  24039. */
  24040. mass: number;
  24041. /**
  24042. * The friction of the physics imposter
  24043. */
  24044. friction?: number;
  24045. /**
  24046. * The coefficient of restitution of the physics imposter
  24047. */
  24048. restitution?: number;
  24049. /**
  24050. * The native options of the physics imposter
  24051. */
  24052. nativeOptions?: any;
  24053. /**
  24054. * Specifies if the parent should be ignored
  24055. */
  24056. ignoreParent?: boolean;
  24057. /**
  24058. * Specifies if bi-directional transformations should be disabled
  24059. */
  24060. disableBidirectionalTransformation?: boolean;
  24061. /**
  24062. * The pressure inside the physics imposter, soft object only
  24063. */
  24064. pressure?: number;
  24065. /**
  24066. * The stiffness the physics imposter, soft object only
  24067. */
  24068. stiffness?: number;
  24069. /**
  24070. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24071. */
  24072. velocityIterations?: number;
  24073. /**
  24074. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24075. */
  24076. positionIterations?: number;
  24077. /**
  24078. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24079. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24080. * Add to fix multiple points
  24081. */
  24082. fixedPoints?: number;
  24083. /**
  24084. * The collision margin around a soft object
  24085. */
  24086. margin?: number;
  24087. /**
  24088. * The collision margin around a soft object
  24089. */
  24090. damping?: number;
  24091. /**
  24092. * The path for a rope based on an extrusion
  24093. */
  24094. path?: any;
  24095. /**
  24096. * The shape of an extrusion used for a rope based on an extrusion
  24097. */
  24098. shape?: any;
  24099. }
  24100. /**
  24101. * Interface for a physics-enabled object
  24102. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24103. */
  24104. export interface IPhysicsEnabledObject {
  24105. /**
  24106. * The position of the physics-enabled object
  24107. */
  24108. position: Vector3;
  24109. /**
  24110. * The rotation of the physics-enabled object
  24111. */
  24112. rotationQuaternion: Nullable<Quaternion>;
  24113. /**
  24114. * The scale of the physics-enabled object
  24115. */
  24116. scaling: Vector3;
  24117. /**
  24118. * The rotation of the physics-enabled object
  24119. */
  24120. rotation?: Vector3;
  24121. /**
  24122. * The parent of the physics-enabled object
  24123. */
  24124. parent?: any;
  24125. /**
  24126. * The bounding info of the physics-enabled object
  24127. * @returns The bounding info of the physics-enabled object
  24128. */
  24129. getBoundingInfo(): BoundingInfo;
  24130. /**
  24131. * Computes the world matrix
  24132. * @param force Specifies if the world matrix should be computed by force
  24133. * @returns A world matrix
  24134. */
  24135. computeWorldMatrix(force: boolean): Matrix;
  24136. /**
  24137. * Gets the world matrix
  24138. * @returns A world matrix
  24139. */
  24140. getWorldMatrix?(): Matrix;
  24141. /**
  24142. * Gets the child meshes
  24143. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24144. * @returns An array of abstract meshes
  24145. */
  24146. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24147. /**
  24148. * Gets the vertex data
  24149. * @param kind The type of vertex data
  24150. * @returns A nullable array of numbers, or a float32 array
  24151. */
  24152. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24153. /**
  24154. * Gets the indices from the mesh
  24155. * @returns A nullable array of index arrays
  24156. */
  24157. getIndices?(): Nullable<IndicesArray>;
  24158. /**
  24159. * Gets the scene from the mesh
  24160. * @returns the indices array or null
  24161. */
  24162. getScene?(): Scene;
  24163. /**
  24164. * Gets the absolute position from the mesh
  24165. * @returns the absolute position
  24166. */
  24167. getAbsolutePosition(): Vector3;
  24168. /**
  24169. * Gets the absolute pivot point from the mesh
  24170. * @returns the absolute pivot point
  24171. */
  24172. getAbsolutePivotPoint(): Vector3;
  24173. /**
  24174. * Rotates the mesh
  24175. * @param axis The axis of rotation
  24176. * @param amount The amount of rotation
  24177. * @param space The space of the rotation
  24178. * @returns The rotation transform node
  24179. */
  24180. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24181. /**
  24182. * Translates the mesh
  24183. * @param axis The axis of translation
  24184. * @param distance The distance of translation
  24185. * @param space The space of the translation
  24186. * @returns The transform node
  24187. */
  24188. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24189. /**
  24190. * Sets the absolute position of the mesh
  24191. * @param absolutePosition The absolute position of the mesh
  24192. * @returns The transform node
  24193. */
  24194. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24195. /**
  24196. * Gets the class name of the mesh
  24197. * @returns The class name
  24198. */
  24199. getClassName(): string;
  24200. }
  24201. /**
  24202. * Represents a physics imposter
  24203. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24204. */
  24205. export class PhysicsImpostor {
  24206. /**
  24207. * The physics-enabled object used as the physics imposter
  24208. */
  24209. object: IPhysicsEnabledObject;
  24210. /**
  24211. * The type of the physics imposter
  24212. */
  24213. type: number;
  24214. private _options;
  24215. private _scene?;
  24216. /**
  24217. * The default object size of the imposter
  24218. */
  24219. static DEFAULT_OBJECT_SIZE: Vector3;
  24220. /**
  24221. * The identity quaternion of the imposter
  24222. */
  24223. static IDENTITY_QUATERNION: Quaternion;
  24224. /** @hidden */
  24225. _pluginData: any;
  24226. private _physicsEngine;
  24227. private _physicsBody;
  24228. private _bodyUpdateRequired;
  24229. private _onBeforePhysicsStepCallbacks;
  24230. private _onAfterPhysicsStepCallbacks;
  24231. /** @hidden */
  24232. _onPhysicsCollideCallbacks: Array<{
  24233. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24234. otherImpostors: Array<PhysicsImpostor>;
  24235. }>;
  24236. private _deltaPosition;
  24237. private _deltaRotation;
  24238. private _deltaRotationConjugated;
  24239. /** @hidden */
  24240. _isFromLine: boolean;
  24241. private _parent;
  24242. private _isDisposed;
  24243. private static _tmpVecs;
  24244. private static _tmpQuat;
  24245. /**
  24246. * Specifies if the physics imposter is disposed
  24247. */
  24248. get isDisposed(): boolean;
  24249. /**
  24250. * Gets the mass of the physics imposter
  24251. */
  24252. get mass(): number;
  24253. set mass(value: number);
  24254. /**
  24255. * Gets the coefficient of friction
  24256. */
  24257. get friction(): number;
  24258. /**
  24259. * Sets the coefficient of friction
  24260. */
  24261. set friction(value: number);
  24262. /**
  24263. * Gets the coefficient of restitution
  24264. */
  24265. get restitution(): number;
  24266. /**
  24267. * Sets the coefficient of restitution
  24268. */
  24269. set restitution(value: number);
  24270. /**
  24271. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24272. */
  24273. get pressure(): number;
  24274. /**
  24275. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24276. */
  24277. set pressure(value: number);
  24278. /**
  24279. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24280. */
  24281. get stiffness(): number;
  24282. /**
  24283. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24284. */
  24285. set stiffness(value: number);
  24286. /**
  24287. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24288. */
  24289. get velocityIterations(): number;
  24290. /**
  24291. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24292. */
  24293. set velocityIterations(value: number);
  24294. /**
  24295. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24296. */
  24297. get positionIterations(): number;
  24298. /**
  24299. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24300. */
  24301. set positionIterations(value: number);
  24302. /**
  24303. * The unique id of the physics imposter
  24304. * set by the physics engine when adding this impostor to the array
  24305. */
  24306. uniqueId: number;
  24307. /**
  24308. * @hidden
  24309. */
  24310. soft: boolean;
  24311. /**
  24312. * @hidden
  24313. */
  24314. segments: number;
  24315. private _joints;
  24316. /**
  24317. * Initializes the physics imposter
  24318. * @param object The physics-enabled object used as the physics imposter
  24319. * @param type The type of the physics imposter
  24320. * @param _options The options for the physics imposter
  24321. * @param _scene The Babylon scene
  24322. */
  24323. constructor(
  24324. /**
  24325. * The physics-enabled object used as the physics imposter
  24326. */
  24327. object: IPhysicsEnabledObject,
  24328. /**
  24329. * The type of the physics imposter
  24330. */
  24331. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24332. /**
  24333. * This function will completly initialize this impostor.
  24334. * It will create a new body - but only if this mesh has no parent.
  24335. * If it has, this impostor will not be used other than to define the impostor
  24336. * of the child mesh.
  24337. * @hidden
  24338. */
  24339. _init(): void;
  24340. private _getPhysicsParent;
  24341. /**
  24342. * Should a new body be generated.
  24343. * @returns boolean specifying if body initialization is required
  24344. */
  24345. isBodyInitRequired(): boolean;
  24346. /**
  24347. * Sets the updated scaling
  24348. * @param updated Specifies if the scaling is updated
  24349. */
  24350. setScalingUpdated(): void;
  24351. /**
  24352. * Force a regeneration of this or the parent's impostor's body.
  24353. * Use under cautious - This will remove all joints already implemented.
  24354. */
  24355. forceUpdate(): void;
  24356. /**
  24357. * Gets the body that holds this impostor. Either its own, or its parent.
  24358. */
  24359. get physicsBody(): any;
  24360. /**
  24361. * Get the parent of the physics imposter
  24362. * @returns Physics imposter or null
  24363. */
  24364. get parent(): Nullable<PhysicsImpostor>;
  24365. /**
  24366. * Sets the parent of the physics imposter
  24367. */
  24368. set parent(value: Nullable<PhysicsImpostor>);
  24369. /**
  24370. * Set the physics body. Used mainly by the physics engine/plugin
  24371. */
  24372. set physicsBody(physicsBody: any);
  24373. /**
  24374. * Resets the update flags
  24375. */
  24376. resetUpdateFlags(): void;
  24377. /**
  24378. * Gets the object extend size
  24379. * @returns the object extend size
  24380. */
  24381. getObjectExtendSize(): Vector3;
  24382. /**
  24383. * Gets the object center
  24384. * @returns The object center
  24385. */
  24386. getObjectCenter(): Vector3;
  24387. /**
  24388. * Get a specific parametes from the options parameter
  24389. * @param paramName The object parameter name
  24390. * @returns The object parameter
  24391. */
  24392. getParam(paramName: string): any;
  24393. /**
  24394. * Sets a specific parameter in the options given to the physics plugin
  24395. * @param paramName The parameter name
  24396. * @param value The value of the parameter
  24397. */
  24398. setParam(paramName: string, value: number): void;
  24399. /**
  24400. * Specifically change the body's mass option. Won't recreate the physics body object
  24401. * @param mass The mass of the physics imposter
  24402. */
  24403. setMass(mass: number): void;
  24404. /**
  24405. * Gets the linear velocity
  24406. * @returns linear velocity or null
  24407. */
  24408. getLinearVelocity(): Nullable<Vector3>;
  24409. /**
  24410. * Sets the linear velocity
  24411. * @param velocity linear velocity or null
  24412. */
  24413. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24414. /**
  24415. * Gets the angular velocity
  24416. * @returns angular velocity or null
  24417. */
  24418. getAngularVelocity(): Nullable<Vector3>;
  24419. /**
  24420. * Sets the angular velocity
  24421. * @param velocity The velocity or null
  24422. */
  24423. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24424. /**
  24425. * Execute a function with the physics plugin native code
  24426. * Provide a function the will have two variables - the world object and the physics body object
  24427. * @param func The function to execute with the physics plugin native code
  24428. */
  24429. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24430. /**
  24431. * Register a function that will be executed before the physics world is stepping forward
  24432. * @param func The function to execute before the physics world is stepped forward
  24433. */
  24434. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24435. /**
  24436. * Unregister a function that will be executed before the physics world is stepping forward
  24437. * @param func The function to execute before the physics world is stepped forward
  24438. */
  24439. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24440. /**
  24441. * Register a function that will be executed after the physics step
  24442. * @param func The function to execute after physics step
  24443. */
  24444. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24445. /**
  24446. * Unregisters a function that will be executed after the physics step
  24447. * @param func The function to execute after physics step
  24448. */
  24449. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24450. /**
  24451. * register a function that will be executed when this impostor collides against a different body
  24452. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24453. * @param func Callback that is executed on collision
  24454. */
  24455. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24456. /**
  24457. * Unregisters the physics imposter on contact
  24458. * @param collideAgainst The physics object to collide against
  24459. * @param func Callback to execute on collision
  24460. */
  24461. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24462. private _tmpQuat;
  24463. private _tmpQuat2;
  24464. /**
  24465. * Get the parent rotation
  24466. * @returns The parent rotation
  24467. */
  24468. getParentsRotation(): Quaternion;
  24469. /**
  24470. * this function is executed by the physics engine.
  24471. */
  24472. beforeStep: () => void;
  24473. /**
  24474. * this function is executed by the physics engine
  24475. */
  24476. afterStep: () => void;
  24477. /**
  24478. * Legacy collision detection event support
  24479. */
  24480. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24481. /**
  24482. * event and body object due to cannon's event-based architecture.
  24483. */
  24484. onCollide: (e: {
  24485. body: any;
  24486. }) => void;
  24487. /**
  24488. * Apply a force
  24489. * @param force The force to apply
  24490. * @param contactPoint The contact point for the force
  24491. * @returns The physics imposter
  24492. */
  24493. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24494. /**
  24495. * Apply an impulse
  24496. * @param force The impulse force
  24497. * @param contactPoint The contact point for the impulse force
  24498. * @returns The physics imposter
  24499. */
  24500. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24501. /**
  24502. * A help function to create a joint
  24503. * @param otherImpostor A physics imposter used to create a joint
  24504. * @param jointType The type of joint
  24505. * @param jointData The data for the joint
  24506. * @returns The physics imposter
  24507. */
  24508. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24509. /**
  24510. * Add a joint to this impostor with a different impostor
  24511. * @param otherImpostor A physics imposter used to add a joint
  24512. * @param joint The joint to add
  24513. * @returns The physics imposter
  24514. */
  24515. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24516. /**
  24517. * Add an anchor to a cloth impostor
  24518. * @param otherImpostor rigid impostor to anchor to
  24519. * @param width ratio across width from 0 to 1
  24520. * @param height ratio up height from 0 to 1
  24521. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24522. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24523. * @returns impostor the soft imposter
  24524. */
  24525. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24526. /**
  24527. * Add a hook to a rope impostor
  24528. * @param otherImpostor rigid impostor to anchor to
  24529. * @param length ratio across rope from 0 to 1
  24530. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24531. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24532. * @returns impostor the rope imposter
  24533. */
  24534. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24535. /**
  24536. * Will keep this body still, in a sleep mode.
  24537. * @returns the physics imposter
  24538. */
  24539. sleep(): PhysicsImpostor;
  24540. /**
  24541. * Wake the body up.
  24542. * @returns The physics imposter
  24543. */
  24544. wakeUp(): PhysicsImpostor;
  24545. /**
  24546. * Clones the physics imposter
  24547. * @param newObject The physics imposter clones to this physics-enabled object
  24548. * @returns A nullable physics imposter
  24549. */
  24550. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24551. /**
  24552. * Disposes the physics imposter
  24553. */
  24554. dispose(): void;
  24555. /**
  24556. * Sets the delta position
  24557. * @param position The delta position amount
  24558. */
  24559. setDeltaPosition(position: Vector3): void;
  24560. /**
  24561. * Sets the delta rotation
  24562. * @param rotation The delta rotation amount
  24563. */
  24564. setDeltaRotation(rotation: Quaternion): void;
  24565. /**
  24566. * Gets the box size of the physics imposter and stores the result in the input parameter
  24567. * @param result Stores the box size
  24568. * @returns The physics imposter
  24569. */
  24570. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24571. /**
  24572. * Gets the radius of the physics imposter
  24573. * @returns Radius of the physics imposter
  24574. */
  24575. getRadius(): number;
  24576. /**
  24577. * Sync a bone with this impostor
  24578. * @param bone The bone to sync to the impostor.
  24579. * @param boneMesh The mesh that the bone is influencing.
  24580. * @param jointPivot The pivot of the joint / bone in local space.
  24581. * @param distToJoint Optional distance from the impostor to the joint.
  24582. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24583. */
  24584. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24585. /**
  24586. * Sync impostor to a bone
  24587. * @param bone The bone that the impostor will be synced to.
  24588. * @param boneMesh The mesh that the bone is influencing.
  24589. * @param jointPivot The pivot of the joint / bone in local space.
  24590. * @param distToJoint Optional distance from the impostor to the joint.
  24591. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24592. * @param boneAxis Optional vector3 axis the bone is aligned with
  24593. */
  24594. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24595. /**
  24596. * No-Imposter type
  24597. */
  24598. static NoImpostor: number;
  24599. /**
  24600. * Sphere-Imposter type
  24601. */
  24602. static SphereImpostor: number;
  24603. /**
  24604. * Box-Imposter type
  24605. */
  24606. static BoxImpostor: number;
  24607. /**
  24608. * Plane-Imposter type
  24609. */
  24610. static PlaneImpostor: number;
  24611. /**
  24612. * Mesh-imposter type
  24613. */
  24614. static MeshImpostor: number;
  24615. /**
  24616. * Capsule-Impostor type (Ammo.js plugin only)
  24617. */
  24618. static CapsuleImpostor: number;
  24619. /**
  24620. * Cylinder-Imposter type
  24621. */
  24622. static CylinderImpostor: number;
  24623. /**
  24624. * Particle-Imposter type
  24625. */
  24626. static ParticleImpostor: number;
  24627. /**
  24628. * Heightmap-Imposter type
  24629. */
  24630. static HeightmapImpostor: number;
  24631. /**
  24632. * ConvexHull-Impostor type (Ammo.js plugin only)
  24633. */
  24634. static ConvexHullImpostor: number;
  24635. /**
  24636. * Custom-Imposter type (Ammo.js plugin only)
  24637. */
  24638. static CustomImpostor: number;
  24639. /**
  24640. * Rope-Imposter type
  24641. */
  24642. static RopeImpostor: number;
  24643. /**
  24644. * Cloth-Imposter type
  24645. */
  24646. static ClothImpostor: number;
  24647. /**
  24648. * Softbody-Imposter type
  24649. */
  24650. static SoftbodyImpostor: number;
  24651. }
  24652. }
  24653. declare module "babylonjs/Meshes/mesh" {
  24654. import { Observable } from "babylonjs/Misc/observable";
  24655. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24656. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24657. import { Camera } from "babylonjs/Cameras/camera";
  24658. import { Scene } from "babylonjs/scene";
  24659. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24660. import { Color4 } from "babylonjs/Maths/math.color";
  24661. import { Engine } from "babylonjs/Engines/engine";
  24662. import { Node } from "babylonjs/node";
  24663. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24664. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24665. import { Buffer } from "babylonjs/Meshes/buffer";
  24666. import { Geometry } from "babylonjs/Meshes/geometry";
  24667. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24668. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24669. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24670. import { Effect } from "babylonjs/Materials/effect";
  24671. import { Material } from "babylonjs/Materials/material";
  24672. import { Skeleton } from "babylonjs/Bones/skeleton";
  24673. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24674. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24675. import { Path3D } from "babylonjs/Maths/math.path";
  24676. import { Plane } from "babylonjs/Maths/math.plane";
  24677. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24678. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24679. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24680. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24681. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24682. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24683. /**
  24684. * @hidden
  24685. **/
  24686. export class _CreationDataStorage {
  24687. closePath?: boolean;
  24688. closeArray?: boolean;
  24689. idx: number[];
  24690. dashSize: number;
  24691. gapSize: number;
  24692. path3D: Path3D;
  24693. pathArray: Vector3[][];
  24694. arc: number;
  24695. radius: number;
  24696. cap: number;
  24697. tessellation: number;
  24698. }
  24699. /**
  24700. * @hidden
  24701. **/
  24702. class _InstanceDataStorage {
  24703. visibleInstances: any;
  24704. batchCache: _InstancesBatch;
  24705. instancesBufferSize: number;
  24706. instancesBuffer: Nullable<Buffer>;
  24707. instancesData: Float32Array;
  24708. overridenInstanceCount: number;
  24709. isFrozen: boolean;
  24710. previousBatch: Nullable<_InstancesBatch>;
  24711. hardwareInstancedRendering: boolean;
  24712. sideOrientation: number;
  24713. manualUpdate: boolean;
  24714. }
  24715. /**
  24716. * @hidden
  24717. **/
  24718. export class _InstancesBatch {
  24719. mustReturn: boolean;
  24720. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24721. renderSelf: boolean[];
  24722. hardwareInstancedRendering: boolean[];
  24723. }
  24724. /**
  24725. * Class used to represent renderable models
  24726. */
  24727. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24728. /**
  24729. * Mesh side orientation : usually the external or front surface
  24730. */
  24731. static readonly FRONTSIDE: number;
  24732. /**
  24733. * Mesh side orientation : usually the internal or back surface
  24734. */
  24735. static readonly BACKSIDE: number;
  24736. /**
  24737. * Mesh side orientation : both internal and external or front and back surfaces
  24738. */
  24739. static readonly DOUBLESIDE: number;
  24740. /**
  24741. * Mesh side orientation : by default, `FRONTSIDE`
  24742. */
  24743. static readonly DEFAULTSIDE: number;
  24744. /**
  24745. * Mesh cap setting : no cap
  24746. */
  24747. static readonly NO_CAP: number;
  24748. /**
  24749. * Mesh cap setting : one cap at the beginning of the mesh
  24750. */
  24751. static readonly CAP_START: number;
  24752. /**
  24753. * Mesh cap setting : one cap at the end of the mesh
  24754. */
  24755. static readonly CAP_END: number;
  24756. /**
  24757. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24758. */
  24759. static readonly CAP_ALL: number;
  24760. /**
  24761. * Mesh pattern setting : no flip or rotate
  24762. */
  24763. static readonly NO_FLIP: number;
  24764. /**
  24765. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24766. */
  24767. static readonly FLIP_TILE: number;
  24768. /**
  24769. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24770. */
  24771. static readonly ROTATE_TILE: number;
  24772. /**
  24773. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24774. */
  24775. static readonly FLIP_ROW: number;
  24776. /**
  24777. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24778. */
  24779. static readonly ROTATE_ROW: number;
  24780. /**
  24781. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24782. */
  24783. static readonly FLIP_N_ROTATE_TILE: number;
  24784. /**
  24785. * Mesh pattern setting : rotate pattern and rotate
  24786. */
  24787. static readonly FLIP_N_ROTATE_ROW: number;
  24788. /**
  24789. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24790. */
  24791. static readonly CENTER: number;
  24792. /**
  24793. * Mesh tile positioning : part tiles on left
  24794. */
  24795. static readonly LEFT: number;
  24796. /**
  24797. * Mesh tile positioning : part tiles on right
  24798. */
  24799. static readonly RIGHT: number;
  24800. /**
  24801. * Mesh tile positioning : part tiles on top
  24802. */
  24803. static readonly TOP: number;
  24804. /**
  24805. * Mesh tile positioning : part tiles on bottom
  24806. */
  24807. static readonly BOTTOM: number;
  24808. /**
  24809. * Gets the default side orientation.
  24810. * @param orientation the orientation to value to attempt to get
  24811. * @returns the default orientation
  24812. * @hidden
  24813. */
  24814. static _GetDefaultSideOrientation(orientation?: number): number;
  24815. private _internalMeshDataInfo;
  24816. /**
  24817. * An event triggered before rendering the mesh
  24818. */
  24819. get onBeforeRenderObservable(): Observable<Mesh>;
  24820. /**
  24821. * An event triggered before binding the mesh
  24822. */
  24823. get onBeforeBindObservable(): Observable<Mesh>;
  24824. /**
  24825. * An event triggered after rendering the mesh
  24826. */
  24827. get onAfterRenderObservable(): Observable<Mesh>;
  24828. /**
  24829. * An event triggered before drawing the mesh
  24830. */
  24831. get onBeforeDrawObservable(): Observable<Mesh>;
  24832. private _onBeforeDrawObserver;
  24833. /**
  24834. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24835. */
  24836. set onBeforeDraw(callback: () => void);
  24837. get hasInstances(): boolean;
  24838. /**
  24839. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24840. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24841. */
  24842. delayLoadState: number;
  24843. /**
  24844. * Gets the list of instances created from this mesh
  24845. * it is not supposed to be modified manually.
  24846. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24847. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24848. */
  24849. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24850. /**
  24851. * Gets the file containing delay loading data for this mesh
  24852. */
  24853. delayLoadingFile: string;
  24854. /** @hidden */
  24855. _binaryInfo: any;
  24856. /**
  24857. * User defined function used to change how LOD level selection is done
  24858. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24859. */
  24860. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24861. /**
  24862. * Gets or sets the morph target manager
  24863. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24864. */
  24865. get morphTargetManager(): Nullable<MorphTargetManager>;
  24866. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24867. /** @hidden */
  24868. _creationDataStorage: Nullable<_CreationDataStorage>;
  24869. /** @hidden */
  24870. _geometry: Nullable<Geometry>;
  24871. /** @hidden */
  24872. _delayInfo: Array<string>;
  24873. /** @hidden */
  24874. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24875. /** @hidden */
  24876. _instanceDataStorage: _InstanceDataStorage;
  24877. private _effectiveMaterial;
  24878. /** @hidden */
  24879. _shouldGenerateFlatShading: boolean;
  24880. /** @hidden */
  24881. _originalBuilderSideOrientation: number;
  24882. /**
  24883. * Use this property to change the original side orientation defined at construction time
  24884. */
  24885. overrideMaterialSideOrientation: Nullable<number>;
  24886. /**
  24887. * Gets the source mesh (the one used to clone this one from)
  24888. */
  24889. get source(): Nullable<Mesh>;
  24890. /**
  24891. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24892. */
  24893. get isUnIndexed(): boolean;
  24894. set isUnIndexed(value: boolean);
  24895. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24896. get worldMatrixInstancedBuffer(): Float32Array;
  24897. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24898. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24899. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24900. /**
  24901. * @constructor
  24902. * @param name The value used by scene.getMeshByName() to do a lookup.
  24903. * @param scene The scene to add this mesh to.
  24904. * @param parent The parent of this mesh, if it has one
  24905. * @param source An optional Mesh from which geometry is shared, cloned.
  24906. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24907. * When false, achieved by calling a clone(), also passing False.
  24908. * This will make creation of children, recursive.
  24909. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24910. */
  24911. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24912. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24913. doNotInstantiate: boolean;
  24914. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24915. /**
  24916. * Gets the class name
  24917. * @returns the string "Mesh".
  24918. */
  24919. getClassName(): string;
  24920. /** @hidden */
  24921. get _isMesh(): boolean;
  24922. /**
  24923. * Returns a description of this mesh
  24924. * @param fullDetails define if full details about this mesh must be used
  24925. * @returns a descriptive string representing this mesh
  24926. */
  24927. toString(fullDetails?: boolean): string;
  24928. /** @hidden */
  24929. _unBindEffect(): void;
  24930. /**
  24931. * Gets a boolean indicating if this mesh has LOD
  24932. */
  24933. get hasLODLevels(): boolean;
  24934. /**
  24935. * Gets the list of MeshLODLevel associated with the current mesh
  24936. * @returns an array of MeshLODLevel
  24937. */
  24938. getLODLevels(): MeshLODLevel[];
  24939. private _sortLODLevels;
  24940. /**
  24941. * Add a mesh as LOD level triggered at the given distance.
  24942. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24943. * @param distance The distance from the center of the object to show this level
  24944. * @param mesh The mesh to be added as LOD level (can be null)
  24945. * @return This mesh (for chaining)
  24946. */
  24947. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24948. /**
  24949. * Returns the LOD level mesh at the passed distance or null if not found.
  24950. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24951. * @param distance The distance from the center of the object to show this level
  24952. * @returns a Mesh or `null`
  24953. */
  24954. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24955. /**
  24956. * Remove a mesh from the LOD array
  24957. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24958. * @param mesh defines the mesh to be removed
  24959. * @return This mesh (for chaining)
  24960. */
  24961. removeLODLevel(mesh: Mesh): Mesh;
  24962. /**
  24963. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24964. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24965. * @param camera defines the camera to use to compute distance
  24966. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24967. * @return This mesh (for chaining)
  24968. */
  24969. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24970. /**
  24971. * Gets the mesh internal Geometry object
  24972. */
  24973. get geometry(): Nullable<Geometry>;
  24974. /**
  24975. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24976. * @returns the total number of vertices
  24977. */
  24978. getTotalVertices(): number;
  24979. /**
  24980. * Returns the content of an associated vertex buffer
  24981. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24982. * - VertexBuffer.PositionKind
  24983. * - VertexBuffer.UVKind
  24984. * - VertexBuffer.UV2Kind
  24985. * - VertexBuffer.UV3Kind
  24986. * - VertexBuffer.UV4Kind
  24987. * - VertexBuffer.UV5Kind
  24988. * - VertexBuffer.UV6Kind
  24989. * - VertexBuffer.ColorKind
  24990. * - VertexBuffer.MatricesIndicesKind
  24991. * - VertexBuffer.MatricesIndicesExtraKind
  24992. * - VertexBuffer.MatricesWeightsKind
  24993. * - VertexBuffer.MatricesWeightsExtraKind
  24994. * @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
  24995. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24996. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24997. */
  24998. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24999. /**
  25000. * Returns the mesh VertexBuffer object from the requested `kind`
  25001. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25002. * - VertexBuffer.PositionKind
  25003. * - VertexBuffer.NormalKind
  25004. * - VertexBuffer.UVKind
  25005. * - VertexBuffer.UV2Kind
  25006. * - VertexBuffer.UV3Kind
  25007. * - VertexBuffer.UV4Kind
  25008. * - VertexBuffer.UV5Kind
  25009. * - VertexBuffer.UV6Kind
  25010. * - VertexBuffer.ColorKind
  25011. * - VertexBuffer.MatricesIndicesKind
  25012. * - VertexBuffer.MatricesIndicesExtraKind
  25013. * - VertexBuffer.MatricesWeightsKind
  25014. * - VertexBuffer.MatricesWeightsExtraKind
  25015. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25016. */
  25017. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25018. /**
  25019. * Tests if a specific vertex buffer is associated with this mesh
  25020. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25021. * - VertexBuffer.PositionKind
  25022. * - VertexBuffer.NormalKind
  25023. * - VertexBuffer.UVKind
  25024. * - VertexBuffer.UV2Kind
  25025. * - VertexBuffer.UV3Kind
  25026. * - VertexBuffer.UV4Kind
  25027. * - VertexBuffer.UV5Kind
  25028. * - VertexBuffer.UV6Kind
  25029. * - VertexBuffer.ColorKind
  25030. * - VertexBuffer.MatricesIndicesKind
  25031. * - VertexBuffer.MatricesIndicesExtraKind
  25032. * - VertexBuffer.MatricesWeightsKind
  25033. * - VertexBuffer.MatricesWeightsExtraKind
  25034. * @returns a boolean
  25035. */
  25036. isVerticesDataPresent(kind: string): boolean;
  25037. /**
  25038. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25039. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25040. * - VertexBuffer.PositionKind
  25041. * - VertexBuffer.UVKind
  25042. * - VertexBuffer.UV2Kind
  25043. * - VertexBuffer.UV3Kind
  25044. * - VertexBuffer.UV4Kind
  25045. * - VertexBuffer.UV5Kind
  25046. * - VertexBuffer.UV6Kind
  25047. * - VertexBuffer.ColorKind
  25048. * - VertexBuffer.MatricesIndicesKind
  25049. * - VertexBuffer.MatricesIndicesExtraKind
  25050. * - VertexBuffer.MatricesWeightsKind
  25051. * - VertexBuffer.MatricesWeightsExtraKind
  25052. * @returns a boolean
  25053. */
  25054. isVertexBufferUpdatable(kind: string): boolean;
  25055. /**
  25056. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25057. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25058. * - VertexBuffer.PositionKind
  25059. * - VertexBuffer.NormalKind
  25060. * - VertexBuffer.UVKind
  25061. * - VertexBuffer.UV2Kind
  25062. * - VertexBuffer.UV3Kind
  25063. * - VertexBuffer.UV4Kind
  25064. * - VertexBuffer.UV5Kind
  25065. * - VertexBuffer.UV6Kind
  25066. * - VertexBuffer.ColorKind
  25067. * - VertexBuffer.MatricesIndicesKind
  25068. * - VertexBuffer.MatricesIndicesExtraKind
  25069. * - VertexBuffer.MatricesWeightsKind
  25070. * - VertexBuffer.MatricesWeightsExtraKind
  25071. * @returns an array of strings
  25072. */
  25073. getVerticesDataKinds(): string[];
  25074. /**
  25075. * Returns a positive integer : the total number of indices in this mesh geometry.
  25076. * @returns the numner of indices or zero if the mesh has no geometry.
  25077. */
  25078. getTotalIndices(): number;
  25079. /**
  25080. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25081. * @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.
  25082. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25083. * @returns the indices array or an empty array if the mesh has no geometry
  25084. */
  25085. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25086. get isBlocked(): boolean;
  25087. /**
  25088. * Determine if the current mesh is ready to be rendered
  25089. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25090. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25091. * @returns true if all associated assets are ready (material, textures, shaders)
  25092. */
  25093. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25094. /**
  25095. * 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.
  25096. */
  25097. get areNormalsFrozen(): boolean;
  25098. /**
  25099. * 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.
  25100. * @returns the current mesh
  25101. */
  25102. freezeNormals(): Mesh;
  25103. /**
  25104. * 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
  25105. * @returns the current mesh
  25106. */
  25107. unfreezeNormals(): Mesh;
  25108. /**
  25109. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25110. */
  25111. set overridenInstanceCount(count: number);
  25112. /** @hidden */
  25113. _preActivate(): Mesh;
  25114. /** @hidden */
  25115. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25116. /** @hidden */
  25117. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25118. /**
  25119. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25120. * This means the mesh underlying bounding box and sphere are recomputed.
  25121. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25122. * @returns the current mesh
  25123. */
  25124. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25125. /** @hidden */
  25126. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25127. /**
  25128. * This function will subdivide the mesh into multiple submeshes
  25129. * @param count defines the expected number of submeshes
  25130. */
  25131. subdivide(count: number): void;
  25132. /**
  25133. * Copy a FloatArray into a specific associated vertex buffer
  25134. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25135. * - VertexBuffer.PositionKind
  25136. * - VertexBuffer.UVKind
  25137. * - VertexBuffer.UV2Kind
  25138. * - VertexBuffer.UV3Kind
  25139. * - VertexBuffer.UV4Kind
  25140. * - VertexBuffer.UV5Kind
  25141. * - VertexBuffer.UV6Kind
  25142. * - VertexBuffer.ColorKind
  25143. * - VertexBuffer.MatricesIndicesKind
  25144. * - VertexBuffer.MatricesIndicesExtraKind
  25145. * - VertexBuffer.MatricesWeightsKind
  25146. * - VertexBuffer.MatricesWeightsExtraKind
  25147. * @param data defines the data source
  25148. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25149. * @param stride defines the data stride size (can be null)
  25150. * @returns the current mesh
  25151. */
  25152. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25153. /**
  25154. * Delete a vertex buffer associated with this mesh
  25155. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25156. * - VertexBuffer.PositionKind
  25157. * - VertexBuffer.UVKind
  25158. * - VertexBuffer.UV2Kind
  25159. * - VertexBuffer.UV3Kind
  25160. * - VertexBuffer.UV4Kind
  25161. * - VertexBuffer.UV5Kind
  25162. * - VertexBuffer.UV6Kind
  25163. * - VertexBuffer.ColorKind
  25164. * - VertexBuffer.MatricesIndicesKind
  25165. * - VertexBuffer.MatricesIndicesExtraKind
  25166. * - VertexBuffer.MatricesWeightsKind
  25167. * - VertexBuffer.MatricesWeightsExtraKind
  25168. */
  25169. removeVerticesData(kind: string): void;
  25170. /**
  25171. * Flags an associated vertex buffer as updatable
  25172. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25173. * - VertexBuffer.PositionKind
  25174. * - VertexBuffer.UVKind
  25175. * - VertexBuffer.UV2Kind
  25176. * - VertexBuffer.UV3Kind
  25177. * - VertexBuffer.UV4Kind
  25178. * - VertexBuffer.UV5Kind
  25179. * - VertexBuffer.UV6Kind
  25180. * - VertexBuffer.ColorKind
  25181. * - VertexBuffer.MatricesIndicesKind
  25182. * - VertexBuffer.MatricesIndicesExtraKind
  25183. * - VertexBuffer.MatricesWeightsKind
  25184. * - VertexBuffer.MatricesWeightsExtraKind
  25185. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25186. */
  25187. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25188. /**
  25189. * Sets the mesh global Vertex Buffer
  25190. * @param buffer defines the buffer to use
  25191. * @returns the current mesh
  25192. */
  25193. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25194. /**
  25195. * Update a specific associated vertex buffer
  25196. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25197. * - VertexBuffer.PositionKind
  25198. * - VertexBuffer.UVKind
  25199. * - VertexBuffer.UV2Kind
  25200. * - VertexBuffer.UV3Kind
  25201. * - VertexBuffer.UV4Kind
  25202. * - VertexBuffer.UV5Kind
  25203. * - VertexBuffer.UV6Kind
  25204. * - VertexBuffer.ColorKind
  25205. * - VertexBuffer.MatricesIndicesKind
  25206. * - VertexBuffer.MatricesIndicesExtraKind
  25207. * - VertexBuffer.MatricesWeightsKind
  25208. * - VertexBuffer.MatricesWeightsExtraKind
  25209. * @param data defines the data source
  25210. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25211. * @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)
  25212. * @returns the current mesh
  25213. */
  25214. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25215. /**
  25216. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25217. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25218. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25219. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25220. * @returns the current mesh
  25221. */
  25222. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25223. /**
  25224. * Creates a un-shared specific occurence of the geometry for the mesh.
  25225. * @returns the current mesh
  25226. */
  25227. makeGeometryUnique(): Mesh;
  25228. /**
  25229. * Set the index buffer of this mesh
  25230. * @param indices defines the source data
  25231. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25232. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25233. * @returns the current mesh
  25234. */
  25235. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25236. /**
  25237. * Update the current index buffer
  25238. * @param indices defines the source data
  25239. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25240. * @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)
  25241. * @returns the current mesh
  25242. */
  25243. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25244. /**
  25245. * Invert the geometry to move from a right handed system to a left handed one.
  25246. * @returns the current mesh
  25247. */
  25248. toLeftHanded(): Mesh;
  25249. /** @hidden */
  25250. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25251. /** @hidden */
  25252. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25253. /**
  25254. * Registers for this mesh a javascript function called just before the rendering process
  25255. * @param func defines the function to call before rendering this mesh
  25256. * @returns the current mesh
  25257. */
  25258. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25259. /**
  25260. * Disposes a previously registered javascript function called before the rendering
  25261. * @param func defines the function to remove
  25262. * @returns the current mesh
  25263. */
  25264. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25265. /**
  25266. * Registers for this mesh a javascript function called just after the rendering is complete
  25267. * @param func defines the function to call after rendering this mesh
  25268. * @returns the current mesh
  25269. */
  25270. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25271. /**
  25272. * Disposes a previously registered javascript function called after the rendering.
  25273. * @param func defines the function to remove
  25274. * @returns the current mesh
  25275. */
  25276. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25277. /** @hidden */
  25278. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25279. /** @hidden */
  25280. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25281. /** @hidden */
  25282. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25283. /** @hidden */
  25284. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25285. /** @hidden */
  25286. _rebuild(): void;
  25287. /** @hidden */
  25288. _freeze(): void;
  25289. /** @hidden */
  25290. _unFreeze(): void;
  25291. /**
  25292. * 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
  25293. * @param subMesh defines the subMesh to render
  25294. * @param enableAlphaMode defines if alpha mode can be changed
  25295. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25296. * @returns the current mesh
  25297. */
  25298. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25299. private _onBeforeDraw;
  25300. /**
  25301. * Renormalize the mesh and patch it up if there are no weights
  25302. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25303. * However in the case of zero weights then we set just a single influence to 1.
  25304. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25305. */
  25306. cleanMatrixWeights(): void;
  25307. private normalizeSkinFourWeights;
  25308. private normalizeSkinWeightsAndExtra;
  25309. /**
  25310. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25311. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25312. * the user know there was an issue with importing the mesh
  25313. * @returns a validation object with skinned, valid and report string
  25314. */
  25315. validateSkinning(): {
  25316. skinned: boolean;
  25317. valid: boolean;
  25318. report: string;
  25319. };
  25320. /** @hidden */
  25321. _checkDelayState(): Mesh;
  25322. private _queueLoad;
  25323. /**
  25324. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25325. * A mesh is in the frustum if its bounding box intersects the frustum
  25326. * @param frustumPlanes defines the frustum to test
  25327. * @returns true if the mesh is in the frustum planes
  25328. */
  25329. isInFrustum(frustumPlanes: Plane[]): boolean;
  25330. /**
  25331. * Sets the mesh material by the material or multiMaterial `id` property
  25332. * @param id is a string identifying the material or the multiMaterial
  25333. * @returns the current mesh
  25334. */
  25335. setMaterialByID(id: string): Mesh;
  25336. /**
  25337. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25338. * @returns an array of IAnimatable
  25339. */
  25340. getAnimatables(): IAnimatable[];
  25341. /**
  25342. * Modifies the mesh geometry according to the passed transformation matrix.
  25343. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25344. * The mesh normals are modified using the same transformation.
  25345. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25346. * @param transform defines the transform matrix to use
  25347. * @see http://doc.babylonjs.com/resources/baking_transformations
  25348. * @returns the current mesh
  25349. */
  25350. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25351. /**
  25352. * Modifies the mesh geometry according to its own current World Matrix.
  25353. * The mesh World Matrix is then reset.
  25354. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25355. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25356. * @see http://doc.babylonjs.com/resources/baking_transformations
  25357. * @returns the current mesh
  25358. */
  25359. bakeCurrentTransformIntoVertices(): Mesh;
  25360. /** @hidden */
  25361. get _positions(): Nullable<Vector3[]>;
  25362. /** @hidden */
  25363. _resetPointsArrayCache(): Mesh;
  25364. /** @hidden */
  25365. _generatePointsArray(): boolean;
  25366. /**
  25367. * Returns a new Mesh object generated from the current mesh properties.
  25368. * This method must not get confused with createInstance()
  25369. * @param name is a string, the name given to the new mesh
  25370. * @param newParent can be any Node object (default `null`)
  25371. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25372. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25373. * @returns a new mesh
  25374. */
  25375. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  25376. /**
  25377. * Releases resources associated with this mesh.
  25378. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25379. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25380. */
  25381. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25382. /** @hidden */
  25383. _disposeInstanceSpecificData(): void;
  25384. /**
  25385. * Modifies the mesh geometry according to a displacement map.
  25386. * 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.
  25387. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25388. * @param url is a string, the URL from the image file is to be downloaded.
  25389. * @param minHeight is the lower limit of the displacement.
  25390. * @param maxHeight is the upper limit of the displacement.
  25391. * @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.
  25392. * @param uvOffset is an optional vector2 used to offset UV.
  25393. * @param uvScale is an optional vector2 used to scale UV.
  25394. * @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.
  25395. * @returns the Mesh.
  25396. */
  25397. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25398. /**
  25399. * Modifies the mesh geometry according to a displacementMap buffer.
  25400. * 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.
  25401. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25402. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25403. * @param heightMapWidth is the width of the buffer image.
  25404. * @param heightMapHeight is the height of the buffer image.
  25405. * @param minHeight is the lower limit of the displacement.
  25406. * @param maxHeight is the upper limit of the displacement.
  25407. * @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.
  25408. * @param uvOffset is an optional vector2 used to offset UV.
  25409. * @param uvScale is an optional vector2 used to scale UV.
  25410. * @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.
  25411. * @returns the Mesh.
  25412. */
  25413. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25414. /**
  25415. * Modify the mesh to get a flat shading rendering.
  25416. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25417. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25418. * @returns current mesh
  25419. */
  25420. convertToFlatShadedMesh(): Mesh;
  25421. /**
  25422. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25423. * In other words, more vertices, no more indices and a single bigger VBO.
  25424. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25425. * @returns current mesh
  25426. */
  25427. convertToUnIndexedMesh(): Mesh;
  25428. /**
  25429. * Inverses facet orientations.
  25430. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25431. * @param flipNormals will also inverts the normals
  25432. * @returns current mesh
  25433. */
  25434. flipFaces(flipNormals?: boolean): Mesh;
  25435. /**
  25436. * Increase the number of facets and hence vertices in a mesh
  25437. * Vertex normals are interpolated from existing vertex normals
  25438. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25439. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25440. */
  25441. increaseVertices(numberPerEdge: number): void;
  25442. /**
  25443. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25444. * This will undo any application of covertToFlatShadedMesh
  25445. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25446. */
  25447. forceSharedVertices(): void;
  25448. /** @hidden */
  25449. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25450. /** @hidden */
  25451. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25452. /**
  25453. * Creates a new InstancedMesh object from the mesh model.
  25454. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25455. * @param name defines the name of the new instance
  25456. * @returns a new InstancedMesh
  25457. */
  25458. createInstance(name: string): InstancedMesh;
  25459. /**
  25460. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25461. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25462. * @returns the current mesh
  25463. */
  25464. synchronizeInstances(): Mesh;
  25465. /**
  25466. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25467. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25468. * This should be used together with the simplification to avoid disappearing triangles.
  25469. * @param successCallback an optional success callback to be called after the optimization finished.
  25470. * @returns the current mesh
  25471. */
  25472. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25473. /**
  25474. * Serialize current mesh
  25475. * @param serializationObject defines the object which will receive the serialization data
  25476. */
  25477. serialize(serializationObject: any): void;
  25478. /** @hidden */
  25479. _syncGeometryWithMorphTargetManager(): void;
  25480. /** @hidden */
  25481. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25482. /**
  25483. * Returns a new Mesh object parsed from the source provided.
  25484. * @param parsedMesh is the source
  25485. * @param scene defines the hosting scene
  25486. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25487. * @returns a new Mesh
  25488. */
  25489. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25490. /**
  25491. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25492. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25493. * @param name defines the name of the mesh to create
  25494. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25495. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25496. * @param closePath creates a seam between the first and the last points of each path of the path array
  25497. * @param offset is taken in account only if the `pathArray` is containing a single path
  25498. * @param scene defines the hosting scene
  25499. * @param updatable defines if the mesh must be flagged as updatable
  25500. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25501. * @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)
  25502. * @returns a new Mesh
  25503. */
  25504. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25505. /**
  25506. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25507. * @param name defines the name of the mesh to create
  25508. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25509. * @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
  25510. * @param scene defines the hosting scene
  25511. * @param updatable defines if the mesh must be flagged as updatable
  25512. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25513. * @returns a new Mesh
  25514. */
  25515. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25516. /**
  25517. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25518. * @param name defines the name of the mesh to create
  25519. * @param size sets the size (float) of each box side (default 1)
  25520. * @param scene defines the hosting scene
  25521. * @param updatable defines if the mesh must be flagged as updatable
  25522. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25523. * @returns a new Mesh
  25524. */
  25525. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25526. /**
  25527. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25528. * @param name defines the name of the mesh to create
  25529. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25530. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25531. * @param scene defines the hosting scene
  25532. * @param updatable defines if the mesh must be flagged as updatable
  25533. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25534. * @returns a new Mesh
  25535. */
  25536. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25537. /**
  25538. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25539. * @param name defines the name of the mesh to create
  25540. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25541. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25542. * @param scene defines the hosting scene
  25543. * @returns a new Mesh
  25544. */
  25545. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25546. /**
  25547. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25548. * @param name defines the name of the mesh to create
  25549. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25550. * @param diameterTop set the top cap diameter (floats, default 1)
  25551. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25552. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25553. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25554. * @param scene defines the hosting scene
  25555. * @param updatable defines if the mesh must be flagged as updatable
  25556. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25557. * @returns a new Mesh
  25558. */
  25559. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25560. /**
  25561. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25562. * @param name defines the name of the mesh to create
  25563. * @param diameter sets the diameter size (float) of the torus (default 1)
  25564. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25565. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25566. * @param scene defines the hosting scene
  25567. * @param updatable defines if the mesh must be flagged as updatable
  25568. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25569. * @returns a new Mesh
  25570. */
  25571. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25572. /**
  25573. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25574. * @param name defines the name of the mesh to create
  25575. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25576. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25577. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25578. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25579. * @param p the number of windings on X axis (positive integers, default 2)
  25580. * @param q the number of windings on Y axis (positive integers, default 3)
  25581. * @param scene defines the hosting scene
  25582. * @param updatable defines if the mesh must be flagged as updatable
  25583. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25584. * @returns a new Mesh
  25585. */
  25586. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25587. /**
  25588. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25589. * @param name defines the name of the mesh to create
  25590. * @param points is an array successive Vector3
  25591. * @param scene defines the hosting scene
  25592. * @param updatable defines if the mesh must be flagged as updatable
  25593. * @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).
  25594. * @returns a new Mesh
  25595. */
  25596. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25597. /**
  25598. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25599. * @param name defines the name of the mesh to create
  25600. * @param points is an array successive Vector3
  25601. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25602. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25603. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25604. * @param scene defines the hosting scene
  25605. * @param updatable defines if the mesh must be flagged as updatable
  25606. * @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)
  25607. * @returns a new Mesh
  25608. */
  25609. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25610. /**
  25611. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25612. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25613. * 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.
  25614. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25615. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25616. * Remember you can only change the shape positions, not their number when updating a polygon.
  25617. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25618. * @param name defines the name of the mesh to create
  25619. * @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
  25620. * @param scene defines the hosting scene
  25621. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25622. * @param updatable defines if the mesh must be flagged as updatable
  25623. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25624. * @param earcutInjection can be used to inject your own earcut reference
  25625. * @returns a new Mesh
  25626. */
  25627. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25628. /**
  25629. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25630. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25631. * @param name defines the name of the mesh to create
  25632. * @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
  25633. * @param depth defines the height of extrusion
  25634. * @param scene defines the hosting scene
  25635. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25636. * @param updatable defines if the mesh must be flagged as updatable
  25637. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25638. * @param earcutInjection can be used to inject your own earcut reference
  25639. * @returns a new Mesh
  25640. */
  25641. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25642. /**
  25643. * Creates an extruded shape mesh.
  25644. * 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
  25645. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25646. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25647. * @param name defines the name of the mesh to create
  25648. * @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
  25649. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25650. * @param scale is the value to scale the shape
  25651. * @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
  25652. * @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
  25653. * @param scene defines the hosting scene
  25654. * @param updatable defines if the mesh must be flagged as updatable
  25655. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25656. * @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)
  25657. * @returns a new Mesh
  25658. */
  25659. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25660. /**
  25661. * Creates an custom extruded shape mesh.
  25662. * The custom extrusion is a parametric shape.
  25663. * It has no predefined shape. Its final shape will depend on the input parameters.
  25664. * Please consider using the same method from the MeshBuilder class instead
  25665. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25666. * @param name defines the name of the mesh to create
  25667. * @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
  25668. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25669. * @param scaleFunction is a custom Javascript function called on each path point
  25670. * @param rotationFunction is a custom Javascript function called on each path point
  25671. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25672. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25673. * @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
  25674. * @param scene defines the hosting scene
  25675. * @param updatable defines if the mesh must be flagged as updatable
  25676. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25677. * @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)
  25678. * @returns a new Mesh
  25679. */
  25680. 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;
  25681. /**
  25682. * Creates lathe mesh.
  25683. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25684. * Please consider using the same method from the MeshBuilder class instead
  25685. * @param name defines the name of the mesh to create
  25686. * @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
  25687. * @param radius is the radius value of the lathe
  25688. * @param tessellation is the side number of the lathe.
  25689. * @param scene defines the hosting scene
  25690. * @param updatable defines if the mesh must be flagged as updatable
  25691. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25692. * @returns a new Mesh
  25693. */
  25694. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25695. /**
  25696. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25697. * @param name defines the name of the mesh to create
  25698. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25699. * @param scene defines the hosting scene
  25700. * @param updatable defines if the mesh must be flagged as updatable
  25701. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25702. * @returns a new Mesh
  25703. */
  25704. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25705. /**
  25706. * Creates a ground mesh.
  25707. * Please consider using the same method from the MeshBuilder class instead
  25708. * @param name defines the name of the mesh to create
  25709. * @param width set the width of the ground
  25710. * @param height set the height of the ground
  25711. * @param subdivisions sets the number of subdivisions per side
  25712. * @param scene defines the hosting scene
  25713. * @param updatable defines if the mesh must be flagged as updatable
  25714. * @returns a new Mesh
  25715. */
  25716. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25717. /**
  25718. * Creates a tiled ground mesh.
  25719. * Please consider using the same method from the MeshBuilder class instead
  25720. * @param name defines the name of the mesh to create
  25721. * @param xmin set the ground minimum X coordinate
  25722. * @param zmin set the ground minimum Y coordinate
  25723. * @param xmax set the ground maximum X coordinate
  25724. * @param zmax set the ground maximum Z coordinate
  25725. * @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
  25726. * @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
  25727. * @param scene defines the hosting scene
  25728. * @param updatable defines if the mesh must be flagged as updatable
  25729. * @returns a new Mesh
  25730. */
  25731. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25732. w: number;
  25733. h: number;
  25734. }, precision: {
  25735. w: number;
  25736. h: number;
  25737. }, scene: Scene, updatable?: boolean): Mesh;
  25738. /**
  25739. * Creates a ground mesh from a height map.
  25740. * Please consider using the same method from the MeshBuilder class instead
  25741. * @see http://doc.babylonjs.com/babylon101/height_map
  25742. * @param name defines the name of the mesh to create
  25743. * @param url sets the URL of the height map image resource
  25744. * @param width set the ground width size
  25745. * @param height set the ground height size
  25746. * @param subdivisions sets the number of subdivision per side
  25747. * @param minHeight is the minimum altitude on the ground
  25748. * @param maxHeight is the maximum altitude on the ground
  25749. * @param scene defines the hosting scene
  25750. * @param updatable defines if the mesh must be flagged as updatable
  25751. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25752. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25753. * @returns a new Mesh
  25754. */
  25755. 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;
  25756. /**
  25757. * Creates a tube mesh.
  25758. * The tube is a parametric shape.
  25759. * It has no predefined shape. Its final shape will depend on the input parameters.
  25760. * Please consider using the same method from the MeshBuilder class instead
  25761. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25762. * @param name defines the name of the mesh to create
  25763. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25764. * @param radius sets the tube radius size
  25765. * @param tessellation is the number of sides on the tubular surface
  25766. * @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
  25767. * @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
  25768. * @param scene defines the hosting scene
  25769. * @param updatable defines if the mesh must be flagged as updatable
  25770. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25771. * @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)
  25772. * @returns a new Mesh
  25773. */
  25774. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25775. (i: number, distance: number): number;
  25776. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25777. /**
  25778. * Creates a polyhedron mesh.
  25779. * Please consider using the same method from the MeshBuilder class instead.
  25780. * * 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
  25781. * * The parameter `size` (positive float, default 1) sets the polygon size
  25782. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25783. * * 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`
  25784. * * 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
  25785. * * 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)`)
  25786. * * 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
  25787. * * 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
  25788. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25789. * * If you create a double-sided mesh, you can choose what parts of 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
  25790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25791. * @param name defines the name of the mesh to create
  25792. * @param options defines the options used to create the mesh
  25793. * @param scene defines the hosting scene
  25794. * @returns a new Mesh
  25795. */
  25796. static CreatePolyhedron(name: string, options: {
  25797. type?: number;
  25798. size?: number;
  25799. sizeX?: number;
  25800. sizeY?: number;
  25801. sizeZ?: number;
  25802. custom?: any;
  25803. faceUV?: Vector4[];
  25804. faceColors?: Color4[];
  25805. updatable?: boolean;
  25806. sideOrientation?: number;
  25807. }, scene: Scene): Mesh;
  25808. /**
  25809. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25810. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25811. * * 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`)
  25812. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25813. * * 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
  25814. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25815. * * If you create a double-sided mesh, you can choose what parts of 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
  25816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25817. * @param name defines the name of the mesh
  25818. * @param options defines the options used to create the mesh
  25819. * @param scene defines the hosting scene
  25820. * @returns a new Mesh
  25821. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25822. */
  25823. static CreateIcoSphere(name: string, options: {
  25824. radius?: number;
  25825. flat?: boolean;
  25826. subdivisions?: number;
  25827. sideOrientation?: number;
  25828. updatable?: boolean;
  25829. }, scene: Scene): Mesh;
  25830. /**
  25831. * Creates a decal mesh.
  25832. * Please consider using the same method from the MeshBuilder class instead.
  25833. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25834. * @param name defines the name of the mesh
  25835. * @param sourceMesh defines the mesh receiving the decal
  25836. * @param position sets the position of the decal in world coordinates
  25837. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25838. * @param size sets the decal scaling
  25839. * @param angle sets the angle to rotate the decal
  25840. * @returns a new Mesh
  25841. */
  25842. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25843. /**
  25844. * Prepare internal position array for software CPU skinning
  25845. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25846. */
  25847. setPositionsForCPUSkinning(): Float32Array;
  25848. /**
  25849. * Prepare internal normal array for software CPU skinning
  25850. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25851. */
  25852. setNormalsForCPUSkinning(): Float32Array;
  25853. /**
  25854. * Updates the vertex buffer by applying transformation from the bones
  25855. * @param skeleton defines the skeleton to apply to current mesh
  25856. * @returns the current mesh
  25857. */
  25858. applySkeleton(skeleton: Skeleton): Mesh;
  25859. /**
  25860. * 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
  25861. * @param meshes defines the list of meshes to scan
  25862. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25863. */
  25864. static MinMax(meshes: AbstractMesh[]): {
  25865. min: Vector3;
  25866. max: Vector3;
  25867. };
  25868. /**
  25869. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25870. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25871. * @returns a vector3
  25872. */
  25873. static Center(meshesOrMinMaxVector: {
  25874. min: Vector3;
  25875. max: Vector3;
  25876. } | AbstractMesh[]): Vector3;
  25877. /**
  25878. * Merge the array of meshes into a single mesh for performance reasons.
  25879. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25880. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25881. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25882. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25883. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25884. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25885. * @returns a new mesh
  25886. */
  25887. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25888. /** @hidden */
  25889. addInstance(instance: InstancedMesh): void;
  25890. /** @hidden */
  25891. removeInstance(instance: InstancedMesh): void;
  25892. }
  25893. }
  25894. declare module "babylonjs/Cameras/camera" {
  25895. import { SmartArray } from "babylonjs/Misc/smartArray";
  25896. import { Observable } from "babylonjs/Misc/observable";
  25897. import { Nullable } from "babylonjs/types";
  25898. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25899. import { Scene } from "babylonjs/scene";
  25900. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25901. import { Node } from "babylonjs/node";
  25902. import { Mesh } from "babylonjs/Meshes/mesh";
  25903. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25904. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25905. import { Viewport } from "babylonjs/Maths/math.viewport";
  25906. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25907. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25908. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25909. import { Ray } from "babylonjs/Culling/ray";
  25910. /**
  25911. * This is the base class of all the camera used in the application.
  25912. * @see http://doc.babylonjs.com/features/cameras
  25913. */
  25914. export class Camera extends Node {
  25915. /** @hidden */
  25916. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25917. /**
  25918. * This is the default projection mode used by the cameras.
  25919. * It helps recreating a feeling of perspective and better appreciate depth.
  25920. * This is the best way to simulate real life cameras.
  25921. */
  25922. static readonly PERSPECTIVE_CAMERA: number;
  25923. /**
  25924. * This helps creating camera with an orthographic mode.
  25925. * 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.
  25926. */
  25927. static readonly ORTHOGRAPHIC_CAMERA: number;
  25928. /**
  25929. * This is the default FOV mode for perspective cameras.
  25930. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25931. */
  25932. static readonly FOVMODE_VERTICAL_FIXED: number;
  25933. /**
  25934. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25935. */
  25936. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25937. /**
  25938. * This specifies ther is no need for a camera rig.
  25939. * Basically only one eye is rendered corresponding to the camera.
  25940. */
  25941. static readonly RIG_MODE_NONE: number;
  25942. /**
  25943. * Simulates a camera Rig with one blue eye and one red eye.
  25944. * This can be use with 3d blue and red glasses.
  25945. */
  25946. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25947. /**
  25948. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25949. */
  25950. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25951. /**
  25952. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25953. */
  25954. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25955. /**
  25956. * Defines that both eyes of the camera will be rendered over under each other.
  25957. */
  25958. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25959. /**
  25960. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25961. */
  25962. static readonly RIG_MODE_VR: number;
  25963. /**
  25964. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25965. */
  25966. static readonly RIG_MODE_WEBVR: number;
  25967. /**
  25968. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25969. */
  25970. static readonly RIG_MODE_CUSTOM: number;
  25971. /**
  25972. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25973. */
  25974. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25975. /**
  25976. * Define the input manager associated with the camera.
  25977. */
  25978. inputs: CameraInputsManager<Camera>;
  25979. /** @hidden */
  25980. _position: Vector3;
  25981. /**
  25982. * Define the current local position of the camera in the scene
  25983. */
  25984. get position(): Vector3;
  25985. set position(newPosition: Vector3);
  25986. /**
  25987. * The vector the camera should consider as up.
  25988. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25989. */
  25990. upVector: Vector3;
  25991. /**
  25992. * Define the current limit on the left side for an orthographic camera
  25993. * In scene unit
  25994. */
  25995. orthoLeft: Nullable<number>;
  25996. /**
  25997. * Define the current limit on the right side for an orthographic camera
  25998. * In scene unit
  25999. */
  26000. orthoRight: Nullable<number>;
  26001. /**
  26002. * Define the current limit on the bottom side for an orthographic camera
  26003. * In scene unit
  26004. */
  26005. orthoBottom: Nullable<number>;
  26006. /**
  26007. * Define the current limit on the top side for an orthographic camera
  26008. * In scene unit
  26009. */
  26010. orthoTop: Nullable<number>;
  26011. /**
  26012. * Field Of View is set in Radians. (default is 0.8)
  26013. */
  26014. fov: number;
  26015. /**
  26016. * Define the minimum distance the camera can see from.
  26017. * This is important to note that the depth buffer are not infinite and the closer it starts
  26018. * the more your scene might encounter depth fighting issue.
  26019. */
  26020. minZ: number;
  26021. /**
  26022. * Define the maximum distance the camera can see to.
  26023. * This is important to note that the depth buffer are not infinite and the further it end
  26024. * the more your scene might encounter depth fighting issue.
  26025. */
  26026. maxZ: number;
  26027. /**
  26028. * Define the default inertia of the camera.
  26029. * This helps giving a smooth feeling to the camera movement.
  26030. */
  26031. inertia: number;
  26032. /**
  26033. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26034. */
  26035. mode: number;
  26036. /**
  26037. * Define wether the camera is intermediate.
  26038. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26039. */
  26040. isIntermediate: boolean;
  26041. /**
  26042. * Define the viewport of the camera.
  26043. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26044. */
  26045. viewport: Viewport;
  26046. /**
  26047. * Restricts the camera to viewing objects with the same layerMask.
  26048. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26049. */
  26050. layerMask: number;
  26051. /**
  26052. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26053. */
  26054. fovMode: number;
  26055. /**
  26056. * Rig mode of the camera.
  26057. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26058. * This is normally controlled byt the camera themselves as internal use.
  26059. */
  26060. cameraRigMode: number;
  26061. /**
  26062. * Defines the distance between both "eyes" in case of a RIG
  26063. */
  26064. interaxialDistance: number;
  26065. /**
  26066. * Defines if stereoscopic rendering is done side by side or over under.
  26067. */
  26068. isStereoscopicSideBySide: boolean;
  26069. /**
  26070. * 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
  26071. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26072. * else in the scene. (Eg. security camera)
  26073. *
  26074. * 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)
  26075. */
  26076. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26077. /**
  26078. * When set, the camera will render to this render target instead of the default canvas
  26079. *
  26080. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26081. */
  26082. outputRenderTarget: Nullable<RenderTargetTexture>;
  26083. /**
  26084. * Observable triggered when the camera view matrix has changed.
  26085. */
  26086. onViewMatrixChangedObservable: Observable<Camera>;
  26087. /**
  26088. * Observable triggered when the camera Projection matrix has changed.
  26089. */
  26090. onProjectionMatrixChangedObservable: Observable<Camera>;
  26091. /**
  26092. * Observable triggered when the inputs have been processed.
  26093. */
  26094. onAfterCheckInputsObservable: Observable<Camera>;
  26095. /**
  26096. * Observable triggered when reset has been called and applied to the camera.
  26097. */
  26098. onRestoreStateObservable: Observable<Camera>;
  26099. /** @hidden */
  26100. _cameraRigParams: any;
  26101. /** @hidden */
  26102. _rigCameras: Camera[];
  26103. /** @hidden */
  26104. _rigPostProcess: Nullable<PostProcess>;
  26105. protected _webvrViewMatrix: Matrix;
  26106. /** @hidden */
  26107. _skipRendering: boolean;
  26108. /** @hidden */
  26109. _projectionMatrix: Matrix;
  26110. /** @hidden */
  26111. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26112. /** @hidden */
  26113. _activeMeshes: SmartArray<AbstractMesh>;
  26114. protected _globalPosition: Vector3;
  26115. /** @hidden */
  26116. _computedViewMatrix: Matrix;
  26117. private _doNotComputeProjectionMatrix;
  26118. private _transformMatrix;
  26119. private _frustumPlanes;
  26120. private _refreshFrustumPlanes;
  26121. private _storedFov;
  26122. private _stateStored;
  26123. /**
  26124. * Instantiates a new camera object.
  26125. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26126. * @see http://doc.babylonjs.com/features/cameras
  26127. * @param name Defines the name of the camera in the scene
  26128. * @param position Defines the position of the camera
  26129. * @param scene Defines the scene the camera belongs too
  26130. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26131. */
  26132. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26133. /**
  26134. * Store current camera state (fov, position, etc..)
  26135. * @returns the camera
  26136. */
  26137. storeState(): Camera;
  26138. /**
  26139. * Restores the camera state values if it has been stored. You must call storeState() first
  26140. */
  26141. protected _restoreStateValues(): boolean;
  26142. /**
  26143. * Restored camera state. You must call storeState() first.
  26144. * @returns true if restored and false otherwise
  26145. */
  26146. restoreState(): boolean;
  26147. /**
  26148. * Gets the class name of the camera.
  26149. * @returns the class name
  26150. */
  26151. getClassName(): string;
  26152. /** @hidden */
  26153. readonly _isCamera: boolean;
  26154. /**
  26155. * Gets a string representation of the camera useful for debug purpose.
  26156. * @param fullDetails Defines that a more verboe level of logging is required
  26157. * @returns the string representation
  26158. */
  26159. toString(fullDetails?: boolean): string;
  26160. /**
  26161. * Gets the current world space position of the camera.
  26162. */
  26163. get globalPosition(): Vector3;
  26164. /**
  26165. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26166. * @returns the active meshe list
  26167. */
  26168. getActiveMeshes(): SmartArray<AbstractMesh>;
  26169. /**
  26170. * Check wether a mesh is part of the current active mesh list of the camera
  26171. * @param mesh Defines the mesh to check
  26172. * @returns true if active, false otherwise
  26173. */
  26174. isActiveMesh(mesh: Mesh): boolean;
  26175. /**
  26176. * Is this camera ready to be used/rendered
  26177. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26178. * @return true if the camera is ready
  26179. */
  26180. isReady(completeCheck?: boolean): boolean;
  26181. /** @hidden */
  26182. _initCache(): void;
  26183. /** @hidden */
  26184. _updateCache(ignoreParentClass?: boolean): void;
  26185. /** @hidden */
  26186. _isSynchronized(): boolean;
  26187. /** @hidden */
  26188. _isSynchronizedViewMatrix(): boolean;
  26189. /** @hidden */
  26190. _isSynchronizedProjectionMatrix(): boolean;
  26191. /**
  26192. * Attach the input controls to a specific dom element to get the input from.
  26193. * @param element Defines the element the controls should be listened from
  26194. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26195. */
  26196. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26197. /**
  26198. * Detach the current controls from the specified dom element.
  26199. * @param element Defines the element to stop listening the inputs from
  26200. */
  26201. detachControl(element: HTMLElement): void;
  26202. /**
  26203. * Update the camera state according to the different inputs gathered during the frame.
  26204. */
  26205. update(): void;
  26206. /** @hidden */
  26207. _checkInputs(): void;
  26208. /** @hidden */
  26209. get rigCameras(): Camera[];
  26210. /**
  26211. * Gets the post process used by the rig cameras
  26212. */
  26213. get rigPostProcess(): Nullable<PostProcess>;
  26214. /**
  26215. * Internal, gets the first post proces.
  26216. * @returns the first post process to be run on this camera.
  26217. */
  26218. _getFirstPostProcess(): Nullable<PostProcess>;
  26219. private _cascadePostProcessesToRigCams;
  26220. /**
  26221. * Attach a post process to the camera.
  26222. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26223. * @param postProcess The post process to attach to the camera
  26224. * @param insertAt The position of the post process in case several of them are in use in the scene
  26225. * @returns the position the post process has been inserted at
  26226. */
  26227. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26228. /**
  26229. * Detach a post process to the camera.
  26230. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26231. * @param postProcess The post process to detach from the camera
  26232. */
  26233. detachPostProcess(postProcess: PostProcess): void;
  26234. /**
  26235. * Gets the current world matrix of the camera
  26236. */
  26237. getWorldMatrix(): Matrix;
  26238. /** @hidden */
  26239. _getViewMatrix(): Matrix;
  26240. /**
  26241. * Gets the current view matrix of the camera.
  26242. * @param force forces the camera to recompute the matrix without looking at the cached state
  26243. * @returns the view matrix
  26244. */
  26245. getViewMatrix(force?: boolean): Matrix;
  26246. /**
  26247. * Freeze the projection matrix.
  26248. * It will prevent the cache check of the camera projection compute and can speed up perf
  26249. * if no parameter of the camera are meant to change
  26250. * @param projection Defines manually a projection if necessary
  26251. */
  26252. freezeProjectionMatrix(projection?: Matrix): void;
  26253. /**
  26254. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26255. */
  26256. unfreezeProjectionMatrix(): void;
  26257. /**
  26258. * Gets the current projection matrix of the camera.
  26259. * @param force forces the camera to recompute the matrix without looking at the cached state
  26260. * @returns the projection matrix
  26261. */
  26262. getProjectionMatrix(force?: boolean): Matrix;
  26263. /**
  26264. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26265. * @returns a Matrix
  26266. */
  26267. getTransformationMatrix(): Matrix;
  26268. private _updateFrustumPlanes;
  26269. /**
  26270. * Checks if a cullable object (mesh...) is in the camera frustum
  26271. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26272. * @param target The object to check
  26273. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26274. * @returns true if the object is in frustum otherwise false
  26275. */
  26276. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26277. /**
  26278. * Checks if a cullable object (mesh...) is in the camera frustum
  26279. * Unlike isInFrustum this cheks the full bounding box
  26280. * @param target The object to check
  26281. * @returns true if the object is in frustum otherwise false
  26282. */
  26283. isCompletelyInFrustum(target: ICullable): boolean;
  26284. /**
  26285. * Gets a ray in the forward direction from the camera.
  26286. * @param length Defines the length of the ray to create
  26287. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26288. * @param origin Defines the start point of the ray which defaults to the camera position
  26289. * @returns the forward ray
  26290. */
  26291. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26292. /**
  26293. * Releases resources associated with this node.
  26294. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26295. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26296. */
  26297. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26298. /** @hidden */
  26299. _isLeftCamera: boolean;
  26300. /**
  26301. * Gets the left camera of a rig setup in case of Rigged Camera
  26302. */
  26303. get isLeftCamera(): boolean;
  26304. /** @hidden */
  26305. _isRightCamera: boolean;
  26306. /**
  26307. * Gets the right camera of a rig setup in case of Rigged Camera
  26308. */
  26309. get isRightCamera(): boolean;
  26310. /**
  26311. * Gets the left camera of a rig setup in case of Rigged Camera
  26312. */
  26313. get leftCamera(): Nullable<FreeCamera>;
  26314. /**
  26315. * Gets the right camera of a rig setup in case of Rigged Camera
  26316. */
  26317. get rightCamera(): Nullable<FreeCamera>;
  26318. /**
  26319. * Gets the left camera target of a rig setup in case of Rigged Camera
  26320. * @returns the target position
  26321. */
  26322. getLeftTarget(): Nullable<Vector3>;
  26323. /**
  26324. * Gets the right camera target of a rig setup in case of Rigged Camera
  26325. * @returns the target position
  26326. */
  26327. getRightTarget(): Nullable<Vector3>;
  26328. /**
  26329. * @hidden
  26330. */
  26331. setCameraRigMode(mode: number, rigParams: any): void;
  26332. /** @hidden */
  26333. static _setStereoscopicRigMode(camera: Camera): void;
  26334. /** @hidden */
  26335. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26336. /** @hidden */
  26337. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26338. /** @hidden */
  26339. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26340. /** @hidden */
  26341. _getVRProjectionMatrix(): Matrix;
  26342. protected _updateCameraRotationMatrix(): void;
  26343. protected _updateWebVRCameraRotationMatrix(): void;
  26344. /**
  26345. * This function MUST be overwritten by the different WebVR cameras available.
  26346. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26347. * @hidden
  26348. */
  26349. _getWebVRProjectionMatrix(): Matrix;
  26350. /**
  26351. * This function MUST be overwritten by the different WebVR cameras available.
  26352. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26353. * @hidden
  26354. */
  26355. _getWebVRViewMatrix(): Matrix;
  26356. /** @hidden */
  26357. setCameraRigParameter(name: string, value: any): void;
  26358. /**
  26359. * needs to be overridden by children so sub has required properties to be copied
  26360. * @hidden
  26361. */
  26362. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26363. /**
  26364. * May need to be overridden by children
  26365. * @hidden
  26366. */
  26367. _updateRigCameras(): void;
  26368. /** @hidden */
  26369. _setupInputs(): void;
  26370. /**
  26371. * Serialiaze the camera setup to a json represention
  26372. * @returns the JSON representation
  26373. */
  26374. serialize(): any;
  26375. /**
  26376. * Clones the current camera.
  26377. * @param name The cloned camera name
  26378. * @returns the cloned camera
  26379. */
  26380. clone(name: string): Camera;
  26381. /**
  26382. * Gets the direction of the camera relative to a given local axis.
  26383. * @param localAxis Defines the reference axis to provide a relative direction.
  26384. * @return the direction
  26385. */
  26386. getDirection(localAxis: Vector3): Vector3;
  26387. /**
  26388. * Returns the current camera absolute rotation
  26389. */
  26390. get absoluteRotation(): Quaternion;
  26391. /**
  26392. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26393. * @param localAxis Defines the reference axis to provide a relative direction.
  26394. * @param result Defines the vector to store the result in
  26395. */
  26396. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26397. /**
  26398. * Gets a camera constructor for a given camera type
  26399. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26400. * @param name The name of the camera the result will be able to instantiate
  26401. * @param scene The scene the result will construct the camera in
  26402. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26403. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26404. * @returns a factory method to construc the camera
  26405. */
  26406. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26407. /**
  26408. * Compute the world matrix of the camera.
  26409. * @returns the camera world matrix
  26410. */
  26411. computeWorldMatrix(): Matrix;
  26412. /**
  26413. * Parse a JSON and creates the camera from the parsed information
  26414. * @param parsedCamera The JSON to parse
  26415. * @param scene The scene to instantiate the camera in
  26416. * @returns the newly constructed camera
  26417. */
  26418. static Parse(parsedCamera: any, scene: Scene): Camera;
  26419. }
  26420. }
  26421. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26422. import { Nullable } from "babylonjs/types";
  26423. import { Scene } from "babylonjs/scene";
  26424. import { Vector4 } from "babylonjs/Maths/math.vector";
  26425. import { Mesh } from "babylonjs/Meshes/mesh";
  26426. /**
  26427. * Class containing static functions to help procedurally build meshes
  26428. */
  26429. export class DiscBuilder {
  26430. /**
  26431. * Creates a plane polygonal mesh. By default, this is a disc
  26432. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26433. * * 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
  26434. * * 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
  26435. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26436. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26438. * @param name defines the name of the mesh
  26439. * @param options defines the options used to create the mesh
  26440. * @param scene defines the hosting scene
  26441. * @returns the plane polygonal mesh
  26442. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26443. */
  26444. static CreateDisc(name: string, options: {
  26445. radius?: number;
  26446. tessellation?: number;
  26447. arc?: number;
  26448. updatable?: boolean;
  26449. sideOrientation?: number;
  26450. frontUVs?: Vector4;
  26451. backUVs?: Vector4;
  26452. }, scene?: Nullable<Scene>): Mesh;
  26453. }
  26454. }
  26455. declare module "babylonjs/Materials/fresnelParameters" {
  26456. import { Color3 } from "babylonjs/Maths/math.color";
  26457. /**
  26458. * This represents all the required information to add a fresnel effect on a material:
  26459. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26460. */
  26461. export class FresnelParameters {
  26462. private _isEnabled;
  26463. /**
  26464. * Define if the fresnel effect is enable or not.
  26465. */
  26466. get isEnabled(): boolean;
  26467. set isEnabled(value: boolean);
  26468. /**
  26469. * Define the color used on edges (grazing angle)
  26470. */
  26471. leftColor: Color3;
  26472. /**
  26473. * Define the color used on center
  26474. */
  26475. rightColor: Color3;
  26476. /**
  26477. * Define bias applied to computed fresnel term
  26478. */
  26479. bias: number;
  26480. /**
  26481. * Defined the power exponent applied to fresnel term
  26482. */
  26483. power: number;
  26484. /**
  26485. * Clones the current fresnel and its valuues
  26486. * @returns a clone fresnel configuration
  26487. */
  26488. clone(): FresnelParameters;
  26489. /**
  26490. * Serializes the current fresnel parameters to a JSON representation.
  26491. * @return the JSON serialization
  26492. */
  26493. serialize(): any;
  26494. /**
  26495. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26496. * @param parsedFresnelParameters Define the JSON representation
  26497. * @returns the parsed parameters
  26498. */
  26499. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26500. }
  26501. }
  26502. declare module "babylonjs/Materials/pushMaterial" {
  26503. import { Nullable } from "babylonjs/types";
  26504. import { Scene } from "babylonjs/scene";
  26505. import { Matrix } from "babylonjs/Maths/math.vector";
  26506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26507. import { Mesh } from "babylonjs/Meshes/mesh";
  26508. import { Material } from "babylonjs/Materials/material";
  26509. import { Effect } from "babylonjs/Materials/effect";
  26510. /**
  26511. * Base class of materials working in push mode in babylon JS
  26512. * @hidden
  26513. */
  26514. export class PushMaterial extends Material {
  26515. protected _activeEffect: Effect;
  26516. protected _normalMatrix: Matrix;
  26517. /**
  26518. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26519. * This means that the material can keep using a previous shader while a new one is being compiled.
  26520. * This is mostly used when shader parallel compilation is supported (true by default)
  26521. */
  26522. allowShaderHotSwapping: boolean;
  26523. constructor(name: string, scene: Scene);
  26524. getEffect(): Effect;
  26525. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26526. /**
  26527. * Binds the given world matrix to the active effect
  26528. *
  26529. * @param world the matrix to bind
  26530. */
  26531. bindOnlyWorldMatrix(world: Matrix): void;
  26532. /**
  26533. * Binds the given normal matrix to the active effect
  26534. *
  26535. * @param normalMatrix the matrix to bind
  26536. */
  26537. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26538. bind(world: Matrix, mesh?: Mesh): void;
  26539. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26540. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26541. }
  26542. }
  26543. declare module "babylonjs/Materials/materialFlags" {
  26544. /**
  26545. * This groups all the flags used to control the materials channel.
  26546. */
  26547. export class MaterialFlags {
  26548. private static _DiffuseTextureEnabled;
  26549. /**
  26550. * Are diffuse textures enabled in the application.
  26551. */
  26552. static get DiffuseTextureEnabled(): boolean;
  26553. static set DiffuseTextureEnabled(value: boolean);
  26554. private static _AmbientTextureEnabled;
  26555. /**
  26556. * Are ambient textures enabled in the application.
  26557. */
  26558. static get AmbientTextureEnabled(): boolean;
  26559. static set AmbientTextureEnabled(value: boolean);
  26560. private static _OpacityTextureEnabled;
  26561. /**
  26562. * Are opacity textures enabled in the application.
  26563. */
  26564. static get OpacityTextureEnabled(): boolean;
  26565. static set OpacityTextureEnabled(value: boolean);
  26566. private static _ReflectionTextureEnabled;
  26567. /**
  26568. * Are reflection textures enabled in the application.
  26569. */
  26570. static get ReflectionTextureEnabled(): boolean;
  26571. static set ReflectionTextureEnabled(value: boolean);
  26572. private static _EmissiveTextureEnabled;
  26573. /**
  26574. * Are emissive textures enabled in the application.
  26575. */
  26576. static get EmissiveTextureEnabled(): boolean;
  26577. static set EmissiveTextureEnabled(value: boolean);
  26578. private static _SpecularTextureEnabled;
  26579. /**
  26580. * Are specular textures enabled in the application.
  26581. */
  26582. static get SpecularTextureEnabled(): boolean;
  26583. static set SpecularTextureEnabled(value: boolean);
  26584. private static _BumpTextureEnabled;
  26585. /**
  26586. * Are bump textures enabled in the application.
  26587. */
  26588. static get BumpTextureEnabled(): boolean;
  26589. static set BumpTextureEnabled(value: boolean);
  26590. private static _LightmapTextureEnabled;
  26591. /**
  26592. * Are lightmap textures enabled in the application.
  26593. */
  26594. static get LightmapTextureEnabled(): boolean;
  26595. static set LightmapTextureEnabled(value: boolean);
  26596. private static _RefractionTextureEnabled;
  26597. /**
  26598. * Are refraction textures enabled in the application.
  26599. */
  26600. static get RefractionTextureEnabled(): boolean;
  26601. static set RefractionTextureEnabled(value: boolean);
  26602. private static _ColorGradingTextureEnabled;
  26603. /**
  26604. * Are color grading textures enabled in the application.
  26605. */
  26606. static get ColorGradingTextureEnabled(): boolean;
  26607. static set ColorGradingTextureEnabled(value: boolean);
  26608. private static _FresnelEnabled;
  26609. /**
  26610. * Are fresnels enabled in the application.
  26611. */
  26612. static get FresnelEnabled(): boolean;
  26613. static set FresnelEnabled(value: boolean);
  26614. private static _ClearCoatTextureEnabled;
  26615. /**
  26616. * Are clear coat textures enabled in the application.
  26617. */
  26618. static get ClearCoatTextureEnabled(): boolean;
  26619. static set ClearCoatTextureEnabled(value: boolean);
  26620. private static _ClearCoatBumpTextureEnabled;
  26621. /**
  26622. * Are clear coat bump textures enabled in the application.
  26623. */
  26624. static get ClearCoatBumpTextureEnabled(): boolean;
  26625. static set ClearCoatBumpTextureEnabled(value: boolean);
  26626. private static _ClearCoatTintTextureEnabled;
  26627. /**
  26628. * Are clear coat tint textures enabled in the application.
  26629. */
  26630. static get ClearCoatTintTextureEnabled(): boolean;
  26631. static set ClearCoatTintTextureEnabled(value: boolean);
  26632. private static _SheenTextureEnabled;
  26633. /**
  26634. * Are sheen textures enabled in the application.
  26635. */
  26636. static get SheenTextureEnabled(): boolean;
  26637. static set SheenTextureEnabled(value: boolean);
  26638. private static _AnisotropicTextureEnabled;
  26639. /**
  26640. * Are anisotropic textures enabled in the application.
  26641. */
  26642. static get AnisotropicTextureEnabled(): boolean;
  26643. static set AnisotropicTextureEnabled(value: boolean);
  26644. private static _ThicknessTextureEnabled;
  26645. /**
  26646. * Are thickness textures enabled in the application.
  26647. */
  26648. static get ThicknessTextureEnabled(): boolean;
  26649. static set ThicknessTextureEnabled(value: boolean);
  26650. }
  26651. }
  26652. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26653. /** @hidden */
  26654. export var defaultFragmentDeclaration: {
  26655. name: string;
  26656. shader: string;
  26657. };
  26658. }
  26659. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26660. /** @hidden */
  26661. export var defaultUboDeclaration: {
  26662. name: string;
  26663. shader: string;
  26664. };
  26665. }
  26666. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26667. /** @hidden */
  26668. export var lightFragmentDeclaration: {
  26669. name: string;
  26670. shader: string;
  26671. };
  26672. }
  26673. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26674. /** @hidden */
  26675. export var lightUboDeclaration: {
  26676. name: string;
  26677. shader: string;
  26678. };
  26679. }
  26680. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26681. /** @hidden */
  26682. export var lightsFragmentFunctions: {
  26683. name: string;
  26684. shader: string;
  26685. };
  26686. }
  26687. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26688. /** @hidden */
  26689. export var shadowsFragmentFunctions: {
  26690. name: string;
  26691. shader: string;
  26692. };
  26693. }
  26694. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26695. /** @hidden */
  26696. export var fresnelFunction: {
  26697. name: string;
  26698. shader: string;
  26699. };
  26700. }
  26701. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26702. /** @hidden */
  26703. export var reflectionFunction: {
  26704. name: string;
  26705. shader: string;
  26706. };
  26707. }
  26708. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26709. /** @hidden */
  26710. export var bumpFragmentFunctions: {
  26711. name: string;
  26712. shader: string;
  26713. };
  26714. }
  26715. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26716. /** @hidden */
  26717. export var logDepthDeclaration: {
  26718. name: string;
  26719. shader: string;
  26720. };
  26721. }
  26722. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26723. /** @hidden */
  26724. export var bumpFragment: {
  26725. name: string;
  26726. shader: string;
  26727. };
  26728. }
  26729. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26730. /** @hidden */
  26731. export var depthPrePass: {
  26732. name: string;
  26733. shader: string;
  26734. };
  26735. }
  26736. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26737. /** @hidden */
  26738. export var lightFragment: {
  26739. name: string;
  26740. shader: string;
  26741. };
  26742. }
  26743. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  26744. /** @hidden */
  26745. export var logDepthFragment: {
  26746. name: string;
  26747. shader: string;
  26748. };
  26749. }
  26750. declare module "babylonjs/Shaders/default.fragment" {
  26751. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  26752. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26753. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26754. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26755. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26756. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  26757. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26758. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  26759. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26760. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26761. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26762. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26763. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26764. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26765. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26766. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26767. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26768. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26769. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26770. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26771. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  26772. /** @hidden */
  26773. export var defaultPixelShader: {
  26774. name: string;
  26775. shader: string;
  26776. };
  26777. }
  26778. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  26779. /** @hidden */
  26780. export var defaultVertexDeclaration: {
  26781. name: string;
  26782. shader: string;
  26783. };
  26784. }
  26785. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  26786. /** @hidden */
  26787. export var bumpVertexDeclaration: {
  26788. name: string;
  26789. shader: string;
  26790. };
  26791. }
  26792. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  26793. /** @hidden */
  26794. export var bumpVertex: {
  26795. name: string;
  26796. shader: string;
  26797. };
  26798. }
  26799. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  26800. /** @hidden */
  26801. export var fogVertex: {
  26802. name: string;
  26803. shader: string;
  26804. };
  26805. }
  26806. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  26807. /** @hidden */
  26808. export var shadowsVertex: {
  26809. name: string;
  26810. shader: string;
  26811. };
  26812. }
  26813. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  26814. /** @hidden */
  26815. export var pointCloudVertex: {
  26816. name: string;
  26817. shader: string;
  26818. };
  26819. }
  26820. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  26821. /** @hidden */
  26822. export var logDepthVertex: {
  26823. name: string;
  26824. shader: string;
  26825. };
  26826. }
  26827. declare module "babylonjs/Shaders/default.vertex" {
  26828. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  26829. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26830. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26831. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  26832. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  26833. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  26834. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  26835. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  26836. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26837. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26838. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  26839. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  26840. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26841. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  26842. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  26843. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  26844. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  26845. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  26846. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  26847. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  26848. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  26849. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  26850. /** @hidden */
  26851. export var defaultVertexShader: {
  26852. name: string;
  26853. shader: string;
  26854. };
  26855. }
  26856. declare module "babylonjs/Materials/standardMaterial" {
  26857. import { SmartArray } from "babylonjs/Misc/smartArray";
  26858. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26859. import { Nullable } from "babylonjs/types";
  26860. import { Scene } from "babylonjs/scene";
  26861. import { Matrix } from "babylonjs/Maths/math.vector";
  26862. import { Color3 } from "babylonjs/Maths/math.color";
  26863. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26865. import { Mesh } from "babylonjs/Meshes/mesh";
  26866. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  26867. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  26868. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  26869. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26870. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  26871. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26872. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26873. import "babylonjs/Shaders/default.fragment";
  26874. import "babylonjs/Shaders/default.vertex";
  26875. /** @hidden */
  26876. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26877. MAINUV1: boolean;
  26878. MAINUV2: boolean;
  26879. DIFFUSE: boolean;
  26880. DIFFUSEDIRECTUV: number;
  26881. AMBIENT: boolean;
  26882. AMBIENTDIRECTUV: number;
  26883. OPACITY: boolean;
  26884. OPACITYDIRECTUV: number;
  26885. OPACITYRGB: boolean;
  26886. REFLECTION: boolean;
  26887. EMISSIVE: boolean;
  26888. EMISSIVEDIRECTUV: number;
  26889. SPECULAR: boolean;
  26890. SPECULARDIRECTUV: number;
  26891. BUMP: boolean;
  26892. BUMPDIRECTUV: number;
  26893. PARALLAX: boolean;
  26894. PARALLAXOCCLUSION: boolean;
  26895. SPECULAROVERALPHA: boolean;
  26896. CLIPPLANE: boolean;
  26897. CLIPPLANE2: boolean;
  26898. CLIPPLANE3: boolean;
  26899. CLIPPLANE4: boolean;
  26900. CLIPPLANE5: boolean;
  26901. CLIPPLANE6: boolean;
  26902. ALPHATEST: boolean;
  26903. DEPTHPREPASS: boolean;
  26904. ALPHAFROMDIFFUSE: boolean;
  26905. POINTSIZE: boolean;
  26906. FOG: boolean;
  26907. SPECULARTERM: boolean;
  26908. DIFFUSEFRESNEL: boolean;
  26909. OPACITYFRESNEL: boolean;
  26910. REFLECTIONFRESNEL: boolean;
  26911. REFRACTIONFRESNEL: boolean;
  26912. EMISSIVEFRESNEL: boolean;
  26913. FRESNEL: boolean;
  26914. NORMAL: boolean;
  26915. UV1: boolean;
  26916. UV2: boolean;
  26917. VERTEXCOLOR: boolean;
  26918. VERTEXALPHA: boolean;
  26919. NUM_BONE_INFLUENCERS: number;
  26920. BonesPerMesh: number;
  26921. BONETEXTURE: boolean;
  26922. INSTANCES: boolean;
  26923. GLOSSINESS: boolean;
  26924. ROUGHNESS: boolean;
  26925. EMISSIVEASILLUMINATION: boolean;
  26926. LINKEMISSIVEWITHDIFFUSE: boolean;
  26927. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26928. LIGHTMAP: boolean;
  26929. LIGHTMAPDIRECTUV: number;
  26930. OBJECTSPACE_NORMALMAP: boolean;
  26931. USELIGHTMAPASSHADOWMAP: boolean;
  26932. REFLECTIONMAP_3D: boolean;
  26933. REFLECTIONMAP_SPHERICAL: boolean;
  26934. REFLECTIONMAP_PLANAR: boolean;
  26935. REFLECTIONMAP_CUBIC: boolean;
  26936. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26937. REFLECTIONMAP_PROJECTION: boolean;
  26938. REFLECTIONMAP_SKYBOX: boolean;
  26939. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  26940. REFLECTIONMAP_EXPLICIT: boolean;
  26941. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26942. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26943. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26944. INVERTCUBICMAP: boolean;
  26945. LOGARITHMICDEPTH: boolean;
  26946. REFRACTION: boolean;
  26947. REFRACTIONMAP_3D: boolean;
  26948. REFLECTIONOVERALPHA: boolean;
  26949. TWOSIDEDLIGHTING: boolean;
  26950. SHADOWFLOAT: boolean;
  26951. MORPHTARGETS: boolean;
  26952. MORPHTARGETS_NORMAL: boolean;
  26953. MORPHTARGETS_TANGENT: boolean;
  26954. MORPHTARGETS_UV: boolean;
  26955. NUM_MORPH_INFLUENCERS: number;
  26956. NONUNIFORMSCALING: boolean;
  26957. PREMULTIPLYALPHA: boolean;
  26958. IMAGEPROCESSING: boolean;
  26959. VIGNETTE: boolean;
  26960. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26961. VIGNETTEBLENDMODEOPAQUE: boolean;
  26962. TONEMAPPING: boolean;
  26963. TONEMAPPING_ACES: boolean;
  26964. CONTRAST: boolean;
  26965. COLORCURVES: boolean;
  26966. COLORGRADING: boolean;
  26967. COLORGRADING3D: boolean;
  26968. SAMPLER3DGREENDEPTH: boolean;
  26969. SAMPLER3DBGRMAP: boolean;
  26970. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26971. MULTIVIEW: boolean;
  26972. /**
  26973. * If the reflection texture on this material is in linear color space
  26974. * @hidden
  26975. */
  26976. IS_REFLECTION_LINEAR: boolean;
  26977. /**
  26978. * If the refraction texture on this material is in linear color space
  26979. * @hidden
  26980. */
  26981. IS_REFRACTION_LINEAR: boolean;
  26982. EXPOSURE: boolean;
  26983. constructor();
  26984. setReflectionMode(modeToEnable: string): void;
  26985. }
  26986. /**
  26987. * This is the default material used in Babylon. It is the best trade off between quality
  26988. * and performances.
  26989. * @see http://doc.babylonjs.com/babylon101/materials
  26990. */
  26991. export class StandardMaterial extends PushMaterial {
  26992. private _diffuseTexture;
  26993. /**
  26994. * The basic texture of the material as viewed under a light.
  26995. */
  26996. diffuseTexture: Nullable<BaseTexture>;
  26997. private _ambientTexture;
  26998. /**
  26999. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27000. */
  27001. ambientTexture: Nullable<BaseTexture>;
  27002. private _opacityTexture;
  27003. /**
  27004. * Define the transparency of the material from a texture.
  27005. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27006. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27007. */
  27008. opacityTexture: Nullable<BaseTexture>;
  27009. private _reflectionTexture;
  27010. /**
  27011. * Define the texture used to display the reflection.
  27012. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27013. */
  27014. reflectionTexture: Nullable<BaseTexture>;
  27015. private _emissiveTexture;
  27016. /**
  27017. * Define texture of the material as if self lit.
  27018. * This will be mixed in the final result even in the absence of light.
  27019. */
  27020. emissiveTexture: Nullable<BaseTexture>;
  27021. private _specularTexture;
  27022. /**
  27023. * Define how the color and intensity of the highlight given by the light in the material.
  27024. */
  27025. specularTexture: Nullable<BaseTexture>;
  27026. private _bumpTexture;
  27027. /**
  27028. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27029. * 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.
  27030. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27031. */
  27032. bumpTexture: Nullable<BaseTexture>;
  27033. private _lightmapTexture;
  27034. /**
  27035. * Complex lighting can be computationally expensive to compute at runtime.
  27036. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27037. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27038. */
  27039. lightmapTexture: Nullable<BaseTexture>;
  27040. private _refractionTexture;
  27041. /**
  27042. * Define the texture used to display the refraction.
  27043. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27044. */
  27045. refractionTexture: Nullable<BaseTexture>;
  27046. /**
  27047. * The color of the material lit by the environmental background lighting.
  27048. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27049. */
  27050. ambientColor: Color3;
  27051. /**
  27052. * The basic color of the material as viewed under a light.
  27053. */
  27054. diffuseColor: Color3;
  27055. /**
  27056. * Define how the color and intensity of the highlight given by the light in the material.
  27057. */
  27058. specularColor: Color3;
  27059. /**
  27060. * Define the color of the material as if self lit.
  27061. * This will be mixed in the final result even in the absence of light.
  27062. */
  27063. emissiveColor: Color3;
  27064. /**
  27065. * Defines how sharp are the highlights in the material.
  27066. * The bigger the value the sharper giving a more glossy feeling to the result.
  27067. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27068. */
  27069. specularPower: number;
  27070. private _useAlphaFromDiffuseTexture;
  27071. /**
  27072. * Does the transparency come from the diffuse texture alpha channel.
  27073. */
  27074. useAlphaFromDiffuseTexture: boolean;
  27075. private _useEmissiveAsIllumination;
  27076. /**
  27077. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27078. */
  27079. useEmissiveAsIllumination: boolean;
  27080. private _linkEmissiveWithDiffuse;
  27081. /**
  27082. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27083. * the emissive level when the final color is close to one.
  27084. */
  27085. linkEmissiveWithDiffuse: boolean;
  27086. private _useSpecularOverAlpha;
  27087. /**
  27088. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27089. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27090. */
  27091. useSpecularOverAlpha: boolean;
  27092. private _useReflectionOverAlpha;
  27093. /**
  27094. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27095. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27096. */
  27097. useReflectionOverAlpha: boolean;
  27098. private _disableLighting;
  27099. /**
  27100. * Does lights from the scene impacts this material.
  27101. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27102. */
  27103. disableLighting: boolean;
  27104. private _useObjectSpaceNormalMap;
  27105. /**
  27106. * Allows using an object space normal map (instead of tangent space).
  27107. */
  27108. useObjectSpaceNormalMap: boolean;
  27109. private _useParallax;
  27110. /**
  27111. * Is parallax enabled or not.
  27112. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27113. */
  27114. useParallax: boolean;
  27115. private _useParallaxOcclusion;
  27116. /**
  27117. * Is parallax occlusion enabled or not.
  27118. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27119. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27120. */
  27121. useParallaxOcclusion: boolean;
  27122. /**
  27123. * 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.
  27124. */
  27125. parallaxScaleBias: number;
  27126. private _roughness;
  27127. /**
  27128. * Helps to define how blurry the reflections should appears in the material.
  27129. */
  27130. roughness: number;
  27131. /**
  27132. * In case of refraction, define the value of the index of refraction.
  27133. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27134. */
  27135. indexOfRefraction: number;
  27136. /**
  27137. * Invert the refraction texture alongside the y axis.
  27138. * It can be useful with procedural textures or probe for instance.
  27139. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27140. */
  27141. invertRefractionY: boolean;
  27142. /**
  27143. * Defines the alpha limits in alpha test mode.
  27144. */
  27145. alphaCutOff: number;
  27146. private _useLightmapAsShadowmap;
  27147. /**
  27148. * In case of light mapping, define whether the map contains light or shadow informations.
  27149. */
  27150. useLightmapAsShadowmap: boolean;
  27151. private _diffuseFresnelParameters;
  27152. /**
  27153. * Define the diffuse fresnel parameters of the material.
  27154. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27155. */
  27156. diffuseFresnelParameters: FresnelParameters;
  27157. private _opacityFresnelParameters;
  27158. /**
  27159. * Define the opacity fresnel parameters of the material.
  27160. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27161. */
  27162. opacityFresnelParameters: FresnelParameters;
  27163. private _reflectionFresnelParameters;
  27164. /**
  27165. * Define the reflection fresnel parameters of the material.
  27166. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27167. */
  27168. reflectionFresnelParameters: FresnelParameters;
  27169. private _refractionFresnelParameters;
  27170. /**
  27171. * Define the refraction fresnel parameters of the material.
  27172. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27173. */
  27174. refractionFresnelParameters: FresnelParameters;
  27175. private _emissiveFresnelParameters;
  27176. /**
  27177. * Define the emissive fresnel parameters of the material.
  27178. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27179. */
  27180. emissiveFresnelParameters: FresnelParameters;
  27181. private _useReflectionFresnelFromSpecular;
  27182. /**
  27183. * If true automatically deducts the fresnels values from the material specularity.
  27184. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27185. */
  27186. useReflectionFresnelFromSpecular: boolean;
  27187. private _useGlossinessFromSpecularMapAlpha;
  27188. /**
  27189. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27190. */
  27191. useGlossinessFromSpecularMapAlpha: boolean;
  27192. private _maxSimultaneousLights;
  27193. /**
  27194. * Defines the maximum number of lights that can be used in the material
  27195. */
  27196. maxSimultaneousLights: number;
  27197. private _invertNormalMapX;
  27198. /**
  27199. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27200. */
  27201. invertNormalMapX: boolean;
  27202. private _invertNormalMapY;
  27203. /**
  27204. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27205. */
  27206. invertNormalMapY: boolean;
  27207. private _twoSidedLighting;
  27208. /**
  27209. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27210. */
  27211. twoSidedLighting: boolean;
  27212. /**
  27213. * Default configuration related to image processing available in the standard Material.
  27214. */
  27215. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27216. /**
  27217. * Gets the image processing configuration used either in this material.
  27218. */
  27219. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27220. /**
  27221. * Sets the Default image processing configuration used either in the this material.
  27222. *
  27223. * If sets to null, the scene one is in use.
  27224. */
  27225. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27226. /**
  27227. * Keep track of the image processing observer to allow dispose and replace.
  27228. */
  27229. private _imageProcessingObserver;
  27230. /**
  27231. * Attaches a new image processing configuration to the Standard Material.
  27232. * @param configuration
  27233. */
  27234. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27235. /**
  27236. * Gets wether the color curves effect is enabled.
  27237. */
  27238. get cameraColorCurvesEnabled(): boolean;
  27239. /**
  27240. * Sets wether the color curves effect is enabled.
  27241. */
  27242. set cameraColorCurvesEnabled(value: boolean);
  27243. /**
  27244. * Gets wether the color grading effect is enabled.
  27245. */
  27246. get cameraColorGradingEnabled(): boolean;
  27247. /**
  27248. * Gets wether the color grading effect is enabled.
  27249. */
  27250. set cameraColorGradingEnabled(value: boolean);
  27251. /**
  27252. * Gets wether tonemapping is enabled or not.
  27253. */
  27254. get cameraToneMappingEnabled(): boolean;
  27255. /**
  27256. * Sets wether tonemapping is enabled or not
  27257. */
  27258. set cameraToneMappingEnabled(value: boolean);
  27259. /**
  27260. * The camera exposure used on this material.
  27261. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27262. * This corresponds to a photographic exposure.
  27263. */
  27264. get cameraExposure(): number;
  27265. /**
  27266. * The camera exposure used on this material.
  27267. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27268. * This corresponds to a photographic exposure.
  27269. */
  27270. set cameraExposure(value: number);
  27271. /**
  27272. * Gets The camera contrast used on this material.
  27273. */
  27274. get cameraContrast(): number;
  27275. /**
  27276. * Sets The camera contrast used on this material.
  27277. */
  27278. set cameraContrast(value: number);
  27279. /**
  27280. * Gets the Color Grading 2D Lookup Texture.
  27281. */
  27282. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27283. /**
  27284. * Sets the Color Grading 2D Lookup Texture.
  27285. */
  27286. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27287. /**
  27288. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27289. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27290. * 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;
  27291. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27292. */
  27293. get cameraColorCurves(): Nullable<ColorCurves>;
  27294. /**
  27295. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27296. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27297. * 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;
  27298. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27299. */
  27300. set cameraColorCurves(value: Nullable<ColorCurves>);
  27301. /**
  27302. * Custom callback helping to override the default shader used in the material.
  27303. */
  27304. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27305. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27306. protected _worldViewProjectionMatrix: Matrix;
  27307. protected _globalAmbientColor: Color3;
  27308. protected _useLogarithmicDepth: boolean;
  27309. protected _rebuildInParallel: boolean;
  27310. /**
  27311. * Instantiates a new standard material.
  27312. * This is the default material used in Babylon. It is the best trade off between quality
  27313. * and performances.
  27314. * @see http://doc.babylonjs.com/babylon101/materials
  27315. * @param name Define the name of the material in the scene
  27316. * @param scene Define the scene the material belong to
  27317. */
  27318. constructor(name: string, scene: Scene);
  27319. /**
  27320. * Gets a boolean indicating that current material needs to register RTT
  27321. */
  27322. get hasRenderTargetTextures(): boolean;
  27323. /**
  27324. * Gets the current class name of the material e.g. "StandardMaterial"
  27325. * Mainly use in serialization.
  27326. * @returns the class name
  27327. */
  27328. getClassName(): string;
  27329. /**
  27330. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27331. * You can try switching to logarithmic depth.
  27332. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27333. */
  27334. get useLogarithmicDepth(): boolean;
  27335. set useLogarithmicDepth(value: boolean);
  27336. /**
  27337. * Specifies if the material will require alpha blending
  27338. * @returns a boolean specifying if alpha blending is needed
  27339. */
  27340. needAlphaBlending(): boolean;
  27341. /**
  27342. * Specifies if this material should be rendered in alpha test mode
  27343. * @returns a boolean specifying if an alpha test is needed.
  27344. */
  27345. needAlphaTesting(): boolean;
  27346. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27347. /**
  27348. * Get the texture used for alpha test purpose.
  27349. * @returns the diffuse texture in case of the standard material.
  27350. */
  27351. getAlphaTestTexture(): Nullable<BaseTexture>;
  27352. /**
  27353. * Get if the submesh is ready to be used and all its information available.
  27354. * Child classes can use it to update shaders
  27355. * @param mesh defines the mesh to check
  27356. * @param subMesh defines which submesh to check
  27357. * @param useInstances specifies that instances should be used
  27358. * @returns a boolean indicating that the submesh is ready or not
  27359. */
  27360. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27361. /**
  27362. * Builds the material UBO layouts.
  27363. * Used internally during the effect preparation.
  27364. */
  27365. buildUniformLayout(): void;
  27366. /**
  27367. * Unbinds the material from the mesh
  27368. */
  27369. unbind(): void;
  27370. /**
  27371. * Binds the submesh to this material by preparing the effect and shader to draw
  27372. * @param world defines the world transformation matrix
  27373. * @param mesh defines the mesh containing the submesh
  27374. * @param subMesh defines the submesh to bind the material to
  27375. */
  27376. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27377. /**
  27378. * Get the list of animatables in the material.
  27379. * @returns the list of animatables object used in the material
  27380. */
  27381. getAnimatables(): IAnimatable[];
  27382. /**
  27383. * Gets the active textures from the material
  27384. * @returns an array of textures
  27385. */
  27386. getActiveTextures(): BaseTexture[];
  27387. /**
  27388. * Specifies if the material uses a texture
  27389. * @param texture defines the texture to check against the material
  27390. * @returns a boolean specifying if the material uses the texture
  27391. */
  27392. hasTexture(texture: BaseTexture): boolean;
  27393. /**
  27394. * Disposes the material
  27395. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27396. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27397. */
  27398. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27399. /**
  27400. * Makes a duplicate of the material, and gives it a new name
  27401. * @param name defines the new name for the duplicated material
  27402. * @returns the cloned material
  27403. */
  27404. clone(name: string): StandardMaterial;
  27405. /**
  27406. * Serializes this material in a JSON representation
  27407. * @returns the serialized material object
  27408. */
  27409. serialize(): any;
  27410. /**
  27411. * Creates a standard material from parsed material data
  27412. * @param source defines the JSON representation of the material
  27413. * @param scene defines the hosting scene
  27414. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27415. * @returns a new standard material
  27416. */
  27417. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27418. /**
  27419. * Are diffuse textures enabled in the application.
  27420. */
  27421. static get DiffuseTextureEnabled(): boolean;
  27422. static set DiffuseTextureEnabled(value: boolean);
  27423. /**
  27424. * Are ambient textures enabled in the application.
  27425. */
  27426. static get AmbientTextureEnabled(): boolean;
  27427. static set AmbientTextureEnabled(value: boolean);
  27428. /**
  27429. * Are opacity textures enabled in the application.
  27430. */
  27431. static get OpacityTextureEnabled(): boolean;
  27432. static set OpacityTextureEnabled(value: boolean);
  27433. /**
  27434. * Are reflection textures enabled in the application.
  27435. */
  27436. static get ReflectionTextureEnabled(): boolean;
  27437. static set ReflectionTextureEnabled(value: boolean);
  27438. /**
  27439. * Are emissive textures enabled in the application.
  27440. */
  27441. static get EmissiveTextureEnabled(): boolean;
  27442. static set EmissiveTextureEnabled(value: boolean);
  27443. /**
  27444. * Are specular textures enabled in the application.
  27445. */
  27446. static get SpecularTextureEnabled(): boolean;
  27447. static set SpecularTextureEnabled(value: boolean);
  27448. /**
  27449. * Are bump textures enabled in the application.
  27450. */
  27451. static get BumpTextureEnabled(): boolean;
  27452. static set BumpTextureEnabled(value: boolean);
  27453. /**
  27454. * Are lightmap textures enabled in the application.
  27455. */
  27456. static get LightmapTextureEnabled(): boolean;
  27457. static set LightmapTextureEnabled(value: boolean);
  27458. /**
  27459. * Are refraction textures enabled in the application.
  27460. */
  27461. static get RefractionTextureEnabled(): boolean;
  27462. static set RefractionTextureEnabled(value: boolean);
  27463. /**
  27464. * Are color grading textures enabled in the application.
  27465. */
  27466. static get ColorGradingTextureEnabled(): boolean;
  27467. static set ColorGradingTextureEnabled(value: boolean);
  27468. /**
  27469. * Are fresnels enabled in the application.
  27470. */
  27471. static get FresnelEnabled(): boolean;
  27472. static set FresnelEnabled(value: boolean);
  27473. }
  27474. }
  27475. declare module "babylonjs/Particles/solidParticleSystem" {
  27476. import { Nullable } from "babylonjs/types";
  27477. import { Vector3 } from "babylonjs/Maths/math.vector";
  27478. import { Mesh } from "babylonjs/Meshes/mesh";
  27479. import { Scene, IDisposable } from "babylonjs/scene";
  27480. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27481. import { Material } from "babylonjs/Materials/material";
  27482. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27483. /**
  27484. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27485. *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.
  27486. * The SPS is also a particle system. It provides some methods to manage the particles.
  27487. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27488. *
  27489. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27490. */
  27491. export class SolidParticleSystem implements IDisposable {
  27492. /**
  27493. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27494. * Example : var p = SPS.particles[i];
  27495. */
  27496. particles: SolidParticle[];
  27497. /**
  27498. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27499. */
  27500. nbParticles: number;
  27501. /**
  27502. * If the particles must ever face the camera (default false). Useful for planar particles.
  27503. */
  27504. billboard: boolean;
  27505. /**
  27506. * Recompute normals when adding a shape
  27507. */
  27508. recomputeNormals: boolean;
  27509. /**
  27510. * This a counter ofr your own usage. It's not set by any SPS functions.
  27511. */
  27512. counter: number;
  27513. /**
  27514. * The SPS name. This name is also given to the underlying mesh.
  27515. */
  27516. name: string;
  27517. /**
  27518. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27519. */
  27520. mesh: Mesh;
  27521. /**
  27522. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27523. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27524. */
  27525. vars: any;
  27526. /**
  27527. * This array is populated when the SPS is set as 'pickable'.
  27528. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27529. * Each element of this array is an object `{idx: int, faceId: int}`.
  27530. * `idx` is the picked particle index in the `SPS.particles` array
  27531. * `faceId` is the picked face index counted within this particle.
  27532. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27533. */
  27534. pickedParticles: {
  27535. idx: number;
  27536. faceId: number;
  27537. }[];
  27538. /**
  27539. * This array is populated when `enableDepthSort` is set to true.
  27540. * Each element of this array is an instance of the class DepthSortedParticle.
  27541. */
  27542. depthSortedParticles: DepthSortedParticle[];
  27543. /**
  27544. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27545. * @hidden
  27546. */
  27547. _bSphereOnly: boolean;
  27548. /**
  27549. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27550. * @hidden
  27551. */
  27552. _bSphereRadiusFactor: number;
  27553. private _scene;
  27554. private _positions;
  27555. private _indices;
  27556. private _normals;
  27557. private _colors;
  27558. private _uvs;
  27559. private _indices32;
  27560. private _positions32;
  27561. private _normals32;
  27562. private _fixedNormal32;
  27563. private _colors32;
  27564. private _uvs32;
  27565. private _index;
  27566. private _updatable;
  27567. private _pickable;
  27568. private _isVisibilityBoxLocked;
  27569. private _alwaysVisible;
  27570. private _depthSort;
  27571. private _expandable;
  27572. private _shapeCounter;
  27573. private _copy;
  27574. private _color;
  27575. private _computeParticleColor;
  27576. private _computeParticleTexture;
  27577. private _computeParticleRotation;
  27578. private _computeParticleVertex;
  27579. private _computeBoundingBox;
  27580. private _depthSortParticles;
  27581. private _camera;
  27582. private _mustUnrotateFixedNormals;
  27583. private _particlesIntersect;
  27584. private _needs32Bits;
  27585. private _isNotBuilt;
  27586. private _lastParticleId;
  27587. private _idxOfId;
  27588. private _multimaterialEnabled;
  27589. private _useModelMaterial;
  27590. private _indicesByMaterial;
  27591. private _materialIndexes;
  27592. private _depthSortFunction;
  27593. private _materialSortFunction;
  27594. private _materials;
  27595. private _multimaterial;
  27596. private _materialIndexesById;
  27597. private _defaultMaterial;
  27598. private _autoUpdateSubMeshes;
  27599. /**
  27600. * Creates a SPS (Solid Particle System) object.
  27601. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27602. * @param scene (Scene) is the scene in which the SPS is added.
  27603. * @param options defines the options of the sps e.g.
  27604. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27605. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27606. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27607. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  27608. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27609. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27610. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27611. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27612. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27613. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27614. */
  27615. constructor(name: string, scene: Scene, options?: {
  27616. updatable?: boolean;
  27617. isPickable?: boolean;
  27618. enableDepthSort?: boolean;
  27619. particleIntersection?: boolean;
  27620. boundingSphereOnly?: boolean;
  27621. bSphereRadiusFactor?: number;
  27622. expandable?: boolean;
  27623. useModelMaterial?: boolean;
  27624. enableMultiMaterial?: boolean;
  27625. });
  27626. /**
  27627. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27628. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27629. * @returns the created mesh
  27630. */
  27631. buildMesh(): Mesh;
  27632. /**
  27633. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27634. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27635. * Thus the particles generated from `digest()` have their property `position` set yet.
  27636. * @param mesh ( Mesh ) is the mesh to be digested
  27637. * @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
  27638. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27639. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27640. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27641. * @returns the current SPS
  27642. */
  27643. digest(mesh: Mesh, options?: {
  27644. facetNb?: number;
  27645. number?: number;
  27646. delta?: number;
  27647. storage?: [];
  27648. }): SolidParticleSystem;
  27649. /**
  27650. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27651. * @hidden
  27652. */
  27653. private _unrotateFixedNormals;
  27654. /**
  27655. * Resets the temporary working copy particle
  27656. * @hidden
  27657. */
  27658. private _resetCopy;
  27659. /**
  27660. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27661. * @param p the current index in the positions array to be updated
  27662. * @param ind the current index in the indices array
  27663. * @param shape a Vector3 array, the shape geometry
  27664. * @param positions the positions array to be updated
  27665. * @param meshInd the shape indices array
  27666. * @param indices the indices array to be updated
  27667. * @param meshUV the shape uv array
  27668. * @param uvs the uv array to be updated
  27669. * @param meshCol the shape color array
  27670. * @param colors the color array to be updated
  27671. * @param meshNor the shape normals array
  27672. * @param normals the normals array to be updated
  27673. * @param idx the particle index
  27674. * @param idxInShape the particle index in its shape
  27675. * @param options the addShape() method passed options
  27676. * @model the particle model
  27677. * @hidden
  27678. */
  27679. private _meshBuilder;
  27680. /**
  27681. * Returns a shape Vector3 array from positions float array
  27682. * @param positions float array
  27683. * @returns a vector3 array
  27684. * @hidden
  27685. */
  27686. private _posToShape;
  27687. /**
  27688. * Returns a shapeUV array from a float uvs (array deep copy)
  27689. * @param uvs as a float array
  27690. * @returns a shapeUV array
  27691. * @hidden
  27692. */
  27693. private _uvsToShapeUV;
  27694. /**
  27695. * Adds a new particle object in the particles array
  27696. * @param idx particle index in particles array
  27697. * @param id particle id
  27698. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27699. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27700. * @param model particle ModelShape object
  27701. * @param shapeId model shape identifier
  27702. * @param idxInShape index of the particle in the current model
  27703. * @param bInfo model bounding info object
  27704. * @param storage target storage array, if any
  27705. * @hidden
  27706. */
  27707. private _addParticle;
  27708. /**
  27709. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27710. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27711. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27712. * @param nb (positive integer) the number of particles to be created from this model
  27713. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27714. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27715. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27716. * @returns the number of shapes in the system
  27717. */
  27718. addShape(mesh: Mesh, nb: number, options?: {
  27719. positionFunction?: any;
  27720. vertexFunction?: any;
  27721. storage?: [];
  27722. }): number;
  27723. /**
  27724. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27725. * @hidden
  27726. */
  27727. private _rebuildParticle;
  27728. /**
  27729. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27730. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  27731. * @returns the SPS.
  27732. */
  27733. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27734. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27735. * Returns an array with the removed particles.
  27736. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  27737. * The SPS can't be empty so at least one particle needs to remain in place.
  27738. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27739. * @param start index of the first particle to remove
  27740. * @param end index of the last particle to remove (included)
  27741. * @returns an array populated with the removed particles
  27742. */
  27743. removeParticles(start: number, end: number): SolidParticle[];
  27744. /**
  27745. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27746. * @param solidParticleArray an array populated with Solid Particles objects
  27747. * @returns the SPS
  27748. */
  27749. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27750. /**
  27751. * Creates a new particle and modifies the SPS mesh geometry :
  27752. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27753. * - calls _addParticle() to populate the particle array
  27754. * factorized code from addShape() and insertParticlesFromArray()
  27755. * @param idx particle index in the particles array
  27756. * @param i particle index in its shape
  27757. * @param modelShape particle ModelShape object
  27758. * @param shape shape vertex array
  27759. * @param meshInd shape indices array
  27760. * @param meshUV shape uv array
  27761. * @param meshCol shape color array
  27762. * @param meshNor shape normals array
  27763. * @param bbInfo shape bounding info
  27764. * @param storage target particle storage
  27765. * @options addShape() passed options
  27766. * @hidden
  27767. */
  27768. private _insertNewParticle;
  27769. /**
  27770. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27771. * This method calls `updateParticle()` for each particle of the SPS.
  27772. * For an animated SPS, it is usually called within the render loop.
  27773. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  27774. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27775. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27776. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27777. * @returns the SPS.
  27778. */
  27779. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27780. /**
  27781. * Disposes the SPS.
  27782. */
  27783. dispose(): void;
  27784. /**
  27785. * Returns a SolidParticle object from its identifier : particle.id
  27786. * @param id (integer) the particle Id
  27787. * @returns the searched particle or null if not found in the SPS.
  27788. */
  27789. getParticleById(id: number): Nullable<SolidParticle>;
  27790. /**
  27791. * Returns a new array populated with the particles having the passed shapeId.
  27792. * @param shapeId (integer) the shape identifier
  27793. * @returns a new solid particle array
  27794. */
  27795. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27796. /**
  27797. * Populates the passed array "ref" with the particles having the passed shapeId.
  27798. * @param shapeId the shape identifier
  27799. * @returns the SPS
  27800. * @param ref
  27801. */
  27802. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27803. /**
  27804. * Computes the required SubMeshes according the materials assigned to the particles.
  27805. * @returns the solid particle system.
  27806. * Does nothing if called before the SPS mesh is built.
  27807. */
  27808. computeSubMeshes(): SolidParticleSystem;
  27809. /**
  27810. * Sorts the solid particles by material when MultiMaterial is enabled.
  27811. * Updates the indices32 array.
  27812. * Updates the indicesByMaterial array.
  27813. * Updates the mesh indices array.
  27814. * @returns the SPS
  27815. * @hidden
  27816. */
  27817. private _sortParticlesByMaterial;
  27818. /**
  27819. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27820. * @hidden
  27821. */
  27822. private _setMaterialIndexesById;
  27823. /**
  27824. * Returns an array with unique values of Materials from the passed array
  27825. * @param array the material array to be checked and filtered
  27826. * @hidden
  27827. */
  27828. private _filterUniqueMaterialId;
  27829. /**
  27830. * Sets a new Standard Material as _defaultMaterial if not already set.
  27831. * @hidden
  27832. */
  27833. private _setDefaultMaterial;
  27834. /**
  27835. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27836. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27837. * @returns the SPS.
  27838. */
  27839. refreshVisibleSize(): SolidParticleSystem;
  27840. /**
  27841. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27842. * @param size the size (float) of the visibility box
  27843. * note : this doesn't lock the SPS mesh bounding box.
  27844. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27845. */
  27846. setVisibilityBox(size: number): void;
  27847. /**
  27848. * Gets whether the SPS as always visible or not
  27849. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27850. */
  27851. get isAlwaysVisible(): boolean;
  27852. /**
  27853. * Sets the SPS as always visible or not
  27854. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27855. */
  27856. set isAlwaysVisible(val: boolean);
  27857. /**
  27858. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27859. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27860. */
  27861. set isVisibilityBoxLocked(val: boolean);
  27862. /**
  27863. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27864. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27865. */
  27866. get isVisibilityBoxLocked(): boolean;
  27867. /**
  27868. * Tells to `setParticles()` to compute the particle rotations or not.
  27869. * Default value : true. The SPS is faster when it's set to false.
  27870. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27871. */
  27872. set computeParticleRotation(val: boolean);
  27873. /**
  27874. * Tells to `setParticles()` to compute the particle colors or not.
  27875. * Default value : true. The SPS is faster when it's set to false.
  27876. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27877. */
  27878. set computeParticleColor(val: boolean);
  27879. set computeParticleTexture(val: boolean);
  27880. /**
  27881. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27882. * Default value : false. The SPS is faster when it's set to false.
  27883. * Note : the particle custom vertex positions aren't stored values.
  27884. */
  27885. set computeParticleVertex(val: boolean);
  27886. /**
  27887. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27888. */
  27889. set computeBoundingBox(val: boolean);
  27890. /**
  27891. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27892. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27893. * Default : `true`
  27894. */
  27895. set depthSortParticles(val: boolean);
  27896. /**
  27897. * Gets if `setParticles()` computes the particle rotations or not.
  27898. * Default value : true. The SPS is faster when it's set to false.
  27899. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27900. */
  27901. get computeParticleRotation(): boolean;
  27902. /**
  27903. * Gets if `setParticles()` computes the particle colors or not.
  27904. * Default value : true. The SPS is faster when it's set to false.
  27905. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27906. */
  27907. get computeParticleColor(): boolean;
  27908. /**
  27909. * Gets if `setParticles()` computes the particle textures or not.
  27910. * Default value : true. The SPS is faster when it's set to false.
  27911. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27912. */
  27913. get computeParticleTexture(): boolean;
  27914. /**
  27915. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27916. * Default value : false. The SPS is faster when it's set to false.
  27917. * Note : the particle custom vertex positions aren't stored values.
  27918. */
  27919. get computeParticleVertex(): boolean;
  27920. /**
  27921. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27922. */
  27923. get computeBoundingBox(): boolean;
  27924. /**
  27925. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27926. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27927. * Default : `true`
  27928. */
  27929. get depthSortParticles(): boolean;
  27930. /**
  27931. * Gets if the SPS is created as expandable at construction time.
  27932. * Default : `false`
  27933. */
  27934. get expandable(): boolean;
  27935. /**
  27936. * Gets if the SPS supports the Multi Materials
  27937. */
  27938. get multimaterialEnabled(): boolean;
  27939. /**
  27940. * Gets if the SPS uses the model materials for its own multimaterial.
  27941. */
  27942. get useModelMaterial(): boolean;
  27943. /**
  27944. * The SPS used material array.
  27945. */
  27946. get materials(): Material[];
  27947. /**
  27948. * Sets the SPS MultiMaterial from the passed materials.
  27949. * Note : the passed array is internally copied and not used then by reference.
  27950. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27951. */
  27952. setMultiMaterial(materials: Material[]): void;
  27953. /**
  27954. * The SPS computed multimaterial object
  27955. */
  27956. get multimaterial(): MultiMaterial;
  27957. set multimaterial(mm: MultiMaterial);
  27958. /**
  27959. * If the subMeshes must be updated on the next call to setParticles()
  27960. */
  27961. get autoUpdateSubMeshes(): boolean;
  27962. set autoUpdateSubMeshes(val: boolean);
  27963. /**
  27964. * This function does nothing. It may be overwritten to set all the particle first values.
  27965. * The SPS doesn't call this function, you may have to call it by your own.
  27966. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27967. */
  27968. initParticles(): void;
  27969. /**
  27970. * This function does nothing. It may be overwritten to recycle a particle.
  27971. * The SPS doesn't call this function, you may have to call it by your own.
  27972. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27973. * @param particle The particle to recycle
  27974. * @returns the recycled particle
  27975. */
  27976. recycleParticle(particle: SolidParticle): SolidParticle;
  27977. /**
  27978. * Updates a particle : this function should be overwritten by the user.
  27979. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27980. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27981. * @example : just set a particle position or velocity and recycle conditions
  27982. * @param particle The particle to update
  27983. * @returns the updated particle
  27984. */
  27985. updateParticle(particle: SolidParticle): SolidParticle;
  27986. /**
  27987. * Updates a vertex of a particle : it can be overwritten by the user.
  27988. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27989. * @param particle the current particle
  27990. * @param vertex the current index of the current particle
  27991. * @param pt the index of the current vertex in the particle shape
  27992. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27993. * @example : just set a vertex particle position
  27994. * @returns the updated vertex
  27995. */
  27996. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27997. /**
  27998. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27999. * This does nothing and may be overwritten by the user.
  28000. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28001. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28002. * @param update the boolean update value actually passed to setParticles()
  28003. */
  28004. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28005. /**
  28006. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28007. * This will be passed three parameters.
  28008. * This does nothing and may be overwritten by the user.
  28009. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28010. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28011. * @param update the boolean update value actually passed to setParticles()
  28012. */
  28013. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28014. }
  28015. }
  28016. declare module "babylonjs/Particles/solidParticle" {
  28017. import { Nullable } from "babylonjs/types";
  28018. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28019. import { Color4 } from "babylonjs/Maths/math.color";
  28020. import { Mesh } from "babylonjs/Meshes/mesh";
  28021. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28022. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28023. import { Plane } from "babylonjs/Maths/math.plane";
  28024. import { Material } from "babylonjs/Materials/material";
  28025. /**
  28026. * Represents one particle of a solid particle system.
  28027. */
  28028. export class SolidParticle {
  28029. /**
  28030. * particle global index
  28031. */
  28032. idx: number;
  28033. /**
  28034. * particle identifier
  28035. */
  28036. id: number;
  28037. /**
  28038. * The color of the particle
  28039. */
  28040. color: Nullable<Color4>;
  28041. /**
  28042. * The world space position of the particle.
  28043. */
  28044. position: Vector3;
  28045. /**
  28046. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28047. */
  28048. rotation: Vector3;
  28049. /**
  28050. * The world space rotation quaternion of the particle.
  28051. */
  28052. rotationQuaternion: Nullable<Quaternion>;
  28053. /**
  28054. * The scaling of the particle.
  28055. */
  28056. scaling: Vector3;
  28057. /**
  28058. * The uvs of the particle.
  28059. */
  28060. uvs: Vector4;
  28061. /**
  28062. * The current speed of the particle.
  28063. */
  28064. velocity: Vector3;
  28065. /**
  28066. * The pivot point in the particle local space.
  28067. */
  28068. pivot: Vector3;
  28069. /**
  28070. * Must the particle be translated from its pivot point in its local space ?
  28071. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28072. * Default : false
  28073. */
  28074. translateFromPivot: boolean;
  28075. /**
  28076. * Is the particle active or not ?
  28077. */
  28078. alive: boolean;
  28079. /**
  28080. * Is the particle visible or not ?
  28081. */
  28082. isVisible: boolean;
  28083. /**
  28084. * Index of this particle in the global "positions" array (Internal use)
  28085. * @hidden
  28086. */
  28087. _pos: number;
  28088. /**
  28089. * @hidden Index of this particle in the global "indices" array (Internal use)
  28090. */
  28091. _ind: number;
  28092. /**
  28093. * @hidden ModelShape of this particle (Internal use)
  28094. */
  28095. _model: ModelShape;
  28096. /**
  28097. * ModelShape id of this particle
  28098. */
  28099. shapeId: number;
  28100. /**
  28101. * Index of the particle in its shape id
  28102. */
  28103. idxInShape: number;
  28104. /**
  28105. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28106. */
  28107. _modelBoundingInfo: BoundingInfo;
  28108. /**
  28109. * @hidden Particle BoundingInfo object (Internal use)
  28110. */
  28111. _boundingInfo: BoundingInfo;
  28112. /**
  28113. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28114. */
  28115. _sps: SolidParticleSystem;
  28116. /**
  28117. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28118. */
  28119. _stillInvisible: boolean;
  28120. /**
  28121. * @hidden Last computed particle rotation matrix
  28122. */
  28123. _rotationMatrix: number[];
  28124. /**
  28125. * Parent particle Id, if any.
  28126. * Default null.
  28127. */
  28128. parentId: Nullable<number>;
  28129. /**
  28130. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28131. */
  28132. materialIndex: Nullable<number>;
  28133. /**
  28134. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28135. * The possible values are :
  28136. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28137. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28138. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28139. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28140. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28141. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28142. * */
  28143. cullingStrategy: number;
  28144. /**
  28145. * @hidden Internal global position in the SPS.
  28146. */
  28147. _globalPosition: Vector3;
  28148. /**
  28149. * Creates a Solid Particle object.
  28150. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28151. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28152. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28153. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28154. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28155. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28156. * @param shapeId (integer) is the model shape identifier in the SPS.
  28157. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28158. * @param sps defines the sps it is associated to
  28159. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28160. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28161. */
  28162. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28163. /**
  28164. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28165. * @param target the particle target
  28166. * @returns the current particle
  28167. */
  28168. copyToRef(target: SolidParticle): SolidParticle;
  28169. /**
  28170. * Legacy support, changed scale to scaling
  28171. */
  28172. get scale(): Vector3;
  28173. /**
  28174. * Legacy support, changed scale to scaling
  28175. */
  28176. set scale(scale: Vector3);
  28177. /**
  28178. * Legacy support, changed quaternion to rotationQuaternion
  28179. */
  28180. get quaternion(): Nullable<Quaternion>;
  28181. /**
  28182. * Legacy support, changed quaternion to rotationQuaternion
  28183. */
  28184. set quaternion(q: Nullable<Quaternion>);
  28185. /**
  28186. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28187. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28188. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28189. * @returns true if it intersects
  28190. */
  28191. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28192. /**
  28193. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28194. * A particle is in the frustum if its bounding box intersects the frustum
  28195. * @param frustumPlanes defines the frustum to test
  28196. * @returns true if the particle is in the frustum planes
  28197. */
  28198. isInFrustum(frustumPlanes: Plane[]): boolean;
  28199. /**
  28200. * get the rotation matrix of the particle
  28201. * @hidden
  28202. */
  28203. getRotationMatrix(m: Matrix): void;
  28204. }
  28205. /**
  28206. * Represents the shape of the model used by one particle of a solid particle system.
  28207. * SPS internal tool, don't use it manually.
  28208. */
  28209. export class ModelShape {
  28210. /**
  28211. * The shape id
  28212. * @hidden
  28213. */
  28214. shapeID: number;
  28215. /**
  28216. * flat array of model positions (internal use)
  28217. * @hidden
  28218. */
  28219. _shape: Vector3[];
  28220. /**
  28221. * flat array of model UVs (internal use)
  28222. * @hidden
  28223. */
  28224. _shapeUV: number[];
  28225. /**
  28226. * color array of the model
  28227. * @hidden
  28228. */
  28229. _shapeColors: number[];
  28230. /**
  28231. * indices array of the model
  28232. * @hidden
  28233. */
  28234. _indices: number[];
  28235. /**
  28236. * normals array of the model
  28237. * @hidden
  28238. */
  28239. _normals: number[];
  28240. /**
  28241. * length of the shape in the model indices array (internal use)
  28242. * @hidden
  28243. */
  28244. _indicesLength: number;
  28245. /**
  28246. * Custom position function (internal use)
  28247. * @hidden
  28248. */
  28249. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28250. /**
  28251. * Custom vertex function (internal use)
  28252. * @hidden
  28253. */
  28254. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28255. /**
  28256. * Model material (internal use)
  28257. * @hidden
  28258. */
  28259. _material: Nullable<Material>;
  28260. /**
  28261. * 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.
  28262. * SPS internal tool, don't use it manually.
  28263. * @hidden
  28264. */
  28265. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  28266. }
  28267. /**
  28268. * Represents a Depth Sorted Particle in the solid particle system.
  28269. * @hidden
  28270. */
  28271. export class DepthSortedParticle {
  28272. /**
  28273. * Index of the particle in the "indices" array
  28274. */
  28275. ind: number;
  28276. /**
  28277. * Length of the particle shape in the "indices" array
  28278. */
  28279. indicesLength: number;
  28280. /**
  28281. * Squared distance from the particle to the camera
  28282. */
  28283. sqDistance: number;
  28284. /**
  28285. * Material index when used with MultiMaterials
  28286. */
  28287. materialIndex: number;
  28288. /**
  28289. * Creates a new sorted particle
  28290. * @param materialIndex
  28291. */
  28292. constructor(ind: number, indLength: number, materialIndex: number);
  28293. }
  28294. }
  28295. declare module "babylonjs/Collisions/meshCollisionData" {
  28296. import { Collider } from "babylonjs/Collisions/collider";
  28297. import { Vector3 } from "babylonjs/Maths/math.vector";
  28298. import { Nullable } from "babylonjs/types";
  28299. import { Observer } from "babylonjs/Misc/observable";
  28300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28301. /**
  28302. * @hidden
  28303. */
  28304. export class _MeshCollisionData {
  28305. _checkCollisions: boolean;
  28306. _collisionMask: number;
  28307. _collisionGroup: number;
  28308. _collider: Nullable<Collider>;
  28309. _oldPositionForCollisions: Vector3;
  28310. _diffPositionForCollisions: Vector3;
  28311. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28312. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28313. }
  28314. }
  28315. declare module "babylonjs/Meshes/abstractMesh" {
  28316. import { Observable } from "babylonjs/Misc/observable";
  28317. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28318. import { Camera } from "babylonjs/Cameras/camera";
  28319. import { Scene, IDisposable } from "babylonjs/scene";
  28320. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28321. import { Node } from "babylonjs/node";
  28322. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28323. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28324. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28325. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28326. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28327. import { Material } from "babylonjs/Materials/material";
  28328. import { Light } from "babylonjs/Lights/light";
  28329. import { Skeleton } from "babylonjs/Bones/skeleton";
  28330. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28331. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28332. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28333. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28334. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28335. import { Plane } from "babylonjs/Maths/math.plane";
  28336. import { Ray } from "babylonjs/Culling/ray";
  28337. import { Collider } from "babylonjs/Collisions/collider";
  28338. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28339. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28340. /** @hidden */
  28341. class _FacetDataStorage {
  28342. facetPositions: Vector3[];
  28343. facetNormals: Vector3[];
  28344. facetPartitioning: number[][];
  28345. facetNb: number;
  28346. partitioningSubdivisions: number;
  28347. partitioningBBoxRatio: number;
  28348. facetDataEnabled: boolean;
  28349. facetParameters: any;
  28350. bbSize: Vector3;
  28351. subDiv: {
  28352. max: number;
  28353. X: number;
  28354. Y: number;
  28355. Z: number;
  28356. };
  28357. facetDepthSort: boolean;
  28358. facetDepthSortEnabled: boolean;
  28359. depthSortedIndices: IndicesArray;
  28360. depthSortedFacets: {
  28361. ind: number;
  28362. sqDistance: number;
  28363. }[];
  28364. facetDepthSortFunction: (f1: {
  28365. ind: number;
  28366. sqDistance: number;
  28367. }, f2: {
  28368. ind: number;
  28369. sqDistance: number;
  28370. }) => number;
  28371. facetDepthSortFrom: Vector3;
  28372. facetDepthSortOrigin: Vector3;
  28373. invertedMatrix: Matrix;
  28374. }
  28375. /**
  28376. * @hidden
  28377. **/
  28378. class _InternalAbstractMeshDataInfo {
  28379. _hasVertexAlpha: boolean;
  28380. _useVertexColors: boolean;
  28381. _numBoneInfluencers: number;
  28382. _applyFog: boolean;
  28383. _receiveShadows: boolean;
  28384. _facetData: _FacetDataStorage;
  28385. _visibility: number;
  28386. _skeleton: Nullable<Skeleton>;
  28387. _layerMask: number;
  28388. _computeBonesUsingShaders: boolean;
  28389. _isActive: boolean;
  28390. _onlyForInstances: boolean;
  28391. _isActiveIntermediate: boolean;
  28392. _onlyForInstancesIntermediate: boolean;
  28393. _actAsRegularMesh: boolean;
  28394. }
  28395. /**
  28396. * Class used to store all common mesh properties
  28397. */
  28398. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28399. /** No occlusion */
  28400. static OCCLUSION_TYPE_NONE: number;
  28401. /** Occlusion set to optimisitic */
  28402. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28403. /** Occlusion set to strict */
  28404. static OCCLUSION_TYPE_STRICT: number;
  28405. /** Use an accurante occlusion algorithm */
  28406. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28407. /** Use a conservative occlusion algorithm */
  28408. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28409. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28410. * Test order :
  28411. * Is the bounding sphere outside the frustum ?
  28412. * If not, are the bounding box vertices outside the frustum ?
  28413. * It not, then the cullable object is in the frustum.
  28414. */
  28415. static readonly CULLINGSTRATEGY_STANDARD: number;
  28416. /** Culling strategy : Bounding Sphere Only.
  28417. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28418. * It's also less accurate than the standard because some not visible objects can still be selected.
  28419. * Test : is the bounding sphere outside the frustum ?
  28420. * If not, then the cullable object is in the frustum.
  28421. */
  28422. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28423. /** Culling strategy : Optimistic Inclusion.
  28424. * This in an inclusion test first, then the standard exclusion test.
  28425. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28426. * 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.
  28427. * Anyway, it's as accurate as the standard strategy.
  28428. * Test :
  28429. * Is the cullable object bounding sphere center in the frustum ?
  28430. * If not, apply the default culling strategy.
  28431. */
  28432. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28433. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28434. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28435. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28436. * 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.
  28437. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28438. * Test :
  28439. * Is the cullable object bounding sphere center in the frustum ?
  28440. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28441. */
  28442. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28443. /**
  28444. * No billboard
  28445. */
  28446. static get BILLBOARDMODE_NONE(): number;
  28447. /** Billboard on X axis */
  28448. static get BILLBOARDMODE_X(): number;
  28449. /** Billboard on Y axis */
  28450. static get BILLBOARDMODE_Y(): number;
  28451. /** Billboard on Z axis */
  28452. static get BILLBOARDMODE_Z(): number;
  28453. /** Billboard on all axes */
  28454. static get BILLBOARDMODE_ALL(): number;
  28455. /** Billboard on using position instead of orientation */
  28456. static get BILLBOARDMODE_USE_POSITION(): number;
  28457. /** @hidden */
  28458. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28459. /**
  28460. * The culling strategy to use to check whether the mesh must be rendered or not.
  28461. * This value can be changed at any time and will be used on the next render mesh selection.
  28462. * The possible values are :
  28463. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28464. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28465. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28466. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28467. * Please read each static variable documentation to get details about the culling process.
  28468. * */
  28469. cullingStrategy: number;
  28470. /**
  28471. * Gets the number of facets in the mesh
  28472. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28473. */
  28474. get facetNb(): number;
  28475. /**
  28476. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28477. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28478. */
  28479. get partitioningSubdivisions(): number;
  28480. set partitioningSubdivisions(nb: number);
  28481. /**
  28482. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28483. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28484. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28485. */
  28486. get partitioningBBoxRatio(): number;
  28487. set partitioningBBoxRatio(ratio: number);
  28488. /**
  28489. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28490. * Works only for updatable meshes.
  28491. * Doesn't work with multi-materials
  28492. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28493. */
  28494. get mustDepthSortFacets(): boolean;
  28495. set mustDepthSortFacets(sort: boolean);
  28496. /**
  28497. * The location (Vector3) where the facet depth sort must be computed from.
  28498. * By default, the active camera position.
  28499. * Used only when facet depth sort is enabled
  28500. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28501. */
  28502. get facetDepthSortFrom(): Vector3;
  28503. set facetDepthSortFrom(location: Vector3);
  28504. /**
  28505. * gets a boolean indicating if facetData is enabled
  28506. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28507. */
  28508. get isFacetDataEnabled(): boolean;
  28509. /** @hidden */
  28510. _updateNonUniformScalingState(value: boolean): boolean;
  28511. /**
  28512. * An event triggered when this mesh collides with another one
  28513. */
  28514. onCollideObservable: Observable<AbstractMesh>;
  28515. /** Set a function to call when this mesh collides with another one */
  28516. set onCollide(callback: () => void);
  28517. /**
  28518. * An event triggered when the collision's position changes
  28519. */
  28520. onCollisionPositionChangeObservable: Observable<Vector3>;
  28521. /** Set a function to call when the collision's position changes */
  28522. set onCollisionPositionChange(callback: () => void);
  28523. /**
  28524. * An event triggered when material is changed
  28525. */
  28526. onMaterialChangedObservable: Observable<AbstractMesh>;
  28527. /**
  28528. * Gets or sets the orientation for POV movement & rotation
  28529. */
  28530. definedFacingForward: boolean;
  28531. /** @hidden */
  28532. _occlusionQuery: Nullable<WebGLQuery>;
  28533. /** @hidden */
  28534. _renderingGroup: Nullable<RenderingGroup>;
  28535. /**
  28536. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28537. */
  28538. get visibility(): number;
  28539. /**
  28540. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28541. */
  28542. set visibility(value: number);
  28543. /** Gets or sets the alpha index used to sort transparent meshes
  28544. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28545. */
  28546. alphaIndex: number;
  28547. /**
  28548. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28549. */
  28550. isVisible: boolean;
  28551. /**
  28552. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28553. */
  28554. isPickable: boolean;
  28555. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28556. showSubMeshesBoundingBox: boolean;
  28557. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28558. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28559. */
  28560. isBlocker: boolean;
  28561. /**
  28562. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28563. */
  28564. enablePointerMoveEvents: boolean;
  28565. /**
  28566. * Specifies the rendering group id for this mesh (0 by default)
  28567. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28568. */
  28569. renderingGroupId: number;
  28570. private _material;
  28571. /** Gets or sets current material */
  28572. get material(): Nullable<Material>;
  28573. set material(value: Nullable<Material>);
  28574. /**
  28575. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28576. * @see http://doc.babylonjs.com/babylon101/shadows
  28577. */
  28578. get receiveShadows(): boolean;
  28579. set receiveShadows(value: boolean);
  28580. /** Defines color to use when rendering outline */
  28581. outlineColor: Color3;
  28582. /** Define width to use when rendering outline */
  28583. outlineWidth: number;
  28584. /** Defines color to use when rendering overlay */
  28585. overlayColor: Color3;
  28586. /** Defines alpha to use when rendering overlay */
  28587. overlayAlpha: number;
  28588. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28589. get hasVertexAlpha(): boolean;
  28590. set hasVertexAlpha(value: boolean);
  28591. /** 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) */
  28592. get useVertexColors(): boolean;
  28593. set useVertexColors(value: boolean);
  28594. /**
  28595. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28596. */
  28597. get computeBonesUsingShaders(): boolean;
  28598. set computeBonesUsingShaders(value: boolean);
  28599. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28600. get numBoneInfluencers(): number;
  28601. set numBoneInfluencers(value: number);
  28602. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28603. get applyFog(): boolean;
  28604. set applyFog(value: boolean);
  28605. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28606. useOctreeForRenderingSelection: boolean;
  28607. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28608. useOctreeForPicking: boolean;
  28609. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28610. useOctreeForCollisions: boolean;
  28611. /**
  28612. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28613. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28614. */
  28615. get layerMask(): number;
  28616. set layerMask(value: number);
  28617. /**
  28618. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28619. */
  28620. alwaysSelectAsActiveMesh: boolean;
  28621. /**
  28622. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28623. */
  28624. doNotSyncBoundingInfo: boolean;
  28625. /**
  28626. * Gets or sets the current action manager
  28627. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28628. */
  28629. actionManager: Nullable<AbstractActionManager>;
  28630. private _meshCollisionData;
  28631. /**
  28632. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28633. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28634. */
  28635. ellipsoid: Vector3;
  28636. /**
  28637. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28638. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28639. */
  28640. ellipsoidOffset: Vector3;
  28641. /**
  28642. * Gets or sets a collision mask used to mask collisions (default is -1).
  28643. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28644. */
  28645. get collisionMask(): number;
  28646. set collisionMask(mask: number);
  28647. /**
  28648. * Gets or sets the current collision group mask (-1 by default).
  28649. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28650. */
  28651. get collisionGroup(): number;
  28652. set collisionGroup(mask: number);
  28653. /**
  28654. * Defines edge width used when edgesRenderer is enabled
  28655. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28656. */
  28657. edgesWidth: number;
  28658. /**
  28659. * Defines edge color used when edgesRenderer is enabled
  28660. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28661. */
  28662. edgesColor: Color4;
  28663. /** @hidden */
  28664. _edgesRenderer: Nullable<IEdgesRenderer>;
  28665. /** @hidden */
  28666. _masterMesh: Nullable<AbstractMesh>;
  28667. /** @hidden */
  28668. _boundingInfo: Nullable<BoundingInfo>;
  28669. /** @hidden */
  28670. _renderId: number;
  28671. /**
  28672. * Gets or sets the list of subMeshes
  28673. * @see http://doc.babylonjs.com/how_to/multi_materials
  28674. */
  28675. subMeshes: SubMesh[];
  28676. /** @hidden */
  28677. _intersectionsInProgress: AbstractMesh[];
  28678. /** @hidden */
  28679. _unIndexed: boolean;
  28680. /** @hidden */
  28681. _lightSources: Light[];
  28682. /** Gets the list of lights affecting that mesh */
  28683. get lightSources(): Light[];
  28684. /** @hidden */
  28685. get _positions(): Nullable<Vector3[]>;
  28686. /** @hidden */
  28687. _waitingData: {
  28688. lods: Nullable<any>;
  28689. actions: Nullable<any>;
  28690. freezeWorldMatrix: Nullable<boolean>;
  28691. };
  28692. /** @hidden */
  28693. _bonesTransformMatrices: Nullable<Float32Array>;
  28694. /** @hidden */
  28695. _transformMatrixTexture: Nullable<RawTexture>;
  28696. /**
  28697. * Gets or sets a skeleton to apply skining transformations
  28698. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28699. */
  28700. set skeleton(value: Nullable<Skeleton>);
  28701. get skeleton(): Nullable<Skeleton>;
  28702. /**
  28703. * An event triggered when the mesh is rebuilt.
  28704. */
  28705. onRebuildObservable: Observable<AbstractMesh>;
  28706. /**
  28707. * Creates a new AbstractMesh
  28708. * @param name defines the name of the mesh
  28709. * @param scene defines the hosting scene
  28710. */
  28711. constructor(name: string, scene?: Nullable<Scene>);
  28712. /**
  28713. * Returns the string "AbstractMesh"
  28714. * @returns "AbstractMesh"
  28715. */
  28716. getClassName(): string;
  28717. /**
  28718. * Gets a string representation of the current mesh
  28719. * @param fullDetails defines a boolean indicating if full details must be included
  28720. * @returns a string representation of the current mesh
  28721. */
  28722. toString(fullDetails?: boolean): string;
  28723. /**
  28724. * @hidden
  28725. */
  28726. protected _getEffectiveParent(): Nullable<Node>;
  28727. /** @hidden */
  28728. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28729. /** @hidden */
  28730. _rebuild(): void;
  28731. /** @hidden */
  28732. _resyncLightSources(): void;
  28733. /** @hidden */
  28734. _resyncLightSource(light: Light): void;
  28735. /** @hidden */
  28736. _unBindEffect(): void;
  28737. /** @hidden */
  28738. _removeLightSource(light: Light, dispose: boolean): void;
  28739. private _markSubMeshesAsDirty;
  28740. /** @hidden */
  28741. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28742. /** @hidden */
  28743. _markSubMeshesAsAttributesDirty(): void;
  28744. /** @hidden */
  28745. _markSubMeshesAsMiscDirty(): void;
  28746. /**
  28747. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28748. */
  28749. get scaling(): Vector3;
  28750. set scaling(newScaling: Vector3);
  28751. /**
  28752. * Returns true if the mesh is blocked. Implemented by child classes
  28753. */
  28754. get isBlocked(): boolean;
  28755. /**
  28756. * Returns the mesh itself by default. Implemented by child classes
  28757. * @param camera defines the camera to use to pick the right LOD level
  28758. * @returns the currentAbstractMesh
  28759. */
  28760. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28761. /**
  28762. * Returns 0 by default. Implemented by child classes
  28763. * @returns an integer
  28764. */
  28765. getTotalVertices(): number;
  28766. /**
  28767. * Returns a positive integer : the total number of indices in this mesh geometry.
  28768. * @returns the numner of indices or zero if the mesh has no geometry.
  28769. */
  28770. getTotalIndices(): number;
  28771. /**
  28772. * Returns null by default. Implemented by child classes
  28773. * @returns null
  28774. */
  28775. getIndices(): Nullable<IndicesArray>;
  28776. /**
  28777. * Returns the array of the requested vertex data kind. Implemented by child classes
  28778. * @param kind defines the vertex data kind to use
  28779. * @returns null
  28780. */
  28781. getVerticesData(kind: string): Nullable<FloatArray>;
  28782. /**
  28783. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28784. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28785. * Note that a new underlying VertexBuffer object is created each call.
  28786. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28787. * @param kind defines vertex data kind:
  28788. * * VertexBuffer.PositionKind
  28789. * * VertexBuffer.UVKind
  28790. * * VertexBuffer.UV2Kind
  28791. * * VertexBuffer.UV3Kind
  28792. * * VertexBuffer.UV4Kind
  28793. * * VertexBuffer.UV5Kind
  28794. * * VertexBuffer.UV6Kind
  28795. * * VertexBuffer.ColorKind
  28796. * * VertexBuffer.MatricesIndicesKind
  28797. * * VertexBuffer.MatricesIndicesExtraKind
  28798. * * VertexBuffer.MatricesWeightsKind
  28799. * * VertexBuffer.MatricesWeightsExtraKind
  28800. * @param data defines the data source
  28801. * @param updatable defines if the data must be flagged as updatable (or static)
  28802. * @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
  28803. * @returns the current mesh
  28804. */
  28805. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28806. /**
  28807. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28808. * If the mesh has no geometry, it is simply returned as it is.
  28809. * @param kind defines vertex data kind:
  28810. * * VertexBuffer.PositionKind
  28811. * * VertexBuffer.UVKind
  28812. * * VertexBuffer.UV2Kind
  28813. * * VertexBuffer.UV3Kind
  28814. * * VertexBuffer.UV4Kind
  28815. * * VertexBuffer.UV5Kind
  28816. * * VertexBuffer.UV6Kind
  28817. * * VertexBuffer.ColorKind
  28818. * * VertexBuffer.MatricesIndicesKind
  28819. * * VertexBuffer.MatricesIndicesExtraKind
  28820. * * VertexBuffer.MatricesWeightsKind
  28821. * * VertexBuffer.MatricesWeightsExtraKind
  28822. * @param data defines the data source
  28823. * @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
  28824. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28825. * @returns the current mesh
  28826. */
  28827. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28828. /**
  28829. * Sets the mesh indices,
  28830. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28831. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28832. * @param totalVertices Defines the total number of vertices
  28833. * @returns the current mesh
  28834. */
  28835. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28836. /**
  28837. * Gets a boolean indicating if specific vertex data is present
  28838. * @param kind defines the vertex data kind to use
  28839. * @returns true is data kind is present
  28840. */
  28841. isVerticesDataPresent(kind: string): boolean;
  28842. /**
  28843. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28844. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28845. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28846. * @returns a BoundingInfo
  28847. */
  28848. getBoundingInfo(): BoundingInfo;
  28849. /**
  28850. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28851. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28852. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28853. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28854. * @returns the current mesh
  28855. */
  28856. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28857. /**
  28858. * Overwrite the current bounding info
  28859. * @param boundingInfo defines the new bounding info
  28860. * @returns the current mesh
  28861. */
  28862. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28863. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28864. get useBones(): boolean;
  28865. /** @hidden */
  28866. _preActivate(): void;
  28867. /** @hidden */
  28868. _preActivateForIntermediateRendering(renderId: number): void;
  28869. /** @hidden */
  28870. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28871. /** @hidden */
  28872. _postActivate(): void;
  28873. /** @hidden */
  28874. _freeze(): void;
  28875. /** @hidden */
  28876. _unFreeze(): void;
  28877. /**
  28878. * Gets the current world matrix
  28879. * @returns a Matrix
  28880. */
  28881. getWorldMatrix(): Matrix;
  28882. /** @hidden */
  28883. _getWorldMatrixDeterminant(): number;
  28884. /**
  28885. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28886. */
  28887. get isAnInstance(): boolean;
  28888. /**
  28889. * Gets a boolean indicating if this mesh has instances
  28890. */
  28891. get hasInstances(): boolean;
  28892. /**
  28893. * Perform relative position change from the point of view of behind the front of the mesh.
  28894. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28895. * Supports definition of mesh facing forward or backward
  28896. * @param amountRight defines the distance on the right axis
  28897. * @param amountUp defines the distance on the up axis
  28898. * @param amountForward defines the distance on the forward axis
  28899. * @returns the current mesh
  28900. */
  28901. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28902. /**
  28903. * Calculate relative position change from the point of view of behind the front of the mesh.
  28904. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28905. * Supports definition of mesh facing forward or backward
  28906. * @param amountRight defines the distance on the right axis
  28907. * @param amountUp defines the distance on the up axis
  28908. * @param amountForward defines the distance on the forward axis
  28909. * @returns the new displacement vector
  28910. */
  28911. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28912. /**
  28913. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28914. * Supports definition of mesh facing forward or backward
  28915. * @param flipBack defines the flip
  28916. * @param twirlClockwise defines the twirl
  28917. * @param tiltRight defines the tilt
  28918. * @returns the current mesh
  28919. */
  28920. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28921. /**
  28922. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28923. * Supports definition of mesh facing forward or backward.
  28924. * @param flipBack defines the flip
  28925. * @param twirlClockwise defines the twirl
  28926. * @param tiltRight defines the tilt
  28927. * @returns the new rotation vector
  28928. */
  28929. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28930. /**
  28931. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28932. * This means the mesh underlying bounding box and sphere are recomputed.
  28933. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28934. * @returns the current mesh
  28935. */
  28936. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28937. /** @hidden */
  28938. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28939. /** @hidden */
  28940. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28941. /** @hidden */
  28942. _updateBoundingInfo(): AbstractMesh;
  28943. /** @hidden */
  28944. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28945. /** @hidden */
  28946. protected _afterComputeWorldMatrix(): void;
  28947. /** @hidden */
  28948. get _effectiveMesh(): AbstractMesh;
  28949. /**
  28950. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28951. * A mesh is in the frustum if its bounding box intersects the frustum
  28952. * @param frustumPlanes defines the frustum to test
  28953. * @returns true if the mesh is in the frustum planes
  28954. */
  28955. isInFrustum(frustumPlanes: Plane[]): boolean;
  28956. /**
  28957. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28958. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28959. * @param frustumPlanes defines the frustum to test
  28960. * @returns true if the mesh is completely in the frustum planes
  28961. */
  28962. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28963. /**
  28964. * True if the mesh intersects another mesh or a SolidParticle object
  28965. * @param mesh defines a target mesh or SolidParticle to test
  28966. * @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)
  28967. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28968. * @returns true if there is an intersection
  28969. */
  28970. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28971. /**
  28972. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28973. * @param point defines the point to test
  28974. * @returns true if there is an intersection
  28975. */
  28976. intersectsPoint(point: Vector3): boolean;
  28977. /**
  28978. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28979. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28980. */
  28981. get checkCollisions(): boolean;
  28982. set checkCollisions(collisionEnabled: boolean);
  28983. /**
  28984. * Gets Collider object used to compute collisions (not physics)
  28985. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28986. */
  28987. get collider(): Nullable<Collider>;
  28988. /**
  28989. * Move the mesh using collision engine
  28990. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28991. * @param displacement defines the requested displacement vector
  28992. * @returns the current mesh
  28993. */
  28994. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28995. private _onCollisionPositionChange;
  28996. /** @hidden */
  28997. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28998. /** @hidden */
  28999. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29000. /** @hidden */
  29001. _checkCollision(collider: Collider): AbstractMesh;
  29002. /** @hidden */
  29003. _generatePointsArray(): boolean;
  29004. /**
  29005. * Checks if the passed Ray intersects with the mesh
  29006. * @param ray defines the ray to use
  29007. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29008. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29009. * @returns the picking info
  29010. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29011. */
  29012. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29013. /**
  29014. * Clones the current mesh
  29015. * @param name defines the mesh name
  29016. * @param newParent defines the new mesh parent
  29017. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29018. * @returns the new mesh
  29019. */
  29020. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29021. /**
  29022. * Disposes all the submeshes of the current meshnp
  29023. * @returns the current mesh
  29024. */
  29025. releaseSubMeshes(): AbstractMesh;
  29026. /**
  29027. * Releases resources associated with this abstract mesh.
  29028. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29029. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29030. */
  29031. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29032. /**
  29033. * Adds the passed mesh as a child to the current mesh
  29034. * @param mesh defines the child mesh
  29035. * @returns the current mesh
  29036. */
  29037. addChild(mesh: AbstractMesh): AbstractMesh;
  29038. /**
  29039. * Removes the passed mesh from the current mesh children list
  29040. * @param mesh defines the child mesh
  29041. * @returns the current mesh
  29042. */
  29043. removeChild(mesh: AbstractMesh): AbstractMesh;
  29044. /** @hidden */
  29045. private _initFacetData;
  29046. /**
  29047. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29048. * This method can be called within the render loop.
  29049. * 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
  29050. * @returns the current mesh
  29051. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29052. */
  29053. updateFacetData(): AbstractMesh;
  29054. /**
  29055. * Returns the facetLocalNormals array.
  29056. * The normals are expressed in the mesh local spac
  29057. * @returns an array of Vector3
  29058. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29059. */
  29060. getFacetLocalNormals(): Vector3[];
  29061. /**
  29062. * Returns the facetLocalPositions array.
  29063. * The facet positions are expressed in the mesh local space
  29064. * @returns an array of Vector3
  29065. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29066. */
  29067. getFacetLocalPositions(): Vector3[];
  29068. /**
  29069. * Returns the facetLocalPartioning array
  29070. * @returns an array of array of numbers
  29071. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29072. */
  29073. getFacetLocalPartitioning(): number[][];
  29074. /**
  29075. * Returns the i-th facet position in the world system.
  29076. * This method allocates a new Vector3 per call
  29077. * @param i defines the facet index
  29078. * @returns a new Vector3
  29079. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29080. */
  29081. getFacetPosition(i: number): Vector3;
  29082. /**
  29083. * Sets the reference Vector3 with the i-th facet position in the world system
  29084. * @param i defines the facet index
  29085. * @param ref defines the target vector
  29086. * @returns the current mesh
  29087. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29088. */
  29089. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29090. /**
  29091. * Returns the i-th facet normal in the world system.
  29092. * This method allocates a new Vector3 per call
  29093. * @param i defines the facet index
  29094. * @returns a new Vector3
  29095. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29096. */
  29097. getFacetNormal(i: number): Vector3;
  29098. /**
  29099. * Sets the reference Vector3 with the i-th facet normal in the world system
  29100. * @param i defines the facet index
  29101. * @param ref defines the target vector
  29102. * @returns the current mesh
  29103. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29104. */
  29105. getFacetNormalToRef(i: number, ref: Vector3): this;
  29106. /**
  29107. * 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)
  29108. * @param x defines x coordinate
  29109. * @param y defines y coordinate
  29110. * @param z defines z coordinate
  29111. * @returns the array of facet indexes
  29112. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29113. */
  29114. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29115. /**
  29116. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29117. * @param projected sets as the (x,y,z) world projection on the facet
  29118. * @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
  29119. * @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
  29120. * @param x defines x coordinate
  29121. * @param y defines y coordinate
  29122. * @param z defines z coordinate
  29123. * @returns the face index if found (or null instead)
  29124. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29125. */
  29126. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29127. /**
  29128. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29129. * @param projected sets as the (x,y,z) local projection on the facet
  29130. * @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
  29131. * @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
  29132. * @param x defines x coordinate
  29133. * @param y defines y coordinate
  29134. * @param z defines z coordinate
  29135. * @returns the face index if found (or null instead)
  29136. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29137. */
  29138. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29139. /**
  29140. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29141. * @returns the parameters
  29142. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29143. */
  29144. getFacetDataParameters(): any;
  29145. /**
  29146. * Disables the feature FacetData and frees the related memory
  29147. * @returns the current mesh
  29148. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29149. */
  29150. disableFacetData(): AbstractMesh;
  29151. /**
  29152. * Updates the AbstractMesh indices array
  29153. * @param indices defines the data source
  29154. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29155. * @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)
  29156. * @returns the current mesh
  29157. */
  29158. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29159. /**
  29160. * Creates new normals data for the mesh
  29161. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29162. * @returns the current mesh
  29163. */
  29164. createNormals(updatable: boolean): AbstractMesh;
  29165. /**
  29166. * Align the mesh with a normal
  29167. * @param normal defines the normal to use
  29168. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29169. * @returns the current mesh
  29170. */
  29171. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29172. /** @hidden */
  29173. _checkOcclusionQuery(): boolean;
  29174. /**
  29175. * Disables the mesh edge rendering mode
  29176. * @returns the currentAbstractMesh
  29177. */
  29178. disableEdgesRendering(): AbstractMesh;
  29179. /**
  29180. * Enables the edge rendering mode on the mesh.
  29181. * This mode makes the mesh edges visible
  29182. * @param epsilon defines the maximal distance between two angles to detect a face
  29183. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29184. * @returns the currentAbstractMesh
  29185. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29186. */
  29187. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29188. }
  29189. }
  29190. declare module "babylonjs/Actions/actionEvent" {
  29191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29192. import { Nullable } from "babylonjs/types";
  29193. import { Sprite } from "babylonjs/Sprites/sprite";
  29194. import { Scene } from "babylonjs/scene";
  29195. import { Vector2 } from "babylonjs/Maths/math.vector";
  29196. /**
  29197. * Interface used to define ActionEvent
  29198. */
  29199. export interface IActionEvent {
  29200. /** The mesh or sprite that triggered the action */
  29201. source: any;
  29202. /** The X mouse cursor position at the time of the event */
  29203. pointerX: number;
  29204. /** The Y mouse cursor position at the time of the event */
  29205. pointerY: number;
  29206. /** The mesh that is currently pointed at (can be null) */
  29207. meshUnderPointer: Nullable<AbstractMesh>;
  29208. /** the original (browser) event that triggered the ActionEvent */
  29209. sourceEvent?: any;
  29210. /** additional data for the event */
  29211. additionalData?: any;
  29212. }
  29213. /**
  29214. * ActionEvent is the event being sent when an action is triggered.
  29215. */
  29216. export class ActionEvent implements IActionEvent {
  29217. /** The mesh or sprite that triggered the action */
  29218. source: any;
  29219. /** The X mouse cursor position at the time of the event */
  29220. pointerX: number;
  29221. /** The Y mouse cursor position at the time of the event */
  29222. pointerY: number;
  29223. /** The mesh that is currently pointed at (can be null) */
  29224. meshUnderPointer: Nullable<AbstractMesh>;
  29225. /** the original (browser) event that triggered the ActionEvent */
  29226. sourceEvent?: any;
  29227. /** additional data for the event */
  29228. additionalData?: any;
  29229. /**
  29230. * Creates a new ActionEvent
  29231. * @param source The mesh or sprite that triggered the action
  29232. * @param pointerX The X mouse cursor position at the time of the event
  29233. * @param pointerY The Y mouse cursor position at the time of the event
  29234. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29235. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29236. * @param additionalData additional data for the event
  29237. */
  29238. constructor(
  29239. /** The mesh or sprite that triggered the action */
  29240. source: any,
  29241. /** The X mouse cursor position at the time of the event */
  29242. pointerX: number,
  29243. /** The Y mouse cursor position at the time of the event */
  29244. pointerY: number,
  29245. /** The mesh that is currently pointed at (can be null) */
  29246. meshUnderPointer: Nullable<AbstractMesh>,
  29247. /** the original (browser) event that triggered the ActionEvent */
  29248. sourceEvent?: any,
  29249. /** additional data for the event */
  29250. additionalData?: any);
  29251. /**
  29252. * Helper function to auto-create an ActionEvent from a source mesh.
  29253. * @param source The source mesh that triggered the event
  29254. * @param evt The original (browser) event
  29255. * @param additionalData additional data for the event
  29256. * @returns the new ActionEvent
  29257. */
  29258. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29259. /**
  29260. * Helper function to auto-create an ActionEvent from a source sprite
  29261. * @param source The source sprite that triggered the event
  29262. * @param scene Scene associated with the sprite
  29263. * @param evt The original (browser) event
  29264. * @param additionalData additional data for the event
  29265. * @returns the new ActionEvent
  29266. */
  29267. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29268. /**
  29269. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29270. * @param scene the scene where the event occurred
  29271. * @param evt The original (browser) event
  29272. * @returns the new ActionEvent
  29273. */
  29274. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29275. /**
  29276. * Helper function to auto-create an ActionEvent from a primitive
  29277. * @param prim defines the target primitive
  29278. * @param pointerPos defines the pointer position
  29279. * @param evt The original (browser) event
  29280. * @param additionalData additional data for the event
  29281. * @returns the new ActionEvent
  29282. */
  29283. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29284. }
  29285. }
  29286. declare module "babylonjs/Actions/abstractActionManager" {
  29287. import { IDisposable } from "babylonjs/scene";
  29288. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29289. import { IAction } from "babylonjs/Actions/action";
  29290. import { Nullable } from "babylonjs/types";
  29291. /**
  29292. * Abstract class used to decouple action Manager from scene and meshes.
  29293. * Do not instantiate.
  29294. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29295. */
  29296. export abstract class AbstractActionManager implements IDisposable {
  29297. /** Gets the list of active triggers */
  29298. static Triggers: {
  29299. [key: string]: number;
  29300. };
  29301. /** Gets the cursor to use when hovering items */
  29302. hoverCursor: string;
  29303. /** Gets the list of actions */
  29304. actions: IAction[];
  29305. /**
  29306. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29307. */
  29308. isRecursive: boolean;
  29309. /**
  29310. * Releases all associated resources
  29311. */
  29312. abstract dispose(): void;
  29313. /**
  29314. * Does this action manager has pointer triggers
  29315. */
  29316. abstract get hasPointerTriggers(): boolean;
  29317. /**
  29318. * Does this action manager has pick triggers
  29319. */
  29320. abstract get hasPickTriggers(): boolean;
  29321. /**
  29322. * Process a specific trigger
  29323. * @param trigger defines the trigger to process
  29324. * @param evt defines the event details to be processed
  29325. */
  29326. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29327. /**
  29328. * Does this action manager handles actions of any of the given triggers
  29329. * @param triggers defines the triggers to be tested
  29330. * @return a boolean indicating whether one (or more) of the triggers is handled
  29331. */
  29332. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29333. /**
  29334. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29335. * speed.
  29336. * @param triggerA defines the trigger to be tested
  29337. * @param triggerB defines the trigger to be tested
  29338. * @return a boolean indicating whether one (or more) of the triggers is handled
  29339. */
  29340. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29341. /**
  29342. * Does this action manager handles actions of a given trigger
  29343. * @param trigger defines the trigger to be tested
  29344. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29345. * @return whether the trigger is handled
  29346. */
  29347. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29348. /**
  29349. * Serialize this manager to a JSON object
  29350. * @param name defines the property name to store this manager
  29351. * @returns a JSON representation of this manager
  29352. */
  29353. abstract serialize(name: string): any;
  29354. /**
  29355. * Registers an action to this action manager
  29356. * @param action defines the action to be registered
  29357. * @return the action amended (prepared) after registration
  29358. */
  29359. abstract registerAction(action: IAction): Nullable<IAction>;
  29360. /**
  29361. * Unregisters an action to this action manager
  29362. * @param action defines the action to be unregistered
  29363. * @return a boolean indicating whether the action has been unregistered
  29364. */
  29365. abstract unregisterAction(action: IAction): Boolean;
  29366. /**
  29367. * Does exist one action manager with at least one trigger
  29368. **/
  29369. static get HasTriggers(): boolean;
  29370. /**
  29371. * Does exist one action manager with at least one pick trigger
  29372. **/
  29373. static get HasPickTriggers(): boolean;
  29374. /**
  29375. * Does exist one action manager that handles actions of a given trigger
  29376. * @param trigger defines the trigger to be tested
  29377. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29378. **/
  29379. static HasSpecificTrigger(trigger: number): boolean;
  29380. }
  29381. }
  29382. declare module "babylonjs/node" {
  29383. import { Scene } from "babylonjs/scene";
  29384. import { Nullable } from "babylonjs/types";
  29385. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29386. import { Engine } from "babylonjs/Engines/engine";
  29387. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29388. import { Observable } from "babylonjs/Misc/observable";
  29389. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29390. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29391. import { Animatable } from "babylonjs/Animations/animatable";
  29392. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29393. import { Animation } from "babylonjs/Animations/animation";
  29394. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29396. /**
  29397. * Defines how a node can be built from a string name.
  29398. */
  29399. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29400. /**
  29401. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29402. */
  29403. export class Node implements IBehaviorAware<Node> {
  29404. /** @hidden */
  29405. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29406. private static _NodeConstructors;
  29407. /**
  29408. * Add a new node constructor
  29409. * @param type defines the type name of the node to construct
  29410. * @param constructorFunc defines the constructor function
  29411. */
  29412. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29413. /**
  29414. * Returns a node constructor based on type name
  29415. * @param type defines the type name
  29416. * @param name defines the new node name
  29417. * @param scene defines the hosting scene
  29418. * @param options defines optional options to transmit to constructors
  29419. * @returns the new constructor or null
  29420. */
  29421. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29422. /**
  29423. * Gets or sets the name of the node
  29424. */
  29425. name: string;
  29426. /**
  29427. * Gets or sets the id of the node
  29428. */
  29429. id: string;
  29430. /**
  29431. * Gets or sets the unique id of the node
  29432. */
  29433. uniqueId: number;
  29434. /**
  29435. * Gets or sets a string used to store user defined state for the node
  29436. */
  29437. state: string;
  29438. /**
  29439. * Gets or sets an object used to store user defined information for the node
  29440. */
  29441. metadata: any;
  29442. /**
  29443. * For internal use only. Please do not use.
  29444. */
  29445. reservedDataStore: any;
  29446. /**
  29447. * List of inspectable custom properties (used by the Inspector)
  29448. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29449. */
  29450. inspectableCustomProperties: IInspectable[];
  29451. private _doNotSerialize;
  29452. /**
  29453. * Gets or sets a boolean used to define if the node must be serialized
  29454. */
  29455. get doNotSerialize(): boolean;
  29456. set doNotSerialize(value: boolean);
  29457. /** @hidden */
  29458. _isDisposed: boolean;
  29459. /**
  29460. * Gets a list of Animations associated with the node
  29461. */
  29462. animations: import("babylonjs/Animations/animation").Animation[];
  29463. protected _ranges: {
  29464. [name: string]: Nullable<AnimationRange>;
  29465. };
  29466. /**
  29467. * Callback raised when the node is ready to be used
  29468. */
  29469. onReady: Nullable<(node: Node) => void>;
  29470. private _isEnabled;
  29471. private _isParentEnabled;
  29472. private _isReady;
  29473. /** @hidden */
  29474. _currentRenderId: number;
  29475. private _parentUpdateId;
  29476. /** @hidden */
  29477. _childUpdateId: number;
  29478. /** @hidden */
  29479. _waitingParentId: Nullable<string>;
  29480. /** @hidden */
  29481. _scene: Scene;
  29482. /** @hidden */
  29483. _cache: any;
  29484. private _parentNode;
  29485. private _children;
  29486. /** @hidden */
  29487. _worldMatrix: Matrix;
  29488. /** @hidden */
  29489. _worldMatrixDeterminant: number;
  29490. /** @hidden */
  29491. _worldMatrixDeterminantIsDirty: boolean;
  29492. /** @hidden */
  29493. private _sceneRootNodesIndex;
  29494. /**
  29495. * Gets a boolean indicating if the node has been disposed
  29496. * @returns true if the node was disposed
  29497. */
  29498. isDisposed(): boolean;
  29499. /**
  29500. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29501. * @see https://doc.babylonjs.com/how_to/parenting
  29502. */
  29503. set parent(parent: Nullable<Node>);
  29504. get parent(): Nullable<Node>;
  29505. /** @hidden */
  29506. _addToSceneRootNodes(): void;
  29507. /** @hidden */
  29508. _removeFromSceneRootNodes(): void;
  29509. private _animationPropertiesOverride;
  29510. /**
  29511. * Gets or sets the animation properties override
  29512. */
  29513. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29514. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29515. /**
  29516. * Gets a string idenfifying the name of the class
  29517. * @returns "Node" string
  29518. */
  29519. getClassName(): string;
  29520. /** @hidden */
  29521. readonly _isNode: boolean;
  29522. /**
  29523. * An event triggered when the mesh is disposed
  29524. */
  29525. onDisposeObservable: Observable<Node>;
  29526. private _onDisposeObserver;
  29527. /**
  29528. * Sets a callback that will be raised when the node will be disposed
  29529. */
  29530. set onDispose(callback: () => void);
  29531. /**
  29532. * Creates a new Node
  29533. * @param name the name and id to be given to this node
  29534. * @param scene the scene this node will be added to
  29535. */
  29536. constructor(name: string, scene?: Nullable<Scene>);
  29537. /**
  29538. * Gets the scene of the node
  29539. * @returns a scene
  29540. */
  29541. getScene(): Scene;
  29542. /**
  29543. * Gets the engine of the node
  29544. * @returns a Engine
  29545. */
  29546. getEngine(): Engine;
  29547. private _behaviors;
  29548. /**
  29549. * Attach a behavior to the node
  29550. * @see http://doc.babylonjs.com/features/behaviour
  29551. * @param behavior defines the behavior to attach
  29552. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29553. * @returns the current Node
  29554. */
  29555. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29556. /**
  29557. * Remove an attached behavior
  29558. * @see http://doc.babylonjs.com/features/behaviour
  29559. * @param behavior defines the behavior to attach
  29560. * @returns the current Node
  29561. */
  29562. removeBehavior(behavior: Behavior<Node>): Node;
  29563. /**
  29564. * Gets the list of attached behaviors
  29565. * @see http://doc.babylonjs.com/features/behaviour
  29566. */
  29567. get behaviors(): Behavior<Node>[];
  29568. /**
  29569. * Gets an attached behavior by name
  29570. * @param name defines the name of the behavior to look for
  29571. * @see http://doc.babylonjs.com/features/behaviour
  29572. * @returns null if behavior was not found else the requested behavior
  29573. */
  29574. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29575. /**
  29576. * Returns the latest update of the World matrix
  29577. * @returns a Matrix
  29578. */
  29579. getWorldMatrix(): Matrix;
  29580. /** @hidden */
  29581. _getWorldMatrixDeterminant(): number;
  29582. /**
  29583. * Returns directly the latest state of the mesh World matrix.
  29584. * A Matrix is returned.
  29585. */
  29586. get worldMatrixFromCache(): Matrix;
  29587. /** @hidden */
  29588. _initCache(): void;
  29589. /** @hidden */
  29590. updateCache(force?: boolean): void;
  29591. /** @hidden */
  29592. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29593. /** @hidden */
  29594. _updateCache(ignoreParentClass?: boolean): void;
  29595. /** @hidden */
  29596. _isSynchronized(): boolean;
  29597. /** @hidden */
  29598. _markSyncedWithParent(): void;
  29599. /** @hidden */
  29600. isSynchronizedWithParent(): boolean;
  29601. /** @hidden */
  29602. isSynchronized(): boolean;
  29603. /**
  29604. * Is this node ready to be used/rendered
  29605. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29606. * @return true if the node is ready
  29607. */
  29608. isReady(completeCheck?: boolean): boolean;
  29609. /**
  29610. * Is this node enabled?
  29611. * 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
  29612. * @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
  29613. * @return whether this node (and its parent) is enabled
  29614. */
  29615. isEnabled(checkAncestors?: boolean): boolean;
  29616. /** @hidden */
  29617. protected _syncParentEnabledState(): void;
  29618. /**
  29619. * Set the enabled state of this node
  29620. * @param value defines the new enabled state
  29621. */
  29622. setEnabled(value: boolean): void;
  29623. /**
  29624. * Is this node a descendant of the given node?
  29625. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29626. * @param ancestor defines the parent node to inspect
  29627. * @returns a boolean indicating if this node is a descendant of the given node
  29628. */
  29629. isDescendantOf(ancestor: Node): boolean;
  29630. /** @hidden */
  29631. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29632. /**
  29633. * Will return all nodes that have this node as ascendant
  29634. * @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
  29635. * @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
  29636. * @return all children nodes of all types
  29637. */
  29638. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29639. /**
  29640. * Get all child-meshes of this node
  29641. * @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)
  29642. * @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
  29643. * @returns an array of AbstractMesh
  29644. */
  29645. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29646. /**
  29647. * Get all direct children of this node
  29648. * @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
  29649. * @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)
  29650. * @returns an array of Node
  29651. */
  29652. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29653. /** @hidden */
  29654. _setReady(state: boolean): void;
  29655. /**
  29656. * Get an animation by name
  29657. * @param name defines the name of the animation to look for
  29658. * @returns null if not found else the requested animation
  29659. */
  29660. getAnimationByName(name: string): Nullable<Animation>;
  29661. /**
  29662. * Creates an animation range for this node
  29663. * @param name defines the name of the range
  29664. * @param from defines the starting key
  29665. * @param to defines the end key
  29666. */
  29667. createAnimationRange(name: string, from: number, to: number): void;
  29668. /**
  29669. * Delete a specific animation range
  29670. * @param name defines the name of the range to delete
  29671. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29672. */
  29673. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29674. /**
  29675. * Get an animation range by name
  29676. * @param name defines the name of the animation range to look for
  29677. * @returns null if not found else the requested animation range
  29678. */
  29679. getAnimationRange(name: string): Nullable<AnimationRange>;
  29680. /**
  29681. * Gets the list of all animation ranges defined on this node
  29682. * @returns an array
  29683. */
  29684. getAnimationRanges(): Nullable<AnimationRange>[];
  29685. /**
  29686. * Will start the animation sequence
  29687. * @param name defines the range frames for animation sequence
  29688. * @param loop defines if the animation should loop (false by default)
  29689. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29690. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29691. * @returns the object created for this animation. If range does not exist, it will return null
  29692. */
  29693. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29694. /**
  29695. * Serialize animation ranges into a JSON compatible object
  29696. * @returns serialization object
  29697. */
  29698. serializeAnimationRanges(): any;
  29699. /**
  29700. * Computes the world matrix of the node
  29701. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29702. * @returns the world matrix
  29703. */
  29704. computeWorldMatrix(force?: boolean): Matrix;
  29705. /**
  29706. * Releases resources associated with this node.
  29707. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29708. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29709. */
  29710. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29711. /**
  29712. * Parse animation range data from a serialization object and store them into a given node
  29713. * @param node defines where to store the animation ranges
  29714. * @param parsedNode defines the serialization object to read data from
  29715. * @param scene defines the hosting scene
  29716. */
  29717. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29718. /**
  29719. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29720. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29721. * @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
  29722. * @returns the new bounding vectors
  29723. */
  29724. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29725. min: Vector3;
  29726. max: Vector3;
  29727. };
  29728. }
  29729. }
  29730. declare module "babylonjs/Animations/animation" {
  29731. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29732. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29733. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29734. import { Nullable } from "babylonjs/types";
  29735. import { Scene } from "babylonjs/scene";
  29736. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29737. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29738. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29739. import { Node } from "babylonjs/node";
  29740. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29741. import { Size } from "babylonjs/Maths/math.size";
  29742. import { Animatable } from "babylonjs/Animations/animatable";
  29743. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  29744. /**
  29745. * @hidden
  29746. */
  29747. export class _IAnimationState {
  29748. key: number;
  29749. repeatCount: number;
  29750. workValue?: any;
  29751. loopMode?: number;
  29752. offsetValue?: any;
  29753. highLimitValue?: any;
  29754. }
  29755. /**
  29756. * Class used to store any kind of animation
  29757. */
  29758. export class Animation {
  29759. /**Name of the animation */
  29760. name: string;
  29761. /**Property to animate */
  29762. targetProperty: string;
  29763. /**The frames per second of the animation */
  29764. framePerSecond: number;
  29765. /**The data type of the animation */
  29766. dataType: number;
  29767. /**The loop mode of the animation */
  29768. loopMode?: number | undefined;
  29769. /**Specifies if blending should be enabled */
  29770. enableBlending?: boolean | undefined;
  29771. /**
  29772. * Use matrix interpolation instead of using direct key value when animating matrices
  29773. */
  29774. static AllowMatricesInterpolation: boolean;
  29775. /**
  29776. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29777. */
  29778. static AllowMatrixDecomposeForInterpolation: boolean;
  29779. /**
  29780. * Stores the key frames of the animation
  29781. */
  29782. private _keys;
  29783. /**
  29784. * Stores the easing function of the animation
  29785. */
  29786. private _easingFunction;
  29787. /**
  29788. * @hidden Internal use only
  29789. */
  29790. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  29791. /**
  29792. * The set of event that will be linked to this animation
  29793. */
  29794. private _events;
  29795. /**
  29796. * Stores an array of target property paths
  29797. */
  29798. targetPropertyPath: string[];
  29799. /**
  29800. * Stores the blending speed of the animation
  29801. */
  29802. blendingSpeed: number;
  29803. /**
  29804. * Stores the animation ranges for the animation
  29805. */
  29806. private _ranges;
  29807. /**
  29808. * @hidden Internal use
  29809. */
  29810. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29811. /**
  29812. * Sets up an animation
  29813. * @param property The property to animate
  29814. * @param animationType The animation type to apply
  29815. * @param framePerSecond The frames per second of the animation
  29816. * @param easingFunction The easing function used in the animation
  29817. * @returns The created animation
  29818. */
  29819. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29820. /**
  29821. * Create and start an animation on a node
  29822. * @param name defines the name of the global animation that will be run on all nodes
  29823. * @param node defines the root node where the animation will take place
  29824. * @param targetProperty defines property to animate
  29825. * @param framePerSecond defines the number of frame per second yo use
  29826. * @param totalFrame defines the number of frames in total
  29827. * @param from defines the initial value
  29828. * @param to defines the final value
  29829. * @param loopMode defines which loop mode you want to use (off by default)
  29830. * @param easingFunction defines the easing function to use (linear by default)
  29831. * @param onAnimationEnd defines the callback to call when animation end
  29832. * @returns the animatable created for this animation
  29833. */
  29834. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29835. /**
  29836. * Create and start an animation on a node and its descendants
  29837. * @param name defines the name of the global animation that will be run on all nodes
  29838. * @param node defines the root node where the animation will take place
  29839. * @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
  29840. * @param targetProperty defines property to animate
  29841. * @param framePerSecond defines the number of frame per second to use
  29842. * @param totalFrame defines the number of frames in total
  29843. * @param from defines the initial value
  29844. * @param to defines the final value
  29845. * @param loopMode defines which loop mode you want to use (off by default)
  29846. * @param easingFunction defines the easing function to use (linear by default)
  29847. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29848. * @returns the list of animatables created for all nodes
  29849. * @example https://www.babylonjs-playground.com/#MH0VLI
  29850. */
  29851. 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[]>;
  29852. /**
  29853. * Creates a new animation, merges it with the existing animations and starts it
  29854. * @param name Name of the animation
  29855. * @param node Node which contains the scene that begins the animations
  29856. * @param targetProperty Specifies which property to animate
  29857. * @param framePerSecond The frames per second of the animation
  29858. * @param totalFrame The total number of frames
  29859. * @param from The frame at the beginning of the animation
  29860. * @param to The frame at the end of the animation
  29861. * @param loopMode Specifies the loop mode of the animation
  29862. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29863. * @param onAnimationEnd Callback to run once the animation is complete
  29864. * @returns Nullable animation
  29865. */
  29866. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29867. /**
  29868. * Transition property of an host to the target Value
  29869. * @param property The property to transition
  29870. * @param targetValue The target Value of the property
  29871. * @param host The object where the property to animate belongs
  29872. * @param scene Scene used to run the animation
  29873. * @param frameRate Framerate (in frame/s) to use
  29874. * @param transition The transition type we want to use
  29875. * @param duration The duration of the animation, in milliseconds
  29876. * @param onAnimationEnd Callback trigger at the end of the animation
  29877. * @returns Nullable animation
  29878. */
  29879. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29880. /**
  29881. * Return the array of runtime animations currently using this animation
  29882. */
  29883. get runtimeAnimations(): RuntimeAnimation[];
  29884. /**
  29885. * Specifies if any of the runtime animations are currently running
  29886. */
  29887. get hasRunningRuntimeAnimations(): boolean;
  29888. /**
  29889. * Initializes the animation
  29890. * @param name Name of the animation
  29891. * @param targetProperty Property to animate
  29892. * @param framePerSecond The frames per second of the animation
  29893. * @param dataType The data type of the animation
  29894. * @param loopMode The loop mode of the animation
  29895. * @param enableBlending Specifies if blending should be enabled
  29896. */
  29897. constructor(
  29898. /**Name of the animation */
  29899. name: string,
  29900. /**Property to animate */
  29901. targetProperty: string,
  29902. /**The frames per second of the animation */
  29903. framePerSecond: number,
  29904. /**The data type of the animation */
  29905. dataType: number,
  29906. /**The loop mode of the animation */
  29907. loopMode?: number | undefined,
  29908. /**Specifies if blending should be enabled */
  29909. enableBlending?: boolean | undefined);
  29910. /**
  29911. * Converts the animation to a string
  29912. * @param fullDetails support for multiple levels of logging within scene loading
  29913. * @returns String form of the animation
  29914. */
  29915. toString(fullDetails?: boolean): string;
  29916. /**
  29917. * Add an event to this animation
  29918. * @param event Event to add
  29919. */
  29920. addEvent(event: AnimationEvent): void;
  29921. /**
  29922. * Remove all events found at the given frame
  29923. * @param frame The frame to remove events from
  29924. */
  29925. removeEvents(frame: number): void;
  29926. /**
  29927. * Retrieves all the events from the animation
  29928. * @returns Events from the animation
  29929. */
  29930. getEvents(): AnimationEvent[];
  29931. /**
  29932. * Creates an animation range
  29933. * @param name Name of the animation range
  29934. * @param from Starting frame of the animation range
  29935. * @param to Ending frame of the animation
  29936. */
  29937. createRange(name: string, from: number, to: number): void;
  29938. /**
  29939. * Deletes an animation range by name
  29940. * @param name Name of the animation range to delete
  29941. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29942. */
  29943. deleteRange(name: string, deleteFrames?: boolean): void;
  29944. /**
  29945. * Gets the animation range by name, or null if not defined
  29946. * @param name Name of the animation range
  29947. * @returns Nullable animation range
  29948. */
  29949. getRange(name: string): Nullable<AnimationRange>;
  29950. /**
  29951. * Gets the key frames from the animation
  29952. * @returns The key frames of the animation
  29953. */
  29954. getKeys(): Array<IAnimationKey>;
  29955. /**
  29956. * Gets the highest frame rate of the animation
  29957. * @returns Highest frame rate of the animation
  29958. */
  29959. getHighestFrame(): number;
  29960. /**
  29961. * Gets the easing function of the animation
  29962. * @returns Easing function of the animation
  29963. */
  29964. getEasingFunction(): IEasingFunction;
  29965. /**
  29966. * Sets the easing function of the animation
  29967. * @param easingFunction A custom mathematical formula for animation
  29968. */
  29969. setEasingFunction(easingFunction: EasingFunction): void;
  29970. /**
  29971. * Interpolates a scalar linearly
  29972. * @param startValue Start value of the animation curve
  29973. * @param endValue End value of the animation curve
  29974. * @param gradient Scalar amount to interpolate
  29975. * @returns Interpolated scalar value
  29976. */
  29977. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29978. /**
  29979. * Interpolates a scalar cubically
  29980. * @param startValue Start value of the animation curve
  29981. * @param outTangent End tangent of the animation
  29982. * @param endValue End value of the animation curve
  29983. * @param inTangent Start tangent of the animation curve
  29984. * @param gradient Scalar amount to interpolate
  29985. * @returns Interpolated scalar value
  29986. */
  29987. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29988. /**
  29989. * Interpolates a quaternion using a spherical linear interpolation
  29990. * @param startValue Start value of the animation curve
  29991. * @param endValue End value of the animation curve
  29992. * @param gradient Scalar amount to interpolate
  29993. * @returns Interpolated quaternion value
  29994. */
  29995. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29996. /**
  29997. * Interpolates a quaternion cubically
  29998. * @param startValue Start value of the animation curve
  29999. * @param outTangent End tangent of the animation curve
  30000. * @param endValue End value of the animation curve
  30001. * @param inTangent Start tangent of the animation curve
  30002. * @param gradient Scalar amount to interpolate
  30003. * @returns Interpolated quaternion value
  30004. */
  30005. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30006. /**
  30007. * Interpolates a Vector3 linearl
  30008. * @param startValue Start value of the animation curve
  30009. * @param endValue End value of the animation curve
  30010. * @param gradient Scalar amount to interpolate
  30011. * @returns Interpolated scalar value
  30012. */
  30013. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30014. /**
  30015. * Interpolates a Vector3 cubically
  30016. * @param startValue Start value of the animation curve
  30017. * @param outTangent End tangent of the animation
  30018. * @param endValue End value of the animation curve
  30019. * @param inTangent Start tangent of the animation curve
  30020. * @param gradient Scalar amount to interpolate
  30021. * @returns InterpolatedVector3 value
  30022. */
  30023. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30024. /**
  30025. * Interpolates a Vector2 linearly
  30026. * @param startValue Start value of the animation curve
  30027. * @param endValue End value of the animation curve
  30028. * @param gradient Scalar amount to interpolate
  30029. * @returns Interpolated Vector2 value
  30030. */
  30031. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30032. /**
  30033. * Interpolates a Vector2 cubically
  30034. * @param startValue Start value of the animation curve
  30035. * @param outTangent End tangent of the animation
  30036. * @param endValue End value of the animation curve
  30037. * @param inTangent Start tangent of the animation curve
  30038. * @param gradient Scalar amount to interpolate
  30039. * @returns Interpolated Vector2 value
  30040. */
  30041. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30042. /**
  30043. * Interpolates a size linearly
  30044. * @param startValue Start value of the animation curve
  30045. * @param endValue End value of the animation curve
  30046. * @param gradient Scalar amount to interpolate
  30047. * @returns Interpolated Size value
  30048. */
  30049. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30050. /**
  30051. * Interpolates a Color3 linearly
  30052. * @param startValue Start value of the animation curve
  30053. * @param endValue End value of the animation curve
  30054. * @param gradient Scalar amount to interpolate
  30055. * @returns Interpolated Color3 value
  30056. */
  30057. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30058. /**
  30059. * Interpolates a Color4 linearly
  30060. * @param startValue Start value of the animation curve
  30061. * @param endValue End value of the animation curve
  30062. * @param gradient Scalar amount to interpolate
  30063. * @returns Interpolated Color3 value
  30064. */
  30065. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30066. /**
  30067. * @hidden Internal use only
  30068. */
  30069. _getKeyValue(value: any): any;
  30070. /**
  30071. * @hidden Internal use only
  30072. */
  30073. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30074. /**
  30075. * Defines the function to use to interpolate matrices
  30076. * @param startValue defines the start matrix
  30077. * @param endValue defines the end matrix
  30078. * @param gradient defines the gradient between both matrices
  30079. * @param result defines an optional target matrix where to store the interpolation
  30080. * @returns the interpolated matrix
  30081. */
  30082. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30083. /**
  30084. * Makes a copy of the animation
  30085. * @returns Cloned animation
  30086. */
  30087. clone(): Animation;
  30088. /**
  30089. * Sets the key frames of the animation
  30090. * @param values The animation key frames to set
  30091. */
  30092. setKeys(values: Array<IAnimationKey>): void;
  30093. /**
  30094. * Serializes the animation to an object
  30095. * @returns Serialized object
  30096. */
  30097. serialize(): any;
  30098. /**
  30099. * Float animation type
  30100. */
  30101. static readonly ANIMATIONTYPE_FLOAT: number;
  30102. /**
  30103. * Vector3 animation type
  30104. */
  30105. static readonly ANIMATIONTYPE_VECTOR3: number;
  30106. /**
  30107. * Quaternion animation type
  30108. */
  30109. static readonly ANIMATIONTYPE_QUATERNION: number;
  30110. /**
  30111. * Matrix animation type
  30112. */
  30113. static readonly ANIMATIONTYPE_MATRIX: number;
  30114. /**
  30115. * Color3 animation type
  30116. */
  30117. static readonly ANIMATIONTYPE_COLOR3: number;
  30118. /**
  30119. * Color3 animation type
  30120. */
  30121. static readonly ANIMATIONTYPE_COLOR4: number;
  30122. /**
  30123. * Vector2 animation type
  30124. */
  30125. static readonly ANIMATIONTYPE_VECTOR2: number;
  30126. /**
  30127. * Size animation type
  30128. */
  30129. static readonly ANIMATIONTYPE_SIZE: number;
  30130. /**
  30131. * Relative Loop Mode
  30132. */
  30133. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30134. /**
  30135. * Cycle Loop Mode
  30136. */
  30137. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30138. /**
  30139. * Constant Loop Mode
  30140. */
  30141. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30142. /** @hidden */
  30143. static _UniversalLerp(left: any, right: any, amount: number): any;
  30144. /**
  30145. * Parses an animation object and creates an animation
  30146. * @param parsedAnimation Parsed animation object
  30147. * @returns Animation object
  30148. */
  30149. static Parse(parsedAnimation: any): Animation;
  30150. /**
  30151. * Appends the serialized animations from the source animations
  30152. * @param source Source containing the animations
  30153. * @param destination Target to store the animations
  30154. */
  30155. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30156. }
  30157. }
  30158. declare module "babylonjs/Animations/animatable.interface" {
  30159. import { Nullable } from "babylonjs/types";
  30160. import { Animation } from "babylonjs/Animations/animation";
  30161. /**
  30162. * Interface containing an array of animations
  30163. */
  30164. export interface IAnimatable {
  30165. /**
  30166. * Array of animations
  30167. */
  30168. animations: Nullable<Array<Animation>>;
  30169. }
  30170. }
  30171. declare module "babylonjs/Misc/decorators" {
  30172. import { Nullable } from "babylonjs/types";
  30173. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30174. import { Scene } from "babylonjs/scene";
  30175. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30176. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30177. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30178. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30179. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30180. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30181. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30182. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30183. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30184. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30185. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30186. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30187. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30188. /**
  30189. * Decorator used to define property that can be serialized as reference to a camera
  30190. * @param sourceName defines the name of the property to decorate
  30191. */
  30192. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30193. /**
  30194. * Class used to help serialization objects
  30195. */
  30196. export class SerializationHelper {
  30197. /** @hidden */
  30198. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30199. /** @hidden */
  30200. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30201. /** @hidden */
  30202. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30203. /** @hidden */
  30204. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30205. /**
  30206. * Appends the serialized animations from the source animations
  30207. * @param source Source containing the animations
  30208. * @param destination Target to store the animations
  30209. */
  30210. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30211. /**
  30212. * Static function used to serialized a specific entity
  30213. * @param entity defines the entity to serialize
  30214. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30215. * @returns a JSON compatible object representing the serialization of the entity
  30216. */
  30217. static Serialize<T>(entity: T, serializationObject?: any): any;
  30218. /**
  30219. * Creates a new entity from a serialization data object
  30220. * @param creationFunction defines a function used to instanciated the new entity
  30221. * @param source defines the source serialization data
  30222. * @param scene defines the hosting scene
  30223. * @param rootUrl defines the root url for resources
  30224. * @returns a new entity
  30225. */
  30226. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30227. /**
  30228. * Clones an object
  30229. * @param creationFunction defines the function used to instanciate the new object
  30230. * @param source defines the source object
  30231. * @returns the cloned object
  30232. */
  30233. static Clone<T>(creationFunction: () => T, source: T): T;
  30234. /**
  30235. * Instanciates a new object based on a source one (some data will be shared between both object)
  30236. * @param creationFunction defines the function used to instanciate the new object
  30237. * @param source defines the source object
  30238. * @returns the new object
  30239. */
  30240. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30241. }
  30242. }
  30243. declare module "babylonjs/Misc/guid" {
  30244. /**
  30245. * Class used to manipulate GUIDs
  30246. */
  30247. export class GUID {
  30248. /**
  30249. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30250. * Be aware Math.random() could cause collisions, but:
  30251. * "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"
  30252. * @returns a pseudo random id
  30253. */
  30254. static RandomId(): string;
  30255. }
  30256. }
  30257. declare module "babylonjs/Materials/Textures/baseTexture" {
  30258. import { Observable } from "babylonjs/Misc/observable";
  30259. import { Nullable } from "babylonjs/types";
  30260. import { Scene } from "babylonjs/scene";
  30261. import { Matrix } from "babylonjs/Maths/math.vector";
  30262. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30263. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30264. import { ISize } from "babylonjs/Maths/math.size";
  30265. import "babylonjs/Misc/fileTools";
  30266. /**
  30267. * Base class of all the textures in babylon.
  30268. * It groups all the common properties the materials, post process, lights... might need
  30269. * in order to make a correct use of the texture.
  30270. */
  30271. export class BaseTexture implements IAnimatable {
  30272. /**
  30273. * Default anisotropic filtering level for the application.
  30274. * It is set to 4 as a good tradeoff between perf and quality.
  30275. */
  30276. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30277. /**
  30278. * Gets or sets the unique id of the texture
  30279. */
  30280. uniqueId: number;
  30281. /**
  30282. * Define the name of the texture.
  30283. */
  30284. name: string;
  30285. /**
  30286. * Gets or sets an object used to store user defined information.
  30287. */
  30288. metadata: any;
  30289. /**
  30290. * For internal use only. Please do not use.
  30291. */
  30292. reservedDataStore: any;
  30293. private _hasAlpha;
  30294. /**
  30295. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30296. */
  30297. set hasAlpha(value: boolean);
  30298. get hasAlpha(): boolean;
  30299. /**
  30300. * Defines if the alpha value should be determined via the rgb values.
  30301. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30302. */
  30303. getAlphaFromRGB: boolean;
  30304. /**
  30305. * Intensity or strength of the texture.
  30306. * It is commonly used by materials to fine tune the intensity of the texture
  30307. */
  30308. level: number;
  30309. /**
  30310. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30311. * This is part of the texture as textures usually maps to one uv set.
  30312. */
  30313. coordinatesIndex: number;
  30314. private _coordinatesMode;
  30315. /**
  30316. * How a texture is mapped.
  30317. *
  30318. * | Value | Type | Description |
  30319. * | ----- | ----------------------------------- | ----------- |
  30320. * | 0 | EXPLICIT_MODE | |
  30321. * | 1 | SPHERICAL_MODE | |
  30322. * | 2 | PLANAR_MODE | |
  30323. * | 3 | CUBIC_MODE | |
  30324. * | 4 | PROJECTION_MODE | |
  30325. * | 5 | SKYBOX_MODE | |
  30326. * | 6 | INVCUBIC_MODE | |
  30327. * | 7 | EQUIRECTANGULAR_MODE | |
  30328. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30329. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30330. */
  30331. set coordinatesMode(value: number);
  30332. get coordinatesMode(): number;
  30333. /**
  30334. * | Value | Type | Description |
  30335. * | ----- | ------------------ | ----------- |
  30336. * | 0 | CLAMP_ADDRESSMODE | |
  30337. * | 1 | WRAP_ADDRESSMODE | |
  30338. * | 2 | MIRROR_ADDRESSMODE | |
  30339. */
  30340. wrapU: number;
  30341. /**
  30342. * | Value | Type | Description |
  30343. * | ----- | ------------------ | ----------- |
  30344. * | 0 | CLAMP_ADDRESSMODE | |
  30345. * | 1 | WRAP_ADDRESSMODE | |
  30346. * | 2 | MIRROR_ADDRESSMODE | |
  30347. */
  30348. wrapV: number;
  30349. /**
  30350. * | Value | Type | Description |
  30351. * | ----- | ------------------ | ----------- |
  30352. * | 0 | CLAMP_ADDRESSMODE | |
  30353. * | 1 | WRAP_ADDRESSMODE | |
  30354. * | 2 | MIRROR_ADDRESSMODE | |
  30355. */
  30356. wrapR: number;
  30357. /**
  30358. * With compliant hardware and browser (supporting anisotropic filtering)
  30359. * this defines the level of anisotropic filtering in the texture.
  30360. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30361. */
  30362. anisotropicFilteringLevel: number;
  30363. /**
  30364. * Define if the texture is a cube texture or if false a 2d texture.
  30365. */
  30366. get isCube(): boolean;
  30367. set isCube(value: boolean);
  30368. /**
  30369. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30370. */
  30371. get is3D(): boolean;
  30372. set is3D(value: boolean);
  30373. /**
  30374. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30375. */
  30376. get is2DArray(): boolean;
  30377. set is2DArray(value: boolean);
  30378. /**
  30379. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30380. * HDR texture are usually stored in linear space.
  30381. * This only impacts the PBR and Background materials
  30382. */
  30383. gammaSpace: boolean;
  30384. /**
  30385. * Gets or sets whether or not the texture contains RGBD data.
  30386. */
  30387. get isRGBD(): boolean;
  30388. set isRGBD(value: boolean);
  30389. /**
  30390. * Is Z inverted in the texture (useful in a cube texture).
  30391. */
  30392. invertZ: boolean;
  30393. /**
  30394. * Are mip maps generated for this texture or not.
  30395. */
  30396. get noMipmap(): boolean;
  30397. /**
  30398. * @hidden
  30399. */
  30400. lodLevelInAlpha: boolean;
  30401. /**
  30402. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30403. */
  30404. get lodGenerationOffset(): number;
  30405. set lodGenerationOffset(value: number);
  30406. /**
  30407. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30408. */
  30409. get lodGenerationScale(): number;
  30410. set lodGenerationScale(value: number);
  30411. /**
  30412. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30413. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30414. * average roughness values.
  30415. */
  30416. get linearSpecularLOD(): boolean;
  30417. set linearSpecularLOD(value: boolean);
  30418. /**
  30419. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30420. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30421. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30422. */
  30423. get irradianceTexture(): Nullable<BaseTexture>;
  30424. set irradianceTexture(value: Nullable<BaseTexture>);
  30425. /**
  30426. * Define if the texture is a render target.
  30427. */
  30428. isRenderTarget: boolean;
  30429. /**
  30430. * Define the unique id of the texture in the scene.
  30431. */
  30432. get uid(): string;
  30433. /**
  30434. * Return a string representation of the texture.
  30435. * @returns the texture as a string
  30436. */
  30437. toString(): string;
  30438. /**
  30439. * Get the class name of the texture.
  30440. * @returns "BaseTexture"
  30441. */
  30442. getClassName(): string;
  30443. /**
  30444. * Define the list of animation attached to the texture.
  30445. */
  30446. animations: import("babylonjs/Animations/animation").Animation[];
  30447. /**
  30448. * An event triggered when the texture is disposed.
  30449. */
  30450. onDisposeObservable: Observable<BaseTexture>;
  30451. private _onDisposeObserver;
  30452. /**
  30453. * Callback triggered when the texture has been disposed.
  30454. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30455. */
  30456. set onDispose(callback: () => void);
  30457. /**
  30458. * Define the current state of the loading sequence when in delayed load mode.
  30459. */
  30460. delayLoadState: number;
  30461. private _scene;
  30462. /** @hidden */
  30463. _texture: Nullable<InternalTexture>;
  30464. private _uid;
  30465. /**
  30466. * Define if the texture is preventinga material to render or not.
  30467. * If not and the texture is not ready, the engine will use a default black texture instead.
  30468. */
  30469. get isBlocking(): boolean;
  30470. /**
  30471. * Instantiates a new BaseTexture.
  30472. * Base class of all the textures in babylon.
  30473. * It groups all the common properties the materials, post process, lights... might need
  30474. * in order to make a correct use of the texture.
  30475. * @param scene Define the scene the texture blongs to
  30476. */
  30477. constructor(scene: Nullable<Scene>);
  30478. /**
  30479. * Get the scene the texture belongs to.
  30480. * @returns the scene or null if undefined
  30481. */
  30482. getScene(): Nullable<Scene>;
  30483. /**
  30484. * Get the texture transform matrix used to offset tile the texture for istance.
  30485. * @returns the transformation matrix
  30486. */
  30487. getTextureMatrix(): Matrix;
  30488. /**
  30489. * Get the texture reflection matrix used to rotate/transform the reflection.
  30490. * @returns the reflection matrix
  30491. */
  30492. getReflectionTextureMatrix(): Matrix;
  30493. /**
  30494. * Get the underlying lower level texture from Babylon.
  30495. * @returns the insternal texture
  30496. */
  30497. getInternalTexture(): Nullable<InternalTexture>;
  30498. /**
  30499. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30500. * @returns true if ready or not blocking
  30501. */
  30502. isReadyOrNotBlocking(): boolean;
  30503. /**
  30504. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30505. * @returns true if fully ready
  30506. */
  30507. isReady(): boolean;
  30508. private _cachedSize;
  30509. /**
  30510. * Get the size of the texture.
  30511. * @returns the texture size.
  30512. */
  30513. getSize(): ISize;
  30514. /**
  30515. * Get the base size of the texture.
  30516. * It can be different from the size if the texture has been resized for POT for instance
  30517. * @returns the base size
  30518. */
  30519. getBaseSize(): ISize;
  30520. /**
  30521. * Update the sampling mode of the texture.
  30522. * Default is Trilinear mode.
  30523. *
  30524. * | Value | Type | Description |
  30525. * | ----- | ------------------ | ----------- |
  30526. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30527. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30528. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30529. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30530. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30531. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30532. * | 7 | NEAREST_LINEAR | |
  30533. * | 8 | NEAREST_NEAREST | |
  30534. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30535. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30536. * | 11 | LINEAR_LINEAR | |
  30537. * | 12 | LINEAR_NEAREST | |
  30538. *
  30539. * > _mag_: magnification filter (close to the viewer)
  30540. * > _min_: minification filter (far from the viewer)
  30541. * > _mip_: filter used between mip map levels
  30542. *@param samplingMode Define the new sampling mode of the texture
  30543. */
  30544. updateSamplingMode(samplingMode: number): void;
  30545. /**
  30546. * Scales the texture if is `canRescale()`
  30547. * @param ratio the resize factor we want to use to rescale
  30548. */
  30549. scale(ratio: number): void;
  30550. /**
  30551. * Get if the texture can rescale.
  30552. */
  30553. get canRescale(): boolean;
  30554. /** @hidden */
  30555. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30556. /** @hidden */
  30557. _rebuild(): void;
  30558. /**
  30559. * Triggers the load sequence in delayed load mode.
  30560. */
  30561. delayLoad(): void;
  30562. /**
  30563. * Clones the texture.
  30564. * @returns the cloned texture
  30565. */
  30566. clone(): Nullable<BaseTexture>;
  30567. /**
  30568. * Get the texture underlying type (INT, FLOAT...)
  30569. */
  30570. get textureType(): number;
  30571. /**
  30572. * Get the texture underlying format (RGB, RGBA...)
  30573. */
  30574. get textureFormat(): number;
  30575. /**
  30576. * Indicates that textures need to be re-calculated for all materials
  30577. */
  30578. protected _markAllSubMeshesAsTexturesDirty(): void;
  30579. /**
  30580. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30581. * This will returns an RGBA array buffer containing either in values (0-255) or
  30582. * float values (0-1) depending of the underlying buffer type.
  30583. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30584. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30585. * @param buffer defines a user defined buffer to fill with data (can be null)
  30586. * @returns The Array buffer containing the pixels data.
  30587. */
  30588. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30589. /**
  30590. * Release and destroy the underlying lower level texture aka internalTexture.
  30591. */
  30592. releaseInternalTexture(): void;
  30593. /** @hidden */
  30594. get _lodTextureHigh(): Nullable<BaseTexture>;
  30595. /** @hidden */
  30596. get _lodTextureMid(): Nullable<BaseTexture>;
  30597. /** @hidden */
  30598. get _lodTextureLow(): Nullable<BaseTexture>;
  30599. /**
  30600. * Dispose the texture and release its associated resources.
  30601. */
  30602. dispose(): void;
  30603. /**
  30604. * Serialize the texture into a JSON representation that can be parsed later on.
  30605. * @returns the JSON representation of the texture
  30606. */
  30607. serialize(): any;
  30608. /**
  30609. * Helper function to be called back once a list of texture contains only ready textures.
  30610. * @param textures Define the list of textures to wait for
  30611. * @param callback Define the callback triggered once the entire list will be ready
  30612. */
  30613. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30614. }
  30615. }
  30616. declare module "babylonjs/Materials/effect" {
  30617. import { Observable } from "babylonjs/Misc/observable";
  30618. import { Nullable } from "babylonjs/types";
  30619. import { IDisposable } from "babylonjs/scene";
  30620. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30621. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30622. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30623. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30624. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30625. import { Engine } from "babylonjs/Engines/engine";
  30626. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30627. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30628. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30629. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30630. /**
  30631. * Options to be used when creating an effect.
  30632. */
  30633. export interface IEffectCreationOptions {
  30634. /**
  30635. * Atrributes that will be used in the shader.
  30636. */
  30637. attributes: string[];
  30638. /**
  30639. * Uniform varible names that will be set in the shader.
  30640. */
  30641. uniformsNames: string[];
  30642. /**
  30643. * Uniform buffer variable names that will be set in the shader.
  30644. */
  30645. uniformBuffersNames: string[];
  30646. /**
  30647. * Sampler texture variable names that will be set in the shader.
  30648. */
  30649. samplers: string[];
  30650. /**
  30651. * Define statements that will be set in the shader.
  30652. */
  30653. defines: any;
  30654. /**
  30655. * Possible fallbacks for this effect to improve performance when needed.
  30656. */
  30657. fallbacks: Nullable<IEffectFallbacks>;
  30658. /**
  30659. * Callback that will be called when the shader is compiled.
  30660. */
  30661. onCompiled: Nullable<(effect: Effect) => void>;
  30662. /**
  30663. * Callback that will be called if an error occurs during shader compilation.
  30664. */
  30665. onError: Nullable<(effect: Effect, errors: string) => void>;
  30666. /**
  30667. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30668. */
  30669. indexParameters?: any;
  30670. /**
  30671. * Max number of lights that can be used in the shader.
  30672. */
  30673. maxSimultaneousLights?: number;
  30674. /**
  30675. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30676. */
  30677. transformFeedbackVaryings?: Nullable<string[]>;
  30678. }
  30679. /**
  30680. * Effect containing vertex and fragment shader that can be executed on an object.
  30681. */
  30682. export class Effect implements IDisposable {
  30683. /**
  30684. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30685. */
  30686. static ShadersRepository: string;
  30687. /**
  30688. * Name of the effect.
  30689. */
  30690. name: any;
  30691. /**
  30692. * String container all the define statements that should be set on the shader.
  30693. */
  30694. defines: string;
  30695. /**
  30696. * Callback that will be called when the shader is compiled.
  30697. */
  30698. onCompiled: Nullable<(effect: Effect) => void>;
  30699. /**
  30700. * Callback that will be called if an error occurs during shader compilation.
  30701. */
  30702. onError: Nullable<(effect: Effect, errors: string) => void>;
  30703. /**
  30704. * Callback that will be called when effect is bound.
  30705. */
  30706. onBind: Nullable<(effect: Effect) => void>;
  30707. /**
  30708. * Unique ID of the effect.
  30709. */
  30710. uniqueId: number;
  30711. /**
  30712. * Observable that will be called when the shader is compiled.
  30713. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30714. */
  30715. onCompileObservable: Observable<Effect>;
  30716. /**
  30717. * Observable that will be called if an error occurs during shader compilation.
  30718. */
  30719. onErrorObservable: Observable<Effect>;
  30720. /** @hidden */
  30721. _onBindObservable: Nullable<Observable<Effect>>;
  30722. /**
  30723. * Observable that will be called when effect is bound.
  30724. */
  30725. get onBindObservable(): Observable<Effect>;
  30726. /** @hidden */
  30727. _bonesComputationForcedToCPU: boolean;
  30728. private static _uniqueIdSeed;
  30729. private _engine;
  30730. private _uniformBuffersNames;
  30731. private _uniformsNames;
  30732. private _samplerList;
  30733. private _samplers;
  30734. private _isReady;
  30735. private _compilationError;
  30736. private _allFallbacksProcessed;
  30737. private _attributesNames;
  30738. private _attributes;
  30739. private _attributeLocationByName;
  30740. private _uniforms;
  30741. /**
  30742. * Key for the effect.
  30743. * @hidden
  30744. */
  30745. _key: string;
  30746. private _indexParameters;
  30747. private _fallbacks;
  30748. private _vertexSourceCode;
  30749. private _fragmentSourceCode;
  30750. private _vertexSourceCodeOverride;
  30751. private _fragmentSourceCodeOverride;
  30752. private _transformFeedbackVaryings;
  30753. /**
  30754. * Compiled shader to webGL program.
  30755. * @hidden
  30756. */
  30757. _pipelineContext: Nullable<IPipelineContext>;
  30758. private _valueCache;
  30759. private static _baseCache;
  30760. /**
  30761. * Instantiates an effect.
  30762. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30763. * @param baseName Name of the effect.
  30764. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30765. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30766. * @param samplers List of sampler variables that will be passed to the shader.
  30767. * @param engine Engine to be used to render the effect
  30768. * @param defines Define statements to be added to the shader.
  30769. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30770. * @param onCompiled Callback that will be called when the shader is compiled.
  30771. * @param onError Callback that will be called if an error occurs during shader compilation.
  30772. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30773. */
  30774. 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);
  30775. private _useFinalCode;
  30776. /**
  30777. * Unique key for this effect
  30778. */
  30779. get key(): string;
  30780. /**
  30781. * If the effect has been compiled and prepared.
  30782. * @returns if the effect is compiled and prepared.
  30783. */
  30784. isReady(): boolean;
  30785. private _isReadyInternal;
  30786. /**
  30787. * The engine the effect was initialized with.
  30788. * @returns the engine.
  30789. */
  30790. getEngine(): Engine;
  30791. /**
  30792. * The pipeline context for this effect
  30793. * @returns the associated pipeline context
  30794. */
  30795. getPipelineContext(): Nullable<IPipelineContext>;
  30796. /**
  30797. * The set of names of attribute variables for the shader.
  30798. * @returns An array of attribute names.
  30799. */
  30800. getAttributesNames(): string[];
  30801. /**
  30802. * Returns the attribute at the given index.
  30803. * @param index The index of the attribute.
  30804. * @returns The location of the attribute.
  30805. */
  30806. getAttributeLocation(index: number): number;
  30807. /**
  30808. * Returns the attribute based on the name of the variable.
  30809. * @param name of the attribute to look up.
  30810. * @returns the attribute location.
  30811. */
  30812. getAttributeLocationByName(name: string): number;
  30813. /**
  30814. * The number of attributes.
  30815. * @returns the numnber of attributes.
  30816. */
  30817. getAttributesCount(): number;
  30818. /**
  30819. * Gets the index of a uniform variable.
  30820. * @param uniformName of the uniform to look up.
  30821. * @returns the index.
  30822. */
  30823. getUniformIndex(uniformName: string): number;
  30824. /**
  30825. * Returns the attribute based on the name of the variable.
  30826. * @param uniformName of the uniform to look up.
  30827. * @returns the location of the uniform.
  30828. */
  30829. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30830. /**
  30831. * Returns an array of sampler variable names
  30832. * @returns The array of sampler variable neames.
  30833. */
  30834. getSamplers(): string[];
  30835. /**
  30836. * The error from the last compilation.
  30837. * @returns the error string.
  30838. */
  30839. getCompilationError(): string;
  30840. /**
  30841. * Gets a boolean indicating that all fallbacks were used during compilation
  30842. * @returns true if all fallbacks were used
  30843. */
  30844. allFallbacksProcessed(): boolean;
  30845. /**
  30846. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30847. * @param func The callback to be used.
  30848. */
  30849. executeWhenCompiled(func: (effect: Effect) => void): void;
  30850. private _checkIsReady;
  30851. private _loadShader;
  30852. /**
  30853. * Recompiles the webGL program
  30854. * @param vertexSourceCode The source code for the vertex shader.
  30855. * @param fragmentSourceCode The source code for the fragment shader.
  30856. * @param onCompiled Callback called when completed.
  30857. * @param onError Callback called on error.
  30858. * @hidden
  30859. */
  30860. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30861. /**
  30862. * Prepares the effect
  30863. * @hidden
  30864. */
  30865. _prepareEffect(): void;
  30866. private _processCompilationErrors;
  30867. /**
  30868. * Checks if the effect is supported. (Must be called after compilation)
  30869. */
  30870. get isSupported(): boolean;
  30871. /**
  30872. * Binds a texture to the engine to be used as output of the shader.
  30873. * @param channel Name of the output variable.
  30874. * @param texture Texture to bind.
  30875. * @hidden
  30876. */
  30877. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30878. /**
  30879. * Sets a texture on the engine to be used in the shader.
  30880. * @param channel Name of the sampler variable.
  30881. * @param texture Texture to set.
  30882. */
  30883. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30884. /**
  30885. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30886. * @param channel Name of the sampler variable.
  30887. * @param texture Texture to set.
  30888. */
  30889. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30890. /**
  30891. * Sets an array of textures on the engine to be used in the shader.
  30892. * @param channel Name of the variable.
  30893. * @param textures Textures to set.
  30894. */
  30895. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30896. /**
  30897. * 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)
  30898. * @param channel Name of the sampler variable.
  30899. * @param postProcess Post process to get the input texture from.
  30900. */
  30901. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30902. /**
  30903. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30904. * 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)
  30905. * @param channel Name of the sampler variable.
  30906. * @param postProcess Post process to get the output texture from.
  30907. */
  30908. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30909. /** @hidden */
  30910. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30911. /** @hidden */
  30912. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30913. /** @hidden */
  30914. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30915. /** @hidden */
  30916. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30917. /**
  30918. * Binds a buffer to a uniform.
  30919. * @param buffer Buffer to bind.
  30920. * @param name Name of the uniform variable to bind to.
  30921. */
  30922. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30923. /**
  30924. * Binds block to a uniform.
  30925. * @param blockName Name of the block to bind.
  30926. * @param index Index to bind.
  30927. */
  30928. bindUniformBlock(blockName: string, index: number): void;
  30929. /**
  30930. * Sets an interger value on a uniform variable.
  30931. * @param uniformName Name of the variable.
  30932. * @param value Value to be set.
  30933. * @returns this effect.
  30934. */
  30935. setInt(uniformName: string, value: number): Effect;
  30936. /**
  30937. * Sets an int array on a uniform variable.
  30938. * @param uniformName Name of the variable.
  30939. * @param array array to be set.
  30940. * @returns this effect.
  30941. */
  30942. setIntArray(uniformName: string, array: Int32Array): Effect;
  30943. /**
  30944. * 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)
  30945. * @param uniformName Name of the variable.
  30946. * @param array array to be set.
  30947. * @returns this effect.
  30948. */
  30949. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30950. /**
  30951. * 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)
  30952. * @param uniformName Name of the variable.
  30953. * @param array array to be set.
  30954. * @returns this effect.
  30955. */
  30956. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30957. /**
  30958. * 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)
  30959. * @param uniformName Name of the variable.
  30960. * @param array array to be set.
  30961. * @returns this effect.
  30962. */
  30963. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30964. /**
  30965. * Sets an float array on a uniform variable.
  30966. * @param uniformName Name of the variable.
  30967. * @param array array to be set.
  30968. * @returns this effect.
  30969. */
  30970. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30971. /**
  30972. * 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)
  30973. * @param uniformName Name of the variable.
  30974. * @param array array to be set.
  30975. * @returns this effect.
  30976. */
  30977. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30978. /**
  30979. * 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)
  30980. * @param uniformName Name of the variable.
  30981. * @param array array to be set.
  30982. * @returns this effect.
  30983. */
  30984. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30985. /**
  30986. * 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)
  30987. * @param uniformName Name of the variable.
  30988. * @param array array to be set.
  30989. * @returns this effect.
  30990. */
  30991. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30992. /**
  30993. * Sets an array on a uniform variable.
  30994. * @param uniformName Name of the variable.
  30995. * @param array array to be set.
  30996. * @returns this effect.
  30997. */
  30998. setArray(uniformName: string, array: number[]): Effect;
  30999. /**
  31000. * 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)
  31001. * @param uniformName Name of the variable.
  31002. * @param array array to be set.
  31003. * @returns this effect.
  31004. */
  31005. setArray2(uniformName: string, array: number[]): Effect;
  31006. /**
  31007. * 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)
  31008. * @param uniformName Name of the variable.
  31009. * @param array array to be set.
  31010. * @returns this effect.
  31011. */
  31012. setArray3(uniformName: string, array: number[]): Effect;
  31013. /**
  31014. * 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)
  31015. * @param uniformName Name of the variable.
  31016. * @param array array to be set.
  31017. * @returns this effect.
  31018. */
  31019. setArray4(uniformName: string, array: number[]): Effect;
  31020. /**
  31021. * Sets matrices on a uniform variable.
  31022. * @param uniformName Name of the variable.
  31023. * @param matrices matrices to be set.
  31024. * @returns this effect.
  31025. */
  31026. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31027. /**
  31028. * Sets matrix on a uniform variable.
  31029. * @param uniformName Name of the variable.
  31030. * @param matrix matrix to be set.
  31031. * @returns this effect.
  31032. */
  31033. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31034. /**
  31035. * 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)
  31036. * @param uniformName Name of the variable.
  31037. * @param matrix matrix to be set.
  31038. * @returns this effect.
  31039. */
  31040. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31041. /**
  31042. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31043. * @param uniformName Name of the variable.
  31044. * @param matrix matrix to be set.
  31045. * @returns this effect.
  31046. */
  31047. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31048. /**
  31049. * Sets a float on a uniform variable.
  31050. * @param uniformName Name of the variable.
  31051. * @param value value to be set.
  31052. * @returns this effect.
  31053. */
  31054. setFloat(uniformName: string, value: number): Effect;
  31055. /**
  31056. * Sets a boolean on a uniform variable.
  31057. * @param uniformName Name of the variable.
  31058. * @param bool value to be set.
  31059. * @returns this effect.
  31060. */
  31061. setBool(uniformName: string, bool: boolean): Effect;
  31062. /**
  31063. * Sets a Vector2 on a uniform variable.
  31064. * @param uniformName Name of the variable.
  31065. * @param vector2 vector2 to be set.
  31066. * @returns this effect.
  31067. */
  31068. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31069. /**
  31070. * Sets a float2 on a uniform variable.
  31071. * @param uniformName Name of the variable.
  31072. * @param x First float in float2.
  31073. * @param y Second float in float2.
  31074. * @returns this effect.
  31075. */
  31076. setFloat2(uniformName: string, x: number, y: number): Effect;
  31077. /**
  31078. * Sets a Vector3 on a uniform variable.
  31079. * @param uniformName Name of the variable.
  31080. * @param vector3 Value to be set.
  31081. * @returns this effect.
  31082. */
  31083. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31084. /**
  31085. * Sets a float3 on a uniform variable.
  31086. * @param uniformName Name of the variable.
  31087. * @param x First float in float3.
  31088. * @param y Second float in float3.
  31089. * @param z Third float in float3.
  31090. * @returns this effect.
  31091. */
  31092. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31093. /**
  31094. * Sets a Vector4 on a uniform variable.
  31095. * @param uniformName Name of the variable.
  31096. * @param vector4 Value to be set.
  31097. * @returns this effect.
  31098. */
  31099. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31100. /**
  31101. * Sets a float4 on a uniform variable.
  31102. * @param uniformName Name of the variable.
  31103. * @param x First float in float4.
  31104. * @param y Second float in float4.
  31105. * @param z Third float in float4.
  31106. * @param w Fourth float in float4.
  31107. * @returns this effect.
  31108. */
  31109. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31110. /**
  31111. * Sets a Color3 on a uniform variable.
  31112. * @param uniformName Name of the variable.
  31113. * @param color3 Value to be set.
  31114. * @returns this effect.
  31115. */
  31116. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31117. /**
  31118. * Sets a Color4 on a uniform variable.
  31119. * @param uniformName Name of the variable.
  31120. * @param color3 Value to be set.
  31121. * @param alpha Alpha value to be set.
  31122. * @returns this effect.
  31123. */
  31124. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31125. /**
  31126. * Sets a Color4 on a uniform variable
  31127. * @param uniformName defines the name of the variable
  31128. * @param color4 defines the value to be set
  31129. * @returns this effect.
  31130. */
  31131. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31132. /** Release all associated resources */
  31133. dispose(): void;
  31134. /**
  31135. * This function will add a new shader to the shader store
  31136. * @param name the name of the shader
  31137. * @param pixelShader optional pixel shader content
  31138. * @param vertexShader optional vertex shader content
  31139. */
  31140. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31141. /**
  31142. * Store of each shader (The can be looked up using effect.key)
  31143. */
  31144. static ShadersStore: {
  31145. [key: string]: string;
  31146. };
  31147. /**
  31148. * Store of each included file for a shader (The can be looked up using effect.key)
  31149. */
  31150. static IncludesShadersStore: {
  31151. [key: string]: string;
  31152. };
  31153. /**
  31154. * Resets the cache of effects.
  31155. */
  31156. static ResetCache(): void;
  31157. }
  31158. }
  31159. declare module "babylonjs/Engines/engineCapabilities" {
  31160. /**
  31161. * Interface used to describe the capabilities of the engine relatively to the current browser
  31162. */
  31163. export interface EngineCapabilities {
  31164. /** Maximum textures units per fragment shader */
  31165. maxTexturesImageUnits: number;
  31166. /** Maximum texture units per vertex shader */
  31167. maxVertexTextureImageUnits: number;
  31168. /** Maximum textures units in the entire pipeline */
  31169. maxCombinedTexturesImageUnits: number;
  31170. /** Maximum texture size */
  31171. maxTextureSize: number;
  31172. /** Maximum texture samples */
  31173. maxSamples?: number;
  31174. /** Maximum cube texture size */
  31175. maxCubemapTextureSize: number;
  31176. /** Maximum render texture size */
  31177. maxRenderTextureSize: number;
  31178. /** Maximum number of vertex attributes */
  31179. maxVertexAttribs: number;
  31180. /** Maximum number of varyings */
  31181. maxVaryingVectors: number;
  31182. /** Maximum number of uniforms per vertex shader */
  31183. maxVertexUniformVectors: number;
  31184. /** Maximum number of uniforms per fragment shader */
  31185. maxFragmentUniformVectors: number;
  31186. /** Defines if standard derivates (dx/dy) are supported */
  31187. standardDerivatives: boolean;
  31188. /** Defines if s3tc texture compression is supported */
  31189. s3tc?: WEBGL_compressed_texture_s3tc;
  31190. /** Defines if pvrtc texture compression is supported */
  31191. pvrtc: any;
  31192. /** Defines if etc1 texture compression is supported */
  31193. etc1: any;
  31194. /** Defines if etc2 texture compression is supported */
  31195. etc2: any;
  31196. /** Defines if astc texture compression is supported */
  31197. astc: any;
  31198. /** Defines if float textures are supported */
  31199. textureFloat: boolean;
  31200. /** Defines if vertex array objects are supported */
  31201. vertexArrayObject: boolean;
  31202. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31203. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31204. /** Gets the maximum level of anisotropy supported */
  31205. maxAnisotropy: number;
  31206. /** Defines if instancing is supported */
  31207. instancedArrays: boolean;
  31208. /** Defines if 32 bits indices are supported */
  31209. uintIndices: boolean;
  31210. /** Defines if high precision shaders are supported */
  31211. highPrecisionShaderSupported: boolean;
  31212. /** Defines if depth reading in the fragment shader is supported */
  31213. fragmentDepthSupported: boolean;
  31214. /** Defines if float texture linear filtering is supported*/
  31215. textureFloatLinearFiltering: boolean;
  31216. /** Defines if rendering to float textures is supported */
  31217. textureFloatRender: boolean;
  31218. /** Defines if half float textures are supported*/
  31219. textureHalfFloat: boolean;
  31220. /** Defines if half float texture linear filtering is supported*/
  31221. textureHalfFloatLinearFiltering: boolean;
  31222. /** Defines if rendering to half float textures is supported */
  31223. textureHalfFloatRender: boolean;
  31224. /** Defines if textureLOD shader command is supported */
  31225. textureLOD: boolean;
  31226. /** Defines if draw buffers extension is supported */
  31227. drawBuffersExtension: boolean;
  31228. /** Defines if depth textures are supported */
  31229. depthTextureExtension: boolean;
  31230. /** Defines if float color buffer are supported */
  31231. colorBufferFloat: boolean;
  31232. /** Gets disjoint timer query extension (null if not supported) */
  31233. timerQuery?: EXT_disjoint_timer_query;
  31234. /** Defines if timestamp can be used with timer query */
  31235. canUseTimestampForTimerQuery: boolean;
  31236. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31237. multiview?: any;
  31238. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31239. oculusMultiview?: any;
  31240. /** Function used to let the system compiles shaders in background */
  31241. parallelShaderCompile?: {
  31242. COMPLETION_STATUS_KHR: number;
  31243. };
  31244. /** Max number of texture samples for MSAA */
  31245. maxMSAASamples: number;
  31246. /** Defines if the blend min max extension is supported */
  31247. blendMinMax: boolean;
  31248. }
  31249. }
  31250. declare module "babylonjs/States/depthCullingState" {
  31251. import { Nullable } from "babylonjs/types";
  31252. /**
  31253. * @hidden
  31254. **/
  31255. export class DepthCullingState {
  31256. private _isDepthTestDirty;
  31257. private _isDepthMaskDirty;
  31258. private _isDepthFuncDirty;
  31259. private _isCullFaceDirty;
  31260. private _isCullDirty;
  31261. private _isZOffsetDirty;
  31262. private _isFrontFaceDirty;
  31263. private _depthTest;
  31264. private _depthMask;
  31265. private _depthFunc;
  31266. private _cull;
  31267. private _cullFace;
  31268. private _zOffset;
  31269. private _frontFace;
  31270. /**
  31271. * Initializes the state.
  31272. */
  31273. constructor();
  31274. get isDirty(): boolean;
  31275. get zOffset(): number;
  31276. set zOffset(value: number);
  31277. get cullFace(): Nullable<number>;
  31278. set cullFace(value: Nullable<number>);
  31279. get cull(): Nullable<boolean>;
  31280. set cull(value: Nullable<boolean>);
  31281. get depthFunc(): Nullable<number>;
  31282. set depthFunc(value: Nullable<number>);
  31283. get depthMask(): boolean;
  31284. set depthMask(value: boolean);
  31285. get depthTest(): boolean;
  31286. set depthTest(value: boolean);
  31287. get frontFace(): Nullable<number>;
  31288. set frontFace(value: Nullable<number>);
  31289. reset(): void;
  31290. apply(gl: WebGLRenderingContext): void;
  31291. }
  31292. }
  31293. declare module "babylonjs/States/stencilState" {
  31294. /**
  31295. * @hidden
  31296. **/
  31297. export class StencilState {
  31298. /** 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 */
  31299. static readonly ALWAYS: number;
  31300. /** Passed to stencilOperation to specify that stencil value must be kept */
  31301. static readonly KEEP: number;
  31302. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31303. static readonly REPLACE: number;
  31304. private _isStencilTestDirty;
  31305. private _isStencilMaskDirty;
  31306. private _isStencilFuncDirty;
  31307. private _isStencilOpDirty;
  31308. private _stencilTest;
  31309. private _stencilMask;
  31310. private _stencilFunc;
  31311. private _stencilFuncRef;
  31312. private _stencilFuncMask;
  31313. private _stencilOpStencilFail;
  31314. private _stencilOpDepthFail;
  31315. private _stencilOpStencilDepthPass;
  31316. get isDirty(): boolean;
  31317. get stencilFunc(): number;
  31318. set stencilFunc(value: number);
  31319. get stencilFuncRef(): number;
  31320. set stencilFuncRef(value: number);
  31321. get stencilFuncMask(): number;
  31322. set stencilFuncMask(value: number);
  31323. get stencilOpStencilFail(): number;
  31324. set stencilOpStencilFail(value: number);
  31325. get stencilOpDepthFail(): number;
  31326. set stencilOpDepthFail(value: number);
  31327. get stencilOpStencilDepthPass(): number;
  31328. set stencilOpStencilDepthPass(value: number);
  31329. get stencilMask(): number;
  31330. set stencilMask(value: number);
  31331. get stencilTest(): boolean;
  31332. set stencilTest(value: boolean);
  31333. constructor();
  31334. reset(): void;
  31335. apply(gl: WebGLRenderingContext): void;
  31336. }
  31337. }
  31338. declare module "babylonjs/States/alphaCullingState" {
  31339. /**
  31340. * @hidden
  31341. **/
  31342. export class AlphaState {
  31343. private _isAlphaBlendDirty;
  31344. private _isBlendFunctionParametersDirty;
  31345. private _isBlendEquationParametersDirty;
  31346. private _isBlendConstantsDirty;
  31347. private _alphaBlend;
  31348. private _blendFunctionParameters;
  31349. private _blendEquationParameters;
  31350. private _blendConstants;
  31351. /**
  31352. * Initializes the state.
  31353. */
  31354. constructor();
  31355. get isDirty(): boolean;
  31356. get alphaBlend(): boolean;
  31357. set alphaBlend(value: boolean);
  31358. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31359. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31360. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31361. reset(): void;
  31362. apply(gl: WebGLRenderingContext): void;
  31363. }
  31364. }
  31365. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31366. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31367. /** @hidden */
  31368. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31369. attributeProcessor(attribute: string): string;
  31370. varyingProcessor(varying: string, isFragment: boolean): string;
  31371. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31372. }
  31373. }
  31374. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31375. /**
  31376. * Interface for attribute information associated with buffer instanciation
  31377. */
  31378. export interface InstancingAttributeInfo {
  31379. /**
  31380. * Name of the GLSL attribute
  31381. * if attribute index is not specified, this is used to retrieve the index from the effect
  31382. */
  31383. attributeName: string;
  31384. /**
  31385. * Index/offset of the attribute in the vertex shader
  31386. * if not specified, this will be computes from the name.
  31387. */
  31388. index?: number;
  31389. /**
  31390. * size of the attribute, 1, 2, 3 or 4
  31391. */
  31392. attributeSize: number;
  31393. /**
  31394. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31395. */
  31396. offset: number;
  31397. /**
  31398. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31399. * default to 1
  31400. */
  31401. divisor?: number;
  31402. /**
  31403. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31404. * default is FLOAT
  31405. */
  31406. attributeType?: number;
  31407. /**
  31408. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31409. */
  31410. normalized?: boolean;
  31411. }
  31412. }
  31413. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31414. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31415. import { Nullable } from "babylonjs/types";
  31416. module "babylonjs/Engines/thinEngine" {
  31417. interface ThinEngine {
  31418. /**
  31419. * Update a video texture
  31420. * @param texture defines the texture to update
  31421. * @param video defines the video element to use
  31422. * @param invertY defines if data must be stored with Y axis inverted
  31423. */
  31424. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31425. }
  31426. }
  31427. }
  31428. declare module "babylonjs/Materials/Textures/videoTexture" {
  31429. import { Observable } from "babylonjs/Misc/observable";
  31430. import { Nullable } from "babylonjs/types";
  31431. import { Scene } from "babylonjs/scene";
  31432. import { Texture } from "babylonjs/Materials/Textures/texture";
  31433. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31434. /**
  31435. * Settings for finer control over video usage
  31436. */
  31437. export interface VideoTextureSettings {
  31438. /**
  31439. * Applies `autoplay` to video, if specified
  31440. */
  31441. autoPlay?: boolean;
  31442. /**
  31443. * Applies `loop` to video, if specified
  31444. */
  31445. loop?: boolean;
  31446. /**
  31447. * Automatically updates internal texture from video at every frame in the render loop
  31448. */
  31449. autoUpdateTexture: boolean;
  31450. /**
  31451. * Image src displayed during the video loading or until the user interacts with the video.
  31452. */
  31453. poster?: string;
  31454. }
  31455. /**
  31456. * If you want to display a video in your scene, this is the special texture for that.
  31457. * This special texture works similar to other textures, with the exception of a few parameters.
  31458. * @see https://doc.babylonjs.com/how_to/video_texture
  31459. */
  31460. export class VideoTexture extends Texture {
  31461. /**
  31462. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31463. */
  31464. readonly autoUpdateTexture: boolean;
  31465. /**
  31466. * The video instance used by the texture internally
  31467. */
  31468. readonly video: HTMLVideoElement;
  31469. private _onUserActionRequestedObservable;
  31470. /**
  31471. * Event triggerd when a dom action is required by the user to play the video.
  31472. * This happens due to recent changes in browser policies preventing video to auto start.
  31473. */
  31474. get onUserActionRequestedObservable(): Observable<Texture>;
  31475. private _generateMipMaps;
  31476. private _engine;
  31477. private _stillImageCaptured;
  31478. private _displayingPosterTexture;
  31479. private _settings;
  31480. private _createInternalTextureOnEvent;
  31481. private _frameId;
  31482. /**
  31483. * Creates a video texture.
  31484. * If you want to display a video in your scene, this is the special texture for that.
  31485. * This special texture works similar to other textures, with the exception of a few parameters.
  31486. * @see https://doc.babylonjs.com/how_to/video_texture
  31487. * @param name optional name, will detect from video source, if not defined
  31488. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31489. * @param scene is obviously the current scene.
  31490. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31491. * @param invertY is false by default but can be used to invert video on Y axis
  31492. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31493. * @param settings allows finer control over video usage
  31494. */
  31495. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31496. private _getName;
  31497. private _getVideo;
  31498. private _createInternalTexture;
  31499. private reset;
  31500. /**
  31501. * @hidden Internal method to initiate `update`.
  31502. */
  31503. _rebuild(): void;
  31504. /**
  31505. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31506. */
  31507. update(): void;
  31508. /**
  31509. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31510. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31511. */
  31512. updateTexture(isVisible: boolean): void;
  31513. protected _updateInternalTexture: () => void;
  31514. /**
  31515. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31516. * @param url New url.
  31517. */
  31518. updateURL(url: string): void;
  31519. /**
  31520. * Dispose the texture and release its associated resources.
  31521. */
  31522. dispose(): void;
  31523. /**
  31524. * Creates a video texture straight from a stream.
  31525. * @param scene Define the scene the texture should be created in
  31526. * @param stream Define the stream the texture should be created from
  31527. * @returns The created video texture as a promise
  31528. */
  31529. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31530. /**
  31531. * Creates a video texture straight from your WebCam video feed.
  31532. * @param scene Define the scene the texture should be created in
  31533. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31534. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31535. * @returns The created video texture as a promise
  31536. */
  31537. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31538. minWidth: number;
  31539. maxWidth: number;
  31540. minHeight: number;
  31541. maxHeight: number;
  31542. deviceId: string;
  31543. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31544. /**
  31545. * Creates a video texture straight from your WebCam video feed.
  31546. * @param scene Define the scene the texture should be created in
  31547. * @param onReady Define a callback to triggered once the texture will be ready
  31548. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31549. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31550. */
  31551. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31552. minWidth: number;
  31553. maxWidth: number;
  31554. minHeight: number;
  31555. maxHeight: number;
  31556. deviceId: string;
  31557. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31558. }
  31559. }
  31560. declare module "babylonjs/Engines/thinEngine" {
  31561. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31562. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31563. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31564. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31565. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31566. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31567. import { Observable } from "babylonjs/Misc/observable";
  31568. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31569. import { StencilState } from "babylonjs/States/stencilState";
  31570. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31571. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31572. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31573. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31574. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31575. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31576. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31577. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31578. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31579. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31580. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31581. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31582. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31583. import { WebRequest } from "babylonjs/Misc/webRequest";
  31584. import { LoadFileError } from "babylonjs/Misc/fileTools";
  31585. /**
  31586. * Defines the interface used by objects working like Scene
  31587. * @hidden
  31588. */
  31589. interface ISceneLike {
  31590. _addPendingData(data: any): void;
  31591. _removePendingData(data: any): void;
  31592. offlineProvider: IOfflineProvider;
  31593. }
  31594. /** Interface defining initialization parameters for Engine class */
  31595. export interface EngineOptions extends WebGLContextAttributes {
  31596. /**
  31597. * Defines if the engine should no exceed a specified device ratio
  31598. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31599. */
  31600. limitDeviceRatio?: number;
  31601. /**
  31602. * Defines if webvr should be enabled automatically
  31603. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31604. */
  31605. autoEnableWebVR?: boolean;
  31606. /**
  31607. * Defines if webgl2 should be turned off even if supported
  31608. * @see http://doc.babylonjs.com/features/webgl2
  31609. */
  31610. disableWebGL2Support?: boolean;
  31611. /**
  31612. * Defines if webaudio should be initialized as well
  31613. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31614. */
  31615. audioEngine?: boolean;
  31616. /**
  31617. * Defines if animations should run using a deterministic lock step
  31618. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31619. */
  31620. deterministicLockstep?: boolean;
  31621. /** Defines the maximum steps to use with deterministic lock step mode */
  31622. lockstepMaxSteps?: number;
  31623. /** Defines the seconds between each deterministic lock step */
  31624. timeStep?: number;
  31625. /**
  31626. * Defines that engine should ignore context lost events
  31627. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31628. */
  31629. doNotHandleContextLost?: boolean;
  31630. /**
  31631. * Defines that engine should ignore modifying touch action attribute and style
  31632. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31633. */
  31634. doNotHandleTouchAction?: boolean;
  31635. /**
  31636. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31637. */
  31638. useHighPrecisionFloats?: boolean;
  31639. }
  31640. /**
  31641. * The base engine class (root of all engines)
  31642. */
  31643. export class ThinEngine {
  31644. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31645. static ExceptionList: ({
  31646. key: string;
  31647. capture: string;
  31648. captureConstraint: number;
  31649. targets: string[];
  31650. } | {
  31651. key: string;
  31652. capture: null;
  31653. captureConstraint: null;
  31654. targets: string[];
  31655. })[];
  31656. /** @hidden */
  31657. static _TextureLoaders: IInternalTextureLoader[];
  31658. /**
  31659. * Returns the current npm package of the sdk
  31660. */
  31661. static get NpmPackage(): string;
  31662. /**
  31663. * Returns the current version of the framework
  31664. */
  31665. static get Version(): string;
  31666. /**
  31667. * Returns a string describing the current engine
  31668. */
  31669. get description(): string;
  31670. /**
  31671. * Gets or sets the epsilon value used by collision engine
  31672. */
  31673. static CollisionsEpsilon: number;
  31674. /**
  31675. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31676. */
  31677. static get ShadersRepository(): string;
  31678. static set ShadersRepository(value: string);
  31679. /**
  31680. * Gets or sets the textures that the engine should not attempt to load as compressed
  31681. */
  31682. protected _excludedCompressedTextures: string[];
  31683. /**
  31684. * Filters the compressed texture formats to only include
  31685. * files that are not included in the skippable list
  31686. *
  31687. * @param url the current extension
  31688. * @param textureFormatInUse the current compressed texture format
  31689. * @returns "format" string
  31690. */
  31691. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  31692. /** @hidden */
  31693. _shaderProcessor: IShaderProcessor;
  31694. /**
  31695. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31696. */
  31697. forcePOTTextures: boolean;
  31698. /**
  31699. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31700. */
  31701. isFullscreen: boolean;
  31702. /**
  31703. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31704. */
  31705. cullBackFaces: boolean;
  31706. /**
  31707. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31708. */
  31709. renderEvenInBackground: boolean;
  31710. /**
  31711. * Gets or sets a boolean indicating that cache can be kept between frames
  31712. */
  31713. preventCacheWipeBetweenFrames: boolean;
  31714. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31715. validateShaderPrograms: boolean;
  31716. /**
  31717. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31718. * This can provide greater z depth for distant objects.
  31719. */
  31720. useReverseDepthBuffer: boolean;
  31721. /**
  31722. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31723. */
  31724. disableUniformBuffers: boolean;
  31725. /** @hidden */
  31726. _uniformBuffers: UniformBuffer[];
  31727. /**
  31728. * Gets a boolean indicating that the engine supports uniform buffers
  31729. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31730. */
  31731. get supportsUniformBuffers(): boolean;
  31732. /** @hidden */
  31733. _gl: WebGLRenderingContext;
  31734. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31735. protected _windowIsBackground: boolean;
  31736. protected _webGLVersion: number;
  31737. protected _creationOptions: EngineOptions;
  31738. protected _highPrecisionShadersAllowed: boolean;
  31739. /** @hidden */
  31740. get _shouldUseHighPrecisionShader(): boolean;
  31741. /**
  31742. * Gets a boolean indicating that only power of 2 textures are supported
  31743. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31744. */
  31745. get needPOTTextures(): boolean;
  31746. /** @hidden */
  31747. _badOS: boolean;
  31748. /** @hidden */
  31749. _badDesktopOS: boolean;
  31750. private _hardwareScalingLevel;
  31751. /** @hidden */
  31752. _caps: EngineCapabilities;
  31753. private _isStencilEnable;
  31754. private _glVersion;
  31755. private _glRenderer;
  31756. private _glVendor;
  31757. /** @hidden */
  31758. _videoTextureSupported: boolean;
  31759. protected _renderingQueueLaunched: boolean;
  31760. protected _activeRenderLoops: (() => void)[];
  31761. /**
  31762. * Observable signaled when a context lost event is raised
  31763. */
  31764. onContextLostObservable: Observable<ThinEngine>;
  31765. /**
  31766. * Observable signaled when a context restored event is raised
  31767. */
  31768. onContextRestoredObservable: Observable<ThinEngine>;
  31769. private _onContextLost;
  31770. private _onContextRestored;
  31771. protected _contextWasLost: boolean;
  31772. /** @hidden */
  31773. _doNotHandleContextLost: boolean;
  31774. /**
  31775. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31776. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31777. */
  31778. get doNotHandleContextLost(): boolean;
  31779. set doNotHandleContextLost(value: boolean);
  31780. /**
  31781. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31782. */
  31783. disableVertexArrayObjects: boolean;
  31784. /** @hidden */
  31785. protected _colorWrite: boolean;
  31786. /** @hidden */
  31787. protected _colorWriteChanged: boolean;
  31788. /** @hidden */
  31789. protected _depthCullingState: DepthCullingState;
  31790. /** @hidden */
  31791. protected _stencilState: StencilState;
  31792. /** @hidden */
  31793. _alphaState: AlphaState;
  31794. /** @hidden */
  31795. _alphaMode: number;
  31796. /** @hidden */
  31797. _alphaEquation: number;
  31798. /** @hidden */
  31799. _internalTexturesCache: InternalTexture[];
  31800. /** @hidden */
  31801. protected _activeChannel: number;
  31802. private _currentTextureChannel;
  31803. /** @hidden */
  31804. protected _boundTexturesCache: {
  31805. [key: string]: Nullable<InternalTexture>;
  31806. };
  31807. /** @hidden */
  31808. protected _currentEffect: Nullable<Effect>;
  31809. /** @hidden */
  31810. protected _currentProgram: Nullable<WebGLProgram>;
  31811. private _compiledEffects;
  31812. private _vertexAttribArraysEnabled;
  31813. /** @hidden */
  31814. protected _cachedViewport: Nullable<IViewportLike>;
  31815. private _cachedVertexArrayObject;
  31816. /** @hidden */
  31817. protected _cachedVertexBuffers: any;
  31818. /** @hidden */
  31819. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31820. /** @hidden */
  31821. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31822. /** @hidden */
  31823. _currentRenderTarget: Nullable<InternalTexture>;
  31824. private _uintIndicesCurrentlySet;
  31825. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31826. /** @hidden */
  31827. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31828. private _currentBufferPointers;
  31829. private _currentInstanceLocations;
  31830. private _currentInstanceBuffers;
  31831. private _textureUnits;
  31832. /** @hidden */
  31833. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31834. /** @hidden */
  31835. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31836. /** @hidden */
  31837. _boundRenderFunction: any;
  31838. private _vaoRecordInProgress;
  31839. private _mustWipeVertexAttributes;
  31840. private _emptyTexture;
  31841. private _emptyCubeTexture;
  31842. private _emptyTexture3D;
  31843. private _emptyTexture2DArray;
  31844. /** @hidden */
  31845. _frameHandler: number;
  31846. private _nextFreeTextureSlots;
  31847. private _maxSimultaneousTextures;
  31848. private _activeRequests;
  31849. protected _texturesSupported: string[];
  31850. /** @hidden */
  31851. _textureFormatInUse: Nullable<string>;
  31852. protected get _supportsHardwareTextureRescaling(): boolean;
  31853. /**
  31854. * Gets the list of texture formats supported
  31855. */
  31856. get texturesSupported(): Array<string>;
  31857. /**
  31858. * Gets the list of texture formats in use
  31859. */
  31860. get textureFormatInUse(): Nullable<string>;
  31861. /**
  31862. * Gets the current viewport
  31863. */
  31864. get currentViewport(): Nullable<IViewportLike>;
  31865. /**
  31866. * Gets the default empty texture
  31867. */
  31868. get emptyTexture(): InternalTexture;
  31869. /**
  31870. * Gets the default empty 3D texture
  31871. */
  31872. get emptyTexture3D(): InternalTexture;
  31873. /**
  31874. * Gets the default empty 2D array texture
  31875. */
  31876. get emptyTexture2DArray(): InternalTexture;
  31877. /**
  31878. * Gets the default empty cube texture
  31879. */
  31880. get emptyCubeTexture(): InternalTexture;
  31881. /**
  31882. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31883. */
  31884. readonly premultipliedAlpha: boolean;
  31885. /**
  31886. * Observable event triggered before each texture is initialized
  31887. */
  31888. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  31889. /**
  31890. * Creates a new engine
  31891. * @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
  31892. * @param antialias defines enable antialiasing (default: false)
  31893. * @param options defines further options to be sent to the getContext() function
  31894. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31895. */
  31896. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31897. private _rebuildInternalTextures;
  31898. private _rebuildEffects;
  31899. /**
  31900. * Gets a boolean indicating if all created effects are ready
  31901. * @returns true if all effects are ready
  31902. */
  31903. areAllEffectsReady(): boolean;
  31904. protected _rebuildBuffers(): void;
  31905. private _initGLContext;
  31906. /**
  31907. * Gets version of the current webGL context
  31908. */
  31909. get webGLVersion(): number;
  31910. /**
  31911. * Gets a string idenfifying the name of the class
  31912. * @returns "Engine" string
  31913. */
  31914. getClassName(): string;
  31915. /**
  31916. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31917. */
  31918. get isStencilEnable(): boolean;
  31919. /** @hidden */
  31920. _prepareWorkingCanvas(): void;
  31921. /**
  31922. * Reset the texture cache to empty state
  31923. */
  31924. resetTextureCache(): void;
  31925. /**
  31926. * Gets an object containing information about the current webGL context
  31927. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31928. */
  31929. getGlInfo(): {
  31930. vendor: string;
  31931. renderer: string;
  31932. version: string;
  31933. };
  31934. /**
  31935. * Defines the hardware scaling level.
  31936. * By default the hardware scaling level is computed from the window device ratio.
  31937. * 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.
  31938. * @param level defines the level to use
  31939. */
  31940. setHardwareScalingLevel(level: number): void;
  31941. /**
  31942. * Gets the current hardware scaling level.
  31943. * By default the hardware scaling level is computed from the window device ratio.
  31944. * 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.
  31945. * @returns a number indicating the current hardware scaling level
  31946. */
  31947. getHardwareScalingLevel(): number;
  31948. /**
  31949. * Gets the list of loaded textures
  31950. * @returns an array containing all loaded textures
  31951. */
  31952. getLoadedTexturesCache(): InternalTexture[];
  31953. /**
  31954. * Gets the object containing all engine capabilities
  31955. * @returns the EngineCapabilities object
  31956. */
  31957. getCaps(): EngineCapabilities;
  31958. /**
  31959. * stop executing a render loop function and remove it from the execution array
  31960. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31961. */
  31962. stopRenderLoop(renderFunction?: () => void): void;
  31963. /** @hidden */
  31964. _renderLoop(): void;
  31965. /**
  31966. * Gets the HTML canvas attached with the current webGL context
  31967. * @returns a HTML canvas
  31968. */
  31969. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31970. /**
  31971. * Gets host window
  31972. * @returns the host window object
  31973. */
  31974. getHostWindow(): Nullable<Window>;
  31975. /**
  31976. * Gets the current render width
  31977. * @param useScreen defines if screen size must be used (or the current render target if any)
  31978. * @returns a number defining the current render width
  31979. */
  31980. getRenderWidth(useScreen?: boolean): number;
  31981. /**
  31982. * Gets the current render height
  31983. * @param useScreen defines if screen size must be used (or the current render target if any)
  31984. * @returns a number defining the current render height
  31985. */
  31986. getRenderHeight(useScreen?: boolean): number;
  31987. /**
  31988. * Can be used to override the current requestAnimationFrame requester.
  31989. * @hidden
  31990. */
  31991. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31992. /**
  31993. * Register and execute a render loop. The engine can have more than one render function
  31994. * @param renderFunction defines the function to continuously execute
  31995. */
  31996. runRenderLoop(renderFunction: () => void): void;
  31997. /**
  31998. * Clear the current render buffer or the current render target (if any is set up)
  31999. * @param color defines the color to use
  32000. * @param backBuffer defines if the back buffer must be cleared
  32001. * @param depth defines if the depth buffer must be cleared
  32002. * @param stencil defines if the stencil buffer must be cleared
  32003. */
  32004. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32005. private _viewportCached;
  32006. /** @hidden */
  32007. _viewport(x: number, y: number, width: number, height: number): void;
  32008. /**
  32009. * Set the WebGL's viewport
  32010. * @param viewport defines the viewport element to be used
  32011. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32012. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32013. */
  32014. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32015. /**
  32016. * Begin a new frame
  32017. */
  32018. beginFrame(): void;
  32019. /**
  32020. * Enf the current frame
  32021. */
  32022. endFrame(): void;
  32023. /**
  32024. * Resize the view according to the canvas' size
  32025. */
  32026. resize(): void;
  32027. /**
  32028. * Force a specific size of the canvas
  32029. * @param width defines the new canvas' width
  32030. * @param height defines the new canvas' height
  32031. */
  32032. setSize(width: number, height: number): void;
  32033. /**
  32034. * Binds the frame buffer to the specified texture.
  32035. * @param texture The texture to render to or null for the default canvas
  32036. * @param faceIndex The face of the texture to render to in case of cube texture
  32037. * @param requiredWidth The width of the target to render to
  32038. * @param requiredHeight The height of the target to render to
  32039. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32040. * @param depthStencilTexture The depth stencil texture to use to render
  32041. * @param lodLevel defines le lod level to bind to the frame buffer
  32042. */
  32043. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  32044. /** @hidden */
  32045. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32046. /**
  32047. * Unbind the current render target texture from the webGL context
  32048. * @param texture defines the render target texture to unbind
  32049. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32050. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32051. */
  32052. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32053. /**
  32054. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32055. */
  32056. flushFramebuffer(): void;
  32057. /**
  32058. * Unbind the current render target and bind the default framebuffer
  32059. */
  32060. restoreDefaultFramebuffer(): void;
  32061. /** @hidden */
  32062. protected _resetVertexBufferBinding(): void;
  32063. /**
  32064. * Creates a vertex buffer
  32065. * @param data the data for the vertex buffer
  32066. * @returns the new WebGL static buffer
  32067. */
  32068. createVertexBuffer(data: DataArray): DataBuffer;
  32069. private _createVertexBuffer;
  32070. /**
  32071. * Creates a dynamic vertex buffer
  32072. * @param data the data for the dynamic vertex buffer
  32073. * @returns the new WebGL dynamic buffer
  32074. */
  32075. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32076. protected _resetIndexBufferBinding(): void;
  32077. /**
  32078. * Creates a new index buffer
  32079. * @param indices defines the content of the index buffer
  32080. * @param updatable defines if the index buffer must be updatable
  32081. * @returns a new webGL buffer
  32082. */
  32083. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32084. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32085. /**
  32086. * Bind a webGL buffer to the webGL context
  32087. * @param buffer defines the buffer to bind
  32088. */
  32089. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32090. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32091. private bindBuffer;
  32092. /**
  32093. * update the bound buffer with the given data
  32094. * @param data defines the data to update
  32095. */
  32096. updateArrayBuffer(data: Float32Array): void;
  32097. private _vertexAttribPointer;
  32098. private _bindIndexBufferWithCache;
  32099. private _bindVertexBuffersAttributes;
  32100. /**
  32101. * Records a vertex array object
  32102. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32103. * @param vertexBuffers defines the list of vertex buffers to store
  32104. * @param indexBuffer defines the index buffer to store
  32105. * @param effect defines the effect to store
  32106. * @returns the new vertex array object
  32107. */
  32108. recordVertexArrayObject(vertexBuffers: {
  32109. [key: string]: VertexBuffer;
  32110. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32111. /**
  32112. * Bind a specific vertex array object
  32113. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32114. * @param vertexArrayObject defines the vertex array object to bind
  32115. * @param indexBuffer defines the index buffer to bind
  32116. */
  32117. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32118. /**
  32119. * Bind webGl buffers directly to the webGL context
  32120. * @param vertexBuffer defines the vertex buffer to bind
  32121. * @param indexBuffer defines the index buffer to bind
  32122. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32123. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32124. * @param effect defines the effect associated with the vertex buffer
  32125. */
  32126. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32127. private _unbindVertexArrayObject;
  32128. /**
  32129. * Bind a list of vertex buffers to the webGL context
  32130. * @param vertexBuffers defines the list of vertex buffers to bind
  32131. * @param indexBuffer defines the index buffer to bind
  32132. * @param effect defines the effect associated with the vertex buffers
  32133. */
  32134. bindBuffers(vertexBuffers: {
  32135. [key: string]: Nullable<VertexBuffer>;
  32136. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32137. /**
  32138. * Unbind all instance attributes
  32139. */
  32140. unbindInstanceAttributes(): void;
  32141. /**
  32142. * Release and free the memory of a vertex array object
  32143. * @param vao defines the vertex array object to delete
  32144. */
  32145. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32146. /** @hidden */
  32147. _releaseBuffer(buffer: DataBuffer): boolean;
  32148. protected _deleteBuffer(buffer: DataBuffer): void;
  32149. /**
  32150. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32151. * @param instancesBuffer defines the webGL buffer to update and bind
  32152. * @param data defines the data to store in the buffer
  32153. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32154. */
  32155. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32156. /**
  32157. * Bind the content of a webGL buffer used with instanciation
  32158. * @param instancesBuffer defines the webGL buffer to bind
  32159. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32160. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  32161. */
  32162. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32163. /**
  32164. * Disable the instance attribute corresponding to the name in parameter
  32165. * @param name defines the name of the attribute to disable
  32166. */
  32167. disableInstanceAttributeByName(name: string): void;
  32168. /**
  32169. * Disable the instance attribute corresponding to the location in parameter
  32170. * @param attributeLocation defines the attribute location of the attribute to disable
  32171. */
  32172. disableInstanceAttribute(attributeLocation: number): void;
  32173. /**
  32174. * Disable the attribute corresponding to the location in parameter
  32175. * @param attributeLocation defines the attribute location of the attribute to disable
  32176. */
  32177. disableAttributeByIndex(attributeLocation: number): void;
  32178. /**
  32179. * Send a draw order
  32180. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32181. * @param indexStart defines the starting index
  32182. * @param indexCount defines the number of index to draw
  32183. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32184. */
  32185. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32186. /**
  32187. * Draw a list of points
  32188. * @param verticesStart defines the index of first vertex to draw
  32189. * @param verticesCount defines the count of vertices to draw
  32190. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32191. */
  32192. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32193. /**
  32194. * Draw a list of unindexed primitives
  32195. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32196. * @param verticesStart defines the index of first vertex to draw
  32197. * @param verticesCount defines the count of vertices to draw
  32198. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32199. */
  32200. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32201. /**
  32202. * Draw a list of indexed primitives
  32203. * @param fillMode defines the primitive to use
  32204. * @param indexStart defines the starting index
  32205. * @param indexCount defines the number of index to draw
  32206. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32207. */
  32208. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32209. /**
  32210. * Draw a list of unindexed primitives
  32211. * @param fillMode defines the primitive to use
  32212. * @param verticesStart defines the index of first vertex to draw
  32213. * @param verticesCount defines the count of vertices to draw
  32214. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32215. */
  32216. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32217. private _drawMode;
  32218. /** @hidden */
  32219. protected _reportDrawCall(): void;
  32220. /** @hidden */
  32221. _releaseEffect(effect: Effect): void;
  32222. /** @hidden */
  32223. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32224. /**
  32225. * Create a new effect (used to store vertex/fragment shaders)
  32226. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32227. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32228. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32229. * @param samplers defines an array of string used to represent textures
  32230. * @param defines defines the string containing the defines to use to compile the shaders
  32231. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32232. * @param onCompiled defines a function to call when the effect creation is successful
  32233. * @param onError defines a function to call when the effect creation has failed
  32234. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32235. * @returns the new Effect
  32236. */
  32237. 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;
  32238. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32239. private _compileShader;
  32240. private _compileRawShader;
  32241. /**
  32242. * Directly creates a webGL program
  32243. * @param pipelineContext defines the pipeline context to attach to
  32244. * @param vertexCode defines the vertex shader code to use
  32245. * @param fragmentCode defines the fragment shader code to use
  32246. * @param context defines the webGL context to use (if not set, the current one will be used)
  32247. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32248. * @returns the new webGL program
  32249. */
  32250. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32251. /**
  32252. * Creates a webGL program
  32253. * @param pipelineContext defines the pipeline context to attach to
  32254. * @param vertexCode defines the vertex shader code to use
  32255. * @param fragmentCode defines the fragment shader code to use
  32256. * @param defines defines the string containing the defines to use to compile the shaders
  32257. * @param context defines the webGL context to use (if not set, the current one will be used)
  32258. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32259. * @returns the new webGL program
  32260. */
  32261. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32262. /**
  32263. * Creates a new pipeline context
  32264. * @returns the new pipeline
  32265. */
  32266. createPipelineContext(): IPipelineContext;
  32267. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32268. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32269. /** @hidden */
  32270. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32271. /** @hidden */
  32272. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32273. /** @hidden */
  32274. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32275. /**
  32276. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32277. * @param pipelineContext defines the pipeline context to use
  32278. * @param uniformsNames defines the list of uniform names
  32279. * @returns an array of webGL uniform locations
  32280. */
  32281. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32282. /**
  32283. * Gets the lsit of active attributes for a given webGL program
  32284. * @param pipelineContext defines the pipeline context to use
  32285. * @param attributesNames defines the list of attribute names to get
  32286. * @returns an array of indices indicating the offset of each attribute
  32287. */
  32288. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32289. /**
  32290. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32291. * @param effect defines the effect to activate
  32292. */
  32293. enableEffect(effect: Nullable<Effect>): void;
  32294. /**
  32295. * Set the value of an uniform to a number (int)
  32296. * @param uniform defines the webGL uniform location where to store the value
  32297. * @param value defines the int number to store
  32298. */
  32299. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32300. /**
  32301. * Set the value of an uniform to an array of int32
  32302. * @param uniform defines the webGL uniform location where to store the value
  32303. * @param array defines the array of int32 to store
  32304. */
  32305. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32306. /**
  32307. * Set the value of an uniform to an array of int32 (stored as vec2)
  32308. * @param uniform defines the webGL uniform location where to store the value
  32309. * @param array defines the array of int32 to store
  32310. */
  32311. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32312. /**
  32313. * Set the value of an uniform to an array of int32 (stored as vec3)
  32314. * @param uniform defines the webGL uniform location where to store the value
  32315. * @param array defines the array of int32 to store
  32316. */
  32317. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32318. /**
  32319. * Set the value of an uniform to an array of int32 (stored as vec4)
  32320. * @param uniform defines the webGL uniform location where to store the value
  32321. * @param array defines the array of int32 to store
  32322. */
  32323. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32324. /**
  32325. * Set the value of an uniform to an array of number
  32326. * @param uniform defines the webGL uniform location where to store the value
  32327. * @param array defines the array of number to store
  32328. */
  32329. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32330. /**
  32331. * Set the value of an uniform to an array of number (stored as vec2)
  32332. * @param uniform defines the webGL uniform location where to store the value
  32333. * @param array defines the array of number to store
  32334. */
  32335. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32336. /**
  32337. * Set the value of an uniform to an array of number (stored as vec3)
  32338. * @param uniform defines the webGL uniform location where to store the value
  32339. * @param array defines the array of number to store
  32340. */
  32341. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32342. /**
  32343. * Set the value of an uniform to an array of number (stored as vec4)
  32344. * @param uniform defines the webGL uniform location where to store the value
  32345. * @param array defines the array of number to store
  32346. */
  32347. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32348. /**
  32349. * Set the value of an uniform to an array of float32 (stored as matrices)
  32350. * @param uniform defines the webGL uniform location where to store the value
  32351. * @param matrices defines the array of float32 to store
  32352. */
  32353. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32354. /**
  32355. * Set the value of an uniform to a matrix (3x3)
  32356. * @param uniform defines the webGL uniform location where to store the value
  32357. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32358. */
  32359. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32360. /**
  32361. * Set the value of an uniform to a matrix (2x2)
  32362. * @param uniform defines the webGL uniform location where to store the value
  32363. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32364. */
  32365. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32366. /**
  32367. * Set the value of an uniform to a number (float)
  32368. * @param uniform defines the webGL uniform location where to store the value
  32369. * @param value defines the float number to store
  32370. */
  32371. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32372. /**
  32373. * Set the value of an uniform to a vec2
  32374. * @param uniform defines the webGL uniform location where to store the value
  32375. * @param x defines the 1st component of the value
  32376. * @param y defines the 2nd component of the value
  32377. */
  32378. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32379. /**
  32380. * Set the value of an uniform to a vec3
  32381. * @param uniform defines the webGL uniform location where to store the value
  32382. * @param x defines the 1st component of the value
  32383. * @param y defines the 2nd component of the value
  32384. * @param z defines the 3rd component of the value
  32385. */
  32386. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32387. /**
  32388. * Set the value of an uniform to a vec4
  32389. * @param uniform defines the webGL uniform location where to store the value
  32390. * @param x defines the 1st component of the value
  32391. * @param y defines the 2nd component of the value
  32392. * @param z defines the 3rd component of the value
  32393. * @param w defines the 4th component of the value
  32394. */
  32395. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32396. /**
  32397. * Apply all cached states (depth, culling, stencil and alpha)
  32398. */
  32399. applyStates(): void;
  32400. /**
  32401. * Enable or disable color writing
  32402. * @param enable defines the state to set
  32403. */
  32404. setColorWrite(enable: boolean): void;
  32405. /**
  32406. * Gets a boolean indicating if color writing is enabled
  32407. * @returns the current color writing state
  32408. */
  32409. getColorWrite(): boolean;
  32410. /**
  32411. * Gets the depth culling state manager
  32412. */
  32413. get depthCullingState(): DepthCullingState;
  32414. /**
  32415. * Gets the alpha state manager
  32416. */
  32417. get alphaState(): AlphaState;
  32418. /**
  32419. * Gets the stencil state manager
  32420. */
  32421. get stencilState(): StencilState;
  32422. /**
  32423. * Clears the list of texture accessible through engine.
  32424. * This can help preventing texture load conflict due to name collision.
  32425. */
  32426. clearInternalTexturesCache(): void;
  32427. /**
  32428. * Force the entire cache to be cleared
  32429. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32430. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32431. */
  32432. wipeCaches(bruteForce?: boolean): void;
  32433. /** @hidden */
  32434. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32435. min: number;
  32436. mag: number;
  32437. };
  32438. /** @hidden */
  32439. _createTexture(): WebGLTexture;
  32440. /**
  32441. * Usually called from Texture.ts.
  32442. * Passed information to create a WebGLTexture
  32443. * @param urlArg defines a value which contains one of the following:
  32444. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32445. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32446. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32447. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32448. * @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)
  32449. * @param scene needed for loading to the correct scene
  32450. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32451. * @param onLoad optional callback to be called upon successful completion
  32452. * @param onError optional callback to be called upon failure
  32453. * @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
  32454. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32455. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32456. * @param forcedExtension defines the extension to use to pick the right loader
  32457. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32458. * @param mimeType defines an optional mime type
  32459. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32460. */
  32461. 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 | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  32462. /**
  32463. * Loads an image as an HTMLImageElement.
  32464. * @param input url string, ArrayBuffer, or Blob to load
  32465. * @param onLoad callback called when the image successfully loads
  32466. * @param onError callback called when the image fails to load
  32467. * @param offlineProvider offline provider for caching
  32468. * @param mimeType optional mime type
  32469. * @returns the HTMLImageElement of the loaded image
  32470. * @hidden
  32471. */
  32472. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  32473. /**
  32474. * @hidden
  32475. */
  32476. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32477. /**
  32478. * Creates a raw texture
  32479. * @param data defines the data to store in the texture
  32480. * @param width defines the width of the texture
  32481. * @param height defines the height of the texture
  32482. * @param format defines the format of the data
  32483. * @param generateMipMaps defines if the engine should generate the mip levels
  32484. * @param invertY defines if data must be stored with Y axis inverted
  32485. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32486. * @param compression defines the compression used (null by default)
  32487. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32488. * @returns the raw texture inside an InternalTexture
  32489. */
  32490. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32491. /**
  32492. * Creates a new raw cube texture
  32493. * @param data defines the array of data to use to create each face
  32494. * @param size defines the size of the textures
  32495. * @param format defines the format of the data
  32496. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32497. * @param generateMipMaps defines if the engine should generate the mip levels
  32498. * @param invertY defines if data must be stored with Y axis inverted
  32499. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32500. * @param compression defines the compression used (null by default)
  32501. * @returns the cube texture as an InternalTexture
  32502. */
  32503. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32504. /**
  32505. * Creates a new raw 3D texture
  32506. * @param data defines the data used to create the texture
  32507. * @param width defines the width of the texture
  32508. * @param height defines the height of the texture
  32509. * @param depth defines the depth of the texture
  32510. * @param format defines the format of the texture
  32511. * @param generateMipMaps defines if the engine must generate mip levels
  32512. * @param invertY defines if data must be stored with Y axis inverted
  32513. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32514. * @param compression defines the compressed used (can be null)
  32515. * @param textureType defines the compressed used (can be null)
  32516. * @returns a new raw 3D texture (stored in an InternalTexture)
  32517. */
  32518. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32519. /**
  32520. * Creates a new raw 2D array texture
  32521. * @param data defines the data used to create the texture
  32522. * @param width defines the width of the texture
  32523. * @param height defines the height of the texture
  32524. * @param depth defines the number of layers of the texture
  32525. * @param format defines the format of the texture
  32526. * @param generateMipMaps defines if the engine must generate mip levels
  32527. * @param invertY defines if data must be stored with Y axis inverted
  32528. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32529. * @param compression defines the compressed used (can be null)
  32530. * @param textureType defines the compressed used (can be null)
  32531. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32532. */
  32533. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32534. private _unpackFlipYCached;
  32535. /**
  32536. * In case you are sharing the context with other applications, it might
  32537. * be interested to not cache the unpack flip y state to ensure a consistent
  32538. * value would be set.
  32539. */
  32540. enableUnpackFlipYCached: boolean;
  32541. /** @hidden */
  32542. _unpackFlipY(value: boolean): void;
  32543. /** @hidden */
  32544. _getUnpackAlignement(): number;
  32545. private _getTextureTarget;
  32546. /**
  32547. * Update the sampling mode of a given texture
  32548. * @param samplingMode defines the required sampling mode
  32549. * @param texture defines the texture to update
  32550. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32551. */
  32552. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32553. /**
  32554. * Update the sampling mode of a given texture
  32555. * @param texture defines the texture to update
  32556. * @param wrapU defines the texture wrap mode of the u coordinates
  32557. * @param wrapV defines the texture wrap mode of the v coordinates
  32558. * @param wrapR defines the texture wrap mode of the r coordinates
  32559. */
  32560. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32561. /** @hidden */
  32562. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32563. width: number;
  32564. height: number;
  32565. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32566. /** @hidden */
  32567. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32568. /** @hidden */
  32569. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32570. /** @hidden */
  32571. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32572. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32573. private _prepareWebGLTexture;
  32574. /** @hidden */
  32575. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32576. private _getDepthStencilBuffer;
  32577. /** @hidden */
  32578. _releaseFramebufferObjects(texture: InternalTexture): void;
  32579. /** @hidden */
  32580. _releaseTexture(texture: InternalTexture): void;
  32581. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32582. protected _setProgram(program: WebGLProgram): void;
  32583. protected _boundUniforms: {
  32584. [key: number]: WebGLUniformLocation;
  32585. };
  32586. /**
  32587. * Binds an effect to the webGL context
  32588. * @param effect defines the effect to bind
  32589. */
  32590. bindSamplers(effect: Effect): void;
  32591. private _activateCurrentTexture;
  32592. /** @hidden */
  32593. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32594. /** @hidden */
  32595. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32596. /**
  32597. * Unbind all textures from the webGL context
  32598. */
  32599. unbindAllTextures(): void;
  32600. /**
  32601. * Sets a texture to the according uniform.
  32602. * @param channel The texture channel
  32603. * @param uniform The uniform to set
  32604. * @param texture The texture to apply
  32605. */
  32606. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32607. private _bindSamplerUniformToChannel;
  32608. private _getTextureWrapMode;
  32609. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32610. /**
  32611. * Sets an array of texture to the webGL context
  32612. * @param channel defines the channel where the texture array must be set
  32613. * @param uniform defines the associated uniform location
  32614. * @param textures defines the array of textures to bind
  32615. */
  32616. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32617. /** @hidden */
  32618. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32619. private _setTextureParameterFloat;
  32620. private _setTextureParameterInteger;
  32621. /**
  32622. * Unbind all vertex attributes from the webGL context
  32623. */
  32624. unbindAllAttributes(): void;
  32625. /**
  32626. * 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
  32627. */
  32628. releaseEffects(): void;
  32629. /**
  32630. * Dispose and release all associated resources
  32631. */
  32632. dispose(): void;
  32633. /**
  32634. * Attach a new callback raised when context lost event is fired
  32635. * @param callback defines the callback to call
  32636. */
  32637. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32638. /**
  32639. * Attach a new callback raised when context restored event is fired
  32640. * @param callback defines the callback to call
  32641. */
  32642. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32643. /**
  32644. * Get the current error code of the webGL context
  32645. * @returns the error code
  32646. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32647. */
  32648. getError(): number;
  32649. private _canRenderToFloatFramebuffer;
  32650. private _canRenderToHalfFloatFramebuffer;
  32651. private _canRenderToFramebuffer;
  32652. /** @hidden */
  32653. _getWebGLTextureType(type: number): number;
  32654. /** @hidden */
  32655. _getInternalFormat(format: number): number;
  32656. /** @hidden */
  32657. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32658. /** @hidden */
  32659. _getRGBAMultiSampleBufferFormat(type: number): number;
  32660. /** @hidden */
  32661. _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;
  32662. /**
  32663. * Loads a file from a url
  32664. * @param url url to load
  32665. * @param onSuccess callback called when the file successfully loads
  32666. * @param onProgress callback called while file is loading (if the server supports this mode)
  32667. * @param offlineProvider defines the offline provider for caching
  32668. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32669. * @param onError callback called when the file fails to load
  32670. * @returns a file request object
  32671. * @hidden
  32672. */
  32673. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  32674. /**
  32675. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32676. * @param x defines the x coordinate of the rectangle where pixels must be read
  32677. * @param y defines the y coordinate of the rectangle where pixels must be read
  32678. * @param width defines the width of the rectangle where pixels must be read
  32679. * @param height defines the height of the rectangle where pixels must be read
  32680. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  32681. * @returns a Uint8Array containing RGBA colors
  32682. */
  32683. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32684. private static _isSupported;
  32685. /**
  32686. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32687. * @returns true if the engine can be created
  32688. * @ignorenaming
  32689. */
  32690. static isSupported(): boolean;
  32691. /**
  32692. * Find the next highest power of two.
  32693. * @param x Number to start search from.
  32694. * @return Next highest power of two.
  32695. */
  32696. static CeilingPOT(x: number): number;
  32697. /**
  32698. * Find the next lowest power of two.
  32699. * @param x Number to start search from.
  32700. * @return Next lowest power of two.
  32701. */
  32702. static FloorPOT(x: number): number;
  32703. /**
  32704. * Find the nearest power of two.
  32705. * @param x Number to start search from.
  32706. * @return Next nearest power of two.
  32707. */
  32708. static NearestPOT(x: number): number;
  32709. /**
  32710. * Get the closest exponent of two
  32711. * @param value defines the value to approximate
  32712. * @param max defines the maximum value to return
  32713. * @param mode defines how to define the closest value
  32714. * @returns closest exponent of two of the given value
  32715. */
  32716. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32717. /**
  32718. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32719. * @param func - the function to be called
  32720. * @param requester - the object that will request the next frame. Falls back to window.
  32721. * @returns frame number
  32722. */
  32723. static QueueNewFrame(func: () => void, requester?: any): number;
  32724. /**
  32725. * Gets host document
  32726. * @returns the host document object
  32727. */
  32728. getHostDocument(): Nullable<Document>;
  32729. }
  32730. }
  32731. declare module "babylonjs/Maths/sphericalPolynomial" {
  32732. import { Vector3 } from "babylonjs/Maths/math.vector";
  32733. import { Color3 } from "babylonjs/Maths/math.color";
  32734. /**
  32735. * Class representing spherical harmonics coefficients to the 3rd degree
  32736. */
  32737. export class SphericalHarmonics {
  32738. /**
  32739. * Defines whether or not the harmonics have been prescaled for rendering.
  32740. */
  32741. preScaled: boolean;
  32742. /**
  32743. * The l0,0 coefficients of the spherical harmonics
  32744. */
  32745. l00: Vector3;
  32746. /**
  32747. * The l1,-1 coefficients of the spherical harmonics
  32748. */
  32749. l1_1: Vector3;
  32750. /**
  32751. * The l1,0 coefficients of the spherical harmonics
  32752. */
  32753. l10: Vector3;
  32754. /**
  32755. * The l1,1 coefficients of the spherical harmonics
  32756. */
  32757. l11: Vector3;
  32758. /**
  32759. * The l2,-2 coefficients of the spherical harmonics
  32760. */
  32761. l2_2: Vector3;
  32762. /**
  32763. * The l2,-1 coefficients of the spherical harmonics
  32764. */
  32765. l2_1: Vector3;
  32766. /**
  32767. * The l2,0 coefficients of the spherical harmonics
  32768. */
  32769. l20: Vector3;
  32770. /**
  32771. * The l2,1 coefficients of the spherical harmonics
  32772. */
  32773. l21: Vector3;
  32774. /**
  32775. * The l2,2 coefficients of the spherical harmonics
  32776. */
  32777. l22: Vector3;
  32778. /**
  32779. * Adds a light to the spherical harmonics
  32780. * @param direction the direction of the light
  32781. * @param color the color of the light
  32782. * @param deltaSolidAngle the delta solid angle of the light
  32783. */
  32784. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32785. /**
  32786. * Scales the spherical harmonics by the given amount
  32787. * @param scale the amount to scale
  32788. */
  32789. scaleInPlace(scale: number): void;
  32790. /**
  32791. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32792. *
  32793. * ```
  32794. * E_lm = A_l * L_lm
  32795. * ```
  32796. *
  32797. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32798. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32799. * the scaling factors are given in equation 9.
  32800. */
  32801. convertIncidentRadianceToIrradiance(): void;
  32802. /**
  32803. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32804. *
  32805. * ```
  32806. * L = (1/pi) * E * rho
  32807. * ```
  32808. *
  32809. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32810. */
  32811. convertIrradianceToLambertianRadiance(): void;
  32812. /**
  32813. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32814. * required operations at run time.
  32815. *
  32816. * This is simply done by scaling back the SH with Ylm constants parameter.
  32817. * The trigonometric part being applied by the shader at run time.
  32818. */
  32819. preScaleForRendering(): void;
  32820. /**
  32821. * Constructs a spherical harmonics from an array.
  32822. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32823. * @returns the spherical harmonics
  32824. */
  32825. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32826. /**
  32827. * Gets the spherical harmonics from polynomial
  32828. * @param polynomial the spherical polynomial
  32829. * @returns the spherical harmonics
  32830. */
  32831. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32832. }
  32833. /**
  32834. * Class representing spherical polynomial coefficients to the 3rd degree
  32835. */
  32836. export class SphericalPolynomial {
  32837. private _harmonics;
  32838. /**
  32839. * The spherical harmonics used to create the polynomials.
  32840. */
  32841. get preScaledHarmonics(): SphericalHarmonics;
  32842. /**
  32843. * The x coefficients of the spherical polynomial
  32844. */
  32845. x: Vector3;
  32846. /**
  32847. * The y coefficients of the spherical polynomial
  32848. */
  32849. y: Vector3;
  32850. /**
  32851. * The z coefficients of the spherical polynomial
  32852. */
  32853. z: Vector3;
  32854. /**
  32855. * The xx coefficients of the spherical polynomial
  32856. */
  32857. xx: Vector3;
  32858. /**
  32859. * The yy coefficients of the spherical polynomial
  32860. */
  32861. yy: Vector3;
  32862. /**
  32863. * The zz coefficients of the spherical polynomial
  32864. */
  32865. zz: Vector3;
  32866. /**
  32867. * The xy coefficients of the spherical polynomial
  32868. */
  32869. xy: Vector3;
  32870. /**
  32871. * The yz coefficients of the spherical polynomial
  32872. */
  32873. yz: Vector3;
  32874. /**
  32875. * The zx coefficients of the spherical polynomial
  32876. */
  32877. zx: Vector3;
  32878. /**
  32879. * Adds an ambient color to the spherical polynomial
  32880. * @param color the color to add
  32881. */
  32882. addAmbient(color: Color3): void;
  32883. /**
  32884. * Scales the spherical polynomial by the given amount
  32885. * @param scale the amount to scale
  32886. */
  32887. scaleInPlace(scale: number): void;
  32888. /**
  32889. * Gets the spherical polynomial from harmonics
  32890. * @param harmonics the spherical harmonics
  32891. * @returns the spherical polynomial
  32892. */
  32893. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32894. /**
  32895. * Constructs a spherical polynomial from an array.
  32896. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32897. * @returns the spherical polynomial
  32898. */
  32899. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32900. }
  32901. }
  32902. declare module "babylonjs/Materials/Textures/internalTexture" {
  32903. import { Observable } from "babylonjs/Misc/observable";
  32904. import { Nullable, int } from "babylonjs/types";
  32905. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  32906. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32907. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  32908. /**
  32909. * Defines the source of the internal texture
  32910. */
  32911. export enum InternalTextureSource {
  32912. /**
  32913. * The source of the texture data is unknown
  32914. */
  32915. Unknown = 0,
  32916. /**
  32917. * Texture data comes from an URL
  32918. */
  32919. Url = 1,
  32920. /**
  32921. * Texture data is only used for temporary storage
  32922. */
  32923. Temp = 2,
  32924. /**
  32925. * Texture data comes from raw data (ArrayBuffer)
  32926. */
  32927. Raw = 3,
  32928. /**
  32929. * Texture content is dynamic (video or dynamic texture)
  32930. */
  32931. Dynamic = 4,
  32932. /**
  32933. * Texture content is generated by rendering to it
  32934. */
  32935. RenderTarget = 5,
  32936. /**
  32937. * Texture content is part of a multi render target process
  32938. */
  32939. MultiRenderTarget = 6,
  32940. /**
  32941. * Texture data comes from a cube data file
  32942. */
  32943. Cube = 7,
  32944. /**
  32945. * Texture data comes from a raw cube data
  32946. */
  32947. CubeRaw = 8,
  32948. /**
  32949. * Texture data come from a prefiltered cube data file
  32950. */
  32951. CubePrefiltered = 9,
  32952. /**
  32953. * Texture content is raw 3D data
  32954. */
  32955. Raw3D = 10,
  32956. /**
  32957. * Texture content is raw 2D array data
  32958. */
  32959. Raw2DArray = 11,
  32960. /**
  32961. * Texture content is a depth texture
  32962. */
  32963. Depth = 12,
  32964. /**
  32965. * Texture data comes from a raw cube data encoded with RGBD
  32966. */
  32967. CubeRawRGBD = 13
  32968. }
  32969. /**
  32970. * Class used to store data associated with WebGL texture data for the engine
  32971. * This class should not be used directly
  32972. */
  32973. export class InternalTexture {
  32974. /** @hidden */
  32975. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32976. /**
  32977. * Defines if the texture is ready
  32978. */
  32979. isReady: boolean;
  32980. /**
  32981. * Defines if the texture is a cube texture
  32982. */
  32983. isCube: boolean;
  32984. /**
  32985. * Defines if the texture contains 3D data
  32986. */
  32987. is3D: boolean;
  32988. /**
  32989. * Defines if the texture contains 2D array data
  32990. */
  32991. is2DArray: boolean;
  32992. /**
  32993. * Defines if the texture contains multiview data
  32994. */
  32995. isMultiview: boolean;
  32996. /**
  32997. * Gets the URL used to load this texture
  32998. */
  32999. url: string;
  33000. /**
  33001. * Gets the sampling mode of the texture
  33002. */
  33003. samplingMode: number;
  33004. /**
  33005. * Gets a boolean indicating if the texture needs mipmaps generation
  33006. */
  33007. generateMipMaps: boolean;
  33008. /**
  33009. * Gets the number of samples used by the texture (WebGL2+ only)
  33010. */
  33011. samples: number;
  33012. /**
  33013. * Gets the type of the texture (int, float...)
  33014. */
  33015. type: number;
  33016. /**
  33017. * Gets the format of the texture (RGB, RGBA...)
  33018. */
  33019. format: number;
  33020. /**
  33021. * Observable called when the texture is loaded
  33022. */
  33023. onLoadedObservable: Observable<InternalTexture>;
  33024. /**
  33025. * Gets the width of the texture
  33026. */
  33027. width: number;
  33028. /**
  33029. * Gets the height of the texture
  33030. */
  33031. height: number;
  33032. /**
  33033. * Gets the depth of the texture
  33034. */
  33035. depth: number;
  33036. /**
  33037. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33038. */
  33039. baseWidth: number;
  33040. /**
  33041. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33042. */
  33043. baseHeight: number;
  33044. /**
  33045. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33046. */
  33047. baseDepth: number;
  33048. /**
  33049. * Gets a boolean indicating if the texture is inverted on Y axis
  33050. */
  33051. invertY: boolean;
  33052. /** @hidden */
  33053. _invertVScale: boolean;
  33054. /** @hidden */
  33055. _associatedChannel: number;
  33056. /** @hidden */
  33057. _source: InternalTextureSource;
  33058. /** @hidden */
  33059. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33060. /** @hidden */
  33061. _bufferView: Nullable<ArrayBufferView>;
  33062. /** @hidden */
  33063. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33064. /** @hidden */
  33065. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33066. /** @hidden */
  33067. _size: number;
  33068. /** @hidden */
  33069. _extension: string;
  33070. /** @hidden */
  33071. _files: Nullable<string[]>;
  33072. /** @hidden */
  33073. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33074. /** @hidden */
  33075. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33076. /** @hidden */
  33077. _framebuffer: Nullable<WebGLFramebuffer>;
  33078. /** @hidden */
  33079. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33080. /** @hidden */
  33081. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33082. /** @hidden */
  33083. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33084. /** @hidden */
  33085. _attachments: Nullable<number[]>;
  33086. /** @hidden */
  33087. _cachedCoordinatesMode: Nullable<number>;
  33088. /** @hidden */
  33089. _cachedWrapU: Nullable<number>;
  33090. /** @hidden */
  33091. _cachedWrapV: Nullable<number>;
  33092. /** @hidden */
  33093. _cachedWrapR: Nullable<number>;
  33094. /** @hidden */
  33095. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33096. /** @hidden */
  33097. _isDisabled: boolean;
  33098. /** @hidden */
  33099. _compression: Nullable<string>;
  33100. /** @hidden */
  33101. _generateStencilBuffer: boolean;
  33102. /** @hidden */
  33103. _generateDepthBuffer: boolean;
  33104. /** @hidden */
  33105. _comparisonFunction: number;
  33106. /** @hidden */
  33107. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33108. /** @hidden */
  33109. _lodGenerationScale: number;
  33110. /** @hidden */
  33111. _lodGenerationOffset: number;
  33112. /** @hidden */
  33113. _colorTextureArray: Nullable<WebGLTexture>;
  33114. /** @hidden */
  33115. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33116. /** @hidden */
  33117. _lodTextureHigh: Nullable<BaseTexture>;
  33118. /** @hidden */
  33119. _lodTextureMid: Nullable<BaseTexture>;
  33120. /** @hidden */
  33121. _lodTextureLow: Nullable<BaseTexture>;
  33122. /** @hidden */
  33123. _isRGBD: boolean;
  33124. /** @hidden */
  33125. _linearSpecularLOD: boolean;
  33126. /** @hidden */
  33127. _irradianceTexture: Nullable<BaseTexture>;
  33128. /** @hidden */
  33129. _webGLTexture: Nullable<WebGLTexture>;
  33130. /** @hidden */
  33131. _references: number;
  33132. private _engine;
  33133. /**
  33134. * Gets the Engine the texture belongs to.
  33135. * @returns The babylon engine
  33136. */
  33137. getEngine(): ThinEngine;
  33138. /**
  33139. * Gets the data source type of the texture
  33140. */
  33141. get source(): InternalTextureSource;
  33142. /**
  33143. * Creates a new InternalTexture
  33144. * @param engine defines the engine to use
  33145. * @param source defines the type of data that will be used
  33146. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33147. */
  33148. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33149. /**
  33150. * Increments the number of references (ie. the number of Texture that point to it)
  33151. */
  33152. incrementReferences(): void;
  33153. /**
  33154. * Change the size of the texture (not the size of the content)
  33155. * @param width defines the new width
  33156. * @param height defines the new height
  33157. * @param depth defines the new depth (1 by default)
  33158. */
  33159. updateSize(width: int, height: int, depth?: int): void;
  33160. /** @hidden */
  33161. _rebuild(): void;
  33162. /** @hidden */
  33163. _swapAndDie(target: InternalTexture): void;
  33164. /**
  33165. * Dispose the current allocated resources
  33166. */
  33167. dispose(): void;
  33168. }
  33169. }
  33170. declare module "babylonjs/Audio/analyser" {
  33171. import { Scene } from "babylonjs/scene";
  33172. /**
  33173. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33174. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33175. */
  33176. export class Analyser {
  33177. /**
  33178. * Gets or sets the smoothing
  33179. * @ignorenaming
  33180. */
  33181. SMOOTHING: number;
  33182. /**
  33183. * Gets or sets the FFT table size
  33184. * @ignorenaming
  33185. */
  33186. FFT_SIZE: number;
  33187. /**
  33188. * Gets or sets the bar graph amplitude
  33189. * @ignorenaming
  33190. */
  33191. BARGRAPHAMPLITUDE: number;
  33192. /**
  33193. * Gets or sets the position of the debug canvas
  33194. * @ignorenaming
  33195. */
  33196. DEBUGCANVASPOS: {
  33197. x: number;
  33198. y: number;
  33199. };
  33200. /**
  33201. * Gets or sets the debug canvas size
  33202. * @ignorenaming
  33203. */
  33204. DEBUGCANVASSIZE: {
  33205. width: number;
  33206. height: number;
  33207. };
  33208. private _byteFreqs;
  33209. private _byteTime;
  33210. private _floatFreqs;
  33211. private _webAudioAnalyser;
  33212. private _debugCanvas;
  33213. private _debugCanvasContext;
  33214. private _scene;
  33215. private _registerFunc;
  33216. private _audioEngine;
  33217. /**
  33218. * Creates a new analyser
  33219. * @param scene defines hosting scene
  33220. */
  33221. constructor(scene: Scene);
  33222. /**
  33223. * Get the number of data values you will have to play with for the visualization
  33224. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33225. * @returns a number
  33226. */
  33227. getFrequencyBinCount(): number;
  33228. /**
  33229. * Gets the current frequency data as a byte array
  33230. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33231. * @returns a Uint8Array
  33232. */
  33233. getByteFrequencyData(): Uint8Array;
  33234. /**
  33235. * Gets the current waveform as a byte array
  33236. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33237. * @returns a Uint8Array
  33238. */
  33239. getByteTimeDomainData(): Uint8Array;
  33240. /**
  33241. * Gets the current frequency data as a float array
  33242. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33243. * @returns a Float32Array
  33244. */
  33245. getFloatFrequencyData(): Float32Array;
  33246. /**
  33247. * Renders the debug canvas
  33248. */
  33249. drawDebugCanvas(): void;
  33250. /**
  33251. * Stops rendering the debug canvas and removes it
  33252. */
  33253. stopDebugCanvas(): void;
  33254. /**
  33255. * Connects two audio nodes
  33256. * @param inputAudioNode defines first node to connect
  33257. * @param outputAudioNode defines second node to connect
  33258. */
  33259. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33260. /**
  33261. * Releases all associated resources
  33262. */
  33263. dispose(): void;
  33264. }
  33265. }
  33266. declare module "babylonjs/Audio/audioEngine" {
  33267. import { IDisposable } from "babylonjs/scene";
  33268. import { Analyser } from "babylonjs/Audio/analyser";
  33269. import { Nullable } from "babylonjs/types";
  33270. import { Observable } from "babylonjs/Misc/observable";
  33271. /**
  33272. * This represents an audio engine and it is responsible
  33273. * to play, synchronize and analyse sounds throughout the application.
  33274. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33275. */
  33276. export interface IAudioEngine extends IDisposable {
  33277. /**
  33278. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33279. */
  33280. readonly canUseWebAudio: boolean;
  33281. /**
  33282. * Gets the current AudioContext if available.
  33283. */
  33284. readonly audioContext: Nullable<AudioContext>;
  33285. /**
  33286. * The master gain node defines the global audio volume of your audio engine.
  33287. */
  33288. readonly masterGain: GainNode;
  33289. /**
  33290. * Gets whether or not mp3 are supported by your browser.
  33291. */
  33292. readonly isMP3supported: boolean;
  33293. /**
  33294. * Gets whether or not ogg are supported by your browser.
  33295. */
  33296. readonly isOGGsupported: boolean;
  33297. /**
  33298. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33299. * @ignoreNaming
  33300. */
  33301. WarnedWebAudioUnsupported: boolean;
  33302. /**
  33303. * Defines if the audio engine relies on a custom unlocked button.
  33304. * In this case, the embedded button will not be displayed.
  33305. */
  33306. useCustomUnlockedButton: boolean;
  33307. /**
  33308. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33309. */
  33310. readonly unlocked: boolean;
  33311. /**
  33312. * Event raised when audio has been unlocked on the browser.
  33313. */
  33314. onAudioUnlockedObservable: Observable<AudioEngine>;
  33315. /**
  33316. * Event raised when audio has been locked on the browser.
  33317. */
  33318. onAudioLockedObservable: Observable<AudioEngine>;
  33319. /**
  33320. * Flags the audio engine in Locked state.
  33321. * This happens due to new browser policies preventing audio to autoplay.
  33322. */
  33323. lock(): void;
  33324. /**
  33325. * Unlocks the audio engine once a user action has been done on the dom.
  33326. * This is helpful to resume play once browser policies have been satisfied.
  33327. */
  33328. unlock(): void;
  33329. }
  33330. /**
  33331. * This represents the default audio engine used in babylon.
  33332. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33333. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33334. */
  33335. export class AudioEngine implements IAudioEngine {
  33336. private _audioContext;
  33337. private _audioContextInitialized;
  33338. private _muteButton;
  33339. private _hostElement;
  33340. /**
  33341. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33342. */
  33343. canUseWebAudio: boolean;
  33344. /**
  33345. * The master gain node defines the global audio volume of your audio engine.
  33346. */
  33347. masterGain: GainNode;
  33348. /**
  33349. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33350. * @ignoreNaming
  33351. */
  33352. WarnedWebAudioUnsupported: boolean;
  33353. /**
  33354. * Gets whether or not mp3 are supported by your browser.
  33355. */
  33356. isMP3supported: boolean;
  33357. /**
  33358. * Gets whether or not ogg are supported by your browser.
  33359. */
  33360. isOGGsupported: boolean;
  33361. /**
  33362. * Gets whether audio has been unlocked on the device.
  33363. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33364. * a user interaction has happened.
  33365. */
  33366. unlocked: boolean;
  33367. /**
  33368. * Defines if the audio engine relies on a custom unlocked button.
  33369. * In this case, the embedded button will not be displayed.
  33370. */
  33371. useCustomUnlockedButton: boolean;
  33372. /**
  33373. * Event raised when audio has been unlocked on the browser.
  33374. */
  33375. onAudioUnlockedObservable: Observable<AudioEngine>;
  33376. /**
  33377. * Event raised when audio has been locked on the browser.
  33378. */
  33379. onAudioLockedObservable: Observable<AudioEngine>;
  33380. /**
  33381. * Gets the current AudioContext if available.
  33382. */
  33383. get audioContext(): Nullable<AudioContext>;
  33384. private _connectedAnalyser;
  33385. /**
  33386. * Instantiates a new audio engine.
  33387. *
  33388. * There should be only one per page as some browsers restrict the number
  33389. * of audio contexts you can create.
  33390. * @param hostElement defines the host element where to display the mute icon if necessary
  33391. */
  33392. constructor(hostElement?: Nullable<HTMLElement>);
  33393. /**
  33394. * Flags the audio engine in Locked state.
  33395. * This happens due to new browser policies preventing audio to autoplay.
  33396. */
  33397. lock(): void;
  33398. /**
  33399. * Unlocks the audio engine once a user action has been done on the dom.
  33400. * This is helpful to resume play once browser policies have been satisfied.
  33401. */
  33402. unlock(): void;
  33403. private _resumeAudioContext;
  33404. private _initializeAudioContext;
  33405. private _tryToRun;
  33406. private _triggerRunningState;
  33407. private _triggerSuspendedState;
  33408. private _displayMuteButton;
  33409. private _moveButtonToTopLeft;
  33410. private _onResize;
  33411. private _hideMuteButton;
  33412. /**
  33413. * Destroy and release the resources associated with the audio ccontext.
  33414. */
  33415. dispose(): void;
  33416. /**
  33417. * Gets the global volume sets on the master gain.
  33418. * @returns the global volume if set or -1 otherwise
  33419. */
  33420. getGlobalVolume(): number;
  33421. /**
  33422. * Sets the global volume of your experience (sets on the master gain).
  33423. * @param newVolume Defines the new global volume of the application
  33424. */
  33425. setGlobalVolume(newVolume: number): void;
  33426. /**
  33427. * Connect the audio engine to an audio analyser allowing some amazing
  33428. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33429. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33430. * @param analyser The analyser to connect to the engine
  33431. */
  33432. connectToAnalyser(analyser: Analyser): void;
  33433. }
  33434. }
  33435. declare module "babylonjs/Loading/loadingScreen" {
  33436. /**
  33437. * Interface used to present a loading screen while loading a scene
  33438. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33439. */
  33440. export interface ILoadingScreen {
  33441. /**
  33442. * Function called to display the loading screen
  33443. */
  33444. displayLoadingUI: () => void;
  33445. /**
  33446. * Function called to hide the loading screen
  33447. */
  33448. hideLoadingUI: () => void;
  33449. /**
  33450. * Gets or sets the color to use for the background
  33451. */
  33452. loadingUIBackgroundColor: string;
  33453. /**
  33454. * Gets or sets the text to display while loading
  33455. */
  33456. loadingUIText: string;
  33457. }
  33458. /**
  33459. * Class used for the default loading screen
  33460. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33461. */
  33462. export class DefaultLoadingScreen implements ILoadingScreen {
  33463. private _renderingCanvas;
  33464. private _loadingText;
  33465. private _loadingDivBackgroundColor;
  33466. private _loadingDiv;
  33467. private _loadingTextDiv;
  33468. /** Gets or sets the logo url to use for the default loading screen */
  33469. static DefaultLogoUrl: string;
  33470. /** Gets or sets the spinner url to use for the default loading screen */
  33471. static DefaultSpinnerUrl: string;
  33472. /**
  33473. * Creates a new default loading screen
  33474. * @param _renderingCanvas defines the canvas used to render the scene
  33475. * @param _loadingText defines the default text to display
  33476. * @param _loadingDivBackgroundColor defines the default background color
  33477. */
  33478. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33479. /**
  33480. * Function called to display the loading screen
  33481. */
  33482. displayLoadingUI(): void;
  33483. /**
  33484. * Function called to hide the loading screen
  33485. */
  33486. hideLoadingUI(): void;
  33487. /**
  33488. * Gets or sets the text to display while loading
  33489. */
  33490. set loadingUIText(text: string);
  33491. get loadingUIText(): string;
  33492. /**
  33493. * Gets or sets the color to use for the background
  33494. */
  33495. get loadingUIBackgroundColor(): string;
  33496. set loadingUIBackgroundColor(color: string);
  33497. private _resizeLoadingUI;
  33498. }
  33499. }
  33500. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33501. /**
  33502. * Interface for any object that can request an animation frame
  33503. */
  33504. export interface ICustomAnimationFrameRequester {
  33505. /**
  33506. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33507. */
  33508. renderFunction?: Function;
  33509. /**
  33510. * Called to request the next frame to render to
  33511. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33512. */
  33513. requestAnimationFrame: Function;
  33514. /**
  33515. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33516. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33517. */
  33518. requestID?: number;
  33519. }
  33520. }
  33521. declare module "babylonjs/Misc/performanceMonitor" {
  33522. /**
  33523. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33524. */
  33525. export class PerformanceMonitor {
  33526. private _enabled;
  33527. private _rollingFrameTime;
  33528. private _lastFrameTimeMs;
  33529. /**
  33530. * constructor
  33531. * @param frameSampleSize The number of samples required to saturate the sliding window
  33532. */
  33533. constructor(frameSampleSize?: number);
  33534. /**
  33535. * Samples current frame
  33536. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33537. */
  33538. sampleFrame(timeMs?: number): void;
  33539. /**
  33540. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33541. */
  33542. get averageFrameTime(): number;
  33543. /**
  33544. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33545. */
  33546. get averageFrameTimeVariance(): number;
  33547. /**
  33548. * Returns the frame time of the most recent frame
  33549. */
  33550. get instantaneousFrameTime(): number;
  33551. /**
  33552. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33553. */
  33554. get averageFPS(): number;
  33555. /**
  33556. * Returns the average framerate in frames per second using the most recent frame time
  33557. */
  33558. get instantaneousFPS(): number;
  33559. /**
  33560. * Returns true if enough samples have been taken to completely fill the sliding window
  33561. */
  33562. get isSaturated(): boolean;
  33563. /**
  33564. * Enables contributions to the sliding window sample set
  33565. */
  33566. enable(): void;
  33567. /**
  33568. * Disables contributions to the sliding window sample set
  33569. * Samples will not be interpolated over the disabled period
  33570. */
  33571. disable(): void;
  33572. /**
  33573. * Returns true if sampling is enabled
  33574. */
  33575. get isEnabled(): boolean;
  33576. /**
  33577. * Resets performance monitor
  33578. */
  33579. reset(): void;
  33580. }
  33581. /**
  33582. * RollingAverage
  33583. *
  33584. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33585. */
  33586. export class RollingAverage {
  33587. /**
  33588. * Current average
  33589. */
  33590. average: number;
  33591. /**
  33592. * Current variance
  33593. */
  33594. variance: number;
  33595. protected _samples: Array<number>;
  33596. protected _sampleCount: number;
  33597. protected _pos: number;
  33598. protected _m2: number;
  33599. /**
  33600. * constructor
  33601. * @param length The number of samples required to saturate the sliding window
  33602. */
  33603. constructor(length: number);
  33604. /**
  33605. * Adds a sample to the sample set
  33606. * @param v The sample value
  33607. */
  33608. add(v: number): void;
  33609. /**
  33610. * Returns previously added values or null if outside of history or outside the sliding window domain
  33611. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33612. * @return Value previously recorded with add() or null if outside of range
  33613. */
  33614. history(i: number): number;
  33615. /**
  33616. * Returns true if enough samples have been taken to completely fill the sliding window
  33617. * @return true if sample-set saturated
  33618. */
  33619. isSaturated(): boolean;
  33620. /**
  33621. * Resets the rolling average (equivalent to 0 samples taken so far)
  33622. */
  33623. reset(): void;
  33624. /**
  33625. * Wraps a value around the sample range boundaries
  33626. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33627. * @return Wrapped position in sample range
  33628. */
  33629. protected _wrapPosition(i: number): number;
  33630. }
  33631. }
  33632. declare module "babylonjs/Misc/perfCounter" {
  33633. /**
  33634. * This class is used to track a performance counter which is number based.
  33635. * The user has access to many properties which give statistics of different nature.
  33636. *
  33637. * The implementer can track two kinds of Performance Counter: time and count.
  33638. * 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.
  33639. * 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.
  33640. */
  33641. export class PerfCounter {
  33642. /**
  33643. * Gets or sets a global boolean to turn on and off all the counters
  33644. */
  33645. static Enabled: boolean;
  33646. /**
  33647. * Returns the smallest value ever
  33648. */
  33649. get min(): number;
  33650. /**
  33651. * Returns the biggest value ever
  33652. */
  33653. get max(): number;
  33654. /**
  33655. * Returns the average value since the performance counter is running
  33656. */
  33657. get average(): number;
  33658. /**
  33659. * Returns the average value of the last second the counter was monitored
  33660. */
  33661. get lastSecAverage(): number;
  33662. /**
  33663. * Returns the current value
  33664. */
  33665. get current(): number;
  33666. /**
  33667. * Gets the accumulated total
  33668. */
  33669. get total(): number;
  33670. /**
  33671. * Gets the total value count
  33672. */
  33673. get count(): number;
  33674. /**
  33675. * Creates a new counter
  33676. */
  33677. constructor();
  33678. /**
  33679. * Call this method to start monitoring a new frame.
  33680. * 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.
  33681. */
  33682. fetchNewFrame(): void;
  33683. /**
  33684. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33685. * @param newCount the count value to add to the monitored count
  33686. * @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.
  33687. */
  33688. addCount(newCount: number, fetchResult: boolean): void;
  33689. /**
  33690. * Start monitoring this performance counter
  33691. */
  33692. beginMonitoring(): void;
  33693. /**
  33694. * Compute the time lapsed since the previous beginMonitoring() call.
  33695. * @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
  33696. */
  33697. endMonitoring(newFrame?: boolean): void;
  33698. private _fetchResult;
  33699. private _startMonitoringTime;
  33700. private _min;
  33701. private _max;
  33702. private _average;
  33703. private _current;
  33704. private _totalValueCount;
  33705. private _totalAccumulated;
  33706. private _lastSecAverage;
  33707. private _lastSecAccumulated;
  33708. private _lastSecTime;
  33709. private _lastSecValueCount;
  33710. }
  33711. }
  33712. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  33713. module "babylonjs/Engines/thinEngine" {
  33714. interface ThinEngine {
  33715. /**
  33716. * Sets alpha constants used by some alpha blending modes
  33717. * @param r defines the red component
  33718. * @param g defines the green component
  33719. * @param b defines the blue component
  33720. * @param a defines the alpha component
  33721. */
  33722. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33723. /**
  33724. * Sets the current alpha mode
  33725. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33726. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33727. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33728. */
  33729. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33730. /**
  33731. * Gets the current alpha mode
  33732. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33733. * @returns the current alpha mode
  33734. */
  33735. getAlphaMode(): number;
  33736. /**
  33737. * Sets the current alpha equation
  33738. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33739. */
  33740. setAlphaEquation(equation: number): void;
  33741. /**
  33742. * Gets the current alpha equation.
  33743. * @returns the current alpha equation
  33744. */
  33745. getAlphaEquation(): number;
  33746. }
  33747. }
  33748. }
  33749. declare module "babylonjs/Engines/engine" {
  33750. import { Observable } from "babylonjs/Misc/observable";
  33751. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  33752. import { Scene } from "babylonjs/scene";
  33753. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33754. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  33755. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33756. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  33757. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  33758. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  33759. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  33760. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  33761. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  33762. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33763. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  33764. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  33765. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33766. import "babylonjs/Engines/Extensions/engine.alpha";
  33767. import { Material } from "babylonjs/Materials/material";
  33768. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33769. /**
  33770. * Defines the interface used by display changed events
  33771. */
  33772. export interface IDisplayChangedEventArgs {
  33773. /** Gets the vrDisplay object (if any) */
  33774. vrDisplay: Nullable<any>;
  33775. /** Gets a boolean indicating if webVR is supported */
  33776. vrSupported: boolean;
  33777. }
  33778. /**
  33779. * Defines the interface used by objects containing a viewport (like a camera)
  33780. */
  33781. interface IViewportOwnerLike {
  33782. /**
  33783. * Gets or sets the viewport
  33784. */
  33785. viewport: IViewportLike;
  33786. }
  33787. /**
  33788. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33789. */
  33790. export class Engine extends ThinEngine {
  33791. /** Defines that alpha blending is disabled */
  33792. static readonly ALPHA_DISABLE: number;
  33793. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33794. static readonly ALPHA_ADD: number;
  33795. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33796. static readonly ALPHA_COMBINE: number;
  33797. /** Defines that alpha blending to DEST - SRC * DEST */
  33798. static readonly ALPHA_SUBTRACT: number;
  33799. /** Defines that alpha blending to SRC * DEST */
  33800. static readonly ALPHA_MULTIPLY: number;
  33801. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33802. static readonly ALPHA_MAXIMIZED: number;
  33803. /** Defines that alpha blending to SRC + DEST */
  33804. static readonly ALPHA_ONEONE: number;
  33805. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33806. static readonly ALPHA_PREMULTIPLIED: number;
  33807. /**
  33808. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33809. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33810. */
  33811. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33812. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33813. static readonly ALPHA_INTERPOLATE: number;
  33814. /**
  33815. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33816. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33817. */
  33818. static readonly ALPHA_SCREENMODE: number;
  33819. /** Defines that the ressource is not delayed*/
  33820. static readonly DELAYLOADSTATE_NONE: number;
  33821. /** Defines that the ressource was successfully delay loaded */
  33822. static readonly DELAYLOADSTATE_LOADED: number;
  33823. /** Defines that the ressource is currently delay loading */
  33824. static readonly DELAYLOADSTATE_LOADING: number;
  33825. /** Defines that the ressource is delayed and has not started loading */
  33826. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33827. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33828. static readonly NEVER: number;
  33829. /** 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 */
  33830. static readonly ALWAYS: number;
  33831. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33832. static readonly LESS: number;
  33833. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33834. static readonly EQUAL: number;
  33835. /** 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 */
  33836. static readonly LEQUAL: number;
  33837. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33838. static readonly GREATER: number;
  33839. /** 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 */
  33840. static readonly GEQUAL: number;
  33841. /** 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 */
  33842. static readonly NOTEQUAL: number;
  33843. /** Passed to stencilOperation to specify that stencil value must be kept */
  33844. static readonly KEEP: number;
  33845. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33846. static readonly REPLACE: number;
  33847. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33848. static readonly INCR: number;
  33849. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33850. static readonly DECR: number;
  33851. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33852. static readonly INVERT: number;
  33853. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33854. static readonly INCR_WRAP: number;
  33855. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33856. static readonly DECR_WRAP: number;
  33857. /** Texture is not repeating outside of 0..1 UVs */
  33858. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33859. /** Texture is repeating outside of 0..1 UVs */
  33860. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33861. /** Texture is repeating and mirrored */
  33862. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33863. /** ALPHA */
  33864. static readonly TEXTUREFORMAT_ALPHA: number;
  33865. /** LUMINANCE */
  33866. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33867. /** LUMINANCE_ALPHA */
  33868. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33869. /** RGB */
  33870. static readonly TEXTUREFORMAT_RGB: number;
  33871. /** RGBA */
  33872. static readonly TEXTUREFORMAT_RGBA: number;
  33873. /** RED */
  33874. static readonly TEXTUREFORMAT_RED: number;
  33875. /** RED (2nd reference) */
  33876. static readonly TEXTUREFORMAT_R: number;
  33877. /** RG */
  33878. static readonly TEXTUREFORMAT_RG: number;
  33879. /** RED_INTEGER */
  33880. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33881. /** RED_INTEGER (2nd reference) */
  33882. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33883. /** RG_INTEGER */
  33884. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33885. /** RGB_INTEGER */
  33886. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33887. /** RGBA_INTEGER */
  33888. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33889. /** UNSIGNED_BYTE */
  33890. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33891. /** UNSIGNED_BYTE (2nd reference) */
  33892. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33893. /** FLOAT */
  33894. static readonly TEXTURETYPE_FLOAT: number;
  33895. /** HALF_FLOAT */
  33896. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33897. /** BYTE */
  33898. static readonly TEXTURETYPE_BYTE: number;
  33899. /** SHORT */
  33900. static readonly TEXTURETYPE_SHORT: number;
  33901. /** UNSIGNED_SHORT */
  33902. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33903. /** INT */
  33904. static readonly TEXTURETYPE_INT: number;
  33905. /** UNSIGNED_INT */
  33906. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33907. /** UNSIGNED_SHORT_4_4_4_4 */
  33908. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33909. /** UNSIGNED_SHORT_5_5_5_1 */
  33910. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33911. /** UNSIGNED_SHORT_5_6_5 */
  33912. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33913. /** UNSIGNED_INT_2_10_10_10_REV */
  33914. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33915. /** UNSIGNED_INT_24_8 */
  33916. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33917. /** UNSIGNED_INT_10F_11F_11F_REV */
  33918. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33919. /** UNSIGNED_INT_5_9_9_9_REV */
  33920. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33921. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33922. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33923. /** nearest is mag = nearest and min = nearest and mip = linear */
  33924. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33925. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33926. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33927. /** Trilinear is mag = linear and min = linear and mip = linear */
  33928. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33929. /** nearest is mag = nearest and min = nearest and mip = linear */
  33930. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33931. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33932. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33933. /** Trilinear is mag = linear and min = linear and mip = linear */
  33934. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33935. /** mag = nearest and min = nearest and mip = nearest */
  33936. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33937. /** mag = nearest and min = linear and mip = nearest */
  33938. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33939. /** mag = nearest and min = linear and mip = linear */
  33940. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33941. /** mag = nearest and min = linear and mip = none */
  33942. static readonly TEXTURE_NEAREST_LINEAR: number;
  33943. /** mag = nearest and min = nearest and mip = none */
  33944. static readonly TEXTURE_NEAREST_NEAREST: number;
  33945. /** mag = linear and min = nearest and mip = nearest */
  33946. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33947. /** mag = linear and min = nearest and mip = linear */
  33948. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33949. /** mag = linear and min = linear and mip = none */
  33950. static readonly TEXTURE_LINEAR_LINEAR: number;
  33951. /** mag = linear and min = nearest and mip = none */
  33952. static readonly TEXTURE_LINEAR_NEAREST: number;
  33953. /** Explicit coordinates mode */
  33954. static readonly TEXTURE_EXPLICIT_MODE: number;
  33955. /** Spherical coordinates mode */
  33956. static readonly TEXTURE_SPHERICAL_MODE: number;
  33957. /** Planar coordinates mode */
  33958. static readonly TEXTURE_PLANAR_MODE: number;
  33959. /** Cubic coordinates mode */
  33960. static readonly TEXTURE_CUBIC_MODE: number;
  33961. /** Projection coordinates mode */
  33962. static readonly TEXTURE_PROJECTION_MODE: number;
  33963. /** Skybox coordinates mode */
  33964. static readonly TEXTURE_SKYBOX_MODE: number;
  33965. /** Inverse Cubic coordinates mode */
  33966. static readonly TEXTURE_INVCUBIC_MODE: number;
  33967. /** Equirectangular coordinates mode */
  33968. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33969. /** Equirectangular Fixed coordinates mode */
  33970. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33971. /** Equirectangular Fixed Mirrored coordinates mode */
  33972. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33973. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33974. static readonly SCALEMODE_FLOOR: number;
  33975. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33976. static readonly SCALEMODE_NEAREST: number;
  33977. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33978. static readonly SCALEMODE_CEILING: number;
  33979. /**
  33980. * Returns the current npm package of the sdk
  33981. */
  33982. static get NpmPackage(): string;
  33983. /**
  33984. * Returns the current version of the framework
  33985. */
  33986. static get Version(): string;
  33987. /** Gets the list of created engines */
  33988. static get Instances(): Engine[];
  33989. /**
  33990. * Gets the latest created engine
  33991. */
  33992. static get LastCreatedEngine(): Nullable<Engine>;
  33993. /**
  33994. * Gets the latest created scene
  33995. */
  33996. static get LastCreatedScene(): Nullable<Scene>;
  33997. /**
  33998. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33999. * @param flag defines which part of the materials must be marked as dirty
  34000. * @param predicate defines a predicate used to filter which materials should be affected
  34001. */
  34002. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34003. /**
  34004. * Method called to create the default loading screen.
  34005. * This can be overriden in your own app.
  34006. * @param canvas The rendering canvas element
  34007. * @returns The loading screen
  34008. */
  34009. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34010. /**
  34011. * Method called to create the default rescale post process on each engine.
  34012. */
  34013. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34014. /**
  34015. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34016. **/
  34017. enableOfflineSupport: boolean;
  34018. /**
  34019. * 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)
  34020. **/
  34021. disableManifestCheck: boolean;
  34022. /**
  34023. * Gets the list of created scenes
  34024. */
  34025. scenes: Scene[];
  34026. /**
  34027. * Event raised when a new scene is created
  34028. */
  34029. onNewSceneAddedObservable: Observable<Scene>;
  34030. /**
  34031. * Gets the list of created postprocesses
  34032. */
  34033. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34034. /**
  34035. * Gets a boolean indicating if the pointer is currently locked
  34036. */
  34037. isPointerLock: boolean;
  34038. /**
  34039. * Observable event triggered each time the rendering canvas is resized
  34040. */
  34041. onResizeObservable: Observable<Engine>;
  34042. /**
  34043. * Observable event triggered each time the canvas loses focus
  34044. */
  34045. onCanvasBlurObservable: Observable<Engine>;
  34046. /**
  34047. * Observable event triggered each time the canvas gains focus
  34048. */
  34049. onCanvasFocusObservable: Observable<Engine>;
  34050. /**
  34051. * Observable event triggered each time the canvas receives pointerout event
  34052. */
  34053. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34054. /**
  34055. * Observable raised when the engine begins a new frame
  34056. */
  34057. onBeginFrameObservable: Observable<Engine>;
  34058. /**
  34059. * If set, will be used to request the next animation frame for the render loop
  34060. */
  34061. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34062. /**
  34063. * Observable raised when the engine ends the current frame
  34064. */
  34065. onEndFrameObservable: Observable<Engine>;
  34066. /**
  34067. * Observable raised when the engine is about to compile a shader
  34068. */
  34069. onBeforeShaderCompilationObservable: Observable<Engine>;
  34070. /**
  34071. * Observable raised when the engine has jsut compiled a shader
  34072. */
  34073. onAfterShaderCompilationObservable: Observable<Engine>;
  34074. /**
  34075. * Gets the audio engine
  34076. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34077. * @ignorenaming
  34078. */
  34079. static audioEngine: IAudioEngine;
  34080. /**
  34081. * Default AudioEngine factory responsible of creating the Audio Engine.
  34082. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34083. */
  34084. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34085. /**
  34086. * Default offline support factory responsible of creating a tool used to store data locally.
  34087. * By default, this will create a Database object if the workload has been embedded.
  34088. */
  34089. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34090. private _loadingScreen;
  34091. private _pointerLockRequested;
  34092. private _dummyFramebuffer;
  34093. private _rescalePostProcess;
  34094. private _deterministicLockstep;
  34095. private _lockstepMaxSteps;
  34096. private _timeStep;
  34097. protected get _supportsHardwareTextureRescaling(): boolean;
  34098. private _fps;
  34099. private _deltaTime;
  34100. /** @hidden */
  34101. _drawCalls: PerfCounter;
  34102. /**
  34103. * Turn this value on if you want to pause FPS computation when in background
  34104. */
  34105. disablePerformanceMonitorInBackground: boolean;
  34106. private _performanceMonitor;
  34107. /**
  34108. * Gets the performance monitor attached to this engine
  34109. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34110. */
  34111. get performanceMonitor(): PerformanceMonitor;
  34112. private _onFocus;
  34113. private _onBlur;
  34114. private _onCanvasPointerOut;
  34115. private _onCanvasBlur;
  34116. private _onCanvasFocus;
  34117. private _onFullscreenChange;
  34118. private _onPointerLockChange;
  34119. /**
  34120. * Gets the HTML element used to attach event listeners
  34121. * @returns a HTML element
  34122. */
  34123. getInputElement(): Nullable<HTMLElement>;
  34124. /**
  34125. * Creates a new engine
  34126. * @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
  34127. * @param antialias defines enable antialiasing (default: false)
  34128. * @param options defines further options to be sent to the getContext() function
  34129. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34130. */
  34131. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34132. /**
  34133. * Gets current aspect ratio
  34134. * @param viewportOwner defines the camera to use to get the aspect ratio
  34135. * @param useScreen defines if screen size must be used (or the current render target if any)
  34136. * @returns a number defining the aspect ratio
  34137. */
  34138. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34139. /**
  34140. * Gets current screen aspect ratio
  34141. * @returns a number defining the aspect ratio
  34142. */
  34143. getScreenAspectRatio(): number;
  34144. /**
  34145. * Gets the client rect of the HTML canvas attached with the current webGL context
  34146. * @returns a client rectanglee
  34147. */
  34148. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34149. /**
  34150. * Gets the client rect of the HTML element used for events
  34151. * @returns a client rectanglee
  34152. */
  34153. getInputElementClientRect(): Nullable<ClientRect>;
  34154. /**
  34155. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34156. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34157. * @returns true if engine is in deterministic lock step mode
  34158. */
  34159. isDeterministicLockStep(): boolean;
  34160. /**
  34161. * Gets the max steps when engine is running in deterministic lock step
  34162. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34163. * @returns the max steps
  34164. */
  34165. getLockstepMaxSteps(): number;
  34166. /**
  34167. * Returns the time in ms between steps when using deterministic lock step.
  34168. * @returns time step in (ms)
  34169. */
  34170. getTimeStep(): number;
  34171. /**
  34172. * Force the mipmap generation for the given render target texture
  34173. * @param texture defines the render target texture to use
  34174. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34175. */
  34176. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34177. /** States */
  34178. /**
  34179. * Set various states to the webGL context
  34180. * @param culling defines backface culling state
  34181. * @param zOffset defines the value to apply to zOffset (0 by default)
  34182. * @param force defines if states must be applied even if cache is up to date
  34183. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34184. */
  34185. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34186. /**
  34187. * Set the z offset to apply to current rendering
  34188. * @param value defines the offset to apply
  34189. */
  34190. setZOffset(value: number): void;
  34191. /**
  34192. * Gets the current value of the zOffset
  34193. * @returns the current zOffset state
  34194. */
  34195. getZOffset(): number;
  34196. /**
  34197. * Enable or disable depth buffering
  34198. * @param enable defines the state to set
  34199. */
  34200. setDepthBuffer(enable: boolean): void;
  34201. /**
  34202. * Gets a boolean indicating if depth writing is enabled
  34203. * @returns the current depth writing state
  34204. */
  34205. getDepthWrite(): boolean;
  34206. /**
  34207. * Enable or disable depth writing
  34208. * @param enable defines the state to set
  34209. */
  34210. setDepthWrite(enable: boolean): void;
  34211. /**
  34212. * Gets a boolean indicating if stencil buffer is enabled
  34213. * @returns the current stencil buffer state
  34214. */
  34215. getStencilBuffer(): boolean;
  34216. /**
  34217. * Enable or disable the stencil buffer
  34218. * @param enable defines if the stencil buffer must be enabled or disabled
  34219. */
  34220. setStencilBuffer(enable: boolean): void;
  34221. /**
  34222. * Gets the current stencil mask
  34223. * @returns a number defining the new stencil mask to use
  34224. */
  34225. getStencilMask(): number;
  34226. /**
  34227. * Sets the current stencil mask
  34228. * @param mask defines the new stencil mask to use
  34229. */
  34230. setStencilMask(mask: number): void;
  34231. /**
  34232. * Gets the current stencil function
  34233. * @returns a number defining the stencil function to use
  34234. */
  34235. getStencilFunction(): number;
  34236. /**
  34237. * Gets the current stencil reference value
  34238. * @returns a number defining the stencil reference value to use
  34239. */
  34240. getStencilFunctionReference(): number;
  34241. /**
  34242. * Gets the current stencil mask
  34243. * @returns a number defining the stencil mask to use
  34244. */
  34245. getStencilFunctionMask(): number;
  34246. /**
  34247. * Sets the current stencil function
  34248. * @param stencilFunc defines the new stencil function to use
  34249. */
  34250. setStencilFunction(stencilFunc: number): void;
  34251. /**
  34252. * Sets the current stencil reference
  34253. * @param reference defines the new stencil reference to use
  34254. */
  34255. setStencilFunctionReference(reference: number): void;
  34256. /**
  34257. * Sets the current stencil mask
  34258. * @param mask defines the new stencil mask to use
  34259. */
  34260. setStencilFunctionMask(mask: number): void;
  34261. /**
  34262. * Gets the current stencil operation when stencil fails
  34263. * @returns a number defining stencil operation to use when stencil fails
  34264. */
  34265. getStencilOperationFail(): number;
  34266. /**
  34267. * Gets the current stencil operation when depth fails
  34268. * @returns a number defining stencil operation to use when depth fails
  34269. */
  34270. getStencilOperationDepthFail(): number;
  34271. /**
  34272. * Gets the current stencil operation when stencil passes
  34273. * @returns a number defining stencil operation to use when stencil passes
  34274. */
  34275. getStencilOperationPass(): number;
  34276. /**
  34277. * Sets the stencil operation to use when stencil fails
  34278. * @param operation defines the stencil operation to use when stencil fails
  34279. */
  34280. setStencilOperationFail(operation: number): void;
  34281. /**
  34282. * Sets the stencil operation to use when depth fails
  34283. * @param operation defines the stencil operation to use when depth fails
  34284. */
  34285. setStencilOperationDepthFail(operation: number): void;
  34286. /**
  34287. * Sets the stencil operation to use when stencil passes
  34288. * @param operation defines the stencil operation to use when stencil passes
  34289. */
  34290. setStencilOperationPass(operation: number): void;
  34291. /**
  34292. * Sets a boolean indicating if the dithering state is enabled or disabled
  34293. * @param value defines the dithering state
  34294. */
  34295. setDitheringState(value: boolean): void;
  34296. /**
  34297. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34298. * @param value defines the rasterizer state
  34299. */
  34300. setRasterizerState(value: boolean): void;
  34301. /**
  34302. * Gets the current depth function
  34303. * @returns a number defining the depth function
  34304. */
  34305. getDepthFunction(): Nullable<number>;
  34306. /**
  34307. * Sets the current depth function
  34308. * @param depthFunc defines the function to use
  34309. */
  34310. setDepthFunction(depthFunc: number): void;
  34311. /**
  34312. * Sets the current depth function to GREATER
  34313. */
  34314. setDepthFunctionToGreater(): void;
  34315. /**
  34316. * Sets the current depth function to GEQUAL
  34317. */
  34318. setDepthFunctionToGreaterOrEqual(): void;
  34319. /**
  34320. * Sets the current depth function to LESS
  34321. */
  34322. setDepthFunctionToLess(): void;
  34323. /**
  34324. * Sets the current depth function to LEQUAL
  34325. */
  34326. setDepthFunctionToLessOrEqual(): void;
  34327. private _cachedStencilBuffer;
  34328. private _cachedStencilFunction;
  34329. private _cachedStencilMask;
  34330. private _cachedStencilOperationPass;
  34331. private _cachedStencilOperationFail;
  34332. private _cachedStencilOperationDepthFail;
  34333. private _cachedStencilReference;
  34334. /**
  34335. * Caches the the state of the stencil buffer
  34336. */
  34337. cacheStencilState(): void;
  34338. /**
  34339. * Restores the state of the stencil buffer
  34340. */
  34341. restoreStencilState(): void;
  34342. /**
  34343. * Directly set the WebGL Viewport
  34344. * @param x defines the x coordinate of the viewport (in screen space)
  34345. * @param y defines the y coordinate of the viewport (in screen space)
  34346. * @param width defines the width of the viewport (in screen space)
  34347. * @param height defines the height of the viewport (in screen space)
  34348. * @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
  34349. */
  34350. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34351. /**
  34352. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34353. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34354. * @param y defines the y-coordinate of the corner of the clear rectangle
  34355. * @param width defines the width of the clear rectangle
  34356. * @param height defines the height of the clear rectangle
  34357. * @param clearColor defines the clear color
  34358. */
  34359. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34360. /**
  34361. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34362. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34363. * @param y defines the y-coordinate of the corner of the clear rectangle
  34364. * @param width defines the width of the clear rectangle
  34365. * @param height defines the height of the clear rectangle
  34366. */
  34367. enableScissor(x: number, y: number, width: number, height: number): void;
  34368. /**
  34369. * Disable previously set scissor test rectangle
  34370. */
  34371. disableScissor(): void;
  34372. protected _reportDrawCall(): void;
  34373. /**
  34374. * Initializes a webVR display and starts listening to display change events
  34375. * The onVRDisplayChangedObservable will be notified upon these changes
  34376. * @returns The onVRDisplayChangedObservable
  34377. */
  34378. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34379. /** @hidden */
  34380. _prepareVRComponent(): void;
  34381. /** @hidden */
  34382. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34383. /** @hidden */
  34384. _submitVRFrame(): void;
  34385. /**
  34386. * Call this function to leave webVR mode
  34387. * Will do nothing if webVR is not supported or if there is no webVR device
  34388. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34389. */
  34390. disableVR(): void;
  34391. /**
  34392. * Gets a boolean indicating that the system is in VR mode and is presenting
  34393. * @returns true if VR mode is engaged
  34394. */
  34395. isVRPresenting(): boolean;
  34396. /** @hidden */
  34397. _requestVRFrame(): void;
  34398. /** @hidden */
  34399. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34400. /**
  34401. * Gets the source code of the vertex shader associated with a specific webGL program
  34402. * @param program defines the program to use
  34403. * @returns a string containing the source code of the vertex shader associated with the program
  34404. */
  34405. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34406. /**
  34407. * Gets the source code of the fragment shader associated with a specific webGL program
  34408. * @param program defines the program to use
  34409. * @returns a string containing the source code of the fragment shader associated with the program
  34410. */
  34411. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34412. /**
  34413. * Sets a depth stencil texture from a render target to the according uniform.
  34414. * @param channel The texture channel
  34415. * @param uniform The uniform to set
  34416. * @param texture The render target texture containing the depth stencil texture to apply
  34417. */
  34418. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34419. /**
  34420. * Sets a texture to the webGL context from a postprocess
  34421. * @param channel defines the channel to use
  34422. * @param postProcess defines the source postprocess
  34423. */
  34424. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34425. /**
  34426. * Binds the output of the passed in post process to the texture channel specified
  34427. * @param channel The channel the texture should be bound to
  34428. * @param postProcess The post process which's output should be bound
  34429. */
  34430. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34431. /** @hidden */
  34432. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34433. protected _rebuildBuffers(): void;
  34434. /** @hidden */
  34435. _renderFrame(): void;
  34436. _renderLoop(): void;
  34437. /** @hidden */
  34438. _renderViews(): boolean;
  34439. /**
  34440. * Toggle full screen mode
  34441. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34442. */
  34443. switchFullscreen(requestPointerLock: boolean): void;
  34444. /**
  34445. * Enters full screen mode
  34446. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34447. */
  34448. enterFullscreen(requestPointerLock: boolean): void;
  34449. /**
  34450. * Exits full screen mode
  34451. */
  34452. exitFullscreen(): void;
  34453. /**
  34454. * Enters Pointerlock mode
  34455. */
  34456. enterPointerlock(): void;
  34457. /**
  34458. * Exits Pointerlock mode
  34459. */
  34460. exitPointerlock(): void;
  34461. /**
  34462. * Begin a new frame
  34463. */
  34464. beginFrame(): void;
  34465. /**
  34466. * Enf the current frame
  34467. */
  34468. endFrame(): void;
  34469. resize(): void;
  34470. /**
  34471. * Set the compressed texture format to use, based on the formats you have, and the formats
  34472. * supported by the hardware / browser.
  34473. *
  34474. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  34475. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  34476. * to API arguments needed to compressed textures. This puts the burden on the container
  34477. * generator to house the arcane code for determining these for current & future formats.
  34478. *
  34479. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34480. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34481. *
  34482. * Note: The result of this call is not taken into account when a texture is base64.
  34483. *
  34484. * @param formatsAvailable defines the list of those format families you have created
  34485. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  34486. *
  34487. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  34488. * @returns The extension selected.
  34489. */
  34490. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  34491. /**
  34492. * Set the compressed texture extensions or file names to skip.
  34493. *
  34494. * @param skippedFiles defines the list of those texture files you want to skip
  34495. * Example: [".dds", ".env", "myfile.png"]
  34496. */
  34497. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  34498. /**
  34499. * Force a specific size of the canvas
  34500. * @param width defines the new canvas' width
  34501. * @param height defines the new canvas' height
  34502. */
  34503. setSize(width: number, height: number): void;
  34504. /**
  34505. * Updates a dynamic vertex buffer.
  34506. * @param vertexBuffer the vertex buffer to update
  34507. * @param data the data used to update the vertex buffer
  34508. * @param byteOffset the byte offset of the data
  34509. * @param byteLength the byte length of the data
  34510. */
  34511. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34512. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34513. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34514. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34515. _releaseTexture(texture: InternalTexture): void;
  34516. /**
  34517. * @hidden
  34518. * Rescales a texture
  34519. * @param source input texutre
  34520. * @param destination destination texture
  34521. * @param scene scene to use to render the resize
  34522. * @param internalFormat format to use when resizing
  34523. * @param onComplete callback to be called when resize has completed
  34524. */
  34525. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34526. /**
  34527. * Gets the current framerate
  34528. * @returns a number representing the framerate
  34529. */
  34530. getFps(): number;
  34531. /**
  34532. * Gets the time spent between current and previous frame
  34533. * @returns a number representing the delta time in ms
  34534. */
  34535. getDeltaTime(): number;
  34536. private _measureFps;
  34537. /** @hidden */
  34538. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34539. /**
  34540. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  34541. * @param renderTarget The render target to set the frame buffer for
  34542. */
  34543. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  34544. /**
  34545. * Update a dynamic index buffer
  34546. * @param indexBuffer defines the target index buffer
  34547. * @param indices defines the data to update
  34548. * @param offset defines the offset in the target index buffer where update should start
  34549. */
  34550. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34551. /**
  34552. * Updates the sample count of a render target texture
  34553. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34554. * @param texture defines the texture to update
  34555. * @param samples defines the sample count to set
  34556. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34557. */
  34558. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34559. /**
  34560. * Updates a depth texture Comparison Mode and Function.
  34561. * If the comparison Function is equal to 0, the mode will be set to none.
  34562. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34563. * @param texture The texture to set the comparison function for
  34564. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34565. */
  34566. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34567. /**
  34568. * Creates a webGL buffer to use with instanciation
  34569. * @param capacity defines the size of the buffer
  34570. * @returns the webGL buffer
  34571. */
  34572. createInstancesBuffer(capacity: number): DataBuffer;
  34573. /**
  34574. * Delete a webGL buffer used with instanciation
  34575. * @param buffer defines the webGL buffer to delete
  34576. */
  34577. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34578. /** @hidden */
  34579. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34580. dispose(): void;
  34581. private _disableTouchAction;
  34582. /**
  34583. * Display the loading screen
  34584. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34585. */
  34586. displayLoadingUI(): void;
  34587. /**
  34588. * Hide the loading screen
  34589. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34590. */
  34591. hideLoadingUI(): void;
  34592. /**
  34593. * Gets the current loading screen object
  34594. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34595. */
  34596. get loadingScreen(): ILoadingScreen;
  34597. /**
  34598. * Sets the current loading screen object
  34599. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34600. */
  34601. set loadingScreen(loadingScreen: ILoadingScreen);
  34602. /**
  34603. * Sets the current loading screen text
  34604. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34605. */
  34606. set loadingUIText(text: string);
  34607. /**
  34608. * Sets the current loading screen background color
  34609. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34610. */
  34611. set loadingUIBackgroundColor(color: string);
  34612. /** Pointerlock and fullscreen */
  34613. /**
  34614. * Ask the browser to promote the current element to pointerlock mode
  34615. * @param element defines the DOM element to promote
  34616. */
  34617. static _RequestPointerlock(element: HTMLElement): void;
  34618. /**
  34619. * Asks the browser to exit pointerlock mode
  34620. */
  34621. static _ExitPointerlock(): void;
  34622. /**
  34623. * Ask the browser to promote the current element to fullscreen rendering mode
  34624. * @param element defines the DOM element to promote
  34625. */
  34626. static _RequestFullscreen(element: HTMLElement): void;
  34627. /**
  34628. * Asks the browser to exit fullscreen mode
  34629. */
  34630. static _ExitFullscreen(): void;
  34631. }
  34632. }
  34633. declare module "babylonjs/Engines/engineStore" {
  34634. import { Nullable } from "babylonjs/types";
  34635. import { Engine } from "babylonjs/Engines/engine";
  34636. import { Scene } from "babylonjs/scene";
  34637. /**
  34638. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34639. * during the life time of the application.
  34640. */
  34641. export class EngineStore {
  34642. /** Gets the list of created engines */
  34643. static Instances: import("babylonjs/Engines/engine").Engine[];
  34644. /** @hidden */
  34645. static _LastCreatedScene: Nullable<Scene>;
  34646. /**
  34647. * Gets the latest created engine
  34648. */
  34649. static get LastCreatedEngine(): Nullable<Engine>;
  34650. /**
  34651. * Gets the latest created scene
  34652. */
  34653. static get LastCreatedScene(): Nullable<Scene>;
  34654. /**
  34655. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34656. * @ignorenaming
  34657. */
  34658. static UseFallbackTexture: boolean;
  34659. /**
  34660. * Texture content used if a texture cannot loaded
  34661. * @ignorenaming
  34662. */
  34663. static FallbackTexture: string;
  34664. }
  34665. }
  34666. declare module "babylonjs/Misc/promise" {
  34667. /**
  34668. * Helper class that provides a small promise polyfill
  34669. */
  34670. export class PromisePolyfill {
  34671. /**
  34672. * Static function used to check if the polyfill is required
  34673. * If this is the case then the function will inject the polyfill to window.Promise
  34674. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34675. */
  34676. static Apply(force?: boolean): void;
  34677. }
  34678. }
  34679. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34680. /**
  34681. * Interface for screenshot methods with describe argument called `size` as object with options
  34682. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34683. */
  34684. export interface IScreenshotSize {
  34685. /**
  34686. * number in pixels for canvas height
  34687. */
  34688. height?: number;
  34689. /**
  34690. * multiplier allowing render at a higher or lower resolution
  34691. * If value is defined then height and width will be ignored and taken from camera
  34692. */
  34693. precision?: number;
  34694. /**
  34695. * number in pixels for canvas width
  34696. */
  34697. width?: number;
  34698. }
  34699. }
  34700. declare module "babylonjs/Misc/tools" {
  34701. import { Nullable, float } from "babylonjs/types";
  34702. import { DomManagement } from "babylonjs/Misc/domManagement";
  34703. import { WebRequest } from "babylonjs/Misc/webRequest";
  34704. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34705. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34706. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34707. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34708. import { Camera } from "babylonjs/Cameras/camera";
  34709. import { Engine } from "babylonjs/Engines/engine";
  34710. interface IColor4Like {
  34711. r: float;
  34712. g: float;
  34713. b: float;
  34714. a: float;
  34715. }
  34716. /**
  34717. * Class containing a set of static utilities functions
  34718. */
  34719. export class Tools {
  34720. /**
  34721. * Gets or sets the base URL to use to load assets
  34722. */
  34723. static get BaseUrl(): string;
  34724. static set BaseUrl(value: string);
  34725. /**
  34726. * Enable/Disable Custom HTTP Request Headers globally.
  34727. * default = false
  34728. * @see CustomRequestHeaders
  34729. */
  34730. static UseCustomRequestHeaders: boolean;
  34731. /**
  34732. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34733. * i.e. when loading files, where the server/service expects an Authorization header
  34734. */
  34735. static CustomRequestHeaders: {
  34736. [key: string]: string;
  34737. };
  34738. /**
  34739. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34740. */
  34741. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34742. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34743. /**
  34744. * Default behaviour for cors in the application.
  34745. * It can be a string if the expected behavior is identical in the entire app.
  34746. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34747. */
  34748. static CorsBehavior: string | ((url: string | string[]) => string);
  34749. /**
  34750. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34751. * @ignorenaming
  34752. */
  34753. static get UseFallbackTexture(): boolean;
  34754. static set UseFallbackTexture(value: boolean);
  34755. /**
  34756. * Use this object to register external classes like custom textures or material
  34757. * to allow the laoders to instantiate them
  34758. */
  34759. static get RegisteredExternalClasses(): {
  34760. [key: string]: Object;
  34761. };
  34762. static set RegisteredExternalClasses(classes: {
  34763. [key: string]: Object;
  34764. });
  34765. /**
  34766. * Texture content used if a texture cannot loaded
  34767. * @ignorenaming
  34768. */
  34769. static get fallbackTexture(): string;
  34770. static set fallbackTexture(value: string);
  34771. /**
  34772. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34773. * @param u defines the coordinate on X axis
  34774. * @param v defines the coordinate on Y axis
  34775. * @param width defines the width of the source data
  34776. * @param height defines the height of the source data
  34777. * @param pixels defines the source byte array
  34778. * @param color defines the output color
  34779. */
  34780. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34781. /**
  34782. * Interpolates between a and b via alpha
  34783. * @param a The lower value (returned when alpha = 0)
  34784. * @param b The upper value (returned when alpha = 1)
  34785. * @param alpha The interpolation-factor
  34786. * @return The mixed value
  34787. */
  34788. static Mix(a: number, b: number, alpha: number): number;
  34789. /**
  34790. * Tries to instantiate a new object from a given class name
  34791. * @param className defines the class name to instantiate
  34792. * @returns the new object or null if the system was not able to do the instantiation
  34793. */
  34794. static Instantiate(className: string): any;
  34795. /**
  34796. * Provides a slice function that will work even on IE
  34797. * @param data defines the array to slice
  34798. * @param start defines the start of the data (optional)
  34799. * @param end defines the end of the data (optional)
  34800. * @returns the new sliced array
  34801. */
  34802. static Slice<T>(data: T, start?: number, end?: number): T;
  34803. /**
  34804. * Polyfill for setImmediate
  34805. * @param action defines the action to execute after the current execution block
  34806. */
  34807. static SetImmediate(action: () => void): void;
  34808. /**
  34809. * Function indicating if a number is an exponent of 2
  34810. * @param value defines the value to test
  34811. * @returns true if the value is an exponent of 2
  34812. */
  34813. static IsExponentOfTwo(value: number): boolean;
  34814. private static _tmpFloatArray;
  34815. /**
  34816. * Returns the nearest 32-bit single precision float representation of a Number
  34817. * @param value A Number. If the parameter is of a different type, it will get converted
  34818. * to a number or to NaN if it cannot be converted
  34819. * @returns number
  34820. */
  34821. static FloatRound(value: number): number;
  34822. /**
  34823. * Extracts the filename from a path
  34824. * @param path defines the path to use
  34825. * @returns the filename
  34826. */
  34827. static GetFilename(path: string): string;
  34828. /**
  34829. * Extracts the "folder" part of a path (everything before the filename).
  34830. * @param uri The URI to extract the info from
  34831. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34832. * @returns The "folder" part of the path
  34833. */
  34834. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34835. /**
  34836. * Extracts text content from a DOM element hierarchy
  34837. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34838. */
  34839. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34840. /**
  34841. * Convert an angle in radians to degrees
  34842. * @param angle defines the angle to convert
  34843. * @returns the angle in degrees
  34844. */
  34845. static ToDegrees(angle: number): number;
  34846. /**
  34847. * Convert an angle in degrees to radians
  34848. * @param angle defines the angle to convert
  34849. * @returns the angle in radians
  34850. */
  34851. static ToRadians(angle: number): number;
  34852. /**
  34853. * Returns an array if obj is not an array
  34854. * @param obj defines the object to evaluate as an array
  34855. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34856. * @returns either obj directly if obj is an array or a new array containing obj
  34857. */
  34858. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34859. /**
  34860. * Gets the pointer prefix to use
  34861. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34862. */
  34863. static GetPointerPrefix(): string;
  34864. /**
  34865. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34866. * @param url define the url we are trying
  34867. * @param element define the dom element where to configure the cors policy
  34868. */
  34869. static SetCorsBehavior(url: string | string[], element: {
  34870. crossOrigin: string | null;
  34871. }): void;
  34872. /**
  34873. * Removes unwanted characters from an url
  34874. * @param url defines the url to clean
  34875. * @returns the cleaned url
  34876. */
  34877. static CleanUrl(url: string): string;
  34878. /**
  34879. * Gets or sets a function used to pre-process url before using them to load assets
  34880. */
  34881. static get PreprocessUrl(): (url: string) => string;
  34882. static set PreprocessUrl(processor: (url: string) => string);
  34883. /**
  34884. * Loads an image as an HTMLImageElement.
  34885. * @param input url string, ArrayBuffer, or Blob to load
  34886. * @param onLoad callback called when the image successfully loads
  34887. * @param onError callback called when the image fails to load
  34888. * @param offlineProvider offline provider for caching
  34889. * @param mimeType optional mime type
  34890. * @returns the HTMLImageElement of the loaded image
  34891. */
  34892. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34893. /**
  34894. * Loads a file from a url
  34895. * @param url url string, ArrayBuffer, or Blob to load
  34896. * @param onSuccess callback called when the file successfully loads
  34897. * @param onProgress callback called while file is loading (if the server supports this mode)
  34898. * @param offlineProvider defines the offline provider for caching
  34899. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34900. * @param onError callback called when the file fails to load
  34901. * @returns a file request object
  34902. */
  34903. 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;
  34904. /**
  34905. * Loads a file from a url
  34906. * @param url the file url to load
  34907. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  34908. */
  34909. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  34910. /**
  34911. * Load a script (identified by an url). When the url returns, the
  34912. * content of this file is added into a new script element, attached to the DOM (body element)
  34913. * @param scriptUrl defines the url of the script to laod
  34914. * @param onSuccess defines the callback called when the script is loaded
  34915. * @param onError defines the callback to call if an error occurs
  34916. * @param scriptId defines the id of the script element
  34917. */
  34918. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34919. /**
  34920. * Load an asynchronous script (identified by an url). When the url returns, the
  34921. * content of this file is added into a new script element, attached to the DOM (body element)
  34922. * @param scriptUrl defines the url of the script to laod
  34923. * @param scriptId defines the id of the script element
  34924. * @returns a promise request object
  34925. */
  34926. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34927. /**
  34928. * Loads a file from a blob
  34929. * @param fileToLoad defines the blob to use
  34930. * @param callback defines the callback to call when data is loaded
  34931. * @param progressCallback defines the callback to call during loading process
  34932. * @returns a file request object
  34933. */
  34934. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34935. /**
  34936. * Reads a file from a File object
  34937. * @param file defines the file to load
  34938. * @param onSuccess defines the callback to call when data is loaded
  34939. * @param onProgress defines the callback to call during loading process
  34940. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34941. * @param onError defines the callback to call when an error occurs
  34942. * @returns a file request object
  34943. */
  34944. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34945. /**
  34946. * Creates a data url from a given string content
  34947. * @param content defines the content to convert
  34948. * @returns the new data url link
  34949. */
  34950. static FileAsURL(content: string): string;
  34951. /**
  34952. * Format the given number to a specific decimal format
  34953. * @param value defines the number to format
  34954. * @param decimals defines the number of decimals to use
  34955. * @returns the formatted string
  34956. */
  34957. static Format(value: number, decimals?: number): string;
  34958. /**
  34959. * Tries to copy an object by duplicating every property
  34960. * @param source defines the source object
  34961. * @param destination defines the target object
  34962. * @param doNotCopyList defines a list of properties to avoid
  34963. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34964. */
  34965. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34966. /**
  34967. * Gets a boolean indicating if the given object has no own property
  34968. * @param obj defines the object to test
  34969. * @returns true if object has no own property
  34970. */
  34971. static IsEmpty(obj: any): boolean;
  34972. /**
  34973. * Function used to register events at window level
  34974. * @param windowElement defines the Window object to use
  34975. * @param events defines the events to register
  34976. */
  34977. static RegisterTopRootEvents(windowElement: Window, events: {
  34978. name: string;
  34979. handler: Nullable<(e: FocusEvent) => any>;
  34980. }[]): void;
  34981. /**
  34982. * Function used to unregister events from window level
  34983. * @param windowElement defines the Window object to use
  34984. * @param events defines the events to unregister
  34985. */
  34986. static UnregisterTopRootEvents(windowElement: Window, events: {
  34987. name: string;
  34988. handler: Nullable<(e: FocusEvent) => any>;
  34989. }[]): void;
  34990. /**
  34991. * @ignore
  34992. */
  34993. static _ScreenshotCanvas: HTMLCanvasElement;
  34994. /**
  34995. * Dumps the current bound framebuffer
  34996. * @param width defines the rendering width
  34997. * @param height defines the rendering height
  34998. * @param engine defines the hosting engine
  34999. * @param successCallback defines the callback triggered once the data are available
  35000. * @param mimeType defines the mime type of the result
  35001. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35002. */
  35003. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35004. /**
  35005. * Converts the canvas data to blob.
  35006. * This acts as a polyfill for browsers not supporting the to blob function.
  35007. * @param canvas Defines the canvas to extract the data from
  35008. * @param successCallback Defines the callback triggered once the data are available
  35009. * @param mimeType Defines the mime type of the result
  35010. */
  35011. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35012. /**
  35013. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35014. * @param successCallback defines the callback triggered once the data are available
  35015. * @param mimeType defines the mime type of the result
  35016. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35017. */
  35018. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35019. /**
  35020. * Downloads a blob in the browser
  35021. * @param blob defines the blob to download
  35022. * @param fileName defines the name of the downloaded file
  35023. */
  35024. static Download(blob: Blob, fileName: string): void;
  35025. /**
  35026. * Captures a screenshot of the current rendering
  35027. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35028. * @param engine defines the rendering engine
  35029. * @param camera defines the source camera
  35030. * @param size This parameter can be set to a single number or to an object with the
  35031. * following (optional) properties: precision, width, height. If a single number is passed,
  35032. * it will be used for both width and height. If an object is passed, the screenshot size
  35033. * will be derived from the parameters. The precision property is a multiplier allowing
  35034. * rendering at a higher or lower resolution
  35035. * @param successCallback defines the callback receives a single parameter which contains the
  35036. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35037. * src parameter of an <img> to display it
  35038. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35039. * Check your browser for supported MIME types
  35040. */
  35041. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35042. /**
  35043. * Captures a screenshot of the current rendering
  35044. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35045. * @param engine defines the rendering engine
  35046. * @param camera defines the source camera
  35047. * @param size This parameter can be set to a single number or to an object with the
  35048. * following (optional) properties: precision, width, height. If a single number is passed,
  35049. * it will be used for both width and height. If an object is passed, the screenshot size
  35050. * will be derived from the parameters. The precision property is a multiplier allowing
  35051. * rendering at a higher or lower resolution
  35052. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35053. * Check your browser for supported MIME types
  35054. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35055. * to the src parameter of an <img> to display it
  35056. */
  35057. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35058. /**
  35059. * Generates an image screenshot from the specified camera.
  35060. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35061. * @param engine The engine to use for rendering
  35062. * @param camera The camera to use for rendering
  35063. * @param size This parameter can be set to a single number or to an object with the
  35064. * following (optional) properties: precision, width, height. If a single number is passed,
  35065. * it will be used for both width and height. If an object is passed, the screenshot size
  35066. * will be derived from the parameters. The precision property is a multiplier allowing
  35067. * rendering at a higher or lower resolution
  35068. * @param successCallback The callback receives a single parameter which contains the
  35069. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35070. * src parameter of an <img> to display it
  35071. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35072. * Check your browser for supported MIME types
  35073. * @param samples Texture samples (default: 1)
  35074. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35075. * @param fileName A name for for the downloaded file.
  35076. */
  35077. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35078. /**
  35079. * Generates an image screenshot from the specified camera.
  35080. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35081. * @param engine The engine to use for rendering
  35082. * @param camera The camera to use for rendering
  35083. * @param size This parameter can be set to a single number or to an object with the
  35084. * following (optional) properties: precision, width, height. If a single number is passed,
  35085. * it will be used for both width and height. If an object is passed, the screenshot size
  35086. * will be derived from the parameters. The precision property is a multiplier allowing
  35087. * rendering at a higher or lower resolution
  35088. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35089. * Check your browser for supported MIME types
  35090. * @param samples Texture samples (default: 1)
  35091. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35092. * @param fileName A name for for the downloaded file.
  35093. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35094. * to the src parameter of an <img> to display it
  35095. */
  35096. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35097. /**
  35098. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35099. * Be aware Math.random() could cause collisions, but:
  35100. * "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"
  35101. * @returns a pseudo random id
  35102. */
  35103. static RandomId(): string;
  35104. /**
  35105. * Test if the given uri is a base64 string
  35106. * @param uri The uri to test
  35107. * @return True if the uri is a base64 string or false otherwise
  35108. */
  35109. static IsBase64(uri: string): boolean;
  35110. /**
  35111. * Decode the given base64 uri.
  35112. * @param uri The uri to decode
  35113. * @return The decoded base64 data.
  35114. */
  35115. static DecodeBase64(uri: string): ArrayBuffer;
  35116. /**
  35117. * Gets the absolute url.
  35118. * @param url the input url
  35119. * @return the absolute url
  35120. */
  35121. static GetAbsoluteUrl(url: string): string;
  35122. /**
  35123. * No log
  35124. */
  35125. static readonly NoneLogLevel: number;
  35126. /**
  35127. * Only message logs
  35128. */
  35129. static readonly MessageLogLevel: number;
  35130. /**
  35131. * Only warning logs
  35132. */
  35133. static readonly WarningLogLevel: number;
  35134. /**
  35135. * Only error logs
  35136. */
  35137. static readonly ErrorLogLevel: number;
  35138. /**
  35139. * All logs
  35140. */
  35141. static readonly AllLogLevel: number;
  35142. /**
  35143. * Gets a value indicating the number of loading errors
  35144. * @ignorenaming
  35145. */
  35146. static get errorsCount(): number;
  35147. /**
  35148. * Callback called when a new log is added
  35149. */
  35150. static OnNewCacheEntry: (entry: string) => void;
  35151. /**
  35152. * Log a message to the console
  35153. * @param message defines the message to log
  35154. */
  35155. static Log(message: string): void;
  35156. /**
  35157. * Write a warning message to the console
  35158. * @param message defines the message to log
  35159. */
  35160. static Warn(message: string): void;
  35161. /**
  35162. * Write an error message to the console
  35163. * @param message defines the message to log
  35164. */
  35165. static Error(message: string): void;
  35166. /**
  35167. * Gets current log cache (list of logs)
  35168. */
  35169. static get LogCache(): string;
  35170. /**
  35171. * Clears the log cache
  35172. */
  35173. static ClearLogCache(): void;
  35174. /**
  35175. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35176. */
  35177. static set LogLevels(level: number);
  35178. /**
  35179. * Checks if the window object exists
  35180. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35181. */
  35182. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35183. /**
  35184. * No performance log
  35185. */
  35186. static readonly PerformanceNoneLogLevel: number;
  35187. /**
  35188. * Use user marks to log performance
  35189. */
  35190. static readonly PerformanceUserMarkLogLevel: number;
  35191. /**
  35192. * Log performance to the console
  35193. */
  35194. static readonly PerformanceConsoleLogLevel: number;
  35195. private static _performance;
  35196. /**
  35197. * Sets the current performance log level
  35198. */
  35199. static set PerformanceLogLevel(level: number);
  35200. private static _StartPerformanceCounterDisabled;
  35201. private static _EndPerformanceCounterDisabled;
  35202. private static _StartUserMark;
  35203. private static _EndUserMark;
  35204. private static _StartPerformanceConsole;
  35205. private static _EndPerformanceConsole;
  35206. /**
  35207. * Starts a performance counter
  35208. */
  35209. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35210. /**
  35211. * Ends a specific performance coutner
  35212. */
  35213. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35214. /**
  35215. * Gets either window.performance.now() if supported or Date.now() else
  35216. */
  35217. static get Now(): number;
  35218. /**
  35219. * This method will return the name of the class used to create the instance of the given object.
  35220. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35221. * @param object the object to get the class name from
  35222. * @param isType defines if the object is actually a type
  35223. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35224. */
  35225. static GetClassName(object: any, isType?: boolean): string;
  35226. /**
  35227. * Gets the first element of an array satisfying a given predicate
  35228. * @param array defines the array to browse
  35229. * @param predicate defines the predicate to use
  35230. * @returns null if not found or the element
  35231. */
  35232. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35233. /**
  35234. * This method will return the name of the full name of the class, including its owning module (if any).
  35235. * 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).
  35236. * @param object the object to get the class name from
  35237. * @param isType defines if the object is actually a type
  35238. * @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.
  35239. * @ignorenaming
  35240. */
  35241. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35242. /**
  35243. * Returns a promise that resolves after the given amount of time.
  35244. * @param delay Number of milliseconds to delay
  35245. * @returns Promise that resolves after the given amount of time
  35246. */
  35247. static DelayAsync(delay: number): Promise<void>;
  35248. }
  35249. /**
  35250. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35251. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35252. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35253. * @param name The name of the class, case should be preserved
  35254. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35255. */
  35256. export function className(name: string, module?: string): (target: Object) => void;
  35257. /**
  35258. * An implementation of a loop for asynchronous functions.
  35259. */
  35260. export class AsyncLoop {
  35261. /**
  35262. * Defines the number of iterations for the loop
  35263. */
  35264. iterations: number;
  35265. /**
  35266. * Defines the current index of the loop.
  35267. */
  35268. index: number;
  35269. private _done;
  35270. private _fn;
  35271. private _successCallback;
  35272. /**
  35273. * Constructor.
  35274. * @param iterations the number of iterations.
  35275. * @param func the function to run each iteration
  35276. * @param successCallback the callback that will be called upon succesful execution
  35277. * @param offset starting offset.
  35278. */
  35279. constructor(
  35280. /**
  35281. * Defines the number of iterations for the loop
  35282. */
  35283. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35284. /**
  35285. * Execute the next iteration. Must be called after the last iteration was finished.
  35286. */
  35287. executeNext(): void;
  35288. /**
  35289. * Break the loop and run the success callback.
  35290. */
  35291. breakLoop(): void;
  35292. /**
  35293. * Create and run an async loop.
  35294. * @param iterations the number of iterations.
  35295. * @param fn the function to run each iteration
  35296. * @param successCallback the callback that will be called upon succesful execution
  35297. * @param offset starting offset.
  35298. * @returns the created async loop object
  35299. */
  35300. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35301. /**
  35302. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35303. * @param iterations total number of iterations
  35304. * @param syncedIterations number of synchronous iterations in each async iteration.
  35305. * @param fn the function to call each iteration.
  35306. * @param callback a success call back that will be called when iterating stops.
  35307. * @param breakFunction a break condition (optional)
  35308. * @param timeout timeout settings for the setTimeout function. default - 0.
  35309. * @returns the created async loop object
  35310. */
  35311. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35312. }
  35313. }
  35314. declare module "babylonjs/Misc/stringDictionary" {
  35315. import { Nullable } from "babylonjs/types";
  35316. /**
  35317. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35318. * The underlying implementation relies on an associative array to ensure the best performances.
  35319. * The value can be anything including 'null' but except 'undefined'
  35320. */
  35321. export class StringDictionary<T> {
  35322. /**
  35323. * This will clear this dictionary and copy the content from the 'source' one.
  35324. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35325. * @param source the dictionary to take the content from and copy to this dictionary
  35326. */
  35327. copyFrom(source: StringDictionary<T>): void;
  35328. /**
  35329. * Get a value based from its key
  35330. * @param key the given key to get the matching value from
  35331. * @return the value if found, otherwise undefined is returned
  35332. */
  35333. get(key: string): T | undefined;
  35334. /**
  35335. * Get a value from its key or add it if it doesn't exist.
  35336. * This method will ensure you that a given key/data will be present in the dictionary.
  35337. * @param key the given key to get the matching value from
  35338. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35339. * The factory will only be invoked if there's no data for the given key.
  35340. * @return the value corresponding to the key.
  35341. */
  35342. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35343. /**
  35344. * Get a value from its key if present in the dictionary otherwise add it
  35345. * @param key the key to get the value from
  35346. * @param val if there's no such key/value pair in the dictionary add it with this value
  35347. * @return the value corresponding to the key
  35348. */
  35349. getOrAdd(key: string, val: T): T;
  35350. /**
  35351. * Check if there's a given key in the dictionary
  35352. * @param key the key to check for
  35353. * @return true if the key is present, false otherwise
  35354. */
  35355. contains(key: string): boolean;
  35356. /**
  35357. * Add a new key and its corresponding value
  35358. * @param key the key to add
  35359. * @param value the value corresponding to the key
  35360. * @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
  35361. */
  35362. add(key: string, value: T): boolean;
  35363. /**
  35364. * Update a specific value associated to a key
  35365. * @param key defines the key to use
  35366. * @param value defines the value to store
  35367. * @returns true if the value was updated (or false if the key was not found)
  35368. */
  35369. set(key: string, value: T): boolean;
  35370. /**
  35371. * Get the element of the given key and remove it from the dictionary
  35372. * @param key defines the key to search
  35373. * @returns the value associated with the key or null if not found
  35374. */
  35375. getAndRemove(key: string): Nullable<T>;
  35376. /**
  35377. * Remove a key/value from the dictionary.
  35378. * @param key the key to remove
  35379. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35380. */
  35381. remove(key: string): boolean;
  35382. /**
  35383. * Clear the whole content of the dictionary
  35384. */
  35385. clear(): void;
  35386. /**
  35387. * Gets the current count
  35388. */
  35389. get count(): number;
  35390. /**
  35391. * Execute a callback on each key/val of the dictionary.
  35392. * Note that you can remove any element in this dictionary in the callback implementation
  35393. * @param callback the callback to execute on a given key/value pair
  35394. */
  35395. forEach(callback: (key: string, val: T) => void): void;
  35396. /**
  35397. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35398. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35399. * Note that you can remove any element in this dictionary in the callback implementation
  35400. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35401. * @returns the first item
  35402. */
  35403. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35404. private _count;
  35405. private _data;
  35406. }
  35407. }
  35408. declare module "babylonjs/Collisions/collisionCoordinator" {
  35409. import { Nullable } from "babylonjs/types";
  35410. import { Scene } from "babylonjs/scene";
  35411. import { Vector3 } from "babylonjs/Maths/math.vector";
  35412. import { Collider } from "babylonjs/Collisions/collider";
  35413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35414. /** @hidden */
  35415. export interface ICollisionCoordinator {
  35416. createCollider(): Collider;
  35417. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35418. init(scene: Scene): void;
  35419. }
  35420. /** @hidden */
  35421. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35422. private _scene;
  35423. private _scaledPosition;
  35424. private _scaledVelocity;
  35425. private _finalPosition;
  35426. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35427. createCollider(): Collider;
  35428. init(scene: Scene): void;
  35429. private _collideWithWorld;
  35430. }
  35431. }
  35432. declare module "babylonjs/Inputs/scene.inputManager" {
  35433. import { Nullable } from "babylonjs/types";
  35434. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35435. import { Vector2 } from "babylonjs/Maths/math.vector";
  35436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35437. import { Scene } from "babylonjs/scene";
  35438. /**
  35439. * Class used to manage all inputs for the scene.
  35440. */
  35441. export class InputManager {
  35442. /** The distance in pixel that you have to move to prevent some events */
  35443. static DragMovementThreshold: number;
  35444. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35445. static LongPressDelay: number;
  35446. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35447. static DoubleClickDelay: number;
  35448. /** If you need to check double click without raising a single click at first click, enable this flag */
  35449. static ExclusiveDoubleClickMode: boolean;
  35450. private _wheelEventName;
  35451. private _onPointerMove;
  35452. private _onPointerDown;
  35453. private _onPointerUp;
  35454. private _initClickEvent;
  35455. private _initActionManager;
  35456. private _delayedSimpleClick;
  35457. private _delayedSimpleClickTimeout;
  35458. private _previousDelayedSimpleClickTimeout;
  35459. private _meshPickProceed;
  35460. private _previousButtonPressed;
  35461. private _currentPickResult;
  35462. private _previousPickResult;
  35463. private _totalPointersPressed;
  35464. private _doubleClickOccured;
  35465. private _pointerOverMesh;
  35466. private _pickedDownMesh;
  35467. private _pickedUpMesh;
  35468. private _pointerX;
  35469. private _pointerY;
  35470. private _unTranslatedPointerX;
  35471. private _unTranslatedPointerY;
  35472. private _startingPointerPosition;
  35473. private _previousStartingPointerPosition;
  35474. private _startingPointerTime;
  35475. private _previousStartingPointerTime;
  35476. private _pointerCaptures;
  35477. private _onKeyDown;
  35478. private _onKeyUp;
  35479. private _onCanvasFocusObserver;
  35480. private _onCanvasBlurObserver;
  35481. private _scene;
  35482. /**
  35483. * Creates a new InputManager
  35484. * @param scene defines the hosting scene
  35485. */
  35486. constructor(scene: Scene);
  35487. /**
  35488. * Gets the mesh that is currently under the pointer
  35489. */
  35490. get meshUnderPointer(): Nullable<AbstractMesh>;
  35491. /**
  35492. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35493. */
  35494. get unTranslatedPointer(): Vector2;
  35495. /**
  35496. * Gets or sets the current on-screen X position of the pointer
  35497. */
  35498. get pointerX(): number;
  35499. set pointerX(value: number);
  35500. /**
  35501. * Gets or sets the current on-screen Y position of the pointer
  35502. */
  35503. get pointerY(): number;
  35504. set pointerY(value: number);
  35505. private _updatePointerPosition;
  35506. private _processPointerMove;
  35507. private _setRayOnPointerInfo;
  35508. private _checkPrePointerObservable;
  35509. /**
  35510. * Use this method to simulate a pointer move on a mesh
  35511. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35512. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35513. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35514. */
  35515. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35516. /**
  35517. * Use this method to simulate a pointer down on a mesh
  35518. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35519. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35520. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35521. */
  35522. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35523. private _processPointerDown;
  35524. /** @hidden */
  35525. _isPointerSwiping(): boolean;
  35526. /**
  35527. * Use this method to simulate a pointer up on a mesh
  35528. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35529. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35530. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35531. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35532. */
  35533. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35534. private _processPointerUp;
  35535. /**
  35536. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35537. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35538. * @returns true if the pointer was captured
  35539. */
  35540. isPointerCaptured(pointerId?: number): boolean;
  35541. /**
  35542. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35543. * @param attachUp defines if you want to attach events to pointerup
  35544. * @param attachDown defines if you want to attach events to pointerdown
  35545. * @param attachMove defines if you want to attach events to pointermove
  35546. */
  35547. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35548. /**
  35549. * Detaches all event handlers
  35550. */
  35551. detachControl(): void;
  35552. /**
  35553. * Force the value of meshUnderPointer
  35554. * @param mesh defines the mesh to use
  35555. */
  35556. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35557. /**
  35558. * Gets the mesh under the pointer
  35559. * @returns a Mesh or null if no mesh is under the pointer
  35560. */
  35561. getPointerOverMesh(): Nullable<AbstractMesh>;
  35562. }
  35563. }
  35564. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35565. /**
  35566. * Helper class used to generate session unique ID
  35567. */
  35568. export class UniqueIdGenerator {
  35569. private static _UniqueIdCounter;
  35570. /**
  35571. * Gets an unique (relatively to the current scene) Id
  35572. */
  35573. static get UniqueId(): number;
  35574. }
  35575. }
  35576. declare module "babylonjs/Animations/animationGroup" {
  35577. import { Animatable } from "babylonjs/Animations/animatable";
  35578. import { Animation } from "babylonjs/Animations/animation";
  35579. import { Scene, IDisposable } from "babylonjs/scene";
  35580. import { Observable } from "babylonjs/Misc/observable";
  35581. import { Nullable } from "babylonjs/types";
  35582. import "babylonjs/Animations/animatable";
  35583. /**
  35584. * This class defines the direct association between an animation and a target
  35585. */
  35586. export class TargetedAnimation {
  35587. /**
  35588. * Animation to perform
  35589. */
  35590. animation: Animation;
  35591. /**
  35592. * Target to animate
  35593. */
  35594. target: any;
  35595. /**
  35596. * Serialize the object
  35597. * @returns the JSON object representing the current entity
  35598. */
  35599. serialize(): any;
  35600. }
  35601. /**
  35602. * Use this class to create coordinated animations on multiple targets
  35603. */
  35604. export class AnimationGroup implements IDisposable {
  35605. /** The name of the animation group */
  35606. name: string;
  35607. private _scene;
  35608. private _targetedAnimations;
  35609. private _animatables;
  35610. private _from;
  35611. private _to;
  35612. private _isStarted;
  35613. private _isPaused;
  35614. private _speedRatio;
  35615. private _loopAnimation;
  35616. /**
  35617. * Gets or sets the unique id of the node
  35618. */
  35619. uniqueId: number;
  35620. /**
  35621. * This observable will notify when one animation have ended
  35622. */
  35623. onAnimationEndObservable: Observable<TargetedAnimation>;
  35624. /**
  35625. * Observer raised when one animation loops
  35626. */
  35627. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35628. /**
  35629. * Observer raised when all animations have looped
  35630. */
  35631. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35632. /**
  35633. * This observable will notify when all animations have ended.
  35634. */
  35635. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35636. /**
  35637. * This observable will notify when all animations have paused.
  35638. */
  35639. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35640. /**
  35641. * This observable will notify when all animations are playing.
  35642. */
  35643. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35644. /**
  35645. * Gets the first frame
  35646. */
  35647. get from(): number;
  35648. /**
  35649. * Gets the last frame
  35650. */
  35651. get to(): number;
  35652. /**
  35653. * Define if the animations are started
  35654. */
  35655. get isStarted(): boolean;
  35656. /**
  35657. * Gets a value indicating that the current group is playing
  35658. */
  35659. get isPlaying(): boolean;
  35660. /**
  35661. * Gets or sets the speed ratio to use for all animations
  35662. */
  35663. get speedRatio(): number;
  35664. /**
  35665. * Gets or sets the speed ratio to use for all animations
  35666. */
  35667. set speedRatio(value: number);
  35668. /**
  35669. * Gets or sets if all animations should loop or not
  35670. */
  35671. get loopAnimation(): boolean;
  35672. set loopAnimation(value: boolean);
  35673. /**
  35674. * Gets the targeted animations for this animation group
  35675. */
  35676. get targetedAnimations(): Array<TargetedAnimation>;
  35677. /**
  35678. * returning the list of animatables controlled by this animation group.
  35679. */
  35680. get animatables(): Array<Animatable>;
  35681. /**
  35682. * Instantiates a new Animation Group.
  35683. * This helps managing several animations at once.
  35684. * @see http://doc.babylonjs.com/how_to/group
  35685. * @param name Defines the name of the group
  35686. * @param scene Defines the scene the group belongs to
  35687. */
  35688. constructor(
  35689. /** The name of the animation group */
  35690. name: string, scene?: Nullable<Scene>);
  35691. /**
  35692. * Add an animation (with its target) in the group
  35693. * @param animation defines the animation we want to add
  35694. * @param target defines the target of the animation
  35695. * @returns the TargetedAnimation object
  35696. */
  35697. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35698. /**
  35699. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35700. * It can add constant keys at begin or end
  35701. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35702. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35703. * @returns the animation group
  35704. */
  35705. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35706. private _animationLoopCount;
  35707. private _animationLoopFlags;
  35708. private _processLoop;
  35709. /**
  35710. * Start all animations on given targets
  35711. * @param loop defines if animations must loop
  35712. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35713. * @param from defines the from key (optional)
  35714. * @param to defines the to key (optional)
  35715. * @returns the current animation group
  35716. */
  35717. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35718. /**
  35719. * Pause all animations
  35720. * @returns the animation group
  35721. */
  35722. pause(): AnimationGroup;
  35723. /**
  35724. * Play all animations to initial state
  35725. * This function will start() the animations if they were not started or will restart() them if they were paused
  35726. * @param loop defines if animations must loop
  35727. * @returns the animation group
  35728. */
  35729. play(loop?: boolean): AnimationGroup;
  35730. /**
  35731. * Reset all animations to initial state
  35732. * @returns the animation group
  35733. */
  35734. reset(): AnimationGroup;
  35735. /**
  35736. * Restart animations from key 0
  35737. * @returns the animation group
  35738. */
  35739. restart(): AnimationGroup;
  35740. /**
  35741. * Stop all animations
  35742. * @returns the animation group
  35743. */
  35744. stop(): AnimationGroup;
  35745. /**
  35746. * Set animation weight for all animatables
  35747. * @param weight defines the weight to use
  35748. * @return the animationGroup
  35749. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35750. */
  35751. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35752. /**
  35753. * Synchronize and normalize all animatables with a source animatable
  35754. * @param root defines the root animatable to synchronize with
  35755. * @return the animationGroup
  35756. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35757. */
  35758. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35759. /**
  35760. * Goes to a specific frame in this animation group
  35761. * @param frame the frame number to go to
  35762. * @return the animationGroup
  35763. */
  35764. goToFrame(frame: number): AnimationGroup;
  35765. /**
  35766. * Dispose all associated resources
  35767. */
  35768. dispose(): void;
  35769. private _checkAnimationGroupEnded;
  35770. /**
  35771. * Clone the current animation group and returns a copy
  35772. * @param newName defines the name of the new group
  35773. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35774. * @returns the new aniamtion group
  35775. */
  35776. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35777. /**
  35778. * Serializes the animationGroup to an object
  35779. * @returns Serialized object
  35780. */
  35781. serialize(): any;
  35782. /**
  35783. * Returns a new AnimationGroup object parsed from the source provided.
  35784. * @param parsedAnimationGroup defines the source
  35785. * @param scene defines the scene that will receive the animationGroup
  35786. * @returns a new AnimationGroup
  35787. */
  35788. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35789. /**
  35790. * Returns the string "AnimationGroup"
  35791. * @returns "AnimationGroup"
  35792. */
  35793. getClassName(): string;
  35794. /**
  35795. * Creates a detailled string about the object
  35796. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35797. * @returns a string representing the object
  35798. */
  35799. toString(fullDetails?: boolean): string;
  35800. }
  35801. }
  35802. declare module "babylonjs/scene" {
  35803. import { Nullable } from "babylonjs/types";
  35804. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35805. import { Observable } from "babylonjs/Misc/observable";
  35806. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  35807. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  35808. import { Geometry } from "babylonjs/Meshes/geometry";
  35809. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35810. import { SubMesh } from "babylonjs/Meshes/subMesh";
  35811. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35812. import { Mesh } from "babylonjs/Meshes/mesh";
  35813. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35814. import { Bone } from "babylonjs/Bones/bone";
  35815. import { Skeleton } from "babylonjs/Bones/skeleton";
  35816. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35817. import { Camera } from "babylonjs/Cameras/camera";
  35818. import { AbstractScene } from "babylonjs/abstractScene";
  35819. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35820. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35821. import { Material } from "babylonjs/Materials/material";
  35822. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35823. import { Effect } from "babylonjs/Materials/effect";
  35824. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35825. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35826. import { Light } from "babylonjs/Lights/light";
  35827. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35828. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  35829. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  35830. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  35831. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35832. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  35833. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35834. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  35835. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  35836. import { Engine } from "babylonjs/Engines/engine";
  35837. import { Node } from "babylonjs/node";
  35838. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  35839. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35840. import { WebRequest } from "babylonjs/Misc/webRequest";
  35841. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  35842. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  35843. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35844. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  35845. import { Plane } from "babylonjs/Maths/math.plane";
  35846. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  35847. import { Ray } from "babylonjs/Culling/ray";
  35848. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  35849. import { Animation } from "babylonjs/Animations/animation";
  35850. import { Animatable } from "babylonjs/Animations/animatable";
  35851. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35852. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  35853. import { Collider } from "babylonjs/Collisions/collider";
  35854. /**
  35855. * Define an interface for all classes that will hold resources
  35856. */
  35857. export interface IDisposable {
  35858. /**
  35859. * Releases all held resources
  35860. */
  35861. dispose(): void;
  35862. }
  35863. /** Interface defining initialization parameters for Scene class */
  35864. export interface SceneOptions {
  35865. /**
  35866. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35867. * It will improve performance when the number of geometries becomes important.
  35868. */
  35869. useGeometryUniqueIdsMap?: boolean;
  35870. /**
  35871. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35872. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35873. */
  35874. useMaterialMeshMap?: boolean;
  35875. /**
  35876. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35877. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35878. */
  35879. useClonedMeshMap?: boolean;
  35880. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35881. virtual?: boolean;
  35882. }
  35883. /**
  35884. * Represents a scene to be rendered by the engine.
  35885. * @see http://doc.babylonjs.com/features/scene
  35886. */
  35887. export class Scene extends AbstractScene implements IAnimatable {
  35888. /** The fog is deactivated */
  35889. static readonly FOGMODE_NONE: number;
  35890. /** The fog density is following an exponential function */
  35891. static readonly FOGMODE_EXP: number;
  35892. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35893. static readonly FOGMODE_EXP2: number;
  35894. /** The fog density is following a linear function. */
  35895. static readonly FOGMODE_LINEAR: number;
  35896. /**
  35897. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35898. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35899. */
  35900. static MinDeltaTime: number;
  35901. /**
  35902. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35903. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35904. */
  35905. static MaxDeltaTime: number;
  35906. /**
  35907. * Factory used to create the default material.
  35908. * @param name The name of the material to create
  35909. * @param scene The scene to create the material for
  35910. * @returns The default material
  35911. */
  35912. static DefaultMaterialFactory(scene: Scene): Material;
  35913. /**
  35914. * Factory used to create the a collision coordinator.
  35915. * @returns The collision coordinator
  35916. */
  35917. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35918. /** @hidden */
  35919. _inputManager: InputManager;
  35920. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35921. cameraToUseForPointers: Nullable<Camera>;
  35922. /** @hidden */
  35923. readonly _isScene: boolean;
  35924. /**
  35925. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35926. */
  35927. autoClear: boolean;
  35928. /**
  35929. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35930. */
  35931. autoClearDepthAndStencil: boolean;
  35932. /**
  35933. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35934. */
  35935. clearColor: Color4;
  35936. /**
  35937. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35938. */
  35939. ambientColor: Color3;
  35940. /**
  35941. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35942. * It should only be one of the following (if not the default embedded one):
  35943. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35944. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35945. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35946. * The material properties need to be setup according to the type of texture in use.
  35947. */
  35948. environmentBRDFTexture: BaseTexture;
  35949. /** @hidden */
  35950. protected _environmentTexture: Nullable<BaseTexture>;
  35951. /**
  35952. * Texture used in all pbr material as the reflection texture.
  35953. * As in the majority of the scene they are the same (exception for multi room and so on),
  35954. * this is easier to reference from here than from all the materials.
  35955. */
  35956. get environmentTexture(): Nullable<BaseTexture>;
  35957. /**
  35958. * Texture used in all pbr material as the reflection texture.
  35959. * As in the majority of the scene they are the same (exception for multi room and so on),
  35960. * this is easier to set here than in all the materials.
  35961. */
  35962. set environmentTexture(value: Nullable<BaseTexture>);
  35963. /** @hidden */
  35964. protected _environmentIntensity: number;
  35965. /**
  35966. * Intensity of the environment in all pbr material.
  35967. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35968. * As in the majority of the scene they are the same (exception for multi room and so on),
  35969. * this is easier to reference from here than from all the materials.
  35970. */
  35971. get environmentIntensity(): number;
  35972. /**
  35973. * Intensity of the environment in all pbr material.
  35974. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35975. * As in the majority of the scene they are the same (exception for multi room and so on),
  35976. * this is easier to set here than in all the materials.
  35977. */
  35978. set environmentIntensity(value: number);
  35979. /** @hidden */
  35980. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35981. /**
  35982. * Default image processing configuration used either in the rendering
  35983. * Forward main pass or through the imageProcessingPostProcess if present.
  35984. * As in the majority of the scene they are the same (exception for multi camera),
  35985. * this is easier to reference from here than from all the materials and post process.
  35986. *
  35987. * No setter as we it is a shared configuration, you can set the values instead.
  35988. */
  35989. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35990. private _forceWireframe;
  35991. /**
  35992. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35993. */
  35994. set forceWireframe(value: boolean);
  35995. get forceWireframe(): boolean;
  35996. private _skipFrustumClipping;
  35997. /**
  35998. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35999. */
  36000. set skipFrustumClipping(value: boolean);
  36001. get skipFrustumClipping(): boolean;
  36002. private _forcePointsCloud;
  36003. /**
  36004. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36005. */
  36006. set forcePointsCloud(value: boolean);
  36007. get forcePointsCloud(): boolean;
  36008. /**
  36009. * Gets or sets the active clipplane 1
  36010. */
  36011. clipPlane: Nullable<Plane>;
  36012. /**
  36013. * Gets or sets the active clipplane 2
  36014. */
  36015. clipPlane2: Nullable<Plane>;
  36016. /**
  36017. * Gets or sets the active clipplane 3
  36018. */
  36019. clipPlane3: Nullable<Plane>;
  36020. /**
  36021. * Gets or sets the active clipplane 4
  36022. */
  36023. clipPlane4: Nullable<Plane>;
  36024. /**
  36025. * Gets or sets the active clipplane 5
  36026. */
  36027. clipPlane5: Nullable<Plane>;
  36028. /**
  36029. * Gets or sets the active clipplane 6
  36030. */
  36031. clipPlane6: Nullable<Plane>;
  36032. /**
  36033. * Gets or sets a boolean indicating if animations are enabled
  36034. */
  36035. animationsEnabled: boolean;
  36036. private _animationPropertiesOverride;
  36037. /**
  36038. * Gets or sets the animation properties override
  36039. */
  36040. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36041. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36042. /**
  36043. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36044. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36045. */
  36046. useConstantAnimationDeltaTime: boolean;
  36047. /**
  36048. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36049. * Please note that it requires to run a ray cast through the scene on every frame
  36050. */
  36051. constantlyUpdateMeshUnderPointer: boolean;
  36052. /**
  36053. * Defines the HTML cursor to use when hovering over interactive elements
  36054. */
  36055. hoverCursor: string;
  36056. /**
  36057. * Defines the HTML default cursor to use (empty by default)
  36058. */
  36059. defaultCursor: string;
  36060. /**
  36061. * Defines wether cursors are handled by the scene.
  36062. */
  36063. doNotHandleCursors: boolean;
  36064. /**
  36065. * This is used to call preventDefault() on pointer down
  36066. * in order to block unwanted artifacts like system double clicks
  36067. */
  36068. preventDefaultOnPointerDown: boolean;
  36069. /**
  36070. * This is used to call preventDefault() on pointer up
  36071. * in order to block unwanted artifacts like system double clicks
  36072. */
  36073. preventDefaultOnPointerUp: boolean;
  36074. /**
  36075. * Gets or sets user defined metadata
  36076. */
  36077. metadata: any;
  36078. /**
  36079. * For internal use only. Please do not use.
  36080. */
  36081. reservedDataStore: any;
  36082. /**
  36083. * Gets the name of the plugin used to load this scene (null by default)
  36084. */
  36085. loadingPluginName: string;
  36086. /**
  36087. * Use this array to add regular expressions used to disable offline support for specific urls
  36088. */
  36089. disableOfflineSupportExceptionRules: RegExp[];
  36090. /**
  36091. * An event triggered when the scene is disposed.
  36092. */
  36093. onDisposeObservable: Observable<Scene>;
  36094. private _onDisposeObserver;
  36095. /** Sets a function to be executed when this scene is disposed. */
  36096. set onDispose(callback: () => void);
  36097. /**
  36098. * An event triggered before rendering the scene (right after animations and physics)
  36099. */
  36100. onBeforeRenderObservable: Observable<Scene>;
  36101. private _onBeforeRenderObserver;
  36102. /** Sets a function to be executed before rendering this scene */
  36103. set beforeRender(callback: Nullable<() => void>);
  36104. /**
  36105. * An event triggered after rendering the scene
  36106. */
  36107. onAfterRenderObservable: Observable<Scene>;
  36108. /**
  36109. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36110. */
  36111. onAfterRenderCameraObservable: Observable<Camera>;
  36112. private _onAfterRenderObserver;
  36113. /** Sets a function to be executed after rendering this scene */
  36114. set afterRender(callback: Nullable<() => void>);
  36115. /**
  36116. * An event triggered before animating the scene
  36117. */
  36118. onBeforeAnimationsObservable: Observable<Scene>;
  36119. /**
  36120. * An event triggered after animations processing
  36121. */
  36122. onAfterAnimationsObservable: Observable<Scene>;
  36123. /**
  36124. * An event triggered before draw calls are ready to be sent
  36125. */
  36126. onBeforeDrawPhaseObservable: Observable<Scene>;
  36127. /**
  36128. * An event triggered after draw calls have been sent
  36129. */
  36130. onAfterDrawPhaseObservable: Observable<Scene>;
  36131. /**
  36132. * An event triggered when the scene is ready
  36133. */
  36134. onReadyObservable: Observable<Scene>;
  36135. /**
  36136. * An event triggered before rendering a camera
  36137. */
  36138. onBeforeCameraRenderObservable: Observable<Camera>;
  36139. private _onBeforeCameraRenderObserver;
  36140. /** Sets a function to be executed before rendering a camera*/
  36141. set beforeCameraRender(callback: () => void);
  36142. /**
  36143. * An event triggered after rendering a camera
  36144. */
  36145. onAfterCameraRenderObservable: Observable<Camera>;
  36146. private _onAfterCameraRenderObserver;
  36147. /** Sets a function to be executed after rendering a camera*/
  36148. set afterCameraRender(callback: () => void);
  36149. /**
  36150. * An event triggered when active meshes evaluation is about to start
  36151. */
  36152. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36153. /**
  36154. * An event triggered when active meshes evaluation is done
  36155. */
  36156. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36157. /**
  36158. * An event triggered when particles rendering is about to start
  36159. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36160. */
  36161. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36162. /**
  36163. * An event triggered when particles rendering is done
  36164. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36165. */
  36166. onAfterParticlesRenderingObservable: Observable<Scene>;
  36167. /**
  36168. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36169. */
  36170. onDataLoadedObservable: Observable<Scene>;
  36171. /**
  36172. * An event triggered when a camera is created
  36173. */
  36174. onNewCameraAddedObservable: Observable<Camera>;
  36175. /**
  36176. * An event triggered when a camera is removed
  36177. */
  36178. onCameraRemovedObservable: Observable<Camera>;
  36179. /**
  36180. * An event triggered when a light is created
  36181. */
  36182. onNewLightAddedObservable: Observable<Light>;
  36183. /**
  36184. * An event triggered when a light is removed
  36185. */
  36186. onLightRemovedObservable: Observable<Light>;
  36187. /**
  36188. * An event triggered when a geometry is created
  36189. */
  36190. onNewGeometryAddedObservable: Observable<Geometry>;
  36191. /**
  36192. * An event triggered when a geometry is removed
  36193. */
  36194. onGeometryRemovedObservable: Observable<Geometry>;
  36195. /**
  36196. * An event triggered when a transform node is created
  36197. */
  36198. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36199. /**
  36200. * An event triggered when a transform node is removed
  36201. */
  36202. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36203. /**
  36204. * An event triggered when a mesh is created
  36205. */
  36206. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36207. /**
  36208. * An event triggered when a mesh is removed
  36209. */
  36210. onMeshRemovedObservable: Observable<AbstractMesh>;
  36211. /**
  36212. * An event triggered when a skeleton is created
  36213. */
  36214. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36215. /**
  36216. * An event triggered when a skeleton is removed
  36217. */
  36218. onSkeletonRemovedObservable: Observable<Skeleton>;
  36219. /**
  36220. * An event triggered when a material is created
  36221. */
  36222. onNewMaterialAddedObservable: Observable<Material>;
  36223. /**
  36224. * An event triggered when a material is removed
  36225. */
  36226. onMaterialRemovedObservable: Observable<Material>;
  36227. /**
  36228. * An event triggered when a texture is created
  36229. */
  36230. onNewTextureAddedObservable: Observable<BaseTexture>;
  36231. /**
  36232. * An event triggered when a texture is removed
  36233. */
  36234. onTextureRemovedObservable: Observable<BaseTexture>;
  36235. /**
  36236. * An event triggered when render targets are about to be rendered
  36237. * Can happen multiple times per frame.
  36238. */
  36239. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36240. /**
  36241. * An event triggered when render targets were rendered.
  36242. * Can happen multiple times per frame.
  36243. */
  36244. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36245. /**
  36246. * An event triggered before calculating deterministic simulation step
  36247. */
  36248. onBeforeStepObservable: Observable<Scene>;
  36249. /**
  36250. * An event triggered after calculating deterministic simulation step
  36251. */
  36252. onAfterStepObservable: Observable<Scene>;
  36253. /**
  36254. * An event triggered when the activeCamera property is updated
  36255. */
  36256. onActiveCameraChanged: Observable<Scene>;
  36257. /**
  36258. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36259. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36260. * 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)
  36261. */
  36262. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36263. /**
  36264. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36265. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36266. * 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)
  36267. */
  36268. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36269. /**
  36270. * This Observable will when a mesh has been imported into the scene.
  36271. */
  36272. onMeshImportedObservable: Observable<AbstractMesh>;
  36273. /**
  36274. * This Observable will when an animation file has been imported into the scene.
  36275. */
  36276. onAnimationFileImportedObservable: Observable<Scene>;
  36277. /**
  36278. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36279. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36280. */
  36281. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36282. /** @hidden */
  36283. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36284. /**
  36285. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36286. */
  36287. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36288. /**
  36289. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36290. */
  36291. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36292. /**
  36293. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36294. */
  36295. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36296. /** Callback called when a pointer move is detected */
  36297. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36298. /** Callback called when a pointer down is detected */
  36299. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36300. /** Callback called when a pointer up is detected */
  36301. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36302. /** Callback called when a pointer pick is detected */
  36303. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36304. /**
  36305. * 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).
  36306. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36307. */
  36308. onPrePointerObservable: Observable<PointerInfoPre>;
  36309. /**
  36310. * Observable event triggered each time an input event is received from the rendering canvas
  36311. */
  36312. onPointerObservable: Observable<PointerInfo>;
  36313. /**
  36314. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36315. */
  36316. get unTranslatedPointer(): Vector2;
  36317. /**
  36318. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36319. */
  36320. static get DragMovementThreshold(): number;
  36321. static set DragMovementThreshold(value: number);
  36322. /**
  36323. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36324. */
  36325. static get LongPressDelay(): number;
  36326. static set LongPressDelay(value: number);
  36327. /**
  36328. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36329. */
  36330. static get DoubleClickDelay(): number;
  36331. static set DoubleClickDelay(value: number);
  36332. /** If you need to check double click without raising a single click at first click, enable this flag */
  36333. static get ExclusiveDoubleClickMode(): boolean;
  36334. static set ExclusiveDoubleClickMode(value: boolean);
  36335. /** @hidden */
  36336. _mirroredCameraPosition: Nullable<Vector3>;
  36337. /**
  36338. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36339. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36340. */
  36341. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36342. /**
  36343. * Observable event triggered each time an keyboard event is received from the hosting window
  36344. */
  36345. onKeyboardObservable: Observable<KeyboardInfo>;
  36346. private _useRightHandedSystem;
  36347. /**
  36348. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36349. */
  36350. set useRightHandedSystem(value: boolean);
  36351. get useRightHandedSystem(): boolean;
  36352. private _timeAccumulator;
  36353. private _currentStepId;
  36354. private _currentInternalStep;
  36355. /**
  36356. * Sets the step Id used by deterministic lock step
  36357. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36358. * @param newStepId defines the step Id
  36359. */
  36360. setStepId(newStepId: number): void;
  36361. /**
  36362. * Gets the step Id used by deterministic lock step
  36363. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36364. * @returns the step Id
  36365. */
  36366. getStepId(): number;
  36367. /**
  36368. * Gets the internal step used by deterministic lock step
  36369. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36370. * @returns the internal step
  36371. */
  36372. getInternalStep(): number;
  36373. private _fogEnabled;
  36374. /**
  36375. * Gets or sets a boolean indicating if fog is enabled on this scene
  36376. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36377. * (Default is true)
  36378. */
  36379. set fogEnabled(value: boolean);
  36380. get fogEnabled(): boolean;
  36381. private _fogMode;
  36382. /**
  36383. * Gets or sets the fog mode to use
  36384. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36385. * | mode | value |
  36386. * | --- | --- |
  36387. * | FOGMODE_NONE | 0 |
  36388. * | FOGMODE_EXP | 1 |
  36389. * | FOGMODE_EXP2 | 2 |
  36390. * | FOGMODE_LINEAR | 3 |
  36391. */
  36392. set fogMode(value: number);
  36393. get fogMode(): number;
  36394. /**
  36395. * Gets or sets the fog color to use
  36396. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36397. * (Default is Color3(0.2, 0.2, 0.3))
  36398. */
  36399. fogColor: Color3;
  36400. /**
  36401. * Gets or sets the fog density to use
  36402. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36403. * (Default is 0.1)
  36404. */
  36405. fogDensity: number;
  36406. /**
  36407. * Gets or sets the fog start distance to use
  36408. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36409. * (Default is 0)
  36410. */
  36411. fogStart: number;
  36412. /**
  36413. * Gets or sets the fog end distance to use
  36414. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36415. * (Default is 1000)
  36416. */
  36417. fogEnd: number;
  36418. private _shadowsEnabled;
  36419. /**
  36420. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36421. */
  36422. set shadowsEnabled(value: boolean);
  36423. get shadowsEnabled(): boolean;
  36424. private _lightsEnabled;
  36425. /**
  36426. * Gets or sets a boolean indicating if lights are enabled on this scene
  36427. */
  36428. set lightsEnabled(value: boolean);
  36429. get lightsEnabled(): boolean;
  36430. /** All of the active cameras added to this scene. */
  36431. activeCameras: Camera[];
  36432. /** @hidden */
  36433. _activeCamera: Nullable<Camera>;
  36434. /** Gets or sets the current active camera */
  36435. get activeCamera(): Nullable<Camera>;
  36436. set activeCamera(value: Nullable<Camera>);
  36437. private _defaultMaterial;
  36438. /** The default material used on meshes when no material is affected */
  36439. get defaultMaterial(): Material;
  36440. /** The default material used on meshes when no material is affected */
  36441. set defaultMaterial(value: Material);
  36442. private _texturesEnabled;
  36443. /**
  36444. * Gets or sets a boolean indicating if textures are enabled on this scene
  36445. */
  36446. set texturesEnabled(value: boolean);
  36447. get texturesEnabled(): boolean;
  36448. /**
  36449. * Gets or sets a boolean indicating if particles are enabled on this scene
  36450. */
  36451. particlesEnabled: boolean;
  36452. /**
  36453. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36454. */
  36455. spritesEnabled: boolean;
  36456. private _skeletonsEnabled;
  36457. /**
  36458. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36459. */
  36460. set skeletonsEnabled(value: boolean);
  36461. get skeletonsEnabled(): boolean;
  36462. /**
  36463. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36464. */
  36465. lensFlaresEnabled: boolean;
  36466. /**
  36467. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36468. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36469. */
  36470. collisionsEnabled: boolean;
  36471. private _collisionCoordinator;
  36472. /** @hidden */
  36473. get collisionCoordinator(): ICollisionCoordinator;
  36474. /**
  36475. * Defines the gravity applied to this scene (used only for collisions)
  36476. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36477. */
  36478. gravity: Vector3;
  36479. /**
  36480. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36481. */
  36482. postProcessesEnabled: boolean;
  36483. /**
  36484. * The list of postprocesses added to the scene
  36485. */
  36486. postProcesses: PostProcess[];
  36487. /**
  36488. * Gets the current postprocess manager
  36489. */
  36490. postProcessManager: PostProcessManager;
  36491. /**
  36492. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36493. */
  36494. renderTargetsEnabled: boolean;
  36495. /**
  36496. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36497. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36498. */
  36499. dumpNextRenderTargets: boolean;
  36500. /**
  36501. * The list of user defined render targets added to the scene
  36502. */
  36503. customRenderTargets: RenderTargetTexture[];
  36504. /**
  36505. * Defines if texture loading must be delayed
  36506. * If true, textures will only be loaded when they need to be rendered
  36507. */
  36508. useDelayedTextureLoading: boolean;
  36509. /**
  36510. * Gets the list of meshes imported to the scene through SceneLoader
  36511. */
  36512. importedMeshesFiles: String[];
  36513. /**
  36514. * Gets or sets a boolean indicating if probes are enabled on this scene
  36515. */
  36516. probesEnabled: boolean;
  36517. /**
  36518. * Gets or sets the current offline provider to use to store scene data
  36519. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36520. */
  36521. offlineProvider: IOfflineProvider;
  36522. /**
  36523. * Gets or sets the action manager associated with the scene
  36524. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36525. */
  36526. actionManager: AbstractActionManager;
  36527. private _meshesForIntersections;
  36528. /**
  36529. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36530. */
  36531. proceduralTexturesEnabled: boolean;
  36532. private _engine;
  36533. private _totalVertices;
  36534. /** @hidden */
  36535. _activeIndices: PerfCounter;
  36536. /** @hidden */
  36537. _activeParticles: PerfCounter;
  36538. /** @hidden */
  36539. _activeBones: PerfCounter;
  36540. private _animationRatio;
  36541. /** @hidden */
  36542. _animationTimeLast: number;
  36543. /** @hidden */
  36544. _animationTime: number;
  36545. /**
  36546. * Gets or sets a general scale for animation speed
  36547. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36548. */
  36549. animationTimeScale: number;
  36550. /** @hidden */
  36551. _cachedMaterial: Nullable<Material>;
  36552. /** @hidden */
  36553. _cachedEffect: Nullable<Effect>;
  36554. /** @hidden */
  36555. _cachedVisibility: Nullable<number>;
  36556. private _renderId;
  36557. private _frameId;
  36558. private _executeWhenReadyTimeoutId;
  36559. private _intermediateRendering;
  36560. private _viewUpdateFlag;
  36561. private _projectionUpdateFlag;
  36562. /** @hidden */
  36563. _toBeDisposed: Nullable<IDisposable>[];
  36564. private _activeRequests;
  36565. /** @hidden */
  36566. _pendingData: any[];
  36567. private _isDisposed;
  36568. /**
  36569. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36570. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36571. */
  36572. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36573. private _activeMeshes;
  36574. private _processedMaterials;
  36575. private _renderTargets;
  36576. /** @hidden */
  36577. _activeParticleSystems: SmartArray<IParticleSystem>;
  36578. private _activeSkeletons;
  36579. private _softwareSkinnedMeshes;
  36580. private _renderingManager;
  36581. /** @hidden */
  36582. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36583. private _transformMatrix;
  36584. private _sceneUbo;
  36585. /** @hidden */
  36586. _viewMatrix: Matrix;
  36587. private _projectionMatrix;
  36588. /** @hidden */
  36589. _forcedViewPosition: Nullable<Vector3>;
  36590. /** @hidden */
  36591. _frustumPlanes: Plane[];
  36592. /**
  36593. * Gets the list of frustum planes (built from the active camera)
  36594. */
  36595. get frustumPlanes(): Plane[];
  36596. /**
  36597. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36598. * This is useful if there are more lights that the maximum simulteanous authorized
  36599. */
  36600. requireLightSorting: boolean;
  36601. /** @hidden */
  36602. readonly useMaterialMeshMap: boolean;
  36603. /** @hidden */
  36604. readonly useClonedMeshMap: boolean;
  36605. private _externalData;
  36606. private _uid;
  36607. /**
  36608. * @hidden
  36609. * Backing store of defined scene components.
  36610. */
  36611. _components: ISceneComponent[];
  36612. /**
  36613. * @hidden
  36614. * Backing store of defined scene components.
  36615. */
  36616. _serializableComponents: ISceneSerializableComponent[];
  36617. /**
  36618. * List of components to register on the next registration step.
  36619. */
  36620. private _transientComponents;
  36621. /**
  36622. * Registers the transient components if needed.
  36623. */
  36624. private _registerTransientComponents;
  36625. /**
  36626. * @hidden
  36627. * Add a component to the scene.
  36628. * Note that the ccomponent could be registered on th next frame if this is called after
  36629. * the register component stage.
  36630. * @param component Defines the component to add to the scene
  36631. */
  36632. _addComponent(component: ISceneComponent): void;
  36633. /**
  36634. * @hidden
  36635. * Gets a component from the scene.
  36636. * @param name defines the name of the component to retrieve
  36637. * @returns the component or null if not present
  36638. */
  36639. _getComponent(name: string): Nullable<ISceneComponent>;
  36640. /**
  36641. * @hidden
  36642. * Defines the actions happening before camera updates.
  36643. */
  36644. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36645. /**
  36646. * @hidden
  36647. * Defines the actions happening before clear the canvas.
  36648. */
  36649. _beforeClearStage: Stage<SimpleStageAction>;
  36650. /**
  36651. * @hidden
  36652. * Defines the actions when collecting render targets for the frame.
  36653. */
  36654. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36655. /**
  36656. * @hidden
  36657. * Defines the actions happening for one camera in the frame.
  36658. */
  36659. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36660. /**
  36661. * @hidden
  36662. * Defines the actions happening during the per mesh ready checks.
  36663. */
  36664. _isReadyForMeshStage: Stage<MeshStageAction>;
  36665. /**
  36666. * @hidden
  36667. * Defines the actions happening before evaluate active mesh checks.
  36668. */
  36669. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36670. /**
  36671. * @hidden
  36672. * Defines the actions happening during the evaluate sub mesh checks.
  36673. */
  36674. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36675. /**
  36676. * @hidden
  36677. * Defines the actions happening during the active mesh stage.
  36678. */
  36679. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36680. /**
  36681. * @hidden
  36682. * Defines the actions happening during the per camera render target step.
  36683. */
  36684. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36685. /**
  36686. * @hidden
  36687. * Defines the actions happening just before the active camera is drawing.
  36688. */
  36689. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36690. /**
  36691. * @hidden
  36692. * Defines the actions happening just before a render target is drawing.
  36693. */
  36694. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36695. /**
  36696. * @hidden
  36697. * Defines the actions happening just before a rendering group is drawing.
  36698. */
  36699. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36700. /**
  36701. * @hidden
  36702. * Defines the actions happening just before a mesh is drawing.
  36703. */
  36704. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36705. /**
  36706. * @hidden
  36707. * Defines the actions happening just after a mesh has been drawn.
  36708. */
  36709. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36710. /**
  36711. * @hidden
  36712. * Defines the actions happening just after a rendering group has been drawn.
  36713. */
  36714. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36715. /**
  36716. * @hidden
  36717. * Defines the actions happening just after the active camera has been drawn.
  36718. */
  36719. _afterCameraDrawStage: Stage<CameraStageAction>;
  36720. /**
  36721. * @hidden
  36722. * Defines the actions happening just after a render target has been drawn.
  36723. */
  36724. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36725. /**
  36726. * @hidden
  36727. * Defines the actions happening just after rendering all cameras and computing intersections.
  36728. */
  36729. _afterRenderStage: Stage<SimpleStageAction>;
  36730. /**
  36731. * @hidden
  36732. * Defines the actions happening when a pointer move event happens.
  36733. */
  36734. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36735. /**
  36736. * @hidden
  36737. * Defines the actions happening when a pointer down event happens.
  36738. */
  36739. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36740. /**
  36741. * @hidden
  36742. * Defines the actions happening when a pointer up event happens.
  36743. */
  36744. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36745. /**
  36746. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36747. */
  36748. private geometriesByUniqueId;
  36749. /**
  36750. * Creates a new Scene
  36751. * @param engine defines the engine to use to render this scene
  36752. * @param options defines the scene options
  36753. */
  36754. constructor(engine: Engine, options?: SceneOptions);
  36755. /**
  36756. * Gets a string idenfifying the name of the class
  36757. * @returns "Scene" string
  36758. */
  36759. getClassName(): string;
  36760. private _defaultMeshCandidates;
  36761. /**
  36762. * @hidden
  36763. */
  36764. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36765. private _defaultSubMeshCandidates;
  36766. /**
  36767. * @hidden
  36768. */
  36769. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36770. /**
  36771. * Sets the default candidate providers for the scene.
  36772. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36773. * and getCollidingSubMeshCandidates to their default function
  36774. */
  36775. setDefaultCandidateProviders(): void;
  36776. /**
  36777. * Gets the mesh that is currently under the pointer
  36778. */
  36779. get meshUnderPointer(): Nullable<AbstractMesh>;
  36780. /**
  36781. * Gets or sets the current on-screen X position of the pointer
  36782. */
  36783. get pointerX(): number;
  36784. set pointerX(value: number);
  36785. /**
  36786. * Gets or sets the current on-screen Y position of the pointer
  36787. */
  36788. get pointerY(): number;
  36789. set pointerY(value: number);
  36790. /**
  36791. * Gets the cached material (ie. the latest rendered one)
  36792. * @returns the cached material
  36793. */
  36794. getCachedMaterial(): Nullable<Material>;
  36795. /**
  36796. * Gets the cached effect (ie. the latest rendered one)
  36797. * @returns the cached effect
  36798. */
  36799. getCachedEffect(): Nullable<Effect>;
  36800. /**
  36801. * Gets the cached visibility state (ie. the latest rendered one)
  36802. * @returns the cached visibility state
  36803. */
  36804. getCachedVisibility(): Nullable<number>;
  36805. /**
  36806. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36807. * @param material defines the current material
  36808. * @param effect defines the current effect
  36809. * @param visibility defines the current visibility state
  36810. * @returns true if one parameter is not cached
  36811. */
  36812. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36813. /**
  36814. * Gets the engine associated with the scene
  36815. * @returns an Engine
  36816. */
  36817. getEngine(): Engine;
  36818. /**
  36819. * Gets the total number of vertices rendered per frame
  36820. * @returns the total number of vertices rendered per frame
  36821. */
  36822. getTotalVertices(): number;
  36823. /**
  36824. * Gets the performance counter for total vertices
  36825. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36826. */
  36827. get totalVerticesPerfCounter(): PerfCounter;
  36828. /**
  36829. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36830. * @returns the total number of active indices rendered per frame
  36831. */
  36832. getActiveIndices(): number;
  36833. /**
  36834. * Gets the performance counter for active indices
  36835. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36836. */
  36837. get totalActiveIndicesPerfCounter(): PerfCounter;
  36838. /**
  36839. * Gets the total number of active particles rendered per frame
  36840. * @returns the total number of active particles rendered per frame
  36841. */
  36842. getActiveParticles(): number;
  36843. /**
  36844. * Gets the performance counter for active particles
  36845. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36846. */
  36847. get activeParticlesPerfCounter(): PerfCounter;
  36848. /**
  36849. * Gets the total number of active bones rendered per frame
  36850. * @returns the total number of active bones rendered per frame
  36851. */
  36852. getActiveBones(): number;
  36853. /**
  36854. * Gets the performance counter for active bones
  36855. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36856. */
  36857. get activeBonesPerfCounter(): PerfCounter;
  36858. /**
  36859. * Gets the array of active meshes
  36860. * @returns an array of AbstractMesh
  36861. */
  36862. getActiveMeshes(): SmartArray<AbstractMesh>;
  36863. /**
  36864. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36865. * @returns a number
  36866. */
  36867. getAnimationRatio(): number;
  36868. /**
  36869. * Gets an unique Id for the current render phase
  36870. * @returns a number
  36871. */
  36872. getRenderId(): number;
  36873. /**
  36874. * Gets an unique Id for the current frame
  36875. * @returns a number
  36876. */
  36877. getFrameId(): number;
  36878. /** Call this function if you want to manually increment the render Id*/
  36879. incrementRenderId(): void;
  36880. private _createUbo;
  36881. /**
  36882. * Use this method to simulate a pointer move on a mesh
  36883. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36884. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36885. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36886. * @returns the current scene
  36887. */
  36888. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36889. /**
  36890. * Use this method to simulate a pointer down on a mesh
  36891. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36892. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36893. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36894. * @returns the current scene
  36895. */
  36896. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36897. /**
  36898. * Use this method to simulate a pointer up on a mesh
  36899. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36900. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36901. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36902. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36903. * @returns the current scene
  36904. */
  36905. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36906. /**
  36907. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36908. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36909. * @returns true if the pointer was captured
  36910. */
  36911. isPointerCaptured(pointerId?: number): boolean;
  36912. /**
  36913. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36914. * @param attachUp defines if you want to attach events to pointerup
  36915. * @param attachDown defines if you want to attach events to pointerdown
  36916. * @param attachMove defines if you want to attach events to pointermove
  36917. */
  36918. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36919. /** Detaches all event handlers*/
  36920. detachControl(): void;
  36921. /**
  36922. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36923. * Delay loaded resources are not taking in account
  36924. * @return true if all required resources are ready
  36925. */
  36926. isReady(): boolean;
  36927. /** Resets all cached information relative to material (including effect and visibility) */
  36928. resetCachedMaterial(): void;
  36929. /**
  36930. * Registers a function to be called before every frame render
  36931. * @param func defines the function to register
  36932. */
  36933. registerBeforeRender(func: () => void): void;
  36934. /**
  36935. * Unregisters a function called before every frame render
  36936. * @param func defines the function to unregister
  36937. */
  36938. unregisterBeforeRender(func: () => void): void;
  36939. /**
  36940. * Registers a function to be called after every frame render
  36941. * @param func defines the function to register
  36942. */
  36943. registerAfterRender(func: () => void): void;
  36944. /**
  36945. * Unregisters a function called after every frame render
  36946. * @param func defines the function to unregister
  36947. */
  36948. unregisterAfterRender(func: () => void): void;
  36949. private _executeOnceBeforeRender;
  36950. /**
  36951. * The provided function will run before render once and will be disposed afterwards.
  36952. * A timeout delay can be provided so that the function will be executed in N ms.
  36953. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36954. * @param func The function to be executed.
  36955. * @param timeout optional delay in ms
  36956. */
  36957. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36958. /** @hidden */
  36959. _addPendingData(data: any): void;
  36960. /** @hidden */
  36961. _removePendingData(data: any): void;
  36962. /**
  36963. * Returns the number of items waiting to be loaded
  36964. * @returns the number of items waiting to be loaded
  36965. */
  36966. getWaitingItemsCount(): number;
  36967. /**
  36968. * Returns a boolean indicating if the scene is still loading data
  36969. */
  36970. get isLoading(): boolean;
  36971. /**
  36972. * Registers a function to be executed when the scene is ready
  36973. * @param {Function} func - the function to be executed
  36974. */
  36975. executeWhenReady(func: () => void): void;
  36976. /**
  36977. * Returns a promise that resolves when the scene is ready
  36978. * @returns A promise that resolves when the scene is ready
  36979. */
  36980. whenReadyAsync(): Promise<void>;
  36981. /** @hidden */
  36982. _checkIsReady(): void;
  36983. /**
  36984. * Gets all animatable attached to the scene
  36985. */
  36986. get animatables(): Animatable[];
  36987. /**
  36988. * Resets the last animation time frame.
  36989. * Useful to override when animations start running when loading a scene for the first time.
  36990. */
  36991. resetLastAnimationTimeFrame(): void;
  36992. /**
  36993. * Gets the current view matrix
  36994. * @returns a Matrix
  36995. */
  36996. getViewMatrix(): Matrix;
  36997. /**
  36998. * Gets the current projection matrix
  36999. * @returns a Matrix
  37000. */
  37001. getProjectionMatrix(): Matrix;
  37002. /**
  37003. * Gets the current transform matrix
  37004. * @returns a Matrix made of View * Projection
  37005. */
  37006. getTransformMatrix(): Matrix;
  37007. /**
  37008. * Sets the current transform matrix
  37009. * @param viewL defines the View matrix to use
  37010. * @param projectionL defines the Projection matrix to use
  37011. * @param viewR defines the right View matrix to use (if provided)
  37012. * @param projectionR defines the right Projection matrix to use (if provided)
  37013. */
  37014. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37015. /**
  37016. * Gets the uniform buffer used to store scene data
  37017. * @returns a UniformBuffer
  37018. */
  37019. getSceneUniformBuffer(): UniformBuffer;
  37020. /**
  37021. * Gets an unique (relatively to the current scene) Id
  37022. * @returns an unique number for the scene
  37023. */
  37024. getUniqueId(): number;
  37025. /**
  37026. * Add a mesh to the list of scene's meshes
  37027. * @param newMesh defines the mesh to add
  37028. * @param recursive if all child meshes should also be added to the scene
  37029. */
  37030. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37031. /**
  37032. * Remove a mesh for the list of scene's meshes
  37033. * @param toRemove defines the mesh to remove
  37034. * @param recursive if all child meshes should also be removed from the scene
  37035. * @returns the index where the mesh was in the mesh list
  37036. */
  37037. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37038. /**
  37039. * Add a transform node to the list of scene's transform nodes
  37040. * @param newTransformNode defines the transform node to add
  37041. */
  37042. addTransformNode(newTransformNode: TransformNode): void;
  37043. /**
  37044. * Remove a transform node for the list of scene's transform nodes
  37045. * @param toRemove defines the transform node to remove
  37046. * @returns the index where the transform node was in the transform node list
  37047. */
  37048. removeTransformNode(toRemove: TransformNode): number;
  37049. /**
  37050. * Remove a skeleton for the list of scene's skeletons
  37051. * @param toRemove defines the skeleton to remove
  37052. * @returns the index where the skeleton was in the skeleton list
  37053. */
  37054. removeSkeleton(toRemove: Skeleton): number;
  37055. /**
  37056. * Remove a morph target for the list of scene's morph targets
  37057. * @param toRemove defines the morph target to remove
  37058. * @returns the index where the morph target was in the morph target list
  37059. */
  37060. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37061. /**
  37062. * Remove a light for the list of scene's lights
  37063. * @param toRemove defines the light to remove
  37064. * @returns the index where the light was in the light list
  37065. */
  37066. removeLight(toRemove: Light): number;
  37067. /**
  37068. * Remove a camera for the list of scene's cameras
  37069. * @param toRemove defines the camera to remove
  37070. * @returns the index where the camera was in the camera list
  37071. */
  37072. removeCamera(toRemove: Camera): number;
  37073. /**
  37074. * Remove a particle system for the list of scene's particle systems
  37075. * @param toRemove defines the particle system to remove
  37076. * @returns the index where the particle system was in the particle system list
  37077. */
  37078. removeParticleSystem(toRemove: IParticleSystem): number;
  37079. /**
  37080. * Remove a animation for the list of scene's animations
  37081. * @param toRemove defines the animation to remove
  37082. * @returns the index where the animation was in the animation list
  37083. */
  37084. removeAnimation(toRemove: Animation): number;
  37085. /**
  37086. * Will stop the animation of the given target
  37087. * @param target - the target
  37088. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37089. * @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)
  37090. */
  37091. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37092. /**
  37093. * Removes the given animation group from this scene.
  37094. * @param toRemove The animation group to remove
  37095. * @returns The index of the removed animation group
  37096. */
  37097. removeAnimationGroup(toRemove: AnimationGroup): number;
  37098. /**
  37099. * Removes the given multi-material from this scene.
  37100. * @param toRemove The multi-material to remove
  37101. * @returns The index of the removed multi-material
  37102. */
  37103. removeMultiMaterial(toRemove: MultiMaterial): number;
  37104. /**
  37105. * Removes the given material from this scene.
  37106. * @param toRemove The material to remove
  37107. * @returns The index of the removed material
  37108. */
  37109. removeMaterial(toRemove: Material): number;
  37110. /**
  37111. * Removes the given action manager from this scene.
  37112. * @param toRemove The action manager to remove
  37113. * @returns The index of the removed action manager
  37114. */
  37115. removeActionManager(toRemove: AbstractActionManager): number;
  37116. /**
  37117. * Removes the given texture from this scene.
  37118. * @param toRemove The texture to remove
  37119. * @returns The index of the removed texture
  37120. */
  37121. removeTexture(toRemove: BaseTexture): number;
  37122. /**
  37123. * Adds the given light to this scene
  37124. * @param newLight The light to add
  37125. */
  37126. addLight(newLight: Light): void;
  37127. /**
  37128. * Sorts the list list based on light priorities
  37129. */
  37130. sortLightsByPriority(): void;
  37131. /**
  37132. * Adds the given camera to this scene
  37133. * @param newCamera The camera to add
  37134. */
  37135. addCamera(newCamera: Camera): void;
  37136. /**
  37137. * Adds the given skeleton to this scene
  37138. * @param newSkeleton The skeleton to add
  37139. */
  37140. addSkeleton(newSkeleton: Skeleton): void;
  37141. /**
  37142. * Adds the given particle system to this scene
  37143. * @param newParticleSystem The particle system to add
  37144. */
  37145. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37146. /**
  37147. * Adds the given animation to this scene
  37148. * @param newAnimation The animation to add
  37149. */
  37150. addAnimation(newAnimation: Animation): void;
  37151. /**
  37152. * Adds the given animation group to this scene.
  37153. * @param newAnimationGroup The animation group to add
  37154. */
  37155. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37156. /**
  37157. * Adds the given multi-material to this scene
  37158. * @param newMultiMaterial The multi-material to add
  37159. */
  37160. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37161. /**
  37162. * Adds the given material to this scene
  37163. * @param newMaterial The material to add
  37164. */
  37165. addMaterial(newMaterial: Material): void;
  37166. /**
  37167. * Adds the given morph target to this scene
  37168. * @param newMorphTargetManager The morph target to add
  37169. */
  37170. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37171. /**
  37172. * Adds the given geometry to this scene
  37173. * @param newGeometry The geometry to add
  37174. */
  37175. addGeometry(newGeometry: Geometry): void;
  37176. /**
  37177. * Adds the given action manager to this scene
  37178. * @param newActionManager The action manager to add
  37179. */
  37180. addActionManager(newActionManager: AbstractActionManager): void;
  37181. /**
  37182. * Adds the given texture to this scene.
  37183. * @param newTexture The texture to add
  37184. */
  37185. addTexture(newTexture: BaseTexture): void;
  37186. /**
  37187. * Switch active camera
  37188. * @param newCamera defines the new active camera
  37189. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37190. */
  37191. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37192. /**
  37193. * sets the active camera of the scene using its ID
  37194. * @param id defines the camera's ID
  37195. * @return the new active camera or null if none found.
  37196. */
  37197. setActiveCameraByID(id: string): Nullable<Camera>;
  37198. /**
  37199. * sets the active camera of the scene using its name
  37200. * @param name defines the camera's name
  37201. * @returns the new active camera or null if none found.
  37202. */
  37203. setActiveCameraByName(name: string): Nullable<Camera>;
  37204. /**
  37205. * get an animation group using its name
  37206. * @param name defines the material's name
  37207. * @return the animation group or null if none found.
  37208. */
  37209. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37210. /**
  37211. * Get a material using its unique id
  37212. * @param uniqueId defines the material's unique id
  37213. * @return the material or null if none found.
  37214. */
  37215. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37216. /**
  37217. * get a material using its id
  37218. * @param id defines the material's ID
  37219. * @return the material or null if none found.
  37220. */
  37221. getMaterialByID(id: string): Nullable<Material>;
  37222. /**
  37223. * Gets a the last added material using a given id
  37224. * @param id defines the material's ID
  37225. * @return the last material with the given id or null if none found.
  37226. */
  37227. getLastMaterialByID(id: string): Nullable<Material>;
  37228. /**
  37229. * Gets a material using its name
  37230. * @param name defines the material's name
  37231. * @return the material or null if none found.
  37232. */
  37233. getMaterialByName(name: string): Nullable<Material>;
  37234. /**
  37235. * Get a texture using its unique id
  37236. * @param uniqueId defines the texture's unique id
  37237. * @return the texture or null if none found.
  37238. */
  37239. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37240. /**
  37241. * Gets a camera using its id
  37242. * @param id defines the id to look for
  37243. * @returns the camera or null if not found
  37244. */
  37245. getCameraByID(id: string): Nullable<Camera>;
  37246. /**
  37247. * Gets a camera using its unique id
  37248. * @param uniqueId defines the unique id to look for
  37249. * @returns the camera or null if not found
  37250. */
  37251. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37252. /**
  37253. * Gets a camera using its name
  37254. * @param name defines the camera's name
  37255. * @return the camera or null if none found.
  37256. */
  37257. getCameraByName(name: string): Nullable<Camera>;
  37258. /**
  37259. * Gets a bone using its id
  37260. * @param id defines the bone's id
  37261. * @return the bone or null if not found
  37262. */
  37263. getBoneByID(id: string): Nullable<Bone>;
  37264. /**
  37265. * Gets a bone using its id
  37266. * @param name defines the bone's name
  37267. * @return the bone or null if not found
  37268. */
  37269. getBoneByName(name: string): Nullable<Bone>;
  37270. /**
  37271. * Gets a light node using its name
  37272. * @param name defines the the light's name
  37273. * @return the light or null if none found.
  37274. */
  37275. getLightByName(name: string): Nullable<Light>;
  37276. /**
  37277. * Gets a light node using its id
  37278. * @param id defines the light's id
  37279. * @return the light or null if none found.
  37280. */
  37281. getLightByID(id: string): Nullable<Light>;
  37282. /**
  37283. * Gets a light node using its scene-generated unique ID
  37284. * @param uniqueId defines the light's unique id
  37285. * @return the light or null if none found.
  37286. */
  37287. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37288. /**
  37289. * Gets a particle system by id
  37290. * @param id defines the particle system id
  37291. * @return the corresponding system or null if none found
  37292. */
  37293. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37294. /**
  37295. * Gets a geometry using its ID
  37296. * @param id defines the geometry's id
  37297. * @return the geometry or null if none found.
  37298. */
  37299. getGeometryByID(id: string): Nullable<Geometry>;
  37300. private _getGeometryByUniqueID;
  37301. /**
  37302. * Add a new geometry to this scene
  37303. * @param geometry defines the geometry to be added to the scene.
  37304. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37305. * @return a boolean defining if the geometry was added or not
  37306. */
  37307. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37308. /**
  37309. * Removes an existing geometry
  37310. * @param geometry defines the geometry to be removed from the scene
  37311. * @return a boolean defining if the geometry was removed or not
  37312. */
  37313. removeGeometry(geometry: Geometry): boolean;
  37314. /**
  37315. * Gets the list of geometries attached to the scene
  37316. * @returns an array of Geometry
  37317. */
  37318. getGeometries(): Geometry[];
  37319. /**
  37320. * Gets the first added mesh found of a given ID
  37321. * @param id defines the id to search for
  37322. * @return the mesh found or null if not found at all
  37323. */
  37324. getMeshByID(id: string): Nullable<AbstractMesh>;
  37325. /**
  37326. * Gets a list of meshes using their id
  37327. * @param id defines the id to search for
  37328. * @returns a list of meshes
  37329. */
  37330. getMeshesByID(id: string): Array<AbstractMesh>;
  37331. /**
  37332. * Gets the first added transform node found of a given ID
  37333. * @param id defines the id to search for
  37334. * @return the found transform node or null if not found at all.
  37335. */
  37336. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37337. /**
  37338. * Gets a transform node with its auto-generated unique id
  37339. * @param uniqueId efines the unique id to search for
  37340. * @return the found transform node or null if not found at all.
  37341. */
  37342. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37343. /**
  37344. * Gets a list of transform nodes using their id
  37345. * @param id defines the id to search for
  37346. * @returns a list of transform nodes
  37347. */
  37348. getTransformNodesByID(id: string): Array<TransformNode>;
  37349. /**
  37350. * Gets a mesh with its auto-generated unique id
  37351. * @param uniqueId defines the unique id to search for
  37352. * @return the found mesh or null if not found at all.
  37353. */
  37354. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37355. /**
  37356. * Gets a the last added mesh using a given id
  37357. * @param id defines the id to search for
  37358. * @return the found mesh or null if not found at all.
  37359. */
  37360. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37361. /**
  37362. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37363. * @param id defines the id to search for
  37364. * @return the found node or null if not found at all
  37365. */
  37366. getLastEntryByID(id: string): Nullable<Node>;
  37367. /**
  37368. * Gets a node (Mesh, Camera, Light) using a given id
  37369. * @param id defines the id to search for
  37370. * @return the found node or null if not found at all
  37371. */
  37372. getNodeByID(id: string): Nullable<Node>;
  37373. /**
  37374. * Gets a node (Mesh, Camera, Light) using a given name
  37375. * @param name defines the name to search for
  37376. * @return the found node or null if not found at all.
  37377. */
  37378. getNodeByName(name: string): Nullable<Node>;
  37379. /**
  37380. * Gets a mesh using a given name
  37381. * @param name defines the name to search for
  37382. * @return the found mesh or null if not found at all.
  37383. */
  37384. getMeshByName(name: string): Nullable<AbstractMesh>;
  37385. /**
  37386. * Gets a transform node using a given name
  37387. * @param name defines the name to search for
  37388. * @return the found transform node or null if not found at all.
  37389. */
  37390. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37391. /**
  37392. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37393. * @param id defines the id to search for
  37394. * @return the found skeleton or null if not found at all.
  37395. */
  37396. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37397. /**
  37398. * Gets a skeleton using a given auto generated unique id
  37399. * @param uniqueId defines the unique id to search for
  37400. * @return the found skeleton or null if not found at all.
  37401. */
  37402. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37403. /**
  37404. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37405. * @param id defines the id to search for
  37406. * @return the found skeleton or null if not found at all.
  37407. */
  37408. getSkeletonById(id: string): Nullable<Skeleton>;
  37409. /**
  37410. * Gets a skeleton using a given name
  37411. * @param name defines the name to search for
  37412. * @return the found skeleton or null if not found at all.
  37413. */
  37414. getSkeletonByName(name: string): Nullable<Skeleton>;
  37415. /**
  37416. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37417. * @param id defines the id to search for
  37418. * @return the found morph target manager or null if not found at all.
  37419. */
  37420. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37421. /**
  37422. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37423. * @param id defines the id to search for
  37424. * @return the found morph target or null if not found at all.
  37425. */
  37426. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37427. /**
  37428. * Gets a boolean indicating if the given mesh is active
  37429. * @param mesh defines the mesh to look for
  37430. * @returns true if the mesh is in the active list
  37431. */
  37432. isActiveMesh(mesh: AbstractMesh): boolean;
  37433. /**
  37434. * Return a unique id as a string which can serve as an identifier for the scene
  37435. */
  37436. get uid(): string;
  37437. /**
  37438. * Add an externaly attached data from its key.
  37439. * This method call will fail and return false, if such key already exists.
  37440. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37441. * @param key the unique key that identifies the data
  37442. * @param data the data object to associate to the key for this Engine instance
  37443. * @return true if no such key were already present and the data was added successfully, false otherwise
  37444. */
  37445. addExternalData<T>(key: string, data: T): boolean;
  37446. /**
  37447. * Get an externaly attached data from its key
  37448. * @param key the unique key that identifies the data
  37449. * @return the associated data, if present (can be null), or undefined if not present
  37450. */
  37451. getExternalData<T>(key: string): Nullable<T>;
  37452. /**
  37453. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37454. * @param key the unique key that identifies the data
  37455. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37456. * @return the associated data, can be null if the factory returned null.
  37457. */
  37458. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37459. /**
  37460. * Remove an externaly attached data from the Engine instance
  37461. * @param key the unique key that identifies the data
  37462. * @return true if the data was successfully removed, false if it doesn't exist
  37463. */
  37464. removeExternalData(key: string): boolean;
  37465. private _evaluateSubMesh;
  37466. /**
  37467. * Clear the processed materials smart array preventing retention point in material dispose.
  37468. */
  37469. freeProcessedMaterials(): void;
  37470. private _preventFreeActiveMeshesAndRenderingGroups;
  37471. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37472. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37473. * when disposing several meshes in a row or a hierarchy of meshes.
  37474. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37475. */
  37476. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37477. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37478. /**
  37479. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37480. */
  37481. freeActiveMeshes(): void;
  37482. /**
  37483. * Clear the info related to rendering groups preventing retention points during dispose.
  37484. */
  37485. freeRenderingGroups(): void;
  37486. /** @hidden */
  37487. _isInIntermediateRendering(): boolean;
  37488. /**
  37489. * Lambda returning the list of potentially active meshes.
  37490. */
  37491. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37492. /**
  37493. * Lambda returning the list of potentially active sub meshes.
  37494. */
  37495. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37496. /**
  37497. * Lambda returning the list of potentially intersecting sub meshes.
  37498. */
  37499. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37500. /**
  37501. * Lambda returning the list of potentially colliding sub meshes.
  37502. */
  37503. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37504. private _activeMeshesFrozen;
  37505. private _skipEvaluateActiveMeshesCompletely;
  37506. /**
  37507. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37508. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37509. * @returns the current scene
  37510. */
  37511. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37512. /**
  37513. * Use this function to restart evaluating active meshes on every frame
  37514. * @returns the current scene
  37515. */
  37516. unfreezeActiveMeshes(): Scene;
  37517. private _evaluateActiveMeshes;
  37518. private _activeMesh;
  37519. /**
  37520. * Update the transform matrix to update from the current active camera
  37521. * @param force defines a boolean used to force the update even if cache is up to date
  37522. */
  37523. updateTransformMatrix(force?: boolean): void;
  37524. private _bindFrameBuffer;
  37525. /** @hidden */
  37526. _allowPostProcessClearColor: boolean;
  37527. /** @hidden */
  37528. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37529. private _processSubCameras;
  37530. private _checkIntersections;
  37531. /** @hidden */
  37532. _advancePhysicsEngineStep(step: number): void;
  37533. /**
  37534. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37535. */
  37536. getDeterministicFrameTime: () => number;
  37537. /** @hidden */
  37538. _animate(): void;
  37539. /** Execute all animations (for a frame) */
  37540. animate(): void;
  37541. /**
  37542. * Render the scene
  37543. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37544. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37545. */
  37546. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37547. /**
  37548. * Freeze all materials
  37549. * A frozen material will not be updatable but should be faster to render
  37550. */
  37551. freezeMaterials(): void;
  37552. /**
  37553. * Unfreeze all materials
  37554. * A frozen material will not be updatable but should be faster to render
  37555. */
  37556. unfreezeMaterials(): void;
  37557. /**
  37558. * Releases all held ressources
  37559. */
  37560. dispose(): void;
  37561. /**
  37562. * Gets if the scene is already disposed
  37563. */
  37564. get isDisposed(): boolean;
  37565. /**
  37566. * Call this function to reduce memory footprint of the scene.
  37567. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37568. */
  37569. clearCachedVertexData(): void;
  37570. /**
  37571. * This function will remove the local cached buffer data from texture.
  37572. * It will save memory but will prevent the texture from being rebuilt
  37573. */
  37574. cleanCachedTextureBuffer(): void;
  37575. /**
  37576. * Get the world extend vectors with an optional filter
  37577. *
  37578. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37579. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37580. */
  37581. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37582. min: Vector3;
  37583. max: Vector3;
  37584. };
  37585. /**
  37586. * Creates a ray that can be used to pick in the scene
  37587. * @param x defines the x coordinate of the origin (on-screen)
  37588. * @param y defines the y coordinate of the origin (on-screen)
  37589. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37590. * @param camera defines the camera to use for the picking
  37591. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37592. * @returns a Ray
  37593. */
  37594. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37595. /**
  37596. * Creates a ray that can be used to pick in the scene
  37597. * @param x defines the x coordinate of the origin (on-screen)
  37598. * @param y defines the y coordinate of the origin (on-screen)
  37599. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37600. * @param result defines the ray where to store the picking ray
  37601. * @param camera defines the camera to use for the picking
  37602. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37603. * @returns the current scene
  37604. */
  37605. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37606. /**
  37607. * Creates a ray that can be used to pick in the scene
  37608. * @param x defines the x coordinate of the origin (on-screen)
  37609. * @param y defines the y coordinate of the origin (on-screen)
  37610. * @param camera defines the camera to use for the picking
  37611. * @returns a Ray
  37612. */
  37613. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37614. /**
  37615. * Creates a ray that can be used to pick in the scene
  37616. * @param x defines the x coordinate of the origin (on-screen)
  37617. * @param y defines the y coordinate of the origin (on-screen)
  37618. * @param result defines the ray where to store the picking ray
  37619. * @param camera defines the camera to use for the picking
  37620. * @returns the current scene
  37621. */
  37622. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37623. /** Launch a ray to try to pick a mesh in the scene
  37624. * @param x position on screen
  37625. * @param y position on screen
  37626. * @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
  37627. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37628. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37629. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37630. * @returns a PickingInfo
  37631. */
  37632. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37633. /** Use the given ray to pick a mesh in the scene
  37634. * @param ray The ray to use to pick meshes
  37635. * @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
  37636. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37637. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37638. * @returns a PickingInfo
  37639. */
  37640. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37641. /**
  37642. * Launch a ray to try to pick a mesh in the scene
  37643. * @param x X position on screen
  37644. * @param y Y position on screen
  37645. * @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
  37646. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37647. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37648. * @returns an array of PickingInfo
  37649. */
  37650. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37651. /**
  37652. * Launch a ray to try to pick a mesh in the scene
  37653. * @param ray Ray to use
  37654. * @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
  37655. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37656. * @returns an array of PickingInfo
  37657. */
  37658. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37659. /**
  37660. * Force the value of meshUnderPointer
  37661. * @param mesh defines the mesh to use
  37662. */
  37663. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37664. /**
  37665. * Gets the mesh under the pointer
  37666. * @returns a Mesh or null if no mesh is under the pointer
  37667. */
  37668. getPointerOverMesh(): Nullable<AbstractMesh>;
  37669. /** @hidden */
  37670. _rebuildGeometries(): void;
  37671. /** @hidden */
  37672. _rebuildTextures(): void;
  37673. private _getByTags;
  37674. /**
  37675. * Get a list of meshes by tags
  37676. * @param tagsQuery defines the tags query to use
  37677. * @param forEach defines a predicate used to filter results
  37678. * @returns an array of Mesh
  37679. */
  37680. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37681. /**
  37682. * Get a list of cameras by tags
  37683. * @param tagsQuery defines the tags query to use
  37684. * @param forEach defines a predicate used to filter results
  37685. * @returns an array of Camera
  37686. */
  37687. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37688. /**
  37689. * Get a list of lights by tags
  37690. * @param tagsQuery defines the tags query to use
  37691. * @param forEach defines a predicate used to filter results
  37692. * @returns an array of Light
  37693. */
  37694. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37695. /**
  37696. * Get a list of materials by tags
  37697. * @param tagsQuery defines the tags query to use
  37698. * @param forEach defines a predicate used to filter results
  37699. * @returns an array of Material
  37700. */
  37701. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37702. /**
  37703. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37704. * This allowed control for front to back rendering or reversly depending of the special needs.
  37705. *
  37706. * @param renderingGroupId The rendering group id corresponding to its index
  37707. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37708. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37709. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37710. */
  37711. 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;
  37712. /**
  37713. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37714. *
  37715. * @param renderingGroupId The rendering group id corresponding to its index
  37716. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37717. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37718. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37719. */
  37720. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37721. /**
  37722. * Gets the current auto clear configuration for one rendering group of the rendering
  37723. * manager.
  37724. * @param index the rendering group index to get the information for
  37725. * @returns The auto clear setup for the requested rendering group
  37726. */
  37727. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37728. private _blockMaterialDirtyMechanism;
  37729. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37730. get blockMaterialDirtyMechanism(): boolean;
  37731. set blockMaterialDirtyMechanism(value: boolean);
  37732. /**
  37733. * Will flag all materials as dirty to trigger new shader compilation
  37734. * @param flag defines the flag used to specify which material part must be marked as dirty
  37735. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37736. */
  37737. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37738. /** @hidden */
  37739. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  37740. /** @hidden */
  37741. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37742. /** @hidden */
  37743. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  37744. /** @hidden */
  37745. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37746. /** @hidden */
  37747. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37748. /** @hidden */
  37749. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37750. }
  37751. }
  37752. declare module "babylonjs/assetContainer" {
  37753. import { AbstractScene } from "babylonjs/abstractScene";
  37754. import { Scene } from "babylonjs/scene";
  37755. import { Mesh } from "babylonjs/Meshes/mesh";
  37756. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37757. import { Skeleton } from "babylonjs/Bones/skeleton";
  37758. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37759. import { Animatable } from "babylonjs/Animations/animatable";
  37760. import { Nullable } from "babylonjs/types";
  37761. import { Node } from "babylonjs/node";
  37762. /**
  37763. * Set of assets to keep when moving a scene into an asset container.
  37764. */
  37765. export class KeepAssets extends AbstractScene {
  37766. }
  37767. /**
  37768. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37769. */
  37770. export class InstantiatedEntries {
  37771. /**
  37772. * List of new root nodes (eg. nodes with no parent)
  37773. */
  37774. rootNodes: TransformNode[];
  37775. /**
  37776. * List of new skeletons
  37777. */
  37778. skeletons: Skeleton[];
  37779. /**
  37780. * List of new animation groups
  37781. */
  37782. animationGroups: AnimationGroup[];
  37783. }
  37784. /**
  37785. * Container with a set of assets that can be added or removed from a scene.
  37786. */
  37787. export class AssetContainer extends AbstractScene {
  37788. /**
  37789. * The scene the AssetContainer belongs to.
  37790. */
  37791. scene: Scene;
  37792. /**
  37793. * Instantiates an AssetContainer.
  37794. * @param scene The scene the AssetContainer belongs to.
  37795. */
  37796. constructor(scene: Scene);
  37797. /**
  37798. * Instantiate or clone all meshes and add the new ones to the scene.
  37799. * Skeletons and animation groups will all be cloned
  37800. * @param nameFunction defines an optional function used to get new names for clones
  37801. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37802. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37803. */
  37804. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37805. /**
  37806. * Adds all the assets from the container to the scene.
  37807. */
  37808. addAllToScene(): void;
  37809. /**
  37810. * Removes all the assets in the container from the scene
  37811. */
  37812. removeAllFromScene(): void;
  37813. /**
  37814. * Disposes all the assets in the container
  37815. */
  37816. dispose(): void;
  37817. private _moveAssets;
  37818. /**
  37819. * Removes all the assets contained in the scene and adds them to the container.
  37820. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37821. */
  37822. moveAllFromScene(keepAssets?: KeepAssets): void;
  37823. /**
  37824. * 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.
  37825. * @returns the root mesh
  37826. */
  37827. createRootMesh(): Mesh;
  37828. /**
  37829. * Merge animations from this asset container into a scene
  37830. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37831. * @param animatables set of animatables to retarget to a node from the scene
  37832. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37833. */
  37834. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37835. }
  37836. }
  37837. declare module "babylonjs/abstractScene" {
  37838. import { Scene } from "babylonjs/scene";
  37839. import { Nullable } from "babylonjs/types";
  37840. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37841. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37842. import { Geometry } from "babylonjs/Meshes/geometry";
  37843. import { Skeleton } from "babylonjs/Bones/skeleton";
  37844. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  37845. import { AssetContainer } from "babylonjs/assetContainer";
  37846. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  37847. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37848. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37849. import { Material } from "babylonjs/Materials/material";
  37850. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  37851. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37852. import { Camera } from "babylonjs/Cameras/camera";
  37853. import { Light } from "babylonjs/Lights/light";
  37854. import { Node } from "babylonjs/node";
  37855. import { Animation } from "babylonjs/Animations/animation";
  37856. /**
  37857. * Defines how the parser contract is defined.
  37858. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37859. */
  37860. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37861. /**
  37862. * Defines how the individual parser contract is defined.
  37863. * These parser can parse an individual asset
  37864. */
  37865. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37866. /**
  37867. * Base class of the scene acting as a container for the different elements composing a scene.
  37868. * This class is dynamically extended by the different components of the scene increasing
  37869. * flexibility and reducing coupling
  37870. */
  37871. export abstract class AbstractScene {
  37872. /**
  37873. * Stores the list of available parsers in the application.
  37874. */
  37875. private static _BabylonFileParsers;
  37876. /**
  37877. * Stores the list of available individual parsers in the application.
  37878. */
  37879. private static _IndividualBabylonFileParsers;
  37880. /**
  37881. * Adds a parser in the list of available ones
  37882. * @param name Defines the name of the parser
  37883. * @param parser Defines the parser to add
  37884. */
  37885. static AddParser(name: string, parser: BabylonFileParser): void;
  37886. /**
  37887. * Gets a general parser from the list of avaialble ones
  37888. * @param name Defines the name of the parser
  37889. * @returns the requested parser or null
  37890. */
  37891. static GetParser(name: string): Nullable<BabylonFileParser>;
  37892. /**
  37893. * Adds n individual parser in the list of available ones
  37894. * @param name Defines the name of the parser
  37895. * @param parser Defines the parser to add
  37896. */
  37897. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37898. /**
  37899. * Gets an individual parser from the list of avaialble ones
  37900. * @param name Defines the name of the parser
  37901. * @returns the requested parser or null
  37902. */
  37903. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37904. /**
  37905. * Parser json data and populate both a scene and its associated container object
  37906. * @param jsonData Defines the data to parse
  37907. * @param scene Defines the scene to parse the data for
  37908. * @param container Defines the container attached to the parsing sequence
  37909. * @param rootUrl Defines the root url of the data
  37910. */
  37911. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37912. /**
  37913. * Gets the list of root nodes (ie. nodes with no parent)
  37914. */
  37915. rootNodes: Node[];
  37916. /** All of the cameras added to this scene
  37917. * @see http://doc.babylonjs.com/babylon101/cameras
  37918. */
  37919. cameras: Camera[];
  37920. /**
  37921. * All of the lights added to this scene
  37922. * @see http://doc.babylonjs.com/babylon101/lights
  37923. */
  37924. lights: Light[];
  37925. /**
  37926. * All of the (abstract) meshes added to this scene
  37927. */
  37928. meshes: AbstractMesh[];
  37929. /**
  37930. * The list of skeletons added to the scene
  37931. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37932. */
  37933. skeletons: Skeleton[];
  37934. /**
  37935. * All of the particle systems added to this scene
  37936. * @see http://doc.babylonjs.com/babylon101/particles
  37937. */
  37938. particleSystems: IParticleSystem[];
  37939. /**
  37940. * Gets a list of Animations associated with the scene
  37941. */
  37942. animations: Animation[];
  37943. /**
  37944. * All of the animation groups added to this scene
  37945. * @see http://doc.babylonjs.com/how_to/group
  37946. */
  37947. animationGroups: AnimationGroup[];
  37948. /**
  37949. * All of the multi-materials added to this scene
  37950. * @see http://doc.babylonjs.com/how_to/multi_materials
  37951. */
  37952. multiMaterials: MultiMaterial[];
  37953. /**
  37954. * All of the materials added to this scene
  37955. * In the context of a Scene, it is not supposed to be modified manually.
  37956. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37957. * Note also that the order of the Material within the array is not significant and might change.
  37958. * @see http://doc.babylonjs.com/babylon101/materials
  37959. */
  37960. materials: Material[];
  37961. /**
  37962. * The list of morph target managers added to the scene
  37963. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37964. */
  37965. morphTargetManagers: MorphTargetManager[];
  37966. /**
  37967. * The list of geometries used in the scene.
  37968. */
  37969. geometries: Geometry[];
  37970. /**
  37971. * All of the tranform nodes added to this scene
  37972. * In the context of a Scene, it is not supposed to be modified manually.
  37973. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37974. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37975. * @see http://doc.babylonjs.com/how_to/transformnode
  37976. */
  37977. transformNodes: TransformNode[];
  37978. /**
  37979. * ActionManagers available on the scene.
  37980. */
  37981. actionManagers: AbstractActionManager[];
  37982. /**
  37983. * Textures to keep.
  37984. */
  37985. textures: BaseTexture[];
  37986. /**
  37987. * Environment texture for the scene
  37988. */
  37989. environmentTexture: Nullable<BaseTexture>;
  37990. /**
  37991. * @returns all meshes, lights, cameras, transformNodes and bones
  37992. */
  37993. getNodes(): Array<Node>;
  37994. }
  37995. }
  37996. declare module "babylonjs/Audio/sound" {
  37997. import { Observable } from "babylonjs/Misc/observable";
  37998. import { Vector3 } from "babylonjs/Maths/math.vector";
  37999. import { Nullable } from "babylonjs/types";
  38000. import { Scene } from "babylonjs/scene";
  38001. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38002. /**
  38003. * Interface used to define options for Sound class
  38004. */
  38005. export interface ISoundOptions {
  38006. /**
  38007. * Does the sound autoplay once loaded.
  38008. */
  38009. autoplay?: boolean;
  38010. /**
  38011. * Does the sound loop after it finishes playing once.
  38012. */
  38013. loop?: boolean;
  38014. /**
  38015. * Sound's volume
  38016. */
  38017. volume?: number;
  38018. /**
  38019. * Is it a spatial sound?
  38020. */
  38021. spatialSound?: boolean;
  38022. /**
  38023. * Maximum distance to hear that sound
  38024. */
  38025. maxDistance?: number;
  38026. /**
  38027. * Uses user defined attenuation function
  38028. */
  38029. useCustomAttenuation?: boolean;
  38030. /**
  38031. * Define the roll off factor of spatial sounds.
  38032. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38033. */
  38034. rolloffFactor?: number;
  38035. /**
  38036. * Define the reference distance the sound should be heard perfectly.
  38037. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38038. */
  38039. refDistance?: number;
  38040. /**
  38041. * Define the distance attenuation model the sound will follow.
  38042. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38043. */
  38044. distanceModel?: string;
  38045. /**
  38046. * Defines the playback speed (1 by default)
  38047. */
  38048. playbackRate?: number;
  38049. /**
  38050. * Defines if the sound is from a streaming source
  38051. */
  38052. streaming?: boolean;
  38053. /**
  38054. * Defines an optional length (in seconds) inside the sound file
  38055. */
  38056. length?: number;
  38057. /**
  38058. * Defines an optional offset (in seconds) inside the sound file
  38059. */
  38060. offset?: number;
  38061. /**
  38062. * If true, URLs will not be required to state the audio file codec to use.
  38063. */
  38064. skipCodecCheck?: boolean;
  38065. }
  38066. /**
  38067. * Defines a sound that can be played in the application.
  38068. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38069. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38070. */
  38071. export class Sound {
  38072. /**
  38073. * The name of the sound in the scene.
  38074. */
  38075. name: string;
  38076. /**
  38077. * Does the sound autoplay once loaded.
  38078. */
  38079. autoplay: boolean;
  38080. /**
  38081. * Does the sound loop after it finishes playing once.
  38082. */
  38083. loop: boolean;
  38084. /**
  38085. * Does the sound use a custom attenuation curve to simulate the falloff
  38086. * happening when the source gets further away from the camera.
  38087. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38088. */
  38089. useCustomAttenuation: boolean;
  38090. /**
  38091. * The sound track id this sound belongs to.
  38092. */
  38093. soundTrackId: number;
  38094. /**
  38095. * Is this sound currently played.
  38096. */
  38097. isPlaying: boolean;
  38098. /**
  38099. * Is this sound currently paused.
  38100. */
  38101. isPaused: boolean;
  38102. /**
  38103. * Does this sound enables spatial sound.
  38104. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38105. */
  38106. spatialSound: boolean;
  38107. /**
  38108. * Define the reference distance the sound should be heard perfectly.
  38109. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38110. */
  38111. refDistance: number;
  38112. /**
  38113. * Define the roll off factor of spatial sounds.
  38114. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38115. */
  38116. rolloffFactor: number;
  38117. /**
  38118. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38119. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38120. */
  38121. maxDistance: number;
  38122. /**
  38123. * Define the distance attenuation model the sound will follow.
  38124. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38125. */
  38126. distanceModel: string;
  38127. /**
  38128. * @hidden
  38129. * Back Compat
  38130. **/
  38131. onended: () => any;
  38132. /**
  38133. * Observable event when the current playing sound finishes.
  38134. */
  38135. onEndedObservable: Observable<Sound>;
  38136. private _panningModel;
  38137. private _playbackRate;
  38138. private _streaming;
  38139. private _startTime;
  38140. private _startOffset;
  38141. private _position;
  38142. /** @hidden */
  38143. _positionInEmitterSpace: boolean;
  38144. private _localDirection;
  38145. private _volume;
  38146. private _isReadyToPlay;
  38147. private _isDirectional;
  38148. private _readyToPlayCallback;
  38149. private _audioBuffer;
  38150. private _soundSource;
  38151. private _streamingSource;
  38152. private _soundPanner;
  38153. private _soundGain;
  38154. private _inputAudioNode;
  38155. private _outputAudioNode;
  38156. private _coneInnerAngle;
  38157. private _coneOuterAngle;
  38158. private _coneOuterGain;
  38159. private _scene;
  38160. private _connectedTransformNode;
  38161. private _customAttenuationFunction;
  38162. private _registerFunc;
  38163. private _isOutputConnected;
  38164. private _htmlAudioElement;
  38165. private _urlType;
  38166. private _length?;
  38167. private _offset?;
  38168. /** @hidden */
  38169. static _SceneComponentInitialization: (scene: Scene) => void;
  38170. /**
  38171. * Create a sound and attach it to a scene
  38172. * @param name Name of your sound
  38173. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38174. * @param scene defines the scene the sound belongs to
  38175. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38176. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38177. */
  38178. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38179. /**
  38180. * Release the sound and its associated resources
  38181. */
  38182. dispose(): void;
  38183. /**
  38184. * Gets if the sounds is ready to be played or not.
  38185. * @returns true if ready, otherwise false
  38186. */
  38187. isReady(): boolean;
  38188. private _soundLoaded;
  38189. /**
  38190. * Sets the data of the sound from an audiobuffer
  38191. * @param audioBuffer The audioBuffer containing the data
  38192. */
  38193. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38194. /**
  38195. * Updates the current sounds options such as maxdistance, loop...
  38196. * @param options A JSON object containing values named as the object properties
  38197. */
  38198. updateOptions(options: ISoundOptions): void;
  38199. private _createSpatialParameters;
  38200. private _updateSpatialParameters;
  38201. /**
  38202. * Switch the panning model to HRTF:
  38203. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38204. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38205. */
  38206. switchPanningModelToHRTF(): void;
  38207. /**
  38208. * Switch the panning model to Equal Power:
  38209. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38210. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38211. */
  38212. switchPanningModelToEqualPower(): void;
  38213. private _switchPanningModel;
  38214. /**
  38215. * Connect this sound to a sound track audio node like gain...
  38216. * @param soundTrackAudioNode the sound track audio node to connect to
  38217. */
  38218. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38219. /**
  38220. * Transform this sound into a directional source
  38221. * @param coneInnerAngle Size of the inner cone in degree
  38222. * @param coneOuterAngle Size of the outer cone in degree
  38223. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38224. */
  38225. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38226. /**
  38227. * Gets or sets the inner angle for the directional cone.
  38228. */
  38229. get directionalConeInnerAngle(): number;
  38230. /**
  38231. * Gets or sets the inner angle for the directional cone.
  38232. */
  38233. set directionalConeInnerAngle(value: number);
  38234. /**
  38235. * Gets or sets the outer angle for the directional cone.
  38236. */
  38237. get directionalConeOuterAngle(): number;
  38238. /**
  38239. * Gets or sets the outer angle for the directional cone.
  38240. */
  38241. set directionalConeOuterAngle(value: number);
  38242. /**
  38243. * Sets the position of the emitter if spatial sound is enabled
  38244. * @param newPosition Defines the new posisiton
  38245. */
  38246. setPosition(newPosition: Vector3): void;
  38247. /**
  38248. * Sets the local direction of the emitter if spatial sound is enabled
  38249. * @param newLocalDirection Defines the new local direction
  38250. */
  38251. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38252. private _updateDirection;
  38253. /** @hidden */
  38254. updateDistanceFromListener(): void;
  38255. /**
  38256. * Sets a new custom attenuation function for the sound.
  38257. * @param callback Defines the function used for the attenuation
  38258. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38259. */
  38260. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38261. /**
  38262. * Play the sound
  38263. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38264. * @param offset (optional) Start the sound at a specific time in seconds
  38265. * @param length (optional) Sound duration (in seconds)
  38266. */
  38267. play(time?: number, offset?: number, length?: number): void;
  38268. private _onended;
  38269. /**
  38270. * Stop the sound
  38271. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38272. */
  38273. stop(time?: number): void;
  38274. /**
  38275. * Put the sound in pause
  38276. */
  38277. pause(): void;
  38278. /**
  38279. * Sets a dedicated volume for this sounds
  38280. * @param newVolume Define the new volume of the sound
  38281. * @param time Define time for gradual change to new volume
  38282. */
  38283. setVolume(newVolume: number, time?: number): void;
  38284. /**
  38285. * Set the sound play back rate
  38286. * @param newPlaybackRate Define the playback rate the sound should be played at
  38287. */
  38288. setPlaybackRate(newPlaybackRate: number): void;
  38289. /**
  38290. * Gets the volume of the sound.
  38291. * @returns the volume of the sound
  38292. */
  38293. getVolume(): number;
  38294. /**
  38295. * Attach the sound to a dedicated mesh
  38296. * @param transformNode The transform node to connect the sound with
  38297. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38298. */
  38299. attachToMesh(transformNode: TransformNode): void;
  38300. /**
  38301. * Detach the sound from the previously attached mesh
  38302. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38303. */
  38304. detachFromMesh(): void;
  38305. private _onRegisterAfterWorldMatrixUpdate;
  38306. /**
  38307. * Clone the current sound in the scene.
  38308. * @returns the new sound clone
  38309. */
  38310. clone(): Nullable<Sound>;
  38311. /**
  38312. * Gets the current underlying audio buffer containing the data
  38313. * @returns the audio buffer
  38314. */
  38315. getAudioBuffer(): Nullable<AudioBuffer>;
  38316. /**
  38317. * Serializes the Sound in a JSON representation
  38318. * @returns the JSON representation of the sound
  38319. */
  38320. serialize(): any;
  38321. /**
  38322. * Parse a JSON representation of a sound to innstantiate in a given scene
  38323. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38324. * @param scene Define the scene the new parsed sound should be created in
  38325. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38326. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38327. * @returns the newly parsed sound
  38328. */
  38329. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38330. }
  38331. }
  38332. declare module "babylonjs/Actions/directAudioActions" {
  38333. import { Action } from "babylonjs/Actions/action";
  38334. import { Condition } from "babylonjs/Actions/condition";
  38335. import { Sound } from "babylonjs/Audio/sound";
  38336. /**
  38337. * This defines an action helpful to play a defined sound on a triggered action.
  38338. */
  38339. export class PlaySoundAction extends Action {
  38340. private _sound;
  38341. /**
  38342. * Instantiate the action
  38343. * @param triggerOptions defines the trigger options
  38344. * @param sound defines the sound to play
  38345. * @param condition defines the trigger related conditions
  38346. */
  38347. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38348. /** @hidden */
  38349. _prepare(): void;
  38350. /**
  38351. * Execute the action and play the sound.
  38352. */
  38353. execute(): void;
  38354. /**
  38355. * Serializes the actions and its related information.
  38356. * @param parent defines the object to serialize in
  38357. * @returns the serialized object
  38358. */
  38359. serialize(parent: any): any;
  38360. }
  38361. /**
  38362. * This defines an action helpful to stop a defined sound on a triggered action.
  38363. */
  38364. export class StopSoundAction extends Action {
  38365. private _sound;
  38366. /**
  38367. * Instantiate the action
  38368. * @param triggerOptions defines the trigger options
  38369. * @param sound defines the sound to stop
  38370. * @param condition defines the trigger related conditions
  38371. */
  38372. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38373. /** @hidden */
  38374. _prepare(): void;
  38375. /**
  38376. * Execute the action and stop the sound.
  38377. */
  38378. execute(): void;
  38379. /**
  38380. * Serializes the actions and its related information.
  38381. * @param parent defines the object to serialize in
  38382. * @returns the serialized object
  38383. */
  38384. serialize(parent: any): any;
  38385. }
  38386. }
  38387. declare module "babylonjs/Actions/interpolateValueAction" {
  38388. import { Action } from "babylonjs/Actions/action";
  38389. import { Condition } from "babylonjs/Actions/condition";
  38390. import { Observable } from "babylonjs/Misc/observable";
  38391. /**
  38392. * This defines an action responsible to change the value of a property
  38393. * by interpolating between its current value and the newly set one once triggered.
  38394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38395. */
  38396. export class InterpolateValueAction extends Action {
  38397. /**
  38398. * Defines the path of the property where the value should be interpolated
  38399. */
  38400. propertyPath: string;
  38401. /**
  38402. * Defines the target value at the end of the interpolation.
  38403. */
  38404. value: any;
  38405. /**
  38406. * Defines the time it will take for the property to interpolate to the value.
  38407. */
  38408. duration: number;
  38409. /**
  38410. * Defines if the other scene animations should be stopped when the action has been triggered
  38411. */
  38412. stopOtherAnimations?: boolean;
  38413. /**
  38414. * Defines a callback raised once the interpolation animation has been done.
  38415. */
  38416. onInterpolationDone?: () => void;
  38417. /**
  38418. * Observable triggered once the interpolation animation has been done.
  38419. */
  38420. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38421. private _target;
  38422. private _effectiveTarget;
  38423. private _property;
  38424. /**
  38425. * Instantiate the action
  38426. * @param triggerOptions defines the trigger options
  38427. * @param target defines the object containing the value to interpolate
  38428. * @param propertyPath defines the path to the property in the target object
  38429. * @param value defines the target value at the end of the interpolation
  38430. * @param duration deines the time it will take for the property to interpolate to the value.
  38431. * @param condition defines the trigger related conditions
  38432. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38433. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38434. */
  38435. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38436. /** @hidden */
  38437. _prepare(): void;
  38438. /**
  38439. * Execute the action starts the value interpolation.
  38440. */
  38441. execute(): void;
  38442. /**
  38443. * Serializes the actions and its related information.
  38444. * @param parent defines the object to serialize in
  38445. * @returns the serialized object
  38446. */
  38447. serialize(parent: any): any;
  38448. }
  38449. }
  38450. declare module "babylonjs/Actions/index" {
  38451. export * from "babylonjs/Actions/abstractActionManager";
  38452. export * from "babylonjs/Actions/action";
  38453. export * from "babylonjs/Actions/actionEvent";
  38454. export * from "babylonjs/Actions/actionManager";
  38455. export * from "babylonjs/Actions/condition";
  38456. export * from "babylonjs/Actions/directActions";
  38457. export * from "babylonjs/Actions/directAudioActions";
  38458. export * from "babylonjs/Actions/interpolateValueAction";
  38459. }
  38460. declare module "babylonjs/Animations/index" {
  38461. export * from "babylonjs/Animations/animatable";
  38462. export * from "babylonjs/Animations/animation";
  38463. export * from "babylonjs/Animations/animationGroup";
  38464. export * from "babylonjs/Animations/animationPropertiesOverride";
  38465. export * from "babylonjs/Animations/easing";
  38466. export * from "babylonjs/Animations/runtimeAnimation";
  38467. export * from "babylonjs/Animations/animationEvent";
  38468. export * from "babylonjs/Animations/animationGroup";
  38469. export * from "babylonjs/Animations/animationKey";
  38470. export * from "babylonjs/Animations/animationRange";
  38471. export * from "babylonjs/Animations/animatable.interface";
  38472. }
  38473. declare module "babylonjs/Audio/soundTrack" {
  38474. import { Sound } from "babylonjs/Audio/sound";
  38475. import { Analyser } from "babylonjs/Audio/analyser";
  38476. import { Scene } from "babylonjs/scene";
  38477. /**
  38478. * Options allowed during the creation of a sound track.
  38479. */
  38480. export interface ISoundTrackOptions {
  38481. /**
  38482. * The volume the sound track should take during creation
  38483. */
  38484. volume?: number;
  38485. /**
  38486. * Define if the sound track is the main sound track of the scene
  38487. */
  38488. mainTrack?: boolean;
  38489. }
  38490. /**
  38491. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38492. * It will be also used in a future release to apply effects on a specific track.
  38493. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38494. */
  38495. export class SoundTrack {
  38496. /**
  38497. * The unique identifier of the sound track in the scene.
  38498. */
  38499. id: number;
  38500. /**
  38501. * The list of sounds included in the sound track.
  38502. */
  38503. soundCollection: Array<Sound>;
  38504. private _outputAudioNode;
  38505. private _scene;
  38506. private _connectedAnalyser;
  38507. private _options;
  38508. private _isInitialized;
  38509. /**
  38510. * Creates a new sound track.
  38511. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38512. * @param scene Define the scene the sound track belongs to
  38513. * @param options
  38514. */
  38515. constructor(scene: Scene, options?: ISoundTrackOptions);
  38516. private _initializeSoundTrackAudioGraph;
  38517. /**
  38518. * Release the sound track and its associated resources
  38519. */
  38520. dispose(): void;
  38521. /**
  38522. * Adds a sound to this sound track
  38523. * @param sound define the cound to add
  38524. * @ignoreNaming
  38525. */
  38526. AddSound(sound: Sound): void;
  38527. /**
  38528. * Removes a sound to this sound track
  38529. * @param sound define the cound to remove
  38530. * @ignoreNaming
  38531. */
  38532. RemoveSound(sound: Sound): void;
  38533. /**
  38534. * Set a global volume for the full sound track.
  38535. * @param newVolume Define the new volume of the sound track
  38536. */
  38537. setVolume(newVolume: number): void;
  38538. /**
  38539. * Switch the panning model to HRTF:
  38540. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38541. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38542. */
  38543. switchPanningModelToHRTF(): void;
  38544. /**
  38545. * Switch the panning model to Equal Power:
  38546. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38547. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38548. */
  38549. switchPanningModelToEqualPower(): void;
  38550. /**
  38551. * Connect the sound track to an audio analyser allowing some amazing
  38552. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38553. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38554. * @param analyser The analyser to connect to the engine
  38555. */
  38556. connectToAnalyser(analyser: Analyser): void;
  38557. }
  38558. }
  38559. declare module "babylonjs/Audio/audioSceneComponent" {
  38560. import { Sound } from "babylonjs/Audio/sound";
  38561. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38562. import { Nullable } from "babylonjs/types";
  38563. import { Vector3 } from "babylonjs/Maths/math.vector";
  38564. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38565. import { Scene } from "babylonjs/scene";
  38566. import { AbstractScene } from "babylonjs/abstractScene";
  38567. import "babylonjs/Audio/audioEngine";
  38568. module "babylonjs/abstractScene" {
  38569. interface AbstractScene {
  38570. /**
  38571. * The list of sounds used in the scene.
  38572. */
  38573. sounds: Nullable<Array<Sound>>;
  38574. }
  38575. }
  38576. module "babylonjs/scene" {
  38577. interface Scene {
  38578. /**
  38579. * @hidden
  38580. * Backing field
  38581. */
  38582. _mainSoundTrack: SoundTrack;
  38583. /**
  38584. * The main sound track played by the scene.
  38585. * It cotains your primary collection of sounds.
  38586. */
  38587. mainSoundTrack: SoundTrack;
  38588. /**
  38589. * The list of sound tracks added to the scene
  38590. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38591. */
  38592. soundTracks: Nullable<Array<SoundTrack>>;
  38593. /**
  38594. * Gets a sound using a given name
  38595. * @param name defines the name to search for
  38596. * @return the found sound or null if not found at all.
  38597. */
  38598. getSoundByName(name: string): Nullable<Sound>;
  38599. /**
  38600. * Gets or sets if audio support is enabled
  38601. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38602. */
  38603. audioEnabled: boolean;
  38604. /**
  38605. * Gets or sets if audio will be output to headphones
  38606. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38607. */
  38608. headphone: boolean;
  38609. /**
  38610. * Gets or sets custom audio listener position provider
  38611. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38612. */
  38613. audioListenerPositionProvider: Nullable<() => Vector3>;
  38614. /**
  38615. * Gets or sets a refresh rate when using 3D audio positioning
  38616. */
  38617. audioPositioningRefreshRate: number;
  38618. }
  38619. }
  38620. /**
  38621. * Defines the sound scene component responsible to manage any sounds
  38622. * in a given scene.
  38623. */
  38624. export class AudioSceneComponent implements ISceneSerializableComponent {
  38625. /**
  38626. * The component name helpfull to identify the component in the list of scene components.
  38627. */
  38628. readonly name: string;
  38629. /**
  38630. * The scene the component belongs to.
  38631. */
  38632. scene: Scene;
  38633. private _audioEnabled;
  38634. /**
  38635. * Gets whether audio is enabled or not.
  38636. * Please use related enable/disable method to switch state.
  38637. */
  38638. get audioEnabled(): boolean;
  38639. private _headphone;
  38640. /**
  38641. * Gets whether audio is outputing to headphone or not.
  38642. * Please use the according Switch methods to change output.
  38643. */
  38644. get headphone(): boolean;
  38645. /**
  38646. * Gets or sets a refresh rate when using 3D audio positioning
  38647. */
  38648. audioPositioningRefreshRate: number;
  38649. private _audioListenerPositionProvider;
  38650. /**
  38651. * Gets the current audio listener position provider
  38652. */
  38653. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38654. /**
  38655. * Sets a custom listener position for all sounds in the scene
  38656. * By default, this is the position of the first active camera
  38657. */
  38658. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38659. /**
  38660. * Creates a new instance of the component for the given scene
  38661. * @param scene Defines the scene to register the component in
  38662. */
  38663. constructor(scene: Scene);
  38664. /**
  38665. * Registers the component in a given scene
  38666. */
  38667. register(): void;
  38668. /**
  38669. * Rebuilds the elements related to this component in case of
  38670. * context lost for instance.
  38671. */
  38672. rebuild(): void;
  38673. /**
  38674. * Serializes the component data to the specified json object
  38675. * @param serializationObject The object to serialize to
  38676. */
  38677. serialize(serializationObject: any): void;
  38678. /**
  38679. * Adds all the elements from the container to the scene
  38680. * @param container the container holding the elements
  38681. */
  38682. addFromContainer(container: AbstractScene): void;
  38683. /**
  38684. * Removes all the elements in the container from the scene
  38685. * @param container contains the elements to remove
  38686. * @param dispose if the removed element should be disposed (default: false)
  38687. */
  38688. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38689. /**
  38690. * Disposes the component and the associated ressources.
  38691. */
  38692. dispose(): void;
  38693. /**
  38694. * Disables audio in the associated scene.
  38695. */
  38696. disableAudio(): void;
  38697. /**
  38698. * Enables audio in the associated scene.
  38699. */
  38700. enableAudio(): void;
  38701. /**
  38702. * Switch audio to headphone output.
  38703. */
  38704. switchAudioModeForHeadphones(): void;
  38705. /**
  38706. * Switch audio to normal speakers.
  38707. */
  38708. switchAudioModeForNormalSpeakers(): void;
  38709. private _cachedCameraDirection;
  38710. private _cachedCameraPosition;
  38711. private _lastCheck;
  38712. private _afterRender;
  38713. }
  38714. }
  38715. declare module "babylonjs/Audio/weightedsound" {
  38716. import { Sound } from "babylonjs/Audio/sound";
  38717. /**
  38718. * Wraps one or more Sound objects and selects one with random weight for playback.
  38719. */
  38720. export class WeightedSound {
  38721. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38722. loop: boolean;
  38723. private _coneInnerAngle;
  38724. private _coneOuterAngle;
  38725. private _volume;
  38726. /** A Sound is currently playing. */
  38727. isPlaying: boolean;
  38728. /** A Sound is currently paused. */
  38729. isPaused: boolean;
  38730. private _sounds;
  38731. private _weights;
  38732. private _currentIndex?;
  38733. /**
  38734. * Creates a new WeightedSound from the list of sounds given.
  38735. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38736. * @param sounds Array of Sounds that will be selected from.
  38737. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38738. */
  38739. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38740. /**
  38741. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38742. */
  38743. get directionalConeInnerAngle(): number;
  38744. /**
  38745. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38746. */
  38747. set directionalConeInnerAngle(value: number);
  38748. /**
  38749. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38750. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38751. */
  38752. get directionalConeOuterAngle(): number;
  38753. /**
  38754. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38755. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38756. */
  38757. set directionalConeOuterAngle(value: number);
  38758. /**
  38759. * Playback volume.
  38760. */
  38761. get volume(): number;
  38762. /**
  38763. * Playback volume.
  38764. */
  38765. set volume(value: number);
  38766. private _onended;
  38767. /**
  38768. * Suspend playback
  38769. */
  38770. pause(): void;
  38771. /**
  38772. * Stop playback
  38773. */
  38774. stop(): void;
  38775. /**
  38776. * Start playback.
  38777. * @param startOffset Position the clip head at a specific time in seconds.
  38778. */
  38779. play(startOffset?: number): void;
  38780. }
  38781. }
  38782. declare module "babylonjs/Audio/index" {
  38783. export * from "babylonjs/Audio/analyser";
  38784. export * from "babylonjs/Audio/audioEngine";
  38785. export * from "babylonjs/Audio/audioSceneComponent";
  38786. export * from "babylonjs/Audio/sound";
  38787. export * from "babylonjs/Audio/soundTrack";
  38788. export * from "babylonjs/Audio/weightedsound";
  38789. }
  38790. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  38791. import { Behavior } from "babylonjs/Behaviors/behavior";
  38792. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38793. import { BackEase } from "babylonjs/Animations/easing";
  38794. /**
  38795. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38796. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38797. */
  38798. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38799. /**
  38800. * Gets the name of the behavior.
  38801. */
  38802. get name(): string;
  38803. /**
  38804. * The easing function used by animations
  38805. */
  38806. static EasingFunction: BackEase;
  38807. /**
  38808. * The easing mode used by animations
  38809. */
  38810. static EasingMode: number;
  38811. /**
  38812. * The duration of the animation, in milliseconds
  38813. */
  38814. transitionDuration: number;
  38815. /**
  38816. * Length of the distance animated by the transition when lower radius is reached
  38817. */
  38818. lowerRadiusTransitionRange: number;
  38819. /**
  38820. * Length of the distance animated by the transition when upper radius is reached
  38821. */
  38822. upperRadiusTransitionRange: number;
  38823. private _autoTransitionRange;
  38824. /**
  38825. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38826. */
  38827. get autoTransitionRange(): boolean;
  38828. /**
  38829. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38830. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38831. */
  38832. set autoTransitionRange(value: boolean);
  38833. private _attachedCamera;
  38834. private _onAfterCheckInputsObserver;
  38835. private _onMeshTargetChangedObserver;
  38836. /**
  38837. * Initializes the behavior.
  38838. */
  38839. init(): void;
  38840. /**
  38841. * Attaches the behavior to its arc rotate camera.
  38842. * @param camera Defines the camera to attach the behavior to
  38843. */
  38844. attach(camera: ArcRotateCamera): void;
  38845. /**
  38846. * Detaches the behavior from its current arc rotate camera.
  38847. */
  38848. detach(): void;
  38849. private _radiusIsAnimating;
  38850. private _radiusBounceTransition;
  38851. private _animatables;
  38852. private _cachedWheelPrecision;
  38853. /**
  38854. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38855. * @param radiusLimit The limit to check against.
  38856. * @return Bool to indicate if at limit.
  38857. */
  38858. private _isRadiusAtLimit;
  38859. /**
  38860. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38861. * @param radiusDelta The delta by which to animate to. Can be negative.
  38862. */
  38863. private _applyBoundRadiusAnimation;
  38864. /**
  38865. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38866. */
  38867. protected _clearAnimationLocks(): void;
  38868. /**
  38869. * Stops and removes all animations that have been applied to the camera
  38870. */
  38871. stopAllAnimations(): void;
  38872. }
  38873. }
  38874. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  38875. import { Behavior } from "babylonjs/Behaviors/behavior";
  38876. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38877. import { ExponentialEase } from "babylonjs/Animations/easing";
  38878. import { Nullable } from "babylonjs/types";
  38879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38880. import { Vector3 } from "babylonjs/Maths/math.vector";
  38881. /**
  38882. * 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.
  38883. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38884. */
  38885. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38886. /**
  38887. * Gets the name of the behavior.
  38888. */
  38889. get name(): string;
  38890. private _mode;
  38891. private _radiusScale;
  38892. private _positionScale;
  38893. private _defaultElevation;
  38894. private _elevationReturnTime;
  38895. private _elevationReturnWaitTime;
  38896. private _zoomStopsAnimation;
  38897. private _framingTime;
  38898. /**
  38899. * The easing function used by animations
  38900. */
  38901. static EasingFunction: ExponentialEase;
  38902. /**
  38903. * The easing mode used by animations
  38904. */
  38905. static EasingMode: number;
  38906. /**
  38907. * Sets the current mode used by the behavior
  38908. */
  38909. set mode(mode: number);
  38910. /**
  38911. * Gets current mode used by the behavior.
  38912. */
  38913. get mode(): number;
  38914. /**
  38915. * Sets the scale applied to the radius (1 by default)
  38916. */
  38917. set radiusScale(radius: number);
  38918. /**
  38919. * Gets the scale applied to the radius
  38920. */
  38921. get radiusScale(): number;
  38922. /**
  38923. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38924. */
  38925. set positionScale(scale: number);
  38926. /**
  38927. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38928. */
  38929. get positionScale(): number;
  38930. /**
  38931. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38932. * behaviour is triggered, in radians.
  38933. */
  38934. set defaultElevation(elevation: number);
  38935. /**
  38936. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38937. * behaviour is triggered, in radians.
  38938. */
  38939. get defaultElevation(): number;
  38940. /**
  38941. * Sets the time (in milliseconds) taken to return to the default beta position.
  38942. * Negative value indicates camera should not return to default.
  38943. */
  38944. set elevationReturnTime(speed: number);
  38945. /**
  38946. * Gets the time (in milliseconds) taken to return to the default beta position.
  38947. * Negative value indicates camera should not return to default.
  38948. */
  38949. get elevationReturnTime(): number;
  38950. /**
  38951. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38952. */
  38953. set elevationReturnWaitTime(time: number);
  38954. /**
  38955. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38956. */
  38957. get elevationReturnWaitTime(): number;
  38958. /**
  38959. * Sets the flag that indicates if user zooming should stop animation.
  38960. */
  38961. set zoomStopsAnimation(flag: boolean);
  38962. /**
  38963. * Gets the flag that indicates if user zooming should stop animation.
  38964. */
  38965. get zoomStopsAnimation(): boolean;
  38966. /**
  38967. * Sets the transition time when framing the mesh, in milliseconds
  38968. */
  38969. set framingTime(time: number);
  38970. /**
  38971. * Gets the transition time when framing the mesh, in milliseconds
  38972. */
  38973. get framingTime(): number;
  38974. /**
  38975. * Define if the behavior should automatically change the configured
  38976. * camera limits and sensibilities.
  38977. */
  38978. autoCorrectCameraLimitsAndSensibility: boolean;
  38979. private _onPrePointerObservableObserver;
  38980. private _onAfterCheckInputsObserver;
  38981. private _onMeshTargetChangedObserver;
  38982. private _attachedCamera;
  38983. private _isPointerDown;
  38984. private _lastInteractionTime;
  38985. /**
  38986. * Initializes the behavior.
  38987. */
  38988. init(): void;
  38989. /**
  38990. * Attaches the behavior to its arc rotate camera.
  38991. * @param camera Defines the camera to attach the behavior to
  38992. */
  38993. attach(camera: ArcRotateCamera): void;
  38994. /**
  38995. * Detaches the behavior from its current arc rotate camera.
  38996. */
  38997. detach(): void;
  38998. private _animatables;
  38999. private _betaIsAnimating;
  39000. private _betaTransition;
  39001. private _radiusTransition;
  39002. private _vectorTransition;
  39003. /**
  39004. * Targets the given mesh and updates zoom level accordingly.
  39005. * @param mesh The mesh to target.
  39006. * @param radius Optional. If a cached radius position already exists, overrides default.
  39007. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39008. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39009. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39010. */
  39011. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39012. /**
  39013. * Targets the given mesh with its children and updates zoom level accordingly.
  39014. * @param mesh The mesh to target.
  39015. * @param radius Optional. If a cached radius position already exists, overrides default.
  39016. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39017. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39018. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39019. */
  39020. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39021. /**
  39022. * Targets the given meshes with their children and updates zoom level accordingly.
  39023. * @param meshes The mesh to target.
  39024. * @param radius Optional. If a cached radius position already exists, overrides default.
  39025. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39026. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39027. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39028. */
  39029. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39030. /**
  39031. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39032. * @param minimumWorld Determines the smaller position of the bounding box extend
  39033. * @param maximumWorld Determines the bigger position of the bounding box extend
  39034. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39035. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39036. */
  39037. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39038. /**
  39039. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39040. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39041. * frustum width.
  39042. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39043. * to fully enclose the mesh in the viewing frustum.
  39044. */
  39045. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39046. /**
  39047. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39048. * is automatically returned to its default position (expected to be above ground plane).
  39049. */
  39050. private _maintainCameraAboveGround;
  39051. /**
  39052. * Returns the frustum slope based on the canvas ratio and camera FOV
  39053. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39054. */
  39055. private _getFrustumSlope;
  39056. /**
  39057. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39058. */
  39059. private _clearAnimationLocks;
  39060. /**
  39061. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39062. */
  39063. private _applyUserInteraction;
  39064. /**
  39065. * Stops and removes all animations that have been applied to the camera
  39066. */
  39067. stopAllAnimations(): void;
  39068. /**
  39069. * Gets a value indicating if the user is moving the camera
  39070. */
  39071. get isUserIsMoving(): boolean;
  39072. /**
  39073. * The camera can move all the way towards the mesh.
  39074. */
  39075. static IgnoreBoundsSizeMode: number;
  39076. /**
  39077. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39078. */
  39079. static FitFrustumSidesMode: number;
  39080. }
  39081. }
  39082. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39083. import { Nullable } from "babylonjs/types";
  39084. import { Camera } from "babylonjs/Cameras/camera";
  39085. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39086. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39087. /**
  39088. * Base class for Camera Pointer Inputs.
  39089. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39090. * for example usage.
  39091. */
  39092. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39093. /**
  39094. * Defines the camera the input is attached to.
  39095. */
  39096. abstract camera: Camera;
  39097. /**
  39098. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39099. */
  39100. protected _altKey: boolean;
  39101. protected _ctrlKey: boolean;
  39102. protected _metaKey: boolean;
  39103. protected _shiftKey: boolean;
  39104. /**
  39105. * Which mouse buttons were pressed at time of last mouse event.
  39106. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39107. */
  39108. protected _buttonsPressed: number;
  39109. /**
  39110. * Defines the buttons associated with the input to handle camera move.
  39111. */
  39112. buttons: number[];
  39113. /**
  39114. * Attach the input controls to a specific dom element to get the input from.
  39115. * @param element Defines the element the controls should be listened from
  39116. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39117. */
  39118. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39119. /**
  39120. * Detach the current controls from the specified dom element.
  39121. * @param element Defines the element to stop listening the inputs from
  39122. */
  39123. detachControl(element: Nullable<HTMLElement>): void;
  39124. /**
  39125. * Gets the class name of the current input.
  39126. * @returns the class name
  39127. */
  39128. getClassName(): string;
  39129. /**
  39130. * Get the friendly name associated with the input class.
  39131. * @returns the input friendly name
  39132. */
  39133. getSimpleName(): string;
  39134. /**
  39135. * Called on pointer POINTERDOUBLETAP event.
  39136. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39137. */
  39138. protected onDoubleTap(type: string): void;
  39139. /**
  39140. * Called on pointer POINTERMOVE event if only a single touch is active.
  39141. * Override this method to provide functionality.
  39142. */
  39143. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39144. /**
  39145. * Called on pointer POINTERMOVE event if multiple touches are active.
  39146. * Override this method to provide functionality.
  39147. */
  39148. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39149. /**
  39150. * Called on JS contextmenu event.
  39151. * Override this method to provide functionality.
  39152. */
  39153. protected onContextMenu(evt: PointerEvent): void;
  39154. /**
  39155. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39156. * press.
  39157. * Override this method to provide functionality.
  39158. */
  39159. protected onButtonDown(evt: PointerEvent): void;
  39160. /**
  39161. * Called each time a new POINTERUP event occurs. Ie, for each button
  39162. * release.
  39163. * Override this method to provide functionality.
  39164. */
  39165. protected onButtonUp(evt: PointerEvent): void;
  39166. /**
  39167. * Called when window becomes inactive.
  39168. * Override this method to provide functionality.
  39169. */
  39170. protected onLostFocus(): void;
  39171. private _pointerInput;
  39172. private _observer;
  39173. private _onLostFocus;
  39174. private pointA;
  39175. private pointB;
  39176. }
  39177. }
  39178. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39179. import { Nullable } from "babylonjs/types";
  39180. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39181. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39182. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39183. /**
  39184. * Manage the pointers inputs to control an arc rotate camera.
  39185. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39186. */
  39187. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39188. /**
  39189. * Defines the camera the input is attached to.
  39190. */
  39191. camera: ArcRotateCamera;
  39192. /**
  39193. * Gets the class name of the current input.
  39194. * @returns the class name
  39195. */
  39196. getClassName(): string;
  39197. /**
  39198. * Defines the buttons associated with the input to handle camera move.
  39199. */
  39200. buttons: number[];
  39201. /**
  39202. * Defines the pointer angular sensibility along the X axis or how fast is
  39203. * the camera rotating.
  39204. */
  39205. angularSensibilityX: number;
  39206. /**
  39207. * Defines the pointer angular sensibility along the Y axis or how fast is
  39208. * the camera rotating.
  39209. */
  39210. angularSensibilityY: number;
  39211. /**
  39212. * Defines the pointer pinch precision or how fast is the camera zooming.
  39213. */
  39214. pinchPrecision: number;
  39215. /**
  39216. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39217. * from 0.
  39218. * It defines the percentage of current camera.radius to use as delta when
  39219. * pinch zoom is used.
  39220. */
  39221. pinchDeltaPercentage: number;
  39222. /**
  39223. * Defines the pointer panning sensibility or how fast is the camera moving.
  39224. */
  39225. panningSensibility: number;
  39226. /**
  39227. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39228. */
  39229. multiTouchPanning: boolean;
  39230. /**
  39231. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39232. * zoom (pinch) through multitouch.
  39233. */
  39234. multiTouchPanAndZoom: boolean;
  39235. /**
  39236. * Revers pinch action direction.
  39237. */
  39238. pinchInwards: boolean;
  39239. private _isPanClick;
  39240. private _twoFingerActivityCount;
  39241. private _isPinching;
  39242. /**
  39243. * Called on pointer POINTERMOVE event if only a single touch is active.
  39244. */
  39245. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39246. /**
  39247. * Called on pointer POINTERDOUBLETAP event.
  39248. */
  39249. protected onDoubleTap(type: string): void;
  39250. /**
  39251. * Called on pointer POINTERMOVE event if multiple touches are active.
  39252. */
  39253. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39254. /**
  39255. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39256. * press.
  39257. */
  39258. protected onButtonDown(evt: PointerEvent): void;
  39259. /**
  39260. * Called each time a new POINTERUP event occurs. Ie, for each button
  39261. * release.
  39262. */
  39263. protected onButtonUp(evt: PointerEvent): void;
  39264. /**
  39265. * Called when window becomes inactive.
  39266. */
  39267. protected onLostFocus(): void;
  39268. }
  39269. }
  39270. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39271. import { Nullable } from "babylonjs/types";
  39272. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39273. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39274. /**
  39275. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39276. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39277. */
  39278. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39279. /**
  39280. * Defines the camera the input is attached to.
  39281. */
  39282. camera: ArcRotateCamera;
  39283. /**
  39284. * Defines the list of key codes associated with the up action (increase alpha)
  39285. */
  39286. keysUp: number[];
  39287. /**
  39288. * Defines the list of key codes associated with the down action (decrease alpha)
  39289. */
  39290. keysDown: number[];
  39291. /**
  39292. * Defines the list of key codes associated with the left action (increase beta)
  39293. */
  39294. keysLeft: number[];
  39295. /**
  39296. * Defines the list of key codes associated with the right action (decrease beta)
  39297. */
  39298. keysRight: number[];
  39299. /**
  39300. * Defines the list of key codes associated with the reset action.
  39301. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39302. */
  39303. keysReset: number[];
  39304. /**
  39305. * Defines the panning sensibility of the inputs.
  39306. * (How fast is the camera paning)
  39307. */
  39308. panningSensibility: number;
  39309. /**
  39310. * Defines the zooming sensibility of the inputs.
  39311. * (How fast is the camera zooming)
  39312. */
  39313. zoomingSensibility: number;
  39314. /**
  39315. * Defines wether maintaining the alt key down switch the movement mode from
  39316. * orientation to zoom.
  39317. */
  39318. useAltToZoom: boolean;
  39319. /**
  39320. * Rotation speed of the camera
  39321. */
  39322. angularSpeed: number;
  39323. private _keys;
  39324. private _ctrlPressed;
  39325. private _altPressed;
  39326. private _onCanvasBlurObserver;
  39327. private _onKeyboardObserver;
  39328. private _engine;
  39329. private _scene;
  39330. /**
  39331. * Attach the input controls to a specific dom element to get the input from.
  39332. * @param element Defines the element the controls should be listened from
  39333. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39334. */
  39335. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39336. /**
  39337. * Detach the current controls from the specified dom element.
  39338. * @param element Defines the element to stop listening the inputs from
  39339. */
  39340. detachControl(element: Nullable<HTMLElement>): void;
  39341. /**
  39342. * Update the current camera state depending on the inputs that have been used this frame.
  39343. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39344. */
  39345. checkInputs(): void;
  39346. /**
  39347. * Gets the class name of the current intput.
  39348. * @returns the class name
  39349. */
  39350. getClassName(): string;
  39351. /**
  39352. * Get the friendly name associated with the input class.
  39353. * @returns the input friendly name
  39354. */
  39355. getSimpleName(): string;
  39356. }
  39357. }
  39358. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39359. import { Nullable } from "babylonjs/types";
  39360. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39361. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39362. /**
  39363. * Manage the mouse wheel inputs to control an arc rotate camera.
  39364. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39365. */
  39366. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39367. /**
  39368. * Defines the camera the input is attached to.
  39369. */
  39370. camera: ArcRotateCamera;
  39371. /**
  39372. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39373. */
  39374. wheelPrecision: number;
  39375. /**
  39376. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39377. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39378. */
  39379. wheelDeltaPercentage: number;
  39380. private _wheel;
  39381. private _observer;
  39382. private computeDeltaFromMouseWheelLegacyEvent;
  39383. /**
  39384. * Attach the input controls to a specific dom element to get the input from.
  39385. * @param element Defines the element the controls should be listened from
  39386. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39387. */
  39388. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39389. /**
  39390. * Detach the current controls from the specified dom element.
  39391. * @param element Defines the element to stop listening the inputs from
  39392. */
  39393. detachControl(element: Nullable<HTMLElement>): void;
  39394. /**
  39395. * Gets the class name of the current intput.
  39396. * @returns the class name
  39397. */
  39398. getClassName(): string;
  39399. /**
  39400. * Get the friendly name associated with the input class.
  39401. * @returns the input friendly name
  39402. */
  39403. getSimpleName(): string;
  39404. }
  39405. }
  39406. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39407. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39408. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39409. /**
  39410. * Default Inputs manager for the ArcRotateCamera.
  39411. * It groups all the default supported inputs for ease of use.
  39412. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39413. */
  39414. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39415. /**
  39416. * Instantiates a new ArcRotateCameraInputsManager.
  39417. * @param camera Defines the camera the inputs belong to
  39418. */
  39419. constructor(camera: ArcRotateCamera);
  39420. /**
  39421. * Add mouse wheel input support to the input manager.
  39422. * @returns the current input manager
  39423. */
  39424. addMouseWheel(): ArcRotateCameraInputsManager;
  39425. /**
  39426. * Add pointers input support to the input manager.
  39427. * @returns the current input manager
  39428. */
  39429. addPointers(): ArcRotateCameraInputsManager;
  39430. /**
  39431. * Add keyboard input support to the input manager.
  39432. * @returns the current input manager
  39433. */
  39434. addKeyboard(): ArcRotateCameraInputsManager;
  39435. }
  39436. }
  39437. declare module "babylonjs/Cameras/arcRotateCamera" {
  39438. import { Observable } from "babylonjs/Misc/observable";
  39439. import { Nullable } from "babylonjs/types";
  39440. import { Scene } from "babylonjs/scene";
  39441. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39442. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39443. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39444. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39445. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39446. import { Camera } from "babylonjs/Cameras/camera";
  39447. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39448. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39449. import { Collider } from "babylonjs/Collisions/collider";
  39450. /**
  39451. * This represents an orbital type of camera.
  39452. *
  39453. * 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.
  39454. * 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.
  39455. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39456. */
  39457. export class ArcRotateCamera extends TargetCamera {
  39458. /**
  39459. * Defines the rotation angle of the camera along the longitudinal axis.
  39460. */
  39461. alpha: number;
  39462. /**
  39463. * Defines the rotation angle of the camera along the latitudinal axis.
  39464. */
  39465. beta: number;
  39466. /**
  39467. * Defines the radius of the camera from it s target point.
  39468. */
  39469. radius: number;
  39470. protected _target: Vector3;
  39471. protected _targetHost: Nullable<AbstractMesh>;
  39472. /**
  39473. * Defines the target point of the camera.
  39474. * The camera looks towards it form the radius distance.
  39475. */
  39476. get target(): Vector3;
  39477. set target(value: Vector3);
  39478. /**
  39479. * Define the current local position of the camera in the scene
  39480. */
  39481. get position(): Vector3;
  39482. set position(newPosition: Vector3);
  39483. protected _upVector: Vector3;
  39484. protected _upToYMatrix: Matrix;
  39485. protected _YToUpMatrix: Matrix;
  39486. /**
  39487. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39488. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39489. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39490. */
  39491. set upVector(vec: Vector3);
  39492. get upVector(): Vector3;
  39493. /**
  39494. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39495. */
  39496. setMatUp(): void;
  39497. /**
  39498. * Current inertia value on the longitudinal axis.
  39499. * The bigger this number the longer it will take for the camera to stop.
  39500. */
  39501. inertialAlphaOffset: number;
  39502. /**
  39503. * Current inertia value on the latitudinal axis.
  39504. * The bigger this number the longer it will take for the camera to stop.
  39505. */
  39506. inertialBetaOffset: number;
  39507. /**
  39508. * Current inertia value on the radius axis.
  39509. * The bigger this number the longer it will take for the camera to stop.
  39510. */
  39511. inertialRadiusOffset: number;
  39512. /**
  39513. * Minimum allowed angle on the longitudinal axis.
  39514. * This can help limiting how the Camera is able to move in the scene.
  39515. */
  39516. lowerAlphaLimit: Nullable<number>;
  39517. /**
  39518. * Maximum allowed angle on the longitudinal axis.
  39519. * This can help limiting how the Camera is able to move in the scene.
  39520. */
  39521. upperAlphaLimit: Nullable<number>;
  39522. /**
  39523. * Minimum allowed angle on the latitudinal axis.
  39524. * This can help limiting how the Camera is able to move in the scene.
  39525. */
  39526. lowerBetaLimit: number;
  39527. /**
  39528. * Maximum allowed angle on the latitudinal axis.
  39529. * This can help limiting how the Camera is able to move in the scene.
  39530. */
  39531. upperBetaLimit: number;
  39532. /**
  39533. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39534. * This can help limiting how the Camera is able to move in the scene.
  39535. */
  39536. lowerRadiusLimit: Nullable<number>;
  39537. /**
  39538. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39539. * This can help limiting how the Camera is able to move in the scene.
  39540. */
  39541. upperRadiusLimit: Nullable<number>;
  39542. /**
  39543. * Defines the current inertia value used during panning of the camera along the X axis.
  39544. */
  39545. inertialPanningX: number;
  39546. /**
  39547. * Defines the current inertia value used during panning of the camera along the Y axis.
  39548. */
  39549. inertialPanningY: number;
  39550. /**
  39551. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39552. * Basically if your fingers moves away from more than this distance you will be considered
  39553. * in pinch mode.
  39554. */
  39555. pinchToPanMaxDistance: number;
  39556. /**
  39557. * Defines the maximum distance the camera can pan.
  39558. * This could help keeping the cammera always in your scene.
  39559. */
  39560. panningDistanceLimit: Nullable<number>;
  39561. /**
  39562. * Defines the target of the camera before paning.
  39563. */
  39564. panningOriginTarget: Vector3;
  39565. /**
  39566. * Defines the value of the inertia used during panning.
  39567. * 0 would mean stop inertia and one would mean no decelleration at all.
  39568. */
  39569. panningInertia: number;
  39570. /**
  39571. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39572. */
  39573. get angularSensibilityX(): number;
  39574. set angularSensibilityX(value: number);
  39575. /**
  39576. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39577. */
  39578. get angularSensibilityY(): number;
  39579. set angularSensibilityY(value: number);
  39580. /**
  39581. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39582. */
  39583. get pinchPrecision(): number;
  39584. set pinchPrecision(value: number);
  39585. /**
  39586. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39587. * It will be used instead of pinchDeltaPrecision if different from 0.
  39588. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39589. */
  39590. get pinchDeltaPercentage(): number;
  39591. set pinchDeltaPercentage(value: number);
  39592. /**
  39593. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39594. */
  39595. get panningSensibility(): number;
  39596. set panningSensibility(value: number);
  39597. /**
  39598. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39599. */
  39600. get keysUp(): number[];
  39601. set keysUp(value: number[]);
  39602. /**
  39603. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39604. */
  39605. get keysDown(): number[];
  39606. set keysDown(value: number[]);
  39607. /**
  39608. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39609. */
  39610. get keysLeft(): number[];
  39611. set keysLeft(value: number[]);
  39612. /**
  39613. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39614. */
  39615. get keysRight(): number[];
  39616. set keysRight(value: number[]);
  39617. /**
  39618. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39619. */
  39620. get wheelPrecision(): number;
  39621. set wheelPrecision(value: number);
  39622. /**
  39623. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39624. * It will be used instead of pinchDeltaPrecision if different from 0.
  39625. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39626. */
  39627. get wheelDeltaPercentage(): number;
  39628. set wheelDeltaPercentage(value: number);
  39629. /**
  39630. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39631. */
  39632. zoomOnFactor: number;
  39633. /**
  39634. * Defines a screen offset for the camera position.
  39635. */
  39636. targetScreenOffset: Vector2;
  39637. /**
  39638. * Allows the camera to be completely reversed.
  39639. * If false the camera can not arrive upside down.
  39640. */
  39641. allowUpsideDown: boolean;
  39642. /**
  39643. * Define if double tap/click is used to restore the previously saved state of the camera.
  39644. */
  39645. useInputToRestoreState: boolean;
  39646. /** @hidden */
  39647. _viewMatrix: Matrix;
  39648. /** @hidden */
  39649. _useCtrlForPanning: boolean;
  39650. /** @hidden */
  39651. _panningMouseButton: number;
  39652. /**
  39653. * Defines the input associated to the camera.
  39654. */
  39655. inputs: ArcRotateCameraInputsManager;
  39656. /** @hidden */
  39657. _reset: () => void;
  39658. /**
  39659. * Defines the allowed panning axis.
  39660. */
  39661. panningAxis: Vector3;
  39662. protected _localDirection: Vector3;
  39663. protected _transformedDirection: Vector3;
  39664. private _bouncingBehavior;
  39665. /**
  39666. * Gets the bouncing behavior of the camera if it has been enabled.
  39667. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39668. */
  39669. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39670. /**
  39671. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39672. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39673. */
  39674. get useBouncingBehavior(): boolean;
  39675. set useBouncingBehavior(value: boolean);
  39676. private _framingBehavior;
  39677. /**
  39678. * Gets the framing behavior of the camera if it has been enabled.
  39679. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39680. */
  39681. get framingBehavior(): Nullable<FramingBehavior>;
  39682. /**
  39683. * Defines if the framing behavior of the camera is enabled on the camera.
  39684. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39685. */
  39686. get useFramingBehavior(): boolean;
  39687. set useFramingBehavior(value: boolean);
  39688. private _autoRotationBehavior;
  39689. /**
  39690. * Gets the auto rotation behavior of the camera if it has been enabled.
  39691. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39692. */
  39693. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39694. /**
  39695. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39696. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39697. */
  39698. get useAutoRotationBehavior(): boolean;
  39699. set useAutoRotationBehavior(value: boolean);
  39700. /**
  39701. * Observable triggered when the mesh target has been changed on the camera.
  39702. */
  39703. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39704. /**
  39705. * Event raised when the camera is colliding with a mesh.
  39706. */
  39707. onCollide: (collidedMesh: AbstractMesh) => void;
  39708. /**
  39709. * Defines whether the camera should check collision with the objects oh the scene.
  39710. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39711. */
  39712. checkCollisions: boolean;
  39713. /**
  39714. * Defines the collision radius of the camera.
  39715. * This simulates a sphere around the camera.
  39716. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39717. */
  39718. collisionRadius: Vector3;
  39719. protected _collider: Collider;
  39720. protected _previousPosition: Vector3;
  39721. protected _collisionVelocity: Vector3;
  39722. protected _newPosition: Vector3;
  39723. protected _previousAlpha: number;
  39724. protected _previousBeta: number;
  39725. protected _previousRadius: number;
  39726. protected _collisionTriggered: boolean;
  39727. protected _targetBoundingCenter: Nullable<Vector3>;
  39728. private _computationVector;
  39729. /**
  39730. * Instantiates a new ArcRotateCamera in a given scene
  39731. * @param name Defines the name of the camera
  39732. * @param alpha Defines the camera rotation along the logitudinal axis
  39733. * @param beta Defines the camera rotation along the latitudinal axis
  39734. * @param radius Defines the camera distance from its target
  39735. * @param target Defines the camera target
  39736. * @param scene Defines the scene the camera belongs to
  39737. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39738. */
  39739. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39740. /** @hidden */
  39741. _initCache(): void;
  39742. /** @hidden */
  39743. _updateCache(ignoreParentClass?: boolean): void;
  39744. protected _getTargetPosition(): Vector3;
  39745. private _storedAlpha;
  39746. private _storedBeta;
  39747. private _storedRadius;
  39748. private _storedTarget;
  39749. private _storedTargetScreenOffset;
  39750. /**
  39751. * Stores the current state of the camera (alpha, beta, radius and target)
  39752. * @returns the camera itself
  39753. */
  39754. storeState(): Camera;
  39755. /**
  39756. * @hidden
  39757. * Restored camera state. You must call storeState() first
  39758. */
  39759. _restoreStateValues(): boolean;
  39760. /** @hidden */
  39761. _isSynchronizedViewMatrix(): boolean;
  39762. /**
  39763. * Attached controls to the current camera.
  39764. * @param element Defines the element the controls should be listened from
  39765. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39766. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39767. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39768. */
  39769. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39770. /**
  39771. * Detach the current controls from the camera.
  39772. * The camera will stop reacting to inputs.
  39773. * @param element Defines the element to stop listening the inputs from
  39774. */
  39775. detachControl(element: HTMLElement): void;
  39776. /** @hidden */
  39777. _checkInputs(): void;
  39778. protected _checkLimits(): void;
  39779. /**
  39780. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39781. */
  39782. rebuildAnglesAndRadius(): void;
  39783. /**
  39784. * Use a position to define the current camera related information like alpha, beta and radius
  39785. * @param position Defines the position to set the camera at
  39786. */
  39787. setPosition(position: Vector3): void;
  39788. /**
  39789. * Defines the target the camera should look at.
  39790. * This will automatically adapt alpha beta and radius to fit within the new target.
  39791. * @param target Defines the new target as a Vector or a mesh
  39792. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  39793. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39794. */
  39795. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39796. /** @hidden */
  39797. _getViewMatrix(): Matrix;
  39798. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39799. /**
  39800. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39801. * @param meshes Defines the mesh to zoom on
  39802. * @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)
  39803. */
  39804. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39805. /**
  39806. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39807. * The target will be changed but the radius
  39808. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39809. * @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)
  39810. */
  39811. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39812. min: Vector3;
  39813. max: Vector3;
  39814. distance: number;
  39815. }, doNotUpdateMaxZ?: boolean): void;
  39816. /**
  39817. * @override
  39818. * Override Camera.createRigCamera
  39819. */
  39820. createRigCamera(name: string, cameraIndex: number): Camera;
  39821. /**
  39822. * @hidden
  39823. * @override
  39824. * Override Camera._updateRigCameras
  39825. */
  39826. _updateRigCameras(): void;
  39827. /**
  39828. * Destroy the camera and release the current resources hold by it.
  39829. */
  39830. dispose(): void;
  39831. /**
  39832. * Gets the current object class name.
  39833. * @return the class name
  39834. */
  39835. getClassName(): string;
  39836. }
  39837. }
  39838. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  39839. import { Behavior } from "babylonjs/Behaviors/behavior";
  39840. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39841. /**
  39842. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39843. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39844. */
  39845. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39846. /**
  39847. * Gets the name of the behavior.
  39848. */
  39849. get name(): string;
  39850. private _zoomStopsAnimation;
  39851. private _idleRotationSpeed;
  39852. private _idleRotationWaitTime;
  39853. private _idleRotationSpinupTime;
  39854. /**
  39855. * Sets the flag that indicates if user zooming should stop animation.
  39856. */
  39857. set zoomStopsAnimation(flag: boolean);
  39858. /**
  39859. * Gets the flag that indicates if user zooming should stop animation.
  39860. */
  39861. get zoomStopsAnimation(): boolean;
  39862. /**
  39863. * Sets the default speed at which the camera rotates around the model.
  39864. */
  39865. set idleRotationSpeed(speed: number);
  39866. /**
  39867. * Gets the default speed at which the camera rotates around the model.
  39868. */
  39869. get idleRotationSpeed(): number;
  39870. /**
  39871. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39872. */
  39873. set idleRotationWaitTime(time: number);
  39874. /**
  39875. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39876. */
  39877. get idleRotationWaitTime(): number;
  39878. /**
  39879. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39880. */
  39881. set idleRotationSpinupTime(time: number);
  39882. /**
  39883. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39884. */
  39885. get idleRotationSpinupTime(): number;
  39886. /**
  39887. * Gets a value indicating if the camera is currently rotating because of this behavior
  39888. */
  39889. get rotationInProgress(): boolean;
  39890. private _onPrePointerObservableObserver;
  39891. private _onAfterCheckInputsObserver;
  39892. private _attachedCamera;
  39893. private _isPointerDown;
  39894. private _lastFrameTime;
  39895. private _lastInteractionTime;
  39896. private _cameraRotationSpeed;
  39897. /**
  39898. * Initializes the behavior.
  39899. */
  39900. init(): void;
  39901. /**
  39902. * Attaches the behavior to its arc rotate camera.
  39903. * @param camera Defines the camera to attach the behavior to
  39904. */
  39905. attach(camera: ArcRotateCamera): void;
  39906. /**
  39907. * Detaches the behavior from its current arc rotate camera.
  39908. */
  39909. detach(): void;
  39910. /**
  39911. * Returns true if user is scrolling.
  39912. * @return true if user is scrolling.
  39913. */
  39914. private _userIsZooming;
  39915. private _lastFrameRadius;
  39916. private _shouldAnimationStopForInteraction;
  39917. /**
  39918. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39919. */
  39920. private _applyUserInteraction;
  39921. private _userIsMoving;
  39922. }
  39923. }
  39924. declare module "babylonjs/Behaviors/Cameras/index" {
  39925. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39926. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39927. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  39928. }
  39929. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  39930. import { Mesh } from "babylonjs/Meshes/mesh";
  39931. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39932. import { Behavior } from "babylonjs/Behaviors/behavior";
  39933. /**
  39934. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39935. */
  39936. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39937. private ui;
  39938. /**
  39939. * The name of the behavior
  39940. */
  39941. name: string;
  39942. /**
  39943. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39944. */
  39945. distanceAwayFromFace: number;
  39946. /**
  39947. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39948. */
  39949. distanceAwayFromBottomOfFace: number;
  39950. private _faceVectors;
  39951. private _target;
  39952. private _scene;
  39953. private _onRenderObserver;
  39954. private _tmpMatrix;
  39955. private _tmpVector;
  39956. /**
  39957. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39958. * @param ui The transform node that should be attched to the mesh
  39959. */
  39960. constructor(ui: TransformNode);
  39961. /**
  39962. * Initializes the behavior
  39963. */
  39964. init(): void;
  39965. private _closestFace;
  39966. private _zeroVector;
  39967. private _lookAtTmpMatrix;
  39968. private _lookAtToRef;
  39969. /**
  39970. * Attaches the AttachToBoxBehavior to the passed in mesh
  39971. * @param target The mesh that the specified node will be attached to
  39972. */
  39973. attach(target: Mesh): void;
  39974. /**
  39975. * Detaches the behavior from the mesh
  39976. */
  39977. detach(): void;
  39978. }
  39979. }
  39980. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  39981. import { Behavior } from "babylonjs/Behaviors/behavior";
  39982. import { Mesh } from "babylonjs/Meshes/mesh";
  39983. /**
  39984. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39985. */
  39986. export class FadeInOutBehavior implements Behavior<Mesh> {
  39987. /**
  39988. * Time in milliseconds to delay before fading in (Default: 0)
  39989. */
  39990. delay: number;
  39991. /**
  39992. * Time in milliseconds for the mesh to fade in (Default: 300)
  39993. */
  39994. fadeInTime: number;
  39995. private _millisecondsPerFrame;
  39996. private _hovered;
  39997. private _hoverValue;
  39998. private _ownerNode;
  39999. /**
  40000. * Instatiates the FadeInOutBehavior
  40001. */
  40002. constructor();
  40003. /**
  40004. * The name of the behavior
  40005. */
  40006. get name(): string;
  40007. /**
  40008. * Initializes the behavior
  40009. */
  40010. init(): void;
  40011. /**
  40012. * Attaches the fade behavior on the passed in mesh
  40013. * @param ownerNode The mesh that will be faded in/out once attached
  40014. */
  40015. attach(ownerNode: Mesh): void;
  40016. /**
  40017. * Detaches the behavior from the mesh
  40018. */
  40019. detach(): void;
  40020. /**
  40021. * Triggers the mesh to begin fading in or out
  40022. * @param value if the object should fade in or out (true to fade in)
  40023. */
  40024. fadeIn(value: boolean): void;
  40025. private _update;
  40026. private _setAllVisibility;
  40027. }
  40028. }
  40029. declare module "babylonjs/Misc/pivotTools" {
  40030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40031. /**
  40032. * Class containing a set of static utilities functions for managing Pivots
  40033. * @hidden
  40034. */
  40035. export class PivotTools {
  40036. private static _PivotCached;
  40037. private static _OldPivotPoint;
  40038. private static _PivotTranslation;
  40039. private static _PivotTmpVector;
  40040. /** @hidden */
  40041. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40042. /** @hidden */
  40043. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40044. }
  40045. }
  40046. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40047. import { Scene } from "babylonjs/scene";
  40048. import { Vector4 } from "babylonjs/Maths/math.vector";
  40049. import { Mesh } from "babylonjs/Meshes/mesh";
  40050. import { Nullable } from "babylonjs/types";
  40051. import { Plane } from "babylonjs/Maths/math.plane";
  40052. /**
  40053. * Class containing static functions to help procedurally build meshes
  40054. */
  40055. export class PlaneBuilder {
  40056. /**
  40057. * Creates a plane mesh
  40058. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40059. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40060. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40062. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40064. * @param name defines the name of the mesh
  40065. * @param options defines the options used to create the mesh
  40066. * @param scene defines the hosting scene
  40067. * @returns the plane mesh
  40068. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40069. */
  40070. static CreatePlane(name: string, options: {
  40071. size?: number;
  40072. width?: number;
  40073. height?: number;
  40074. sideOrientation?: number;
  40075. frontUVs?: Vector4;
  40076. backUVs?: Vector4;
  40077. updatable?: boolean;
  40078. sourcePlane?: Plane;
  40079. }, scene?: Nullable<Scene>): Mesh;
  40080. }
  40081. }
  40082. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40083. import { Behavior } from "babylonjs/Behaviors/behavior";
  40084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40085. import { Observable } from "babylonjs/Misc/observable";
  40086. import { Vector3 } from "babylonjs/Maths/math.vector";
  40087. import { Ray } from "babylonjs/Culling/ray";
  40088. import "babylonjs/Meshes/Builders/planeBuilder";
  40089. /**
  40090. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40091. */
  40092. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40093. private static _AnyMouseID;
  40094. /**
  40095. * Abstract mesh the behavior is set on
  40096. */
  40097. attachedNode: AbstractMesh;
  40098. private _dragPlane;
  40099. private _scene;
  40100. private _pointerObserver;
  40101. private _beforeRenderObserver;
  40102. private static _planeScene;
  40103. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40104. /**
  40105. * 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)
  40106. */
  40107. maxDragAngle: number;
  40108. /**
  40109. * @hidden
  40110. */
  40111. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40112. /**
  40113. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40114. */
  40115. currentDraggingPointerID: number;
  40116. /**
  40117. * The last position where the pointer hit the drag plane in world space
  40118. */
  40119. lastDragPosition: Vector3;
  40120. /**
  40121. * If the behavior is currently in a dragging state
  40122. */
  40123. dragging: boolean;
  40124. /**
  40125. * 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)
  40126. */
  40127. dragDeltaRatio: number;
  40128. /**
  40129. * If the drag plane orientation should be updated during the dragging (Default: true)
  40130. */
  40131. updateDragPlane: boolean;
  40132. private _debugMode;
  40133. private _moving;
  40134. /**
  40135. * Fires each time the attached mesh is dragged with the pointer
  40136. * * delta between last drag position and current drag position in world space
  40137. * * dragDistance along the drag axis
  40138. * * dragPlaneNormal normal of the current drag plane used during the drag
  40139. * * dragPlanePoint in world space where the drag intersects the drag plane
  40140. */
  40141. onDragObservable: Observable<{
  40142. delta: Vector3;
  40143. dragPlanePoint: Vector3;
  40144. dragPlaneNormal: Vector3;
  40145. dragDistance: number;
  40146. pointerId: number;
  40147. }>;
  40148. /**
  40149. * Fires each time a drag begins (eg. mouse down on mesh)
  40150. */
  40151. onDragStartObservable: Observable<{
  40152. dragPlanePoint: Vector3;
  40153. pointerId: number;
  40154. }>;
  40155. /**
  40156. * Fires each time a drag ends (eg. mouse release after drag)
  40157. */
  40158. onDragEndObservable: Observable<{
  40159. dragPlanePoint: Vector3;
  40160. pointerId: number;
  40161. }>;
  40162. /**
  40163. * If the attached mesh should be moved when dragged
  40164. */
  40165. moveAttached: boolean;
  40166. /**
  40167. * If the drag behavior will react to drag events (Default: true)
  40168. */
  40169. enabled: boolean;
  40170. /**
  40171. * If pointer events should start and release the drag (Default: true)
  40172. */
  40173. startAndReleaseDragOnPointerEvents: boolean;
  40174. /**
  40175. * If camera controls should be detached during the drag
  40176. */
  40177. detachCameraControls: boolean;
  40178. /**
  40179. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40180. */
  40181. useObjectOrientationForDragging: boolean;
  40182. private _options;
  40183. /**
  40184. * Gets the options used by the behavior
  40185. */
  40186. get options(): {
  40187. dragAxis?: Vector3;
  40188. dragPlaneNormal?: Vector3;
  40189. };
  40190. /**
  40191. * Sets the options used by the behavior
  40192. */
  40193. set options(options: {
  40194. dragAxis?: Vector3;
  40195. dragPlaneNormal?: Vector3;
  40196. });
  40197. /**
  40198. * Creates a pointer drag behavior that can be attached to a mesh
  40199. * @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)
  40200. */
  40201. constructor(options?: {
  40202. dragAxis?: Vector3;
  40203. dragPlaneNormal?: Vector3;
  40204. });
  40205. /**
  40206. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40207. */
  40208. validateDrag: (targetPosition: Vector3) => boolean;
  40209. /**
  40210. * The name of the behavior
  40211. */
  40212. get name(): string;
  40213. /**
  40214. * Initializes the behavior
  40215. */
  40216. init(): void;
  40217. private _tmpVector;
  40218. private _alternatePickedPoint;
  40219. private _worldDragAxis;
  40220. private _targetPosition;
  40221. private _attachedElement;
  40222. /**
  40223. * Attaches the drag behavior the passed in mesh
  40224. * @param ownerNode The mesh that will be dragged around once attached
  40225. * @param predicate Predicate to use for pick filtering
  40226. */
  40227. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40228. /**
  40229. * Force relase the drag action by code.
  40230. */
  40231. releaseDrag(): void;
  40232. private _startDragRay;
  40233. private _lastPointerRay;
  40234. /**
  40235. * Simulates the start of a pointer drag event on the behavior
  40236. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40237. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40238. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40239. */
  40240. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40241. private _startDrag;
  40242. private _dragDelta;
  40243. private _moveDrag;
  40244. private _pickWithRayOnDragPlane;
  40245. private _pointA;
  40246. private _pointB;
  40247. private _pointC;
  40248. private _lineA;
  40249. private _lineB;
  40250. private _localAxis;
  40251. private _lookAt;
  40252. private _updateDragPlanePosition;
  40253. /**
  40254. * Detaches the behavior from the mesh
  40255. */
  40256. detach(): void;
  40257. }
  40258. }
  40259. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40260. import { Mesh } from "babylonjs/Meshes/mesh";
  40261. import { Behavior } from "babylonjs/Behaviors/behavior";
  40262. /**
  40263. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40264. */
  40265. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40266. private _dragBehaviorA;
  40267. private _dragBehaviorB;
  40268. private _startDistance;
  40269. private _initialScale;
  40270. private _targetScale;
  40271. private _ownerNode;
  40272. private _sceneRenderObserver;
  40273. /**
  40274. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40275. */
  40276. constructor();
  40277. /**
  40278. * The name of the behavior
  40279. */
  40280. get name(): string;
  40281. /**
  40282. * Initializes the behavior
  40283. */
  40284. init(): void;
  40285. private _getCurrentDistance;
  40286. /**
  40287. * Attaches the scale behavior the passed in mesh
  40288. * @param ownerNode The mesh that will be scaled around once attached
  40289. */
  40290. attach(ownerNode: Mesh): void;
  40291. /**
  40292. * Detaches the behavior from the mesh
  40293. */
  40294. detach(): void;
  40295. }
  40296. }
  40297. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40298. import { Behavior } from "babylonjs/Behaviors/behavior";
  40299. import { Mesh } from "babylonjs/Meshes/mesh";
  40300. import { Observable } from "babylonjs/Misc/observable";
  40301. /**
  40302. * 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
  40303. */
  40304. export class SixDofDragBehavior implements Behavior<Mesh> {
  40305. private static _virtualScene;
  40306. private _ownerNode;
  40307. private _sceneRenderObserver;
  40308. private _scene;
  40309. private _targetPosition;
  40310. private _virtualOriginMesh;
  40311. private _virtualDragMesh;
  40312. private _pointerObserver;
  40313. private _moving;
  40314. private _startingOrientation;
  40315. /**
  40316. * 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)
  40317. */
  40318. private zDragFactor;
  40319. /**
  40320. * If the object should rotate to face the drag origin
  40321. */
  40322. rotateDraggedObject: boolean;
  40323. /**
  40324. * If the behavior is currently in a dragging state
  40325. */
  40326. dragging: boolean;
  40327. /**
  40328. * 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)
  40329. */
  40330. dragDeltaRatio: number;
  40331. /**
  40332. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40333. */
  40334. currentDraggingPointerID: number;
  40335. /**
  40336. * If camera controls should be detached during the drag
  40337. */
  40338. detachCameraControls: boolean;
  40339. /**
  40340. * Fires each time a drag starts
  40341. */
  40342. onDragStartObservable: Observable<{}>;
  40343. /**
  40344. * Fires each time a drag ends (eg. mouse release after drag)
  40345. */
  40346. onDragEndObservable: Observable<{}>;
  40347. /**
  40348. * 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
  40349. */
  40350. constructor();
  40351. /**
  40352. * The name of the behavior
  40353. */
  40354. get name(): string;
  40355. /**
  40356. * Initializes the behavior
  40357. */
  40358. init(): void;
  40359. /**
  40360. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40361. */
  40362. private get _pointerCamera();
  40363. /**
  40364. * Attaches the scale behavior the passed in mesh
  40365. * @param ownerNode The mesh that will be scaled around once attached
  40366. */
  40367. attach(ownerNode: Mesh): void;
  40368. /**
  40369. * Detaches the behavior from the mesh
  40370. */
  40371. detach(): void;
  40372. }
  40373. }
  40374. declare module "babylonjs/Behaviors/Meshes/index" {
  40375. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40376. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40377. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40378. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40379. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40380. }
  40381. declare module "babylonjs/Behaviors/index" {
  40382. export * from "babylonjs/Behaviors/behavior";
  40383. export * from "babylonjs/Behaviors/Cameras/index";
  40384. export * from "babylonjs/Behaviors/Meshes/index";
  40385. }
  40386. declare module "babylonjs/Bones/boneIKController" {
  40387. import { Bone } from "babylonjs/Bones/bone";
  40388. import { Vector3 } from "babylonjs/Maths/math.vector";
  40389. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40390. import { Nullable } from "babylonjs/types";
  40391. /**
  40392. * Class used to apply inverse kinematics to bones
  40393. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40394. */
  40395. export class BoneIKController {
  40396. private static _tmpVecs;
  40397. private static _tmpQuat;
  40398. private static _tmpMats;
  40399. /**
  40400. * Gets or sets the target mesh
  40401. */
  40402. targetMesh: AbstractMesh;
  40403. /** Gets or sets the mesh used as pole */
  40404. poleTargetMesh: AbstractMesh;
  40405. /**
  40406. * Gets or sets the bone used as pole
  40407. */
  40408. poleTargetBone: Nullable<Bone>;
  40409. /**
  40410. * Gets or sets the target position
  40411. */
  40412. targetPosition: Vector3;
  40413. /**
  40414. * Gets or sets the pole target position
  40415. */
  40416. poleTargetPosition: Vector3;
  40417. /**
  40418. * Gets or sets the pole target local offset
  40419. */
  40420. poleTargetLocalOffset: Vector3;
  40421. /**
  40422. * Gets or sets the pole angle
  40423. */
  40424. poleAngle: number;
  40425. /**
  40426. * Gets or sets the mesh associated with the controller
  40427. */
  40428. mesh: AbstractMesh;
  40429. /**
  40430. * 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)
  40431. */
  40432. slerpAmount: number;
  40433. private _bone1Quat;
  40434. private _bone1Mat;
  40435. private _bone2Ang;
  40436. private _bone1;
  40437. private _bone2;
  40438. private _bone1Length;
  40439. private _bone2Length;
  40440. private _maxAngle;
  40441. private _maxReach;
  40442. private _rightHandedSystem;
  40443. private _bendAxis;
  40444. private _slerping;
  40445. private _adjustRoll;
  40446. /**
  40447. * Gets or sets maximum allowed angle
  40448. */
  40449. get maxAngle(): number;
  40450. set maxAngle(value: number);
  40451. /**
  40452. * Creates a new BoneIKController
  40453. * @param mesh defines the mesh to control
  40454. * @param bone defines the bone to control
  40455. * @param options defines options to set up the controller
  40456. */
  40457. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40458. targetMesh?: AbstractMesh;
  40459. poleTargetMesh?: AbstractMesh;
  40460. poleTargetBone?: Bone;
  40461. poleTargetLocalOffset?: Vector3;
  40462. poleAngle?: number;
  40463. bendAxis?: Vector3;
  40464. maxAngle?: number;
  40465. slerpAmount?: number;
  40466. });
  40467. private _setMaxAngle;
  40468. /**
  40469. * Force the controller to update the bones
  40470. */
  40471. update(): void;
  40472. }
  40473. }
  40474. declare module "babylonjs/Bones/boneLookController" {
  40475. import { Vector3 } from "babylonjs/Maths/math.vector";
  40476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40477. import { Bone } from "babylonjs/Bones/bone";
  40478. import { Space } from "babylonjs/Maths/math.axis";
  40479. /**
  40480. * Class used to make a bone look toward a point in space
  40481. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40482. */
  40483. export class BoneLookController {
  40484. private static _tmpVecs;
  40485. private static _tmpQuat;
  40486. private static _tmpMats;
  40487. /**
  40488. * The target Vector3 that the bone will look at
  40489. */
  40490. target: Vector3;
  40491. /**
  40492. * The mesh that the bone is attached to
  40493. */
  40494. mesh: AbstractMesh;
  40495. /**
  40496. * The bone that will be looking to the target
  40497. */
  40498. bone: Bone;
  40499. /**
  40500. * The up axis of the coordinate system that is used when the bone is rotated
  40501. */
  40502. upAxis: Vector3;
  40503. /**
  40504. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40505. */
  40506. upAxisSpace: Space;
  40507. /**
  40508. * Used to make an adjustment to the yaw of the bone
  40509. */
  40510. adjustYaw: number;
  40511. /**
  40512. * Used to make an adjustment to the pitch of the bone
  40513. */
  40514. adjustPitch: number;
  40515. /**
  40516. * Used to make an adjustment to the roll of the bone
  40517. */
  40518. adjustRoll: number;
  40519. /**
  40520. * 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)
  40521. */
  40522. slerpAmount: number;
  40523. private _minYaw;
  40524. private _maxYaw;
  40525. private _minPitch;
  40526. private _maxPitch;
  40527. private _minYawSin;
  40528. private _minYawCos;
  40529. private _maxYawSin;
  40530. private _maxYawCos;
  40531. private _midYawConstraint;
  40532. private _minPitchTan;
  40533. private _maxPitchTan;
  40534. private _boneQuat;
  40535. private _slerping;
  40536. private _transformYawPitch;
  40537. private _transformYawPitchInv;
  40538. private _firstFrameSkipped;
  40539. private _yawRange;
  40540. private _fowardAxis;
  40541. /**
  40542. * Gets or sets the minimum yaw angle that the bone can look to
  40543. */
  40544. get minYaw(): number;
  40545. set minYaw(value: number);
  40546. /**
  40547. * Gets or sets the maximum yaw angle that the bone can look to
  40548. */
  40549. get maxYaw(): number;
  40550. set maxYaw(value: number);
  40551. /**
  40552. * Gets or sets the minimum pitch angle that the bone can look to
  40553. */
  40554. get minPitch(): number;
  40555. set minPitch(value: number);
  40556. /**
  40557. * Gets or sets the maximum pitch angle that the bone can look to
  40558. */
  40559. get maxPitch(): number;
  40560. set maxPitch(value: number);
  40561. /**
  40562. * Create a BoneLookController
  40563. * @param mesh the mesh that the bone belongs to
  40564. * @param bone the bone that will be looking to the target
  40565. * @param target the target Vector3 to look at
  40566. * @param options optional settings:
  40567. * * maxYaw: the maximum angle the bone will yaw to
  40568. * * minYaw: the minimum angle the bone will yaw to
  40569. * * maxPitch: the maximum angle the bone will pitch to
  40570. * * minPitch: the minimum angle the bone will yaw to
  40571. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40572. * * upAxis: the up axis of the coordinate system
  40573. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40574. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40575. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40576. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40577. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40578. * * adjustRoll: used to make an adjustment to the roll of the bone
  40579. **/
  40580. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40581. maxYaw?: number;
  40582. minYaw?: number;
  40583. maxPitch?: number;
  40584. minPitch?: number;
  40585. slerpAmount?: number;
  40586. upAxis?: Vector3;
  40587. upAxisSpace?: Space;
  40588. yawAxis?: Vector3;
  40589. pitchAxis?: Vector3;
  40590. adjustYaw?: number;
  40591. adjustPitch?: number;
  40592. adjustRoll?: number;
  40593. });
  40594. /**
  40595. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40596. */
  40597. update(): void;
  40598. private _getAngleDiff;
  40599. private _getAngleBetween;
  40600. private _isAngleBetween;
  40601. }
  40602. }
  40603. declare module "babylonjs/Bones/index" {
  40604. export * from "babylonjs/Bones/bone";
  40605. export * from "babylonjs/Bones/boneIKController";
  40606. export * from "babylonjs/Bones/boneLookController";
  40607. export * from "babylonjs/Bones/skeleton";
  40608. }
  40609. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40610. import { Nullable } from "babylonjs/types";
  40611. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40612. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40613. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40614. /**
  40615. * Manage the gamepad inputs to control an arc rotate camera.
  40616. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40617. */
  40618. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40619. /**
  40620. * Defines the camera the input is attached to.
  40621. */
  40622. camera: ArcRotateCamera;
  40623. /**
  40624. * Defines the gamepad the input is gathering event from.
  40625. */
  40626. gamepad: Nullable<Gamepad>;
  40627. /**
  40628. * Defines the gamepad rotation sensiblity.
  40629. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40630. */
  40631. gamepadRotationSensibility: number;
  40632. /**
  40633. * Defines the gamepad move sensiblity.
  40634. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40635. */
  40636. gamepadMoveSensibility: number;
  40637. private _yAxisScale;
  40638. /**
  40639. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40640. */
  40641. get invertYAxis(): boolean;
  40642. set invertYAxis(value: boolean);
  40643. private _onGamepadConnectedObserver;
  40644. private _onGamepadDisconnectedObserver;
  40645. /**
  40646. * Attach the input controls to a specific dom element to get the input from.
  40647. * @param element Defines the element the controls should be listened from
  40648. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40649. */
  40650. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40651. /**
  40652. * Detach the current controls from the specified dom element.
  40653. * @param element Defines the element to stop listening the inputs from
  40654. */
  40655. detachControl(element: Nullable<HTMLElement>): void;
  40656. /**
  40657. * Update the current camera state depending on the inputs that have been used this frame.
  40658. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40659. */
  40660. checkInputs(): void;
  40661. /**
  40662. * Gets the class name of the current intput.
  40663. * @returns the class name
  40664. */
  40665. getClassName(): string;
  40666. /**
  40667. * Get the friendly name associated with the input class.
  40668. * @returns the input friendly name
  40669. */
  40670. getSimpleName(): string;
  40671. }
  40672. }
  40673. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40674. import { Nullable } from "babylonjs/types";
  40675. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40676. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40677. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40678. interface ArcRotateCameraInputsManager {
  40679. /**
  40680. * Add orientation input support to the input manager.
  40681. * @returns the current input manager
  40682. */
  40683. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40684. }
  40685. }
  40686. /**
  40687. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40688. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40689. */
  40690. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40691. /**
  40692. * Defines the camera the input is attached to.
  40693. */
  40694. camera: ArcRotateCamera;
  40695. /**
  40696. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40697. */
  40698. alphaCorrection: number;
  40699. /**
  40700. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40701. */
  40702. gammaCorrection: number;
  40703. private _alpha;
  40704. private _gamma;
  40705. private _dirty;
  40706. private _deviceOrientationHandler;
  40707. /**
  40708. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40709. */
  40710. constructor();
  40711. /**
  40712. * Attach the input controls to a specific dom element to get the input from.
  40713. * @param element Defines the element the controls should be listened from
  40714. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40715. */
  40716. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40717. /** @hidden */
  40718. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40719. /**
  40720. * Update the current camera state depending on the inputs that have been used this frame.
  40721. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40722. */
  40723. checkInputs(): void;
  40724. /**
  40725. * Detach the current controls from the specified dom element.
  40726. * @param element Defines the element to stop listening the inputs from
  40727. */
  40728. detachControl(element: Nullable<HTMLElement>): void;
  40729. /**
  40730. * Gets the class name of the current intput.
  40731. * @returns the class name
  40732. */
  40733. getClassName(): string;
  40734. /**
  40735. * Get the friendly name associated with the input class.
  40736. * @returns the input friendly name
  40737. */
  40738. getSimpleName(): string;
  40739. }
  40740. }
  40741. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  40742. import { Nullable } from "babylonjs/types";
  40743. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40744. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40745. /**
  40746. * Listen to mouse events to control the camera.
  40747. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40748. */
  40749. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40750. /**
  40751. * Defines the camera the input is attached to.
  40752. */
  40753. camera: FlyCamera;
  40754. /**
  40755. * Defines if touch is enabled. (Default is true.)
  40756. */
  40757. touchEnabled: boolean;
  40758. /**
  40759. * Defines the buttons associated with the input to handle camera rotation.
  40760. */
  40761. buttons: number[];
  40762. /**
  40763. * Assign buttons for Yaw control.
  40764. */
  40765. buttonsYaw: number[];
  40766. /**
  40767. * Assign buttons for Pitch control.
  40768. */
  40769. buttonsPitch: number[];
  40770. /**
  40771. * Assign buttons for Roll control.
  40772. */
  40773. buttonsRoll: number[];
  40774. /**
  40775. * Detect if any button is being pressed while mouse is moved.
  40776. * -1 = Mouse locked.
  40777. * 0 = Left button.
  40778. * 1 = Middle Button.
  40779. * 2 = Right Button.
  40780. */
  40781. activeButton: number;
  40782. /**
  40783. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40784. * Higher values reduce its sensitivity.
  40785. */
  40786. angularSensibility: number;
  40787. private _mousemoveCallback;
  40788. private _observer;
  40789. private _rollObserver;
  40790. private previousPosition;
  40791. private noPreventDefault;
  40792. private element;
  40793. /**
  40794. * Listen to mouse events to control the camera.
  40795. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40796. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40797. */
  40798. constructor(touchEnabled?: boolean);
  40799. /**
  40800. * Attach the mouse control to the HTML DOM element.
  40801. * @param element Defines the element that listens to the input events.
  40802. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40803. */
  40804. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40805. /**
  40806. * Detach the current controls from the specified dom element.
  40807. * @param element Defines the element to stop listening the inputs from
  40808. */
  40809. detachControl(element: Nullable<HTMLElement>): void;
  40810. /**
  40811. * Gets the class name of the current input.
  40812. * @returns the class name.
  40813. */
  40814. getClassName(): string;
  40815. /**
  40816. * Get the friendly name associated with the input class.
  40817. * @returns the input's friendly name.
  40818. */
  40819. getSimpleName(): string;
  40820. private _pointerInput;
  40821. private _onMouseMove;
  40822. /**
  40823. * Rotate camera by mouse offset.
  40824. */
  40825. private rotateCamera;
  40826. }
  40827. }
  40828. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  40829. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40830. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40831. /**
  40832. * Default Inputs manager for the FlyCamera.
  40833. * It groups all the default supported inputs for ease of use.
  40834. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40835. */
  40836. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40837. /**
  40838. * Instantiates a new FlyCameraInputsManager.
  40839. * @param camera Defines the camera the inputs belong to.
  40840. */
  40841. constructor(camera: FlyCamera);
  40842. /**
  40843. * Add keyboard input support to the input manager.
  40844. * @returns the new FlyCameraKeyboardMoveInput().
  40845. */
  40846. addKeyboard(): FlyCameraInputsManager;
  40847. /**
  40848. * Add mouse input support to the input manager.
  40849. * @param touchEnabled Enable touch screen support.
  40850. * @returns the new FlyCameraMouseInput().
  40851. */
  40852. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40853. }
  40854. }
  40855. declare module "babylonjs/Cameras/flyCamera" {
  40856. import { Scene } from "babylonjs/scene";
  40857. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  40858. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40859. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40860. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  40861. /**
  40862. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40863. * such as in a 3D Space Shooter or a Flight Simulator.
  40864. */
  40865. export class FlyCamera extends TargetCamera {
  40866. /**
  40867. * Define the collision ellipsoid of the camera.
  40868. * This is helpful for simulating a camera body, like a player's body.
  40869. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40870. */
  40871. ellipsoid: Vector3;
  40872. /**
  40873. * Define an offset for the position of the ellipsoid around the camera.
  40874. * This can be helpful if the camera is attached away from the player's body center,
  40875. * such as at its head.
  40876. */
  40877. ellipsoidOffset: Vector3;
  40878. /**
  40879. * Enable or disable collisions of the camera with the rest of the scene objects.
  40880. */
  40881. checkCollisions: boolean;
  40882. /**
  40883. * Enable or disable gravity on the camera.
  40884. */
  40885. applyGravity: boolean;
  40886. /**
  40887. * Define the current direction the camera is moving to.
  40888. */
  40889. cameraDirection: Vector3;
  40890. /**
  40891. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40892. * This overrides and empties cameraRotation.
  40893. */
  40894. rotationQuaternion: Quaternion;
  40895. /**
  40896. * Track Roll to maintain the wanted Rolling when looking around.
  40897. */
  40898. _trackRoll: number;
  40899. /**
  40900. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40901. */
  40902. rollCorrect: number;
  40903. /**
  40904. * Mimic a banked turn, Rolling the camera when Yawing.
  40905. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40906. */
  40907. bankedTurn: boolean;
  40908. /**
  40909. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40910. */
  40911. bankedTurnLimit: number;
  40912. /**
  40913. * Value of 0 disables the banked Roll.
  40914. * Value of 1 is equal to the Yaw angle in radians.
  40915. */
  40916. bankedTurnMultiplier: number;
  40917. /**
  40918. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40919. */
  40920. inputs: FlyCameraInputsManager;
  40921. /**
  40922. * Gets the input sensibility for mouse input.
  40923. * Higher values reduce sensitivity.
  40924. */
  40925. get angularSensibility(): number;
  40926. /**
  40927. * Sets the input sensibility for a mouse input.
  40928. * Higher values reduce sensitivity.
  40929. */
  40930. set angularSensibility(value: number);
  40931. /**
  40932. * Get the keys for camera movement forward.
  40933. */
  40934. get keysForward(): number[];
  40935. /**
  40936. * Set the keys for camera movement forward.
  40937. */
  40938. set keysForward(value: number[]);
  40939. /**
  40940. * Get the keys for camera movement backward.
  40941. */
  40942. get keysBackward(): number[];
  40943. set keysBackward(value: number[]);
  40944. /**
  40945. * Get the keys for camera movement up.
  40946. */
  40947. get keysUp(): number[];
  40948. /**
  40949. * Set the keys for camera movement up.
  40950. */
  40951. set keysUp(value: number[]);
  40952. /**
  40953. * Get the keys for camera movement down.
  40954. */
  40955. get keysDown(): number[];
  40956. /**
  40957. * Set the keys for camera movement down.
  40958. */
  40959. set keysDown(value: number[]);
  40960. /**
  40961. * Get the keys for camera movement left.
  40962. */
  40963. get keysLeft(): number[];
  40964. /**
  40965. * Set the keys for camera movement left.
  40966. */
  40967. set keysLeft(value: number[]);
  40968. /**
  40969. * Set the keys for camera movement right.
  40970. */
  40971. get keysRight(): number[];
  40972. /**
  40973. * Set the keys for camera movement right.
  40974. */
  40975. set keysRight(value: number[]);
  40976. /**
  40977. * Event raised when the camera collides with a mesh in the scene.
  40978. */
  40979. onCollide: (collidedMesh: AbstractMesh) => void;
  40980. private _collider;
  40981. private _needMoveForGravity;
  40982. private _oldPosition;
  40983. private _diffPosition;
  40984. private _newPosition;
  40985. /** @hidden */
  40986. _localDirection: Vector3;
  40987. /** @hidden */
  40988. _transformedDirection: Vector3;
  40989. /**
  40990. * Instantiates a FlyCamera.
  40991. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40992. * such as in a 3D Space Shooter or a Flight Simulator.
  40993. * @param name Define the name of the camera in the scene.
  40994. * @param position Define the starting position of the camera in the scene.
  40995. * @param scene Define the scene the camera belongs to.
  40996. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40997. */
  40998. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40999. /**
  41000. * Attach a control to the HTML DOM element.
  41001. * @param element Defines the element that listens to the input events.
  41002. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41003. */
  41004. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41005. /**
  41006. * Detach a control from the HTML DOM element.
  41007. * The camera will stop reacting to that input.
  41008. * @param element Defines the element that listens to the input events.
  41009. */
  41010. detachControl(element: HTMLElement): void;
  41011. private _collisionMask;
  41012. /**
  41013. * Get the mask that the camera ignores in collision events.
  41014. */
  41015. get collisionMask(): number;
  41016. /**
  41017. * Set the mask that the camera ignores in collision events.
  41018. */
  41019. set collisionMask(mask: number);
  41020. /** @hidden */
  41021. _collideWithWorld(displacement: Vector3): void;
  41022. /** @hidden */
  41023. private _onCollisionPositionChange;
  41024. /** @hidden */
  41025. _checkInputs(): void;
  41026. /** @hidden */
  41027. _decideIfNeedsToMove(): boolean;
  41028. /** @hidden */
  41029. _updatePosition(): void;
  41030. /**
  41031. * Restore the Roll to its target value at the rate specified.
  41032. * @param rate - Higher means slower restoring.
  41033. * @hidden
  41034. */
  41035. restoreRoll(rate: number): void;
  41036. /**
  41037. * Destroy the camera and release the current resources held by it.
  41038. */
  41039. dispose(): void;
  41040. /**
  41041. * Get the current object class name.
  41042. * @returns the class name.
  41043. */
  41044. getClassName(): string;
  41045. }
  41046. }
  41047. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41048. import { Nullable } from "babylonjs/types";
  41049. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41050. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41051. /**
  41052. * Listen to keyboard events to control the camera.
  41053. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41054. */
  41055. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41056. /**
  41057. * Defines the camera the input is attached to.
  41058. */
  41059. camera: FlyCamera;
  41060. /**
  41061. * The list of keyboard keys used to control the forward move of the camera.
  41062. */
  41063. keysForward: number[];
  41064. /**
  41065. * The list of keyboard keys used to control the backward move of the camera.
  41066. */
  41067. keysBackward: number[];
  41068. /**
  41069. * The list of keyboard keys used to control the forward move of the camera.
  41070. */
  41071. keysUp: number[];
  41072. /**
  41073. * The list of keyboard keys used to control the backward move of the camera.
  41074. */
  41075. keysDown: number[];
  41076. /**
  41077. * The list of keyboard keys used to control the right strafe move of the camera.
  41078. */
  41079. keysRight: number[];
  41080. /**
  41081. * The list of keyboard keys used to control the left strafe move of the camera.
  41082. */
  41083. keysLeft: number[];
  41084. private _keys;
  41085. private _onCanvasBlurObserver;
  41086. private _onKeyboardObserver;
  41087. private _engine;
  41088. private _scene;
  41089. /**
  41090. * Attach the input controls to a specific dom element to get the input from.
  41091. * @param element Defines the element the controls should be listened from
  41092. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41093. */
  41094. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41095. /**
  41096. * Detach the current controls from the specified dom element.
  41097. * @param element Defines the element to stop listening the inputs from
  41098. */
  41099. detachControl(element: Nullable<HTMLElement>): void;
  41100. /**
  41101. * Gets the class name of the current intput.
  41102. * @returns the class name
  41103. */
  41104. getClassName(): string;
  41105. /** @hidden */
  41106. _onLostFocus(e: FocusEvent): void;
  41107. /**
  41108. * Get the friendly name associated with the input class.
  41109. * @returns the input friendly name
  41110. */
  41111. getSimpleName(): string;
  41112. /**
  41113. * Update the current camera state depending on the inputs that have been used this frame.
  41114. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41115. */
  41116. checkInputs(): void;
  41117. }
  41118. }
  41119. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41120. import { Nullable } from "babylonjs/types";
  41121. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41122. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41123. /**
  41124. * Manage the mouse wheel inputs to control a follow camera.
  41125. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41126. */
  41127. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41128. /**
  41129. * Defines the camera the input is attached to.
  41130. */
  41131. camera: FollowCamera;
  41132. /**
  41133. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41134. */
  41135. axisControlRadius: boolean;
  41136. /**
  41137. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41138. */
  41139. axisControlHeight: boolean;
  41140. /**
  41141. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41142. */
  41143. axisControlRotation: boolean;
  41144. /**
  41145. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41146. * relation to mouseWheel events.
  41147. */
  41148. wheelPrecision: number;
  41149. /**
  41150. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41151. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41152. */
  41153. wheelDeltaPercentage: number;
  41154. private _wheel;
  41155. private _observer;
  41156. /**
  41157. * Attach the input controls to a specific dom element to get the input from.
  41158. * @param element Defines the element the controls should be listened from
  41159. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41160. */
  41161. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41162. /**
  41163. * Detach the current controls from the specified dom element.
  41164. * @param element Defines the element to stop listening the inputs from
  41165. */
  41166. detachControl(element: Nullable<HTMLElement>): void;
  41167. /**
  41168. * Gets the class name of the current intput.
  41169. * @returns the class name
  41170. */
  41171. getClassName(): string;
  41172. /**
  41173. * Get the friendly name associated with the input class.
  41174. * @returns the input friendly name
  41175. */
  41176. getSimpleName(): string;
  41177. }
  41178. }
  41179. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41180. import { Nullable } from "babylonjs/types";
  41181. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41182. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41183. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41184. /**
  41185. * Manage the pointers inputs to control an follow camera.
  41186. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41187. */
  41188. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41189. /**
  41190. * Defines the camera the input is attached to.
  41191. */
  41192. camera: FollowCamera;
  41193. /**
  41194. * Gets the class name of the current input.
  41195. * @returns the class name
  41196. */
  41197. getClassName(): string;
  41198. /**
  41199. * Defines the pointer angular sensibility along the X axis or how fast is
  41200. * the camera rotating.
  41201. * A negative number will reverse the axis direction.
  41202. */
  41203. angularSensibilityX: number;
  41204. /**
  41205. * Defines the pointer angular sensibility along the Y axis or how fast is
  41206. * the camera rotating.
  41207. * A negative number will reverse the axis direction.
  41208. */
  41209. angularSensibilityY: number;
  41210. /**
  41211. * Defines the pointer pinch precision or how fast is the camera zooming.
  41212. * A negative number will reverse the axis direction.
  41213. */
  41214. pinchPrecision: number;
  41215. /**
  41216. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41217. * from 0.
  41218. * It defines the percentage of current camera.radius to use as delta when
  41219. * pinch zoom is used.
  41220. */
  41221. pinchDeltaPercentage: number;
  41222. /**
  41223. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41224. */
  41225. axisXControlRadius: boolean;
  41226. /**
  41227. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41228. */
  41229. axisXControlHeight: boolean;
  41230. /**
  41231. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41232. */
  41233. axisXControlRotation: boolean;
  41234. /**
  41235. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41236. */
  41237. axisYControlRadius: boolean;
  41238. /**
  41239. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41240. */
  41241. axisYControlHeight: boolean;
  41242. /**
  41243. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41244. */
  41245. axisYControlRotation: boolean;
  41246. /**
  41247. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41248. */
  41249. axisPinchControlRadius: boolean;
  41250. /**
  41251. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41252. */
  41253. axisPinchControlHeight: boolean;
  41254. /**
  41255. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41256. */
  41257. axisPinchControlRotation: boolean;
  41258. /**
  41259. * Log error messages if basic misconfiguration has occurred.
  41260. */
  41261. warningEnable: boolean;
  41262. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41263. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41264. private _warningCounter;
  41265. private _warning;
  41266. }
  41267. }
  41268. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41269. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41270. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41271. /**
  41272. * Default Inputs manager for the FollowCamera.
  41273. * It groups all the default supported inputs for ease of use.
  41274. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41275. */
  41276. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41277. /**
  41278. * Instantiates a new FollowCameraInputsManager.
  41279. * @param camera Defines the camera the inputs belong to
  41280. */
  41281. constructor(camera: FollowCamera);
  41282. /**
  41283. * Add keyboard input support to the input manager.
  41284. * @returns the current input manager
  41285. */
  41286. addKeyboard(): FollowCameraInputsManager;
  41287. /**
  41288. * Add mouse wheel input support to the input manager.
  41289. * @returns the current input manager
  41290. */
  41291. addMouseWheel(): FollowCameraInputsManager;
  41292. /**
  41293. * Add pointers input support to the input manager.
  41294. * @returns the current input manager
  41295. */
  41296. addPointers(): FollowCameraInputsManager;
  41297. /**
  41298. * Add orientation input support to the input manager.
  41299. * @returns the current input manager
  41300. */
  41301. addVRDeviceOrientation(): FollowCameraInputsManager;
  41302. }
  41303. }
  41304. declare module "babylonjs/Cameras/followCamera" {
  41305. import { Nullable } from "babylonjs/types";
  41306. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41307. import { Scene } from "babylonjs/scene";
  41308. import { Vector3 } from "babylonjs/Maths/math.vector";
  41309. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41310. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41311. /**
  41312. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41313. * an arc rotate version arcFollowCamera are available.
  41314. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41315. */
  41316. export class FollowCamera extends TargetCamera {
  41317. /**
  41318. * Distance the follow camera should follow an object at
  41319. */
  41320. radius: number;
  41321. /**
  41322. * Minimum allowed distance of the camera to the axis of rotation
  41323. * (The camera can not get closer).
  41324. * This can help limiting how the Camera is able to move in the scene.
  41325. */
  41326. lowerRadiusLimit: Nullable<number>;
  41327. /**
  41328. * Maximum allowed distance of the camera to the axis of rotation
  41329. * (The camera can not get further).
  41330. * This can help limiting how the Camera is able to move in the scene.
  41331. */
  41332. upperRadiusLimit: Nullable<number>;
  41333. /**
  41334. * Define a rotation offset between the camera and the object it follows
  41335. */
  41336. rotationOffset: number;
  41337. /**
  41338. * Minimum allowed angle to camera position relative to target object.
  41339. * This can help limiting how the Camera is able to move in the scene.
  41340. */
  41341. lowerRotationOffsetLimit: Nullable<number>;
  41342. /**
  41343. * Maximum allowed angle to camera position relative to target object.
  41344. * This can help limiting how the Camera is able to move in the scene.
  41345. */
  41346. upperRotationOffsetLimit: Nullable<number>;
  41347. /**
  41348. * Define a height offset between the camera and the object it follows.
  41349. * It can help following an object from the top (like a car chaing a plane)
  41350. */
  41351. heightOffset: number;
  41352. /**
  41353. * Minimum allowed height of camera position relative to target object.
  41354. * This can help limiting how the Camera is able to move in the scene.
  41355. */
  41356. lowerHeightOffsetLimit: Nullable<number>;
  41357. /**
  41358. * Maximum allowed height of camera position relative to target object.
  41359. * This can help limiting how the Camera is able to move in the scene.
  41360. */
  41361. upperHeightOffsetLimit: Nullable<number>;
  41362. /**
  41363. * Define how fast the camera can accelerate to follow it s target.
  41364. */
  41365. cameraAcceleration: number;
  41366. /**
  41367. * Define the speed limit of the camera following an object.
  41368. */
  41369. maxCameraSpeed: number;
  41370. /**
  41371. * Define the target of the camera.
  41372. */
  41373. lockedTarget: Nullable<AbstractMesh>;
  41374. /**
  41375. * Defines the input associated with the camera.
  41376. */
  41377. inputs: FollowCameraInputsManager;
  41378. /**
  41379. * Instantiates the follow camera.
  41380. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41381. * @param name Define the name of the camera in the scene
  41382. * @param position Define the position of the camera
  41383. * @param scene Define the scene the camera belong to
  41384. * @param lockedTarget Define the target of the camera
  41385. */
  41386. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41387. private _follow;
  41388. /**
  41389. * Attached controls to the current camera.
  41390. * @param element Defines the element the controls should be listened from
  41391. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41392. */
  41393. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41394. /**
  41395. * Detach the current controls from the camera.
  41396. * The camera will stop reacting to inputs.
  41397. * @param element Defines the element to stop listening the inputs from
  41398. */
  41399. detachControl(element: HTMLElement): void;
  41400. /** @hidden */
  41401. _checkInputs(): void;
  41402. private _checkLimits;
  41403. /**
  41404. * Gets the camera class name.
  41405. * @returns the class name
  41406. */
  41407. getClassName(): string;
  41408. }
  41409. /**
  41410. * Arc Rotate version of the follow camera.
  41411. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41412. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41413. */
  41414. export class ArcFollowCamera extends TargetCamera {
  41415. /** The longitudinal angle of the camera */
  41416. alpha: number;
  41417. /** The latitudinal angle of the camera */
  41418. beta: number;
  41419. /** The radius of the camera from its target */
  41420. radius: number;
  41421. /** Define the camera target (the messh it should follow) */
  41422. target: Nullable<AbstractMesh>;
  41423. private _cartesianCoordinates;
  41424. /**
  41425. * Instantiates a new ArcFollowCamera
  41426. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41427. * @param name Define the name of the camera
  41428. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41429. * @param beta Define the rotation angle of the camera around the elevation axis
  41430. * @param radius Define the radius of the camera from its target point
  41431. * @param target Define the target of the camera
  41432. * @param scene Define the scene the camera belongs to
  41433. */
  41434. constructor(name: string,
  41435. /** The longitudinal angle of the camera */
  41436. alpha: number,
  41437. /** The latitudinal angle of the camera */
  41438. beta: number,
  41439. /** The radius of the camera from its target */
  41440. radius: number,
  41441. /** Define the camera target (the messh it should follow) */
  41442. target: Nullable<AbstractMesh>, scene: Scene);
  41443. private _follow;
  41444. /** @hidden */
  41445. _checkInputs(): void;
  41446. /**
  41447. * Returns the class name of the object.
  41448. * It is mostly used internally for serialization purposes.
  41449. */
  41450. getClassName(): string;
  41451. }
  41452. }
  41453. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41454. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41455. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41456. import { Nullable } from "babylonjs/types";
  41457. /**
  41458. * Manage the keyboard inputs to control the movement of a follow camera.
  41459. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41460. */
  41461. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41462. /**
  41463. * Defines the camera the input is attached to.
  41464. */
  41465. camera: FollowCamera;
  41466. /**
  41467. * Defines the list of key codes associated with the up action (increase heightOffset)
  41468. */
  41469. keysHeightOffsetIncr: number[];
  41470. /**
  41471. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41472. */
  41473. keysHeightOffsetDecr: number[];
  41474. /**
  41475. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41476. */
  41477. keysHeightOffsetModifierAlt: boolean;
  41478. /**
  41479. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41480. */
  41481. keysHeightOffsetModifierCtrl: boolean;
  41482. /**
  41483. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41484. */
  41485. keysHeightOffsetModifierShift: boolean;
  41486. /**
  41487. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41488. */
  41489. keysRotationOffsetIncr: number[];
  41490. /**
  41491. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41492. */
  41493. keysRotationOffsetDecr: number[];
  41494. /**
  41495. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41496. */
  41497. keysRotationOffsetModifierAlt: boolean;
  41498. /**
  41499. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41500. */
  41501. keysRotationOffsetModifierCtrl: boolean;
  41502. /**
  41503. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41504. */
  41505. keysRotationOffsetModifierShift: boolean;
  41506. /**
  41507. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41508. */
  41509. keysRadiusIncr: number[];
  41510. /**
  41511. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41512. */
  41513. keysRadiusDecr: number[];
  41514. /**
  41515. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41516. */
  41517. keysRadiusModifierAlt: boolean;
  41518. /**
  41519. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41520. */
  41521. keysRadiusModifierCtrl: boolean;
  41522. /**
  41523. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41524. */
  41525. keysRadiusModifierShift: boolean;
  41526. /**
  41527. * Defines the rate of change of heightOffset.
  41528. */
  41529. heightSensibility: number;
  41530. /**
  41531. * Defines the rate of change of rotationOffset.
  41532. */
  41533. rotationSensibility: number;
  41534. /**
  41535. * Defines the rate of change of radius.
  41536. */
  41537. radiusSensibility: number;
  41538. private _keys;
  41539. private _ctrlPressed;
  41540. private _altPressed;
  41541. private _shiftPressed;
  41542. private _onCanvasBlurObserver;
  41543. private _onKeyboardObserver;
  41544. private _engine;
  41545. private _scene;
  41546. /**
  41547. * Attach the input controls to a specific dom element to get the input from.
  41548. * @param element Defines the element the controls should be listened from
  41549. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41550. */
  41551. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41552. /**
  41553. * Detach the current controls from the specified dom element.
  41554. * @param element Defines the element to stop listening the inputs from
  41555. */
  41556. detachControl(element: Nullable<HTMLElement>): void;
  41557. /**
  41558. * Update the current camera state depending on the inputs that have been used this frame.
  41559. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41560. */
  41561. checkInputs(): void;
  41562. /**
  41563. * Gets the class name of the current input.
  41564. * @returns the class name
  41565. */
  41566. getClassName(): string;
  41567. /**
  41568. * Get the friendly name associated with the input class.
  41569. * @returns the input friendly name
  41570. */
  41571. getSimpleName(): string;
  41572. /**
  41573. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41574. * allow modification of the heightOffset value.
  41575. */
  41576. private _modifierHeightOffset;
  41577. /**
  41578. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41579. * allow modification of the rotationOffset value.
  41580. */
  41581. private _modifierRotationOffset;
  41582. /**
  41583. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41584. * allow modification of the radius value.
  41585. */
  41586. private _modifierRadius;
  41587. }
  41588. }
  41589. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41590. import { Nullable } from "babylonjs/types";
  41591. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41592. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41593. import { Observable } from "babylonjs/Misc/observable";
  41594. module "babylonjs/Cameras/freeCameraInputsManager" {
  41595. interface FreeCameraInputsManager {
  41596. /**
  41597. * @hidden
  41598. */
  41599. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41600. /**
  41601. * Add orientation input support to the input manager.
  41602. * @returns the current input manager
  41603. */
  41604. addDeviceOrientation(): FreeCameraInputsManager;
  41605. }
  41606. }
  41607. /**
  41608. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41609. * Screen rotation is taken into account.
  41610. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41611. */
  41612. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41613. private _camera;
  41614. private _screenOrientationAngle;
  41615. private _constantTranform;
  41616. private _screenQuaternion;
  41617. private _alpha;
  41618. private _beta;
  41619. private _gamma;
  41620. /**
  41621. * Can be used to detect if a device orientation sensor is available on a device
  41622. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41623. * @returns a promise that will resolve on orientation change
  41624. */
  41625. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41626. /**
  41627. * @hidden
  41628. */
  41629. _onDeviceOrientationChangedObservable: Observable<void>;
  41630. /**
  41631. * Instantiates a new input
  41632. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41633. */
  41634. constructor();
  41635. /**
  41636. * Define the camera controlled by the input.
  41637. */
  41638. get camera(): FreeCamera;
  41639. set camera(camera: FreeCamera);
  41640. /**
  41641. * Attach the input controls to a specific dom element to get the input from.
  41642. * @param element Defines the element the controls should be listened from
  41643. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41644. */
  41645. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41646. private _orientationChanged;
  41647. private _deviceOrientation;
  41648. /**
  41649. * Detach the current controls from the specified dom element.
  41650. * @param element Defines the element to stop listening the inputs from
  41651. */
  41652. detachControl(element: Nullable<HTMLElement>): void;
  41653. /**
  41654. * Update the current camera state depending on the inputs that have been used this frame.
  41655. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41656. */
  41657. checkInputs(): void;
  41658. /**
  41659. * Gets the class name of the current intput.
  41660. * @returns the class name
  41661. */
  41662. getClassName(): string;
  41663. /**
  41664. * Get the friendly name associated with the input class.
  41665. * @returns the input friendly name
  41666. */
  41667. getSimpleName(): string;
  41668. }
  41669. }
  41670. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41671. import { Nullable } from "babylonjs/types";
  41672. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41673. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41674. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41675. /**
  41676. * Manage the gamepad inputs to control a free camera.
  41677. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41678. */
  41679. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41680. /**
  41681. * Define the camera the input is attached to.
  41682. */
  41683. camera: FreeCamera;
  41684. /**
  41685. * Define the Gamepad controlling the input
  41686. */
  41687. gamepad: Nullable<Gamepad>;
  41688. /**
  41689. * Defines the gamepad rotation sensiblity.
  41690. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41691. */
  41692. gamepadAngularSensibility: number;
  41693. /**
  41694. * Defines the gamepad move sensiblity.
  41695. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41696. */
  41697. gamepadMoveSensibility: number;
  41698. private _yAxisScale;
  41699. /**
  41700. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41701. */
  41702. get invertYAxis(): boolean;
  41703. set invertYAxis(value: boolean);
  41704. private _onGamepadConnectedObserver;
  41705. private _onGamepadDisconnectedObserver;
  41706. private _cameraTransform;
  41707. private _deltaTransform;
  41708. private _vector3;
  41709. private _vector2;
  41710. /**
  41711. * Attach the input controls to a specific dom element to get the input from.
  41712. * @param element Defines the element the controls should be listened from
  41713. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41714. */
  41715. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41716. /**
  41717. * Detach the current controls from the specified dom element.
  41718. * @param element Defines the element to stop listening the inputs from
  41719. */
  41720. detachControl(element: Nullable<HTMLElement>): void;
  41721. /**
  41722. * Update the current camera state depending on the inputs that have been used this frame.
  41723. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41724. */
  41725. checkInputs(): void;
  41726. /**
  41727. * Gets the class name of the current intput.
  41728. * @returns the class name
  41729. */
  41730. getClassName(): string;
  41731. /**
  41732. * Get the friendly name associated with the input class.
  41733. * @returns the input friendly name
  41734. */
  41735. getSimpleName(): string;
  41736. }
  41737. }
  41738. declare module "babylonjs/Misc/virtualJoystick" {
  41739. import { Nullable } from "babylonjs/types";
  41740. import { Vector3 } from "babylonjs/Maths/math.vector";
  41741. /**
  41742. * Defines the potential axis of a Joystick
  41743. */
  41744. export enum JoystickAxis {
  41745. /** X axis */
  41746. X = 0,
  41747. /** Y axis */
  41748. Y = 1,
  41749. /** Z axis */
  41750. Z = 2
  41751. }
  41752. /**
  41753. * Class used to define virtual joystick (used in touch mode)
  41754. */
  41755. export class VirtualJoystick {
  41756. /**
  41757. * Gets or sets a boolean indicating that left and right values must be inverted
  41758. */
  41759. reverseLeftRight: boolean;
  41760. /**
  41761. * Gets or sets a boolean indicating that up and down values must be inverted
  41762. */
  41763. reverseUpDown: boolean;
  41764. /**
  41765. * Gets the offset value for the position (ie. the change of the position value)
  41766. */
  41767. deltaPosition: Vector3;
  41768. /**
  41769. * Gets a boolean indicating if the virtual joystick was pressed
  41770. */
  41771. pressed: boolean;
  41772. /**
  41773. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41774. */
  41775. static Canvas: Nullable<HTMLCanvasElement>;
  41776. private static _globalJoystickIndex;
  41777. private static vjCanvasContext;
  41778. private static vjCanvasWidth;
  41779. private static vjCanvasHeight;
  41780. private static halfWidth;
  41781. private _action;
  41782. private _axisTargetedByLeftAndRight;
  41783. private _axisTargetedByUpAndDown;
  41784. private _joystickSensibility;
  41785. private _inversedSensibility;
  41786. private _joystickPointerID;
  41787. private _joystickColor;
  41788. private _joystickPointerPos;
  41789. private _joystickPreviousPointerPos;
  41790. private _joystickPointerStartPos;
  41791. private _deltaJoystickVector;
  41792. private _leftJoystick;
  41793. private _touches;
  41794. private _onPointerDownHandlerRef;
  41795. private _onPointerMoveHandlerRef;
  41796. private _onPointerUpHandlerRef;
  41797. private _onResize;
  41798. /**
  41799. * Creates a new virtual joystick
  41800. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41801. */
  41802. constructor(leftJoystick?: boolean);
  41803. /**
  41804. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41805. * @param newJoystickSensibility defines the new sensibility
  41806. */
  41807. setJoystickSensibility(newJoystickSensibility: number): void;
  41808. private _onPointerDown;
  41809. private _onPointerMove;
  41810. private _onPointerUp;
  41811. /**
  41812. * Change the color of the virtual joystick
  41813. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41814. */
  41815. setJoystickColor(newColor: string): void;
  41816. /**
  41817. * Defines a callback to call when the joystick is touched
  41818. * @param action defines the callback
  41819. */
  41820. setActionOnTouch(action: () => any): void;
  41821. /**
  41822. * Defines which axis you'd like to control for left & right
  41823. * @param axis defines the axis to use
  41824. */
  41825. setAxisForLeftRight(axis: JoystickAxis): void;
  41826. /**
  41827. * Defines which axis you'd like to control for up & down
  41828. * @param axis defines the axis to use
  41829. */
  41830. setAxisForUpDown(axis: JoystickAxis): void;
  41831. private _drawVirtualJoystick;
  41832. /**
  41833. * Release internal HTML canvas
  41834. */
  41835. releaseCanvas(): void;
  41836. }
  41837. }
  41838. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  41839. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  41840. import { Nullable } from "babylonjs/types";
  41841. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41842. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41843. module "babylonjs/Cameras/freeCameraInputsManager" {
  41844. interface FreeCameraInputsManager {
  41845. /**
  41846. * Add virtual joystick input support to the input manager.
  41847. * @returns the current input manager
  41848. */
  41849. addVirtualJoystick(): FreeCameraInputsManager;
  41850. }
  41851. }
  41852. /**
  41853. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41854. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41855. */
  41856. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41857. /**
  41858. * Defines the camera the input is attached to.
  41859. */
  41860. camera: FreeCamera;
  41861. private _leftjoystick;
  41862. private _rightjoystick;
  41863. /**
  41864. * Gets the left stick of the virtual joystick.
  41865. * @returns The virtual Joystick
  41866. */
  41867. getLeftJoystick(): VirtualJoystick;
  41868. /**
  41869. * Gets the right stick of the virtual joystick.
  41870. * @returns The virtual Joystick
  41871. */
  41872. getRightJoystick(): VirtualJoystick;
  41873. /**
  41874. * Update the current camera state depending on the inputs that have been used this frame.
  41875. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41876. */
  41877. checkInputs(): void;
  41878. /**
  41879. * Attach the input controls to a specific dom element to get the input from.
  41880. * @param element Defines the element the controls should be listened from
  41881. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41882. */
  41883. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41884. /**
  41885. * Detach the current controls from the specified dom element.
  41886. * @param element Defines the element to stop listening the inputs from
  41887. */
  41888. detachControl(element: Nullable<HTMLElement>): void;
  41889. /**
  41890. * Gets the class name of the current intput.
  41891. * @returns the class name
  41892. */
  41893. getClassName(): string;
  41894. /**
  41895. * Get the friendly name associated with the input class.
  41896. * @returns the input friendly name
  41897. */
  41898. getSimpleName(): string;
  41899. }
  41900. }
  41901. declare module "babylonjs/Cameras/Inputs/index" {
  41902. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  41903. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  41904. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  41905. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  41906. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41907. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  41908. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  41909. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  41910. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  41911. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  41912. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41913. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  41914. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  41915. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  41916. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  41917. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41918. }
  41919. declare module "babylonjs/Cameras/touchCamera" {
  41920. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41921. import { Scene } from "babylonjs/scene";
  41922. import { Vector3 } from "babylonjs/Maths/math.vector";
  41923. /**
  41924. * This represents a FPS type of camera controlled by touch.
  41925. * This is like a universal camera minus the Gamepad controls.
  41926. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41927. */
  41928. export class TouchCamera extends FreeCamera {
  41929. /**
  41930. * Defines the touch sensibility for rotation.
  41931. * The higher the faster.
  41932. */
  41933. get touchAngularSensibility(): number;
  41934. set touchAngularSensibility(value: number);
  41935. /**
  41936. * Defines the touch sensibility for move.
  41937. * The higher the faster.
  41938. */
  41939. get touchMoveSensibility(): number;
  41940. set touchMoveSensibility(value: number);
  41941. /**
  41942. * Instantiates a new touch camera.
  41943. * This represents a FPS type of camera controlled by touch.
  41944. * This is like a universal camera minus the Gamepad controls.
  41945. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41946. * @param name Define the name of the camera in the scene
  41947. * @param position Define the start position of the camera in the scene
  41948. * @param scene Define the scene the camera belongs to
  41949. */
  41950. constructor(name: string, position: Vector3, scene: Scene);
  41951. /**
  41952. * Gets the current object class name.
  41953. * @return the class name
  41954. */
  41955. getClassName(): string;
  41956. /** @hidden */
  41957. _setupInputs(): void;
  41958. }
  41959. }
  41960. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  41961. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41962. import { Scene } from "babylonjs/scene";
  41963. import { Vector3 } from "babylonjs/Maths/math.vector";
  41964. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41965. import { Axis } from "babylonjs/Maths/math.axis";
  41966. /**
  41967. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41968. * being tilted forward or back and left or right.
  41969. */
  41970. export class DeviceOrientationCamera extends FreeCamera {
  41971. private _initialQuaternion;
  41972. private _quaternionCache;
  41973. private _tmpDragQuaternion;
  41974. private _disablePointerInputWhenUsingDeviceOrientation;
  41975. /**
  41976. * Creates a new device orientation camera
  41977. * @param name The name of the camera
  41978. * @param position The start position camera
  41979. * @param scene The scene the camera belongs to
  41980. */
  41981. constructor(name: string, position: Vector3, scene: Scene);
  41982. /**
  41983. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41984. */
  41985. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41986. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41987. private _dragFactor;
  41988. /**
  41989. * Enabled turning on the y axis when the orientation sensor is active
  41990. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41991. */
  41992. enableHorizontalDragging(dragFactor?: number): void;
  41993. /**
  41994. * Gets the current instance class name ("DeviceOrientationCamera").
  41995. * This helps avoiding instanceof at run time.
  41996. * @returns the class name
  41997. */
  41998. getClassName(): string;
  41999. /**
  42000. * @hidden
  42001. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42002. */
  42003. _checkInputs(): void;
  42004. /**
  42005. * Reset the camera to its default orientation on the specified axis only.
  42006. * @param axis The axis to reset
  42007. */
  42008. resetToCurrentRotation(axis?: Axis): void;
  42009. }
  42010. }
  42011. declare module "babylonjs/Gamepads/xboxGamepad" {
  42012. import { Observable } from "babylonjs/Misc/observable";
  42013. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42014. /**
  42015. * Defines supported buttons for XBox360 compatible gamepads
  42016. */
  42017. export enum Xbox360Button {
  42018. /** A */
  42019. A = 0,
  42020. /** B */
  42021. B = 1,
  42022. /** X */
  42023. X = 2,
  42024. /** Y */
  42025. Y = 3,
  42026. /** Start */
  42027. Start = 4,
  42028. /** Back */
  42029. Back = 5,
  42030. /** Left button */
  42031. LB = 6,
  42032. /** Right button */
  42033. RB = 7,
  42034. /** Left stick */
  42035. LeftStick = 8,
  42036. /** Right stick */
  42037. RightStick = 9
  42038. }
  42039. /** Defines values for XBox360 DPad */
  42040. export enum Xbox360Dpad {
  42041. /** Up */
  42042. Up = 0,
  42043. /** Down */
  42044. Down = 1,
  42045. /** Left */
  42046. Left = 2,
  42047. /** Right */
  42048. Right = 3
  42049. }
  42050. /**
  42051. * Defines a XBox360 gamepad
  42052. */
  42053. export class Xbox360Pad extends Gamepad {
  42054. private _leftTrigger;
  42055. private _rightTrigger;
  42056. private _onlefttriggerchanged;
  42057. private _onrighttriggerchanged;
  42058. private _onbuttondown;
  42059. private _onbuttonup;
  42060. private _ondpaddown;
  42061. private _ondpadup;
  42062. /** Observable raised when a button is pressed */
  42063. onButtonDownObservable: Observable<Xbox360Button>;
  42064. /** Observable raised when a button is released */
  42065. onButtonUpObservable: Observable<Xbox360Button>;
  42066. /** Observable raised when a pad is pressed */
  42067. onPadDownObservable: Observable<Xbox360Dpad>;
  42068. /** Observable raised when a pad is released */
  42069. onPadUpObservable: Observable<Xbox360Dpad>;
  42070. private _buttonA;
  42071. private _buttonB;
  42072. private _buttonX;
  42073. private _buttonY;
  42074. private _buttonBack;
  42075. private _buttonStart;
  42076. private _buttonLB;
  42077. private _buttonRB;
  42078. private _buttonLeftStick;
  42079. private _buttonRightStick;
  42080. private _dPadUp;
  42081. private _dPadDown;
  42082. private _dPadLeft;
  42083. private _dPadRight;
  42084. private _isXboxOnePad;
  42085. /**
  42086. * Creates a new XBox360 gamepad object
  42087. * @param id defines the id of this gamepad
  42088. * @param index defines its index
  42089. * @param gamepad defines the internal HTML gamepad object
  42090. * @param xboxOne defines if it is a XBox One gamepad
  42091. */
  42092. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42093. /**
  42094. * Defines the callback to call when left trigger is pressed
  42095. * @param callback defines the callback to use
  42096. */
  42097. onlefttriggerchanged(callback: (value: number) => void): void;
  42098. /**
  42099. * Defines the callback to call when right trigger is pressed
  42100. * @param callback defines the callback to use
  42101. */
  42102. onrighttriggerchanged(callback: (value: number) => void): void;
  42103. /**
  42104. * Gets the left trigger value
  42105. */
  42106. get leftTrigger(): number;
  42107. /**
  42108. * Sets the left trigger value
  42109. */
  42110. set leftTrigger(newValue: number);
  42111. /**
  42112. * Gets the right trigger value
  42113. */
  42114. get rightTrigger(): number;
  42115. /**
  42116. * Sets the right trigger value
  42117. */
  42118. set rightTrigger(newValue: number);
  42119. /**
  42120. * Defines the callback to call when a button is pressed
  42121. * @param callback defines the callback to use
  42122. */
  42123. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42124. /**
  42125. * Defines the callback to call when a button is released
  42126. * @param callback defines the callback to use
  42127. */
  42128. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42129. /**
  42130. * Defines the callback to call when a pad is pressed
  42131. * @param callback defines the callback to use
  42132. */
  42133. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42134. /**
  42135. * Defines the callback to call when a pad is released
  42136. * @param callback defines the callback to use
  42137. */
  42138. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42139. private _setButtonValue;
  42140. private _setDPadValue;
  42141. /**
  42142. * Gets the value of the `A` button
  42143. */
  42144. get buttonA(): number;
  42145. /**
  42146. * Sets the value of the `A` button
  42147. */
  42148. set buttonA(value: number);
  42149. /**
  42150. * Gets the value of the `B` button
  42151. */
  42152. get buttonB(): number;
  42153. /**
  42154. * Sets the value of the `B` button
  42155. */
  42156. set buttonB(value: number);
  42157. /**
  42158. * Gets the value of the `X` button
  42159. */
  42160. get buttonX(): number;
  42161. /**
  42162. * Sets the value of the `X` button
  42163. */
  42164. set buttonX(value: number);
  42165. /**
  42166. * Gets the value of the `Y` button
  42167. */
  42168. get buttonY(): number;
  42169. /**
  42170. * Sets the value of the `Y` button
  42171. */
  42172. set buttonY(value: number);
  42173. /**
  42174. * Gets the value of the `Start` button
  42175. */
  42176. get buttonStart(): number;
  42177. /**
  42178. * Sets the value of the `Start` button
  42179. */
  42180. set buttonStart(value: number);
  42181. /**
  42182. * Gets the value of the `Back` button
  42183. */
  42184. get buttonBack(): number;
  42185. /**
  42186. * Sets the value of the `Back` button
  42187. */
  42188. set buttonBack(value: number);
  42189. /**
  42190. * Gets the value of the `Left` button
  42191. */
  42192. get buttonLB(): number;
  42193. /**
  42194. * Sets the value of the `Left` button
  42195. */
  42196. set buttonLB(value: number);
  42197. /**
  42198. * Gets the value of the `Right` button
  42199. */
  42200. get buttonRB(): number;
  42201. /**
  42202. * Sets the value of the `Right` button
  42203. */
  42204. set buttonRB(value: number);
  42205. /**
  42206. * Gets the value of the Left joystick
  42207. */
  42208. get buttonLeftStick(): number;
  42209. /**
  42210. * Sets the value of the Left joystick
  42211. */
  42212. set buttonLeftStick(value: number);
  42213. /**
  42214. * Gets the value of the Right joystick
  42215. */
  42216. get buttonRightStick(): number;
  42217. /**
  42218. * Sets the value of the Right joystick
  42219. */
  42220. set buttonRightStick(value: number);
  42221. /**
  42222. * Gets the value of D-pad up
  42223. */
  42224. get dPadUp(): number;
  42225. /**
  42226. * Sets the value of D-pad up
  42227. */
  42228. set dPadUp(value: number);
  42229. /**
  42230. * Gets the value of D-pad down
  42231. */
  42232. get dPadDown(): number;
  42233. /**
  42234. * Sets the value of D-pad down
  42235. */
  42236. set dPadDown(value: number);
  42237. /**
  42238. * Gets the value of D-pad left
  42239. */
  42240. get dPadLeft(): number;
  42241. /**
  42242. * Sets the value of D-pad left
  42243. */
  42244. set dPadLeft(value: number);
  42245. /**
  42246. * Gets the value of D-pad right
  42247. */
  42248. get dPadRight(): number;
  42249. /**
  42250. * Sets the value of D-pad right
  42251. */
  42252. set dPadRight(value: number);
  42253. /**
  42254. * Force the gamepad to synchronize with device values
  42255. */
  42256. update(): void;
  42257. /**
  42258. * Disposes the gamepad
  42259. */
  42260. dispose(): void;
  42261. }
  42262. }
  42263. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42264. import { Observable } from "babylonjs/Misc/observable";
  42265. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42266. /**
  42267. * Defines supported buttons for DualShock compatible gamepads
  42268. */
  42269. export enum DualShockButton {
  42270. /** Cross */
  42271. Cross = 0,
  42272. /** Circle */
  42273. Circle = 1,
  42274. /** Square */
  42275. Square = 2,
  42276. /** Triangle */
  42277. Triangle = 3,
  42278. /** Options */
  42279. Options = 4,
  42280. /** Share */
  42281. Share = 5,
  42282. /** L1 */
  42283. L1 = 6,
  42284. /** R1 */
  42285. R1 = 7,
  42286. /** Left stick */
  42287. LeftStick = 8,
  42288. /** Right stick */
  42289. RightStick = 9
  42290. }
  42291. /** Defines values for DualShock DPad */
  42292. export enum DualShockDpad {
  42293. /** Up */
  42294. Up = 0,
  42295. /** Down */
  42296. Down = 1,
  42297. /** Left */
  42298. Left = 2,
  42299. /** Right */
  42300. Right = 3
  42301. }
  42302. /**
  42303. * Defines a DualShock gamepad
  42304. */
  42305. export class DualShockPad extends Gamepad {
  42306. private _leftTrigger;
  42307. private _rightTrigger;
  42308. private _onlefttriggerchanged;
  42309. private _onrighttriggerchanged;
  42310. private _onbuttondown;
  42311. private _onbuttonup;
  42312. private _ondpaddown;
  42313. private _ondpadup;
  42314. /** Observable raised when a button is pressed */
  42315. onButtonDownObservable: Observable<DualShockButton>;
  42316. /** Observable raised when a button is released */
  42317. onButtonUpObservable: Observable<DualShockButton>;
  42318. /** Observable raised when a pad is pressed */
  42319. onPadDownObservable: Observable<DualShockDpad>;
  42320. /** Observable raised when a pad is released */
  42321. onPadUpObservable: Observable<DualShockDpad>;
  42322. private _buttonCross;
  42323. private _buttonCircle;
  42324. private _buttonSquare;
  42325. private _buttonTriangle;
  42326. private _buttonShare;
  42327. private _buttonOptions;
  42328. private _buttonL1;
  42329. private _buttonR1;
  42330. private _buttonLeftStick;
  42331. private _buttonRightStick;
  42332. private _dPadUp;
  42333. private _dPadDown;
  42334. private _dPadLeft;
  42335. private _dPadRight;
  42336. /**
  42337. * Creates a new DualShock gamepad object
  42338. * @param id defines the id of this gamepad
  42339. * @param index defines its index
  42340. * @param gamepad defines the internal HTML gamepad object
  42341. */
  42342. constructor(id: string, index: number, gamepad: any);
  42343. /**
  42344. * Defines the callback to call when left trigger is pressed
  42345. * @param callback defines the callback to use
  42346. */
  42347. onlefttriggerchanged(callback: (value: number) => void): void;
  42348. /**
  42349. * Defines the callback to call when right trigger is pressed
  42350. * @param callback defines the callback to use
  42351. */
  42352. onrighttriggerchanged(callback: (value: number) => void): void;
  42353. /**
  42354. * Gets the left trigger value
  42355. */
  42356. get leftTrigger(): number;
  42357. /**
  42358. * Sets the left trigger value
  42359. */
  42360. set leftTrigger(newValue: number);
  42361. /**
  42362. * Gets the right trigger value
  42363. */
  42364. get rightTrigger(): number;
  42365. /**
  42366. * Sets the right trigger value
  42367. */
  42368. set rightTrigger(newValue: number);
  42369. /**
  42370. * Defines the callback to call when a button is pressed
  42371. * @param callback defines the callback to use
  42372. */
  42373. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42374. /**
  42375. * Defines the callback to call when a button is released
  42376. * @param callback defines the callback to use
  42377. */
  42378. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42379. /**
  42380. * Defines the callback to call when a pad is pressed
  42381. * @param callback defines the callback to use
  42382. */
  42383. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42384. /**
  42385. * Defines the callback to call when a pad is released
  42386. * @param callback defines the callback to use
  42387. */
  42388. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42389. private _setButtonValue;
  42390. private _setDPadValue;
  42391. /**
  42392. * Gets the value of the `Cross` button
  42393. */
  42394. get buttonCross(): number;
  42395. /**
  42396. * Sets the value of the `Cross` button
  42397. */
  42398. set buttonCross(value: number);
  42399. /**
  42400. * Gets the value of the `Circle` button
  42401. */
  42402. get buttonCircle(): number;
  42403. /**
  42404. * Sets the value of the `Circle` button
  42405. */
  42406. set buttonCircle(value: number);
  42407. /**
  42408. * Gets the value of the `Square` button
  42409. */
  42410. get buttonSquare(): number;
  42411. /**
  42412. * Sets the value of the `Square` button
  42413. */
  42414. set buttonSquare(value: number);
  42415. /**
  42416. * Gets the value of the `Triangle` button
  42417. */
  42418. get buttonTriangle(): number;
  42419. /**
  42420. * Sets the value of the `Triangle` button
  42421. */
  42422. set buttonTriangle(value: number);
  42423. /**
  42424. * Gets the value of the `Options` button
  42425. */
  42426. get buttonOptions(): number;
  42427. /**
  42428. * Sets the value of the `Options` button
  42429. */
  42430. set buttonOptions(value: number);
  42431. /**
  42432. * Gets the value of the `Share` button
  42433. */
  42434. get buttonShare(): number;
  42435. /**
  42436. * Sets the value of the `Share` button
  42437. */
  42438. set buttonShare(value: number);
  42439. /**
  42440. * Gets the value of the `L1` button
  42441. */
  42442. get buttonL1(): number;
  42443. /**
  42444. * Sets the value of the `L1` button
  42445. */
  42446. set buttonL1(value: number);
  42447. /**
  42448. * Gets the value of the `R1` button
  42449. */
  42450. get buttonR1(): number;
  42451. /**
  42452. * Sets the value of the `R1` button
  42453. */
  42454. set buttonR1(value: number);
  42455. /**
  42456. * Gets the value of the Left joystick
  42457. */
  42458. get buttonLeftStick(): number;
  42459. /**
  42460. * Sets the value of the Left joystick
  42461. */
  42462. set buttonLeftStick(value: number);
  42463. /**
  42464. * Gets the value of the Right joystick
  42465. */
  42466. get buttonRightStick(): number;
  42467. /**
  42468. * Sets the value of the Right joystick
  42469. */
  42470. set buttonRightStick(value: number);
  42471. /**
  42472. * Gets the value of D-pad up
  42473. */
  42474. get dPadUp(): number;
  42475. /**
  42476. * Sets the value of D-pad up
  42477. */
  42478. set dPadUp(value: number);
  42479. /**
  42480. * Gets the value of D-pad down
  42481. */
  42482. get dPadDown(): number;
  42483. /**
  42484. * Sets the value of D-pad down
  42485. */
  42486. set dPadDown(value: number);
  42487. /**
  42488. * Gets the value of D-pad left
  42489. */
  42490. get dPadLeft(): number;
  42491. /**
  42492. * Sets the value of D-pad left
  42493. */
  42494. set dPadLeft(value: number);
  42495. /**
  42496. * Gets the value of D-pad right
  42497. */
  42498. get dPadRight(): number;
  42499. /**
  42500. * Sets the value of D-pad right
  42501. */
  42502. set dPadRight(value: number);
  42503. /**
  42504. * Force the gamepad to synchronize with device values
  42505. */
  42506. update(): void;
  42507. /**
  42508. * Disposes the gamepad
  42509. */
  42510. dispose(): void;
  42511. }
  42512. }
  42513. declare module "babylonjs/Gamepads/gamepadManager" {
  42514. import { Observable } from "babylonjs/Misc/observable";
  42515. import { Nullable } from "babylonjs/types";
  42516. import { Scene } from "babylonjs/scene";
  42517. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42518. /**
  42519. * Manager for handling gamepads
  42520. */
  42521. export class GamepadManager {
  42522. private _scene?;
  42523. private _babylonGamepads;
  42524. private _oneGamepadConnected;
  42525. /** @hidden */
  42526. _isMonitoring: boolean;
  42527. private _gamepadEventSupported;
  42528. private _gamepadSupport?;
  42529. /**
  42530. * observable to be triggered when the gamepad controller has been connected
  42531. */
  42532. onGamepadConnectedObservable: Observable<Gamepad>;
  42533. /**
  42534. * observable to be triggered when the gamepad controller has been disconnected
  42535. */
  42536. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42537. private _onGamepadConnectedEvent;
  42538. private _onGamepadDisconnectedEvent;
  42539. /**
  42540. * Initializes the gamepad manager
  42541. * @param _scene BabylonJS scene
  42542. */
  42543. constructor(_scene?: Scene | undefined);
  42544. /**
  42545. * The gamepads in the game pad manager
  42546. */
  42547. get gamepads(): Gamepad[];
  42548. /**
  42549. * Get the gamepad controllers based on type
  42550. * @param type The type of gamepad controller
  42551. * @returns Nullable gamepad
  42552. */
  42553. getGamepadByType(type?: number): Nullable<Gamepad>;
  42554. /**
  42555. * Disposes the gamepad manager
  42556. */
  42557. dispose(): void;
  42558. private _addNewGamepad;
  42559. private _startMonitoringGamepads;
  42560. private _stopMonitoringGamepads;
  42561. /** @hidden */
  42562. _checkGamepadsStatus(): void;
  42563. private _updateGamepadObjects;
  42564. }
  42565. }
  42566. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42567. import { Nullable } from "babylonjs/types";
  42568. import { Scene } from "babylonjs/scene";
  42569. import { ISceneComponent } from "babylonjs/sceneComponent";
  42570. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42571. module "babylonjs/scene" {
  42572. interface Scene {
  42573. /** @hidden */
  42574. _gamepadManager: Nullable<GamepadManager>;
  42575. /**
  42576. * Gets the gamepad manager associated with the scene
  42577. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42578. */
  42579. gamepadManager: GamepadManager;
  42580. }
  42581. }
  42582. module "babylonjs/Cameras/freeCameraInputsManager" {
  42583. /**
  42584. * Interface representing a free camera inputs manager
  42585. */
  42586. interface FreeCameraInputsManager {
  42587. /**
  42588. * Adds gamepad input support to the FreeCameraInputsManager.
  42589. * @returns the FreeCameraInputsManager
  42590. */
  42591. addGamepad(): FreeCameraInputsManager;
  42592. }
  42593. }
  42594. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42595. /**
  42596. * Interface representing an arc rotate camera inputs manager
  42597. */
  42598. interface ArcRotateCameraInputsManager {
  42599. /**
  42600. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42601. * @returns the camera inputs manager
  42602. */
  42603. addGamepad(): ArcRotateCameraInputsManager;
  42604. }
  42605. }
  42606. /**
  42607. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42608. */
  42609. export class GamepadSystemSceneComponent implements ISceneComponent {
  42610. /**
  42611. * The component name helpfull to identify the component in the list of scene components.
  42612. */
  42613. readonly name: string;
  42614. /**
  42615. * The scene the component belongs to.
  42616. */
  42617. scene: Scene;
  42618. /**
  42619. * Creates a new instance of the component for the given scene
  42620. * @param scene Defines the scene to register the component in
  42621. */
  42622. constructor(scene: Scene);
  42623. /**
  42624. * Registers the component in a given scene
  42625. */
  42626. register(): void;
  42627. /**
  42628. * Rebuilds the elements related to this component in case of
  42629. * context lost for instance.
  42630. */
  42631. rebuild(): void;
  42632. /**
  42633. * Disposes the component and the associated ressources
  42634. */
  42635. dispose(): void;
  42636. private _beforeCameraUpdate;
  42637. }
  42638. }
  42639. declare module "babylonjs/Cameras/universalCamera" {
  42640. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42641. import { Scene } from "babylonjs/scene";
  42642. import { Vector3 } from "babylonjs/Maths/math.vector";
  42643. import "babylonjs/Gamepads/gamepadSceneComponent";
  42644. /**
  42645. * 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,
  42646. * which still works and will still be found in many Playgrounds.
  42647. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42648. */
  42649. export class UniversalCamera extends TouchCamera {
  42650. /**
  42651. * Defines the gamepad rotation sensiblity.
  42652. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42653. */
  42654. get gamepadAngularSensibility(): number;
  42655. set gamepadAngularSensibility(value: number);
  42656. /**
  42657. * Defines the gamepad move sensiblity.
  42658. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42659. */
  42660. get gamepadMoveSensibility(): number;
  42661. set gamepadMoveSensibility(value: number);
  42662. /**
  42663. * 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,
  42664. * which still works and will still be found in many Playgrounds.
  42665. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42666. * @param name Define the name of the camera in the scene
  42667. * @param position Define the start position of the camera in the scene
  42668. * @param scene Define the scene the camera belongs to
  42669. */
  42670. constructor(name: string, position: Vector3, scene: Scene);
  42671. /**
  42672. * Gets the current object class name.
  42673. * @return the class name
  42674. */
  42675. getClassName(): string;
  42676. }
  42677. }
  42678. declare module "babylonjs/Cameras/gamepadCamera" {
  42679. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42680. import { Scene } from "babylonjs/scene";
  42681. import { Vector3 } from "babylonjs/Maths/math.vector";
  42682. /**
  42683. * This represents a FPS type of camera. This is only here for back compat purpose.
  42684. * Please use the UniversalCamera instead as both are identical.
  42685. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42686. */
  42687. export class GamepadCamera extends UniversalCamera {
  42688. /**
  42689. * Instantiates a new Gamepad Camera
  42690. * This represents a FPS type of camera. This is only here for back compat purpose.
  42691. * Please use the UniversalCamera instead as both are identical.
  42692. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42693. * @param name Define the name of the camera in the scene
  42694. * @param position Define the start position of the camera in the scene
  42695. * @param scene Define the scene the camera belongs to
  42696. */
  42697. constructor(name: string, position: Vector3, scene: Scene);
  42698. /**
  42699. * Gets the current object class name.
  42700. * @return the class name
  42701. */
  42702. getClassName(): string;
  42703. }
  42704. }
  42705. declare module "babylonjs/Shaders/pass.fragment" {
  42706. /** @hidden */
  42707. export var passPixelShader: {
  42708. name: string;
  42709. shader: string;
  42710. };
  42711. }
  42712. declare module "babylonjs/Shaders/passCube.fragment" {
  42713. /** @hidden */
  42714. export var passCubePixelShader: {
  42715. name: string;
  42716. shader: string;
  42717. };
  42718. }
  42719. declare module "babylonjs/PostProcesses/passPostProcess" {
  42720. import { Nullable } from "babylonjs/types";
  42721. import { Camera } from "babylonjs/Cameras/camera";
  42722. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42723. import { Engine } from "babylonjs/Engines/engine";
  42724. import "babylonjs/Shaders/pass.fragment";
  42725. import "babylonjs/Shaders/passCube.fragment";
  42726. /**
  42727. * PassPostProcess which produces an output the same as it's input
  42728. */
  42729. export class PassPostProcess extends PostProcess {
  42730. /**
  42731. * Creates the PassPostProcess
  42732. * @param name The name of the effect.
  42733. * @param options The required width/height ratio to downsize to before computing the render pass.
  42734. * @param camera The camera to apply the render pass to.
  42735. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42736. * @param engine The engine which the post process will be applied. (default: current engine)
  42737. * @param reusable If the post process can be reused on the same frame. (default: false)
  42738. * @param textureType The type of texture to be used when performing the post processing.
  42739. * @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)
  42740. */
  42741. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42742. }
  42743. /**
  42744. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42745. */
  42746. export class PassCubePostProcess extends PostProcess {
  42747. private _face;
  42748. /**
  42749. * Gets or sets the cube face to display.
  42750. * * 0 is +X
  42751. * * 1 is -X
  42752. * * 2 is +Y
  42753. * * 3 is -Y
  42754. * * 4 is +Z
  42755. * * 5 is -Z
  42756. */
  42757. get face(): number;
  42758. set face(value: number);
  42759. /**
  42760. * Creates the PassCubePostProcess
  42761. * @param name The name of the effect.
  42762. * @param options The required width/height ratio to downsize to before computing the render pass.
  42763. * @param camera The camera to apply the render pass to.
  42764. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42765. * @param engine The engine which the post process will be applied. (default: current engine)
  42766. * @param reusable If the post process can be reused on the same frame. (default: false)
  42767. * @param textureType The type of texture to be used when performing the post processing.
  42768. * @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)
  42769. */
  42770. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42771. }
  42772. }
  42773. declare module "babylonjs/Shaders/anaglyph.fragment" {
  42774. /** @hidden */
  42775. export var anaglyphPixelShader: {
  42776. name: string;
  42777. shader: string;
  42778. };
  42779. }
  42780. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  42781. import { Engine } from "babylonjs/Engines/engine";
  42782. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42783. import { Camera } from "babylonjs/Cameras/camera";
  42784. import "babylonjs/Shaders/anaglyph.fragment";
  42785. /**
  42786. * Postprocess used to generate anaglyphic rendering
  42787. */
  42788. export class AnaglyphPostProcess extends PostProcess {
  42789. private _passedProcess;
  42790. /**
  42791. * Creates a new AnaglyphPostProcess
  42792. * @param name defines postprocess name
  42793. * @param options defines creation options or target ratio scale
  42794. * @param rigCameras defines cameras using this postprocess
  42795. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42796. * @param engine defines hosting engine
  42797. * @param reusable defines if the postprocess will be reused multiple times per frame
  42798. */
  42799. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42800. }
  42801. }
  42802. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  42803. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  42804. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42805. import { Scene } from "babylonjs/scene";
  42806. import { Vector3 } from "babylonjs/Maths/math.vector";
  42807. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42808. /**
  42809. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42810. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42811. */
  42812. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42813. /**
  42814. * Creates a new AnaglyphArcRotateCamera
  42815. * @param name defines camera name
  42816. * @param alpha defines alpha angle (in radians)
  42817. * @param beta defines beta angle (in radians)
  42818. * @param radius defines radius
  42819. * @param target defines camera target
  42820. * @param interaxialDistance defines distance between each color axis
  42821. * @param scene defines the hosting scene
  42822. */
  42823. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42824. /**
  42825. * Gets camera class name
  42826. * @returns AnaglyphArcRotateCamera
  42827. */
  42828. getClassName(): string;
  42829. }
  42830. }
  42831. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  42832. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42833. import { Scene } from "babylonjs/scene";
  42834. import { Vector3 } from "babylonjs/Maths/math.vector";
  42835. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42836. /**
  42837. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42838. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42839. */
  42840. export class AnaglyphFreeCamera extends FreeCamera {
  42841. /**
  42842. * Creates a new AnaglyphFreeCamera
  42843. * @param name defines camera name
  42844. * @param position defines initial position
  42845. * @param interaxialDistance defines distance between each color axis
  42846. * @param scene defines the hosting scene
  42847. */
  42848. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42849. /**
  42850. * Gets camera class name
  42851. * @returns AnaglyphFreeCamera
  42852. */
  42853. getClassName(): string;
  42854. }
  42855. }
  42856. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  42857. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42858. import { Scene } from "babylonjs/scene";
  42859. import { Vector3 } from "babylonjs/Maths/math.vector";
  42860. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42861. /**
  42862. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42863. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42864. */
  42865. export class AnaglyphGamepadCamera extends GamepadCamera {
  42866. /**
  42867. * Creates a new AnaglyphGamepadCamera
  42868. * @param name defines camera name
  42869. * @param position defines initial position
  42870. * @param interaxialDistance defines distance between each color axis
  42871. * @param scene defines the hosting scene
  42872. */
  42873. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42874. /**
  42875. * Gets camera class name
  42876. * @returns AnaglyphGamepadCamera
  42877. */
  42878. getClassName(): string;
  42879. }
  42880. }
  42881. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  42882. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42883. import { Scene } from "babylonjs/scene";
  42884. import { Vector3 } from "babylonjs/Maths/math.vector";
  42885. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42886. /**
  42887. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42888. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42889. */
  42890. export class AnaglyphUniversalCamera extends UniversalCamera {
  42891. /**
  42892. * Creates a new AnaglyphUniversalCamera
  42893. * @param name defines camera name
  42894. * @param position defines initial position
  42895. * @param interaxialDistance defines distance between each color axis
  42896. * @param scene defines the hosting scene
  42897. */
  42898. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42899. /**
  42900. * Gets camera class name
  42901. * @returns AnaglyphUniversalCamera
  42902. */
  42903. getClassName(): string;
  42904. }
  42905. }
  42906. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  42907. /** @hidden */
  42908. export var stereoscopicInterlacePixelShader: {
  42909. name: string;
  42910. shader: string;
  42911. };
  42912. }
  42913. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  42914. import { Camera } from "babylonjs/Cameras/camera";
  42915. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42916. import { Engine } from "babylonjs/Engines/engine";
  42917. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  42918. /**
  42919. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42920. */
  42921. export class StereoscopicInterlacePostProcess extends PostProcess {
  42922. private _stepSize;
  42923. private _passedProcess;
  42924. /**
  42925. * Initializes a StereoscopicInterlacePostProcess
  42926. * @param name The name of the effect.
  42927. * @param rigCameras The rig cameras to be appled to the post process
  42928. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42929. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42930. * @param engine The engine which the post process will be applied. (default: current engine)
  42931. * @param reusable If the post process can be reused on the same frame. (default: false)
  42932. */
  42933. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42934. }
  42935. }
  42936. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  42937. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  42938. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42939. import { Scene } from "babylonjs/scene";
  42940. import { Vector3 } from "babylonjs/Maths/math.vector";
  42941. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42942. /**
  42943. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42944. * @see http://doc.babylonjs.com/features/cameras
  42945. */
  42946. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42947. /**
  42948. * Creates a new StereoscopicArcRotateCamera
  42949. * @param name defines camera name
  42950. * @param alpha defines alpha angle (in radians)
  42951. * @param beta defines beta angle (in radians)
  42952. * @param radius defines radius
  42953. * @param target defines camera target
  42954. * @param interaxialDistance defines distance between each color axis
  42955. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42956. * @param scene defines the hosting scene
  42957. */
  42958. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42959. /**
  42960. * Gets camera class name
  42961. * @returns StereoscopicArcRotateCamera
  42962. */
  42963. getClassName(): string;
  42964. }
  42965. }
  42966. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  42967. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42968. import { Scene } from "babylonjs/scene";
  42969. import { Vector3 } from "babylonjs/Maths/math.vector";
  42970. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42971. /**
  42972. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42973. * @see http://doc.babylonjs.com/features/cameras
  42974. */
  42975. export class StereoscopicFreeCamera extends FreeCamera {
  42976. /**
  42977. * Creates a new StereoscopicFreeCamera
  42978. * @param name defines camera name
  42979. * @param position defines initial position
  42980. * @param interaxialDistance defines distance between each color axis
  42981. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42982. * @param scene defines the hosting scene
  42983. */
  42984. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42985. /**
  42986. * Gets camera class name
  42987. * @returns StereoscopicFreeCamera
  42988. */
  42989. getClassName(): string;
  42990. }
  42991. }
  42992. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  42993. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42994. import { Scene } from "babylonjs/scene";
  42995. import { Vector3 } from "babylonjs/Maths/math.vector";
  42996. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42997. /**
  42998. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42999. * @see http://doc.babylonjs.com/features/cameras
  43000. */
  43001. export class StereoscopicGamepadCamera extends GamepadCamera {
  43002. /**
  43003. * Creates a new StereoscopicGamepadCamera
  43004. * @param name defines camera name
  43005. * @param position defines initial position
  43006. * @param interaxialDistance defines distance between each color axis
  43007. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43008. * @param scene defines the hosting scene
  43009. */
  43010. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43011. /**
  43012. * Gets camera class name
  43013. * @returns StereoscopicGamepadCamera
  43014. */
  43015. getClassName(): string;
  43016. }
  43017. }
  43018. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43019. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43020. import { Scene } from "babylonjs/scene";
  43021. import { Vector3 } from "babylonjs/Maths/math.vector";
  43022. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43023. /**
  43024. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43025. * @see http://doc.babylonjs.com/features/cameras
  43026. */
  43027. export class StereoscopicUniversalCamera extends UniversalCamera {
  43028. /**
  43029. * Creates a new StereoscopicUniversalCamera
  43030. * @param name defines camera name
  43031. * @param position defines initial position
  43032. * @param interaxialDistance defines distance between each color axis
  43033. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43034. * @param scene defines the hosting scene
  43035. */
  43036. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43037. /**
  43038. * Gets camera class name
  43039. * @returns StereoscopicUniversalCamera
  43040. */
  43041. getClassName(): string;
  43042. }
  43043. }
  43044. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43045. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43046. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43047. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43048. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43049. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43050. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43051. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43052. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43053. }
  43054. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43055. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43056. import { Scene } from "babylonjs/scene";
  43057. import { Vector3 } from "babylonjs/Maths/math.vector";
  43058. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43059. /**
  43060. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43061. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43062. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43063. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43064. */
  43065. export class VirtualJoysticksCamera extends FreeCamera {
  43066. /**
  43067. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43068. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43069. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43070. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43071. * @param name Define the name of the camera in the scene
  43072. * @param position Define the start position of the camera in the scene
  43073. * @param scene Define the scene the camera belongs to
  43074. */
  43075. constructor(name: string, position: Vector3, scene: Scene);
  43076. /**
  43077. * Gets the current object class name.
  43078. * @return the class name
  43079. */
  43080. getClassName(): string;
  43081. }
  43082. }
  43083. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43084. import { Matrix } from "babylonjs/Maths/math.vector";
  43085. /**
  43086. * This represents all the required metrics to create a VR camera.
  43087. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43088. */
  43089. export class VRCameraMetrics {
  43090. /**
  43091. * Define the horizontal resolution off the screen.
  43092. */
  43093. hResolution: number;
  43094. /**
  43095. * Define the vertical resolution off the screen.
  43096. */
  43097. vResolution: number;
  43098. /**
  43099. * Define the horizontal screen size.
  43100. */
  43101. hScreenSize: number;
  43102. /**
  43103. * Define the vertical screen size.
  43104. */
  43105. vScreenSize: number;
  43106. /**
  43107. * Define the vertical screen center position.
  43108. */
  43109. vScreenCenter: number;
  43110. /**
  43111. * Define the distance of the eyes to the screen.
  43112. */
  43113. eyeToScreenDistance: number;
  43114. /**
  43115. * Define the distance between both lenses
  43116. */
  43117. lensSeparationDistance: number;
  43118. /**
  43119. * Define the distance between both viewer's eyes.
  43120. */
  43121. interpupillaryDistance: number;
  43122. /**
  43123. * Define the distortion factor of the VR postprocess.
  43124. * Please, touch with care.
  43125. */
  43126. distortionK: number[];
  43127. /**
  43128. * Define the chromatic aberration correction factors for the VR post process.
  43129. */
  43130. chromaAbCorrection: number[];
  43131. /**
  43132. * Define the scale factor of the post process.
  43133. * The smaller the better but the slower.
  43134. */
  43135. postProcessScaleFactor: number;
  43136. /**
  43137. * Define an offset for the lens center.
  43138. */
  43139. lensCenterOffset: number;
  43140. /**
  43141. * Define if the current vr camera should compensate the distortion of the lense or not.
  43142. */
  43143. compensateDistortion: boolean;
  43144. /**
  43145. * Defines if multiview should be enabled when rendering (Default: false)
  43146. */
  43147. multiviewEnabled: boolean;
  43148. /**
  43149. * Gets the rendering aspect ratio based on the provided resolutions.
  43150. */
  43151. get aspectRatio(): number;
  43152. /**
  43153. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43154. */
  43155. get aspectRatioFov(): number;
  43156. /**
  43157. * @hidden
  43158. */
  43159. get leftHMatrix(): Matrix;
  43160. /**
  43161. * @hidden
  43162. */
  43163. get rightHMatrix(): Matrix;
  43164. /**
  43165. * @hidden
  43166. */
  43167. get leftPreViewMatrix(): Matrix;
  43168. /**
  43169. * @hidden
  43170. */
  43171. get rightPreViewMatrix(): Matrix;
  43172. /**
  43173. * Get the default VRMetrics based on the most generic setup.
  43174. * @returns the default vr metrics
  43175. */
  43176. static GetDefault(): VRCameraMetrics;
  43177. }
  43178. }
  43179. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43180. /** @hidden */
  43181. export var vrDistortionCorrectionPixelShader: {
  43182. name: string;
  43183. shader: string;
  43184. };
  43185. }
  43186. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43187. import { Camera } from "babylonjs/Cameras/camera";
  43188. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43189. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43190. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43191. /**
  43192. * VRDistortionCorrectionPostProcess used for mobile VR
  43193. */
  43194. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43195. private _isRightEye;
  43196. private _distortionFactors;
  43197. private _postProcessScaleFactor;
  43198. private _lensCenterOffset;
  43199. private _scaleIn;
  43200. private _scaleFactor;
  43201. private _lensCenter;
  43202. /**
  43203. * Initializes the VRDistortionCorrectionPostProcess
  43204. * @param name The name of the effect.
  43205. * @param camera The camera to apply the render pass to.
  43206. * @param isRightEye If this is for the right eye distortion
  43207. * @param vrMetrics All the required metrics for the VR camera
  43208. */
  43209. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43210. }
  43211. }
  43212. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43213. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43214. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43215. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43216. import { Scene } from "babylonjs/scene";
  43217. import { Vector3 } from "babylonjs/Maths/math.vector";
  43218. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43219. import "babylonjs/Cameras/RigModes/vrRigMode";
  43220. /**
  43221. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43222. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43223. */
  43224. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43225. /**
  43226. * Creates a new VRDeviceOrientationArcRotateCamera
  43227. * @param name defines camera name
  43228. * @param alpha defines the camera rotation along the logitudinal axis
  43229. * @param beta defines the camera rotation along the latitudinal axis
  43230. * @param radius defines the camera distance from its target
  43231. * @param target defines the camera target
  43232. * @param scene defines the scene the camera belongs to
  43233. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43234. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43235. */
  43236. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43237. /**
  43238. * Gets camera class name
  43239. * @returns VRDeviceOrientationArcRotateCamera
  43240. */
  43241. getClassName(): string;
  43242. }
  43243. }
  43244. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43245. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43246. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43247. import { Scene } from "babylonjs/scene";
  43248. import { Vector3 } from "babylonjs/Maths/math.vector";
  43249. import "babylonjs/Cameras/RigModes/vrRigMode";
  43250. /**
  43251. * Camera used to simulate VR rendering (based on FreeCamera)
  43252. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43253. */
  43254. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43255. /**
  43256. * Creates a new VRDeviceOrientationFreeCamera
  43257. * @param name defines camera name
  43258. * @param position defines the start position of the camera
  43259. * @param scene defines the scene the camera belongs to
  43260. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43261. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43262. */
  43263. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43264. /**
  43265. * Gets camera class name
  43266. * @returns VRDeviceOrientationFreeCamera
  43267. */
  43268. getClassName(): string;
  43269. }
  43270. }
  43271. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43272. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43273. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43274. import { Scene } from "babylonjs/scene";
  43275. import { Vector3 } from "babylonjs/Maths/math.vector";
  43276. import "babylonjs/Gamepads/gamepadSceneComponent";
  43277. /**
  43278. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43279. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43280. */
  43281. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43282. /**
  43283. * Creates a new VRDeviceOrientationGamepadCamera
  43284. * @param name defines camera name
  43285. * @param position defines the start position of the camera
  43286. * @param scene defines the scene the camera belongs to
  43287. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43288. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43289. */
  43290. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43291. /**
  43292. * Gets camera class name
  43293. * @returns VRDeviceOrientationGamepadCamera
  43294. */
  43295. getClassName(): string;
  43296. }
  43297. }
  43298. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43299. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43300. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43301. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43302. /** @hidden */
  43303. export var imageProcessingPixelShader: {
  43304. name: string;
  43305. shader: string;
  43306. };
  43307. }
  43308. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43309. import { Nullable } from "babylonjs/types";
  43310. import { Color4 } from "babylonjs/Maths/math.color";
  43311. import { Camera } from "babylonjs/Cameras/camera";
  43312. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43313. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43314. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43315. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43316. import { Engine } from "babylonjs/Engines/engine";
  43317. import "babylonjs/Shaders/imageProcessing.fragment";
  43318. import "babylonjs/Shaders/postprocess.vertex";
  43319. /**
  43320. * ImageProcessingPostProcess
  43321. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43322. */
  43323. export class ImageProcessingPostProcess extends PostProcess {
  43324. /**
  43325. * Default configuration related to image processing available in the PBR Material.
  43326. */
  43327. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43328. /**
  43329. * Gets the image processing configuration used either in this material.
  43330. */
  43331. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43332. /**
  43333. * Sets the Default image processing configuration used either in the this material.
  43334. *
  43335. * If sets to null, the scene one is in use.
  43336. */
  43337. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43338. /**
  43339. * Keep track of the image processing observer to allow dispose and replace.
  43340. */
  43341. private _imageProcessingObserver;
  43342. /**
  43343. * Attaches a new image processing configuration to the PBR Material.
  43344. * @param configuration
  43345. */
  43346. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43347. /**
  43348. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43349. */
  43350. get colorCurves(): Nullable<ColorCurves>;
  43351. /**
  43352. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43353. */
  43354. set colorCurves(value: Nullable<ColorCurves>);
  43355. /**
  43356. * Gets wether the color curves effect is enabled.
  43357. */
  43358. get colorCurvesEnabled(): boolean;
  43359. /**
  43360. * Sets wether the color curves effect is enabled.
  43361. */
  43362. set colorCurvesEnabled(value: boolean);
  43363. /**
  43364. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43365. */
  43366. get colorGradingTexture(): Nullable<BaseTexture>;
  43367. /**
  43368. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43369. */
  43370. set colorGradingTexture(value: Nullable<BaseTexture>);
  43371. /**
  43372. * Gets wether the color grading effect is enabled.
  43373. */
  43374. get colorGradingEnabled(): boolean;
  43375. /**
  43376. * Gets wether the color grading effect is enabled.
  43377. */
  43378. set colorGradingEnabled(value: boolean);
  43379. /**
  43380. * Gets exposure used in the effect.
  43381. */
  43382. get exposure(): number;
  43383. /**
  43384. * Sets exposure used in the effect.
  43385. */
  43386. set exposure(value: number);
  43387. /**
  43388. * Gets wether tonemapping is enabled or not.
  43389. */
  43390. get toneMappingEnabled(): boolean;
  43391. /**
  43392. * Sets wether tonemapping is enabled or not
  43393. */
  43394. set toneMappingEnabled(value: boolean);
  43395. /**
  43396. * Gets the type of tone mapping effect.
  43397. */
  43398. get toneMappingType(): number;
  43399. /**
  43400. * Sets the type of tone mapping effect.
  43401. */
  43402. set toneMappingType(value: number);
  43403. /**
  43404. * Gets contrast used in the effect.
  43405. */
  43406. get contrast(): number;
  43407. /**
  43408. * Sets contrast used in the effect.
  43409. */
  43410. set contrast(value: number);
  43411. /**
  43412. * Gets Vignette stretch size.
  43413. */
  43414. get vignetteStretch(): number;
  43415. /**
  43416. * Sets Vignette stretch size.
  43417. */
  43418. set vignetteStretch(value: number);
  43419. /**
  43420. * Gets Vignette centre X Offset.
  43421. */
  43422. get vignetteCentreX(): number;
  43423. /**
  43424. * Sets Vignette centre X Offset.
  43425. */
  43426. set vignetteCentreX(value: number);
  43427. /**
  43428. * Gets Vignette centre Y Offset.
  43429. */
  43430. get vignetteCentreY(): number;
  43431. /**
  43432. * Sets Vignette centre Y Offset.
  43433. */
  43434. set vignetteCentreY(value: number);
  43435. /**
  43436. * Gets Vignette weight or intensity of the vignette effect.
  43437. */
  43438. get vignetteWeight(): number;
  43439. /**
  43440. * Sets Vignette weight or intensity of the vignette effect.
  43441. */
  43442. set vignetteWeight(value: number);
  43443. /**
  43444. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43445. * if vignetteEnabled is set to true.
  43446. */
  43447. get vignetteColor(): Color4;
  43448. /**
  43449. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43450. * if vignetteEnabled is set to true.
  43451. */
  43452. set vignetteColor(value: Color4);
  43453. /**
  43454. * Gets Camera field of view used by the Vignette effect.
  43455. */
  43456. get vignetteCameraFov(): number;
  43457. /**
  43458. * Sets Camera field of view used by the Vignette effect.
  43459. */
  43460. set vignetteCameraFov(value: number);
  43461. /**
  43462. * Gets the vignette blend mode allowing different kind of effect.
  43463. */
  43464. get vignetteBlendMode(): number;
  43465. /**
  43466. * Sets the vignette blend mode allowing different kind of effect.
  43467. */
  43468. set vignetteBlendMode(value: number);
  43469. /**
  43470. * Gets wether the vignette effect is enabled.
  43471. */
  43472. get vignetteEnabled(): boolean;
  43473. /**
  43474. * Sets wether the vignette effect is enabled.
  43475. */
  43476. set vignetteEnabled(value: boolean);
  43477. private _fromLinearSpace;
  43478. /**
  43479. * Gets wether the input of the processing is in Gamma or Linear Space.
  43480. */
  43481. get fromLinearSpace(): boolean;
  43482. /**
  43483. * Sets wether the input of the processing is in Gamma or Linear Space.
  43484. */
  43485. set fromLinearSpace(value: boolean);
  43486. /**
  43487. * Defines cache preventing GC.
  43488. */
  43489. private _defines;
  43490. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43491. /**
  43492. * "ImageProcessingPostProcess"
  43493. * @returns "ImageProcessingPostProcess"
  43494. */
  43495. getClassName(): string;
  43496. protected _updateParameters(): void;
  43497. dispose(camera?: Camera): void;
  43498. }
  43499. }
  43500. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43501. import { Scene } from "babylonjs/scene";
  43502. import { Color3 } from "babylonjs/Maths/math.color";
  43503. import { Mesh } from "babylonjs/Meshes/mesh";
  43504. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43505. import { Nullable } from "babylonjs/types";
  43506. /**
  43507. * Class containing static functions to help procedurally build meshes
  43508. */
  43509. export class GroundBuilder {
  43510. /**
  43511. * Creates a ground mesh
  43512. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43513. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43515. * @param name defines the name of the mesh
  43516. * @param options defines the options used to create the mesh
  43517. * @param scene defines the hosting scene
  43518. * @returns the ground mesh
  43519. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43520. */
  43521. static CreateGround(name: string, options: {
  43522. width?: number;
  43523. height?: number;
  43524. subdivisions?: number;
  43525. subdivisionsX?: number;
  43526. subdivisionsY?: number;
  43527. updatable?: boolean;
  43528. }, scene: any): Mesh;
  43529. /**
  43530. * Creates a tiled ground mesh
  43531. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43532. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43533. * * 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
  43534. * * 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
  43535. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43536. * @param name defines the name of the mesh
  43537. * @param options defines the options used to create the mesh
  43538. * @param scene defines the hosting scene
  43539. * @returns the tiled ground mesh
  43540. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43541. */
  43542. static CreateTiledGround(name: string, options: {
  43543. xmin: number;
  43544. zmin: number;
  43545. xmax: number;
  43546. zmax: number;
  43547. subdivisions?: {
  43548. w: number;
  43549. h: number;
  43550. };
  43551. precision?: {
  43552. w: number;
  43553. h: number;
  43554. };
  43555. updatable?: boolean;
  43556. }, scene?: Nullable<Scene>): Mesh;
  43557. /**
  43558. * Creates a ground mesh from a height map
  43559. * * The parameter `url` sets the URL of the height map image resource.
  43560. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43561. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43562. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43563. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43564. * * 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.
  43565. * * 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).
  43566. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43568. * @param name defines the name of the mesh
  43569. * @param url defines the url to the height map
  43570. * @param options defines the options used to create the mesh
  43571. * @param scene defines the hosting scene
  43572. * @returns the ground mesh
  43573. * @see https://doc.babylonjs.com/babylon101/height_map
  43574. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43575. */
  43576. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43577. width?: number;
  43578. height?: number;
  43579. subdivisions?: number;
  43580. minHeight?: number;
  43581. maxHeight?: number;
  43582. colorFilter?: Color3;
  43583. alphaFilter?: number;
  43584. updatable?: boolean;
  43585. onReady?: (mesh: GroundMesh) => void;
  43586. }, scene?: Nullable<Scene>): GroundMesh;
  43587. }
  43588. }
  43589. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43590. import { Vector4 } from "babylonjs/Maths/math.vector";
  43591. import { Mesh } from "babylonjs/Meshes/mesh";
  43592. /**
  43593. * Class containing static functions to help procedurally build meshes
  43594. */
  43595. export class TorusBuilder {
  43596. /**
  43597. * Creates a torus mesh
  43598. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43599. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43600. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43601. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43602. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43604. * @param name defines the name of the mesh
  43605. * @param options defines the options used to create the mesh
  43606. * @param scene defines the hosting scene
  43607. * @returns the torus mesh
  43608. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43609. */
  43610. static CreateTorus(name: string, options: {
  43611. diameter?: number;
  43612. thickness?: number;
  43613. tessellation?: number;
  43614. updatable?: boolean;
  43615. sideOrientation?: number;
  43616. frontUVs?: Vector4;
  43617. backUVs?: Vector4;
  43618. }, scene: any): Mesh;
  43619. }
  43620. }
  43621. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43622. import { Vector4 } from "babylonjs/Maths/math.vector";
  43623. import { Color4 } from "babylonjs/Maths/math.color";
  43624. import { Mesh } from "babylonjs/Meshes/mesh";
  43625. /**
  43626. * Class containing static functions to help procedurally build meshes
  43627. */
  43628. export class CylinderBuilder {
  43629. /**
  43630. * Creates a cylinder or a cone mesh
  43631. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43632. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43633. * * 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.
  43634. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43635. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43636. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43637. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43638. * * 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).
  43639. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43640. * * 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).
  43641. * * 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
  43642. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43643. * * 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
  43644. * * 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.
  43645. * * If `enclose` is false, a ring surface is one element.
  43646. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43647. * * 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
  43648. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43649. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43651. * @param name defines the name of the mesh
  43652. * @param options defines the options used to create the mesh
  43653. * @param scene defines the hosting scene
  43654. * @returns the cylinder mesh
  43655. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43656. */
  43657. static CreateCylinder(name: string, options: {
  43658. height?: number;
  43659. diameterTop?: number;
  43660. diameterBottom?: number;
  43661. diameter?: number;
  43662. tessellation?: number;
  43663. subdivisions?: number;
  43664. arc?: number;
  43665. faceColors?: Color4[];
  43666. faceUV?: Vector4[];
  43667. updatable?: boolean;
  43668. hasRings?: boolean;
  43669. enclose?: boolean;
  43670. cap?: number;
  43671. sideOrientation?: number;
  43672. frontUVs?: Vector4;
  43673. backUVs?: Vector4;
  43674. }, scene: any): Mesh;
  43675. }
  43676. }
  43677. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43678. import { Nullable } from "babylonjs/types";
  43679. import { IDisposable } from "babylonjs/scene";
  43680. /**
  43681. * States of the webXR experience
  43682. */
  43683. export enum WebXRState {
  43684. /**
  43685. * Transitioning to being in XR mode
  43686. */
  43687. ENTERING_XR = 0,
  43688. /**
  43689. * Transitioning to non XR mode
  43690. */
  43691. EXITING_XR = 1,
  43692. /**
  43693. * In XR mode and presenting
  43694. */
  43695. IN_XR = 2,
  43696. /**
  43697. * Not entered XR mode
  43698. */
  43699. NOT_IN_XR = 3
  43700. }
  43701. /**
  43702. * Abstraction of the XR render target
  43703. */
  43704. export interface WebXRRenderTarget extends IDisposable {
  43705. /**
  43706. * xrpresent context of the canvas which can be used to display/mirror xr content
  43707. */
  43708. canvasContext: WebGLRenderingContext;
  43709. /**
  43710. * xr layer for the canvas
  43711. */
  43712. xrLayer: Nullable<XRWebGLLayer>;
  43713. /**
  43714. * Initializes the xr layer for the session
  43715. * @param xrSession xr session
  43716. * @returns a promise that will resolve once the XR Layer has been created
  43717. */
  43718. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43719. }
  43720. }
  43721. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43722. import { Nullable } from "babylonjs/types";
  43723. import { Observable } from "babylonjs/Misc/observable";
  43724. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43725. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43726. /**
  43727. * COnfiguration object for WebXR output canvas
  43728. */
  43729. export class WebXRManagedOutputCanvasOptions {
  43730. /**
  43731. * Options for this XR Layer output
  43732. */
  43733. canvasOptions: XRWebGLLayerOptions;
  43734. /**
  43735. * CSS styling for a newly created canvas (if not provided)
  43736. */
  43737. newCanvasCssStyle?: string;
  43738. /**
  43739. * Get the default values of the configuration object
  43740. * @returns default values of this configuration object
  43741. */
  43742. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43743. }
  43744. /**
  43745. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43746. */
  43747. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43748. private configuration;
  43749. private _engine;
  43750. private _canvas;
  43751. /**
  43752. * xrpresent context of the canvas which can be used to display/mirror xr content
  43753. */
  43754. canvasContext: WebGLRenderingContext;
  43755. /**
  43756. * xr layer for the canvas
  43757. */
  43758. xrLayer: Nullable<XRWebGLLayer>;
  43759. /**
  43760. * Initializes the xr layer for the session
  43761. * @param xrSession xr session
  43762. * @returns a promise that will resolve once the XR Layer has been created
  43763. */
  43764. initializeXRLayerAsync(xrSession: any): any;
  43765. /**
  43766. * Initializes the canvas to be added/removed upon entering/exiting xr
  43767. * @param engine the Babylon engine
  43768. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43769. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43770. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  43771. */
  43772. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  43773. /**
  43774. * Disposes of the object
  43775. */
  43776. dispose(): void;
  43777. private _setManagedOutputCanvas;
  43778. private _addCanvas;
  43779. private _removeCanvas;
  43780. }
  43781. }
  43782. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43783. import { Observable } from "babylonjs/Misc/observable";
  43784. import { Nullable } from "babylonjs/types";
  43785. import { IDisposable, Scene } from "babylonjs/scene";
  43786. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43787. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43788. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43789. /**
  43790. * Manages an XRSession to work with Babylon's engine
  43791. * @see https://doc.babylonjs.com/how_to/webxr
  43792. */
  43793. export class WebXRSessionManager implements IDisposable {
  43794. /** The scene which the session should be created for */
  43795. scene: Scene;
  43796. /**
  43797. * Fires every time a new xrFrame arrives which can be used to update the camera
  43798. */
  43799. onXRFrameObservable: Observable<XRFrame>;
  43800. /**
  43801. * Fires when the xr session is ended either by the device or manually done
  43802. */
  43803. onXRSessionEnded: Observable<any>;
  43804. /**
  43805. * Fires when the xr session is ended either by the device or manually done
  43806. */
  43807. onXRSessionInit: Observable<XRSession>;
  43808. /**
  43809. * Underlying xr session
  43810. */
  43811. session: XRSession;
  43812. /**
  43813. * Type of reference space used when creating the session
  43814. */
  43815. referenceSpace: XRReferenceSpace;
  43816. /**
  43817. * Current XR frame
  43818. */
  43819. currentFrame: Nullable<XRFrame>;
  43820. /** WebXR timestamp updated every frame */
  43821. currentTimestamp: number;
  43822. private _xrNavigator;
  43823. private baseLayer;
  43824. private _rttProvider;
  43825. private _sessionEnded;
  43826. /**
  43827. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43828. * @param scene The scene which the session should be created for
  43829. */
  43830. constructor(
  43831. /** The scene which the session should be created for */
  43832. scene: Scene);
  43833. /**
  43834. * Initializes the manager
  43835. * After initialization enterXR can be called to start an XR session
  43836. * @returns Promise which resolves after it is initialized
  43837. */
  43838. initializeAsync(): Promise<void>;
  43839. /**
  43840. * Initializes an xr session
  43841. * @param xrSessionMode mode to initialize
  43842. * @param optionalFeatures defines optional values to pass to the session builder
  43843. * @returns a promise which will resolve once the session has been initialized
  43844. */
  43845. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  43846. /**
  43847. * Sets the reference space on the xr session
  43848. * @param referenceSpace space to set
  43849. * @returns a promise that will resolve once the reference space has been set
  43850. */
  43851. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43852. /**
  43853. * Updates the render state of the session
  43854. * @param state state to set
  43855. * @returns a promise that resolves once the render state has been updated
  43856. */
  43857. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43858. /**
  43859. * Starts rendering to the xr layer
  43860. * @returns a promise that will resolve once rendering has started
  43861. */
  43862. startRenderingToXRAsync(): Promise<void>;
  43863. /**
  43864. * Gets the correct render target texture to be rendered this frame for this eye
  43865. * @param eye the eye for which to get the render target
  43866. * @returns the render target for the specified eye
  43867. */
  43868. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43869. /**
  43870. * Stops the xrSession and restores the renderloop
  43871. * @returns Promise which resolves after it exits XR
  43872. */
  43873. exitXRAsync(): Promise<void>;
  43874. /**
  43875. * Checks if a session would be supported for the creation options specified
  43876. * @param sessionMode session mode to check if supported eg. immersive-vr
  43877. * @returns true if supported
  43878. */
  43879. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43880. /**
  43881. * Creates a WebXRRenderTarget object for the XR session
  43882. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43883. * @param options optional options to provide when creating a new render target
  43884. * @returns a WebXR render target to which the session can render
  43885. */
  43886. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43887. /**
  43888. * @hidden
  43889. * Converts the render layer of xrSession to a render target
  43890. * @param session session to create render target for
  43891. * @param scene scene the new render target should be created for
  43892. * @param baseLayer the webgl layer to create the render target for
  43893. */
  43894. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43895. /**
  43896. * Disposes of the session manager
  43897. */
  43898. dispose(): void;
  43899. /**
  43900. * Gets a promise returning true when fullfiled if the given session mode is supported
  43901. * @param sessionMode defines the session to test
  43902. * @returns a promise
  43903. */
  43904. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43905. }
  43906. }
  43907. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43908. import { Scene } from "babylonjs/scene";
  43909. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43910. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43911. /**
  43912. * WebXR Camera which holds the views for the xrSession
  43913. * @see https://doc.babylonjs.com/how_to/webxr
  43914. */
  43915. export class WebXRCamera extends FreeCamera {
  43916. /**
  43917. * Is the camera in debug mode. Used when using an emulator
  43918. */
  43919. debugMode: boolean;
  43920. /**
  43921. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43922. * @param name the name of the camera
  43923. * @param scene the scene to add the camera to
  43924. */
  43925. constructor(name: string, scene: Scene);
  43926. private _updateNumberOfRigCameras;
  43927. /** @hidden */
  43928. _updateForDualEyeDebugging(): void;
  43929. /**
  43930. * Updates the cameras position from the current pose information of the XR session
  43931. * @param xrSessionManager the session containing pose information
  43932. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43933. */
  43934. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43935. }
  43936. }
  43937. declare module "babylonjs/Cameras/XR/webXRFeaturesManager" {
  43938. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43939. import { IDisposable } from "babylonjs/scene";
  43940. /**
  43941. * Defining the interface required for a (webxr) feature
  43942. */
  43943. export interface IWebXRFeature extends IDisposable {
  43944. /**
  43945. * Attach the feature to the session
  43946. * Will usually be called by the features manager
  43947. *
  43948. * @returns true if successful.
  43949. */
  43950. attach(): boolean;
  43951. /**
  43952. * Detach the feature from the session
  43953. * Will usually be called by the features manager
  43954. *
  43955. * @returns true if successful.
  43956. */
  43957. detach(): boolean;
  43958. }
  43959. /**
  43960. * Defining the constructor of a feature. Used to register the modules.
  43961. */
  43962. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43963. /**
  43964. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43965. * It is mainly used in AR sessions.
  43966. *
  43967. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43968. */
  43969. export class WebXRFeaturesManager implements IDisposable {
  43970. private _xrSessionManager;
  43971. private static readonly _AvailableFeatures;
  43972. /**
  43973. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43974. * Mainly used internally.
  43975. *
  43976. * @param featureName the name of the feature to register
  43977. * @param constructorFunction the function used to construct the module
  43978. * @param version the (babylon) version of the module
  43979. * @param stable is that a stable version of this module
  43980. */
  43981. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43982. /**
  43983. * Returns a constructor of a specific feature.
  43984. *
  43985. * @param featureName the name of the feature to construct
  43986. * @param version the version of the feature to load
  43987. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43988. * @param options optional options provided to the module.
  43989. * @returns a function that, when called, will return a new instance of this feature
  43990. */
  43991. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43992. /**
  43993. * Return the latest unstable version of this feature
  43994. * @param featureName the name of the feature to search
  43995. * @returns the version number. if not found will return -1
  43996. */
  43997. static GetLatestVersionOfFeature(featureName: string): number;
  43998. /**
  43999. * Return the latest stable version of this feature
  44000. * @param featureName the name of the feature to search
  44001. * @returns the version number. if not found will return -1
  44002. */
  44003. static GetStableVersionOfFeature(featureName: string): number;
  44004. /**
  44005. * Can be used to return the list of features currently registered
  44006. *
  44007. * @returns an Array of available features
  44008. */
  44009. static GetAvailableFeatures(): string[];
  44010. /**
  44011. * Gets the versions available for a specific feature
  44012. * @param featureName the name of the feature
  44013. * @returns an array with the available versions
  44014. */
  44015. static GetAvailableVersions(featureName: string): string[];
  44016. private _features;
  44017. /**
  44018. * constructs a new features manages.
  44019. *
  44020. * @param _xrSessionManager an instance of WebXRSessionManager
  44021. */
  44022. constructor(_xrSessionManager: WebXRSessionManager);
  44023. /**
  44024. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  44025. *
  44026. * @param featureName the name of the feature to load or the class of the feature
  44027. * @param version optional version to load. if not provided the latest version will be enabled
  44028. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44029. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44030. * @returns a new constructed feature or throws an error if feature not found.
  44031. */
  44032. enableFeature(featureName: string | {
  44033. Name: string;
  44034. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44035. /**
  44036. * Used to disable an already-enabled feature
  44037. * @param featureName the feature to disable
  44038. * @returns true if disable was successful
  44039. */
  44040. disableFeature(featureName: string | {
  44041. Name: string;
  44042. }): boolean;
  44043. /**
  44044. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44045. * Can be used during a session to start a feature
  44046. * @param featureName the name of feature to attach
  44047. */
  44048. attachFeature(featureName: string): void;
  44049. /**
  44050. * Can be used inside a session or when the session ends to detach a specific feature
  44051. * @param featureName the name of the feature to detach
  44052. */
  44053. detachFeature(featureName: string): void;
  44054. /**
  44055. * Get the list of enabled features
  44056. * @returns an array of enabled features
  44057. */
  44058. getEnabledFeatures(): string[];
  44059. /**
  44060. * get the implementation of an enabled feature.
  44061. * @param featureName the name of the feature to load
  44062. * @returns the feature class, if found
  44063. */
  44064. getEnabledFeature(featureName: string): IWebXRFeature;
  44065. /**
  44066. * dispose this features manager
  44067. */
  44068. dispose(): void;
  44069. }
  44070. }
  44071. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  44072. import { Observable } from "babylonjs/Misc/observable";
  44073. import { IDisposable, Scene } from "babylonjs/scene";
  44074. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  44075. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44076. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  44077. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  44078. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44079. import { WebXRFeaturesManager } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  44080. /**
  44081. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  44082. * @see https://doc.babylonjs.com/how_to/webxr
  44083. */
  44084. export class WebXRExperienceHelper implements IDisposable {
  44085. private scene;
  44086. /**
  44087. * 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
  44088. */
  44089. container: AbstractMesh;
  44090. /**
  44091. * Camera used to render xr content
  44092. */
  44093. camera: WebXRCamera;
  44094. /**
  44095. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44096. */
  44097. state: WebXRState;
  44098. private _setState;
  44099. private static _TmpVector;
  44100. /**
  44101. * Fires when the state of the experience helper has changed
  44102. */
  44103. onStateChangedObservable: Observable<WebXRState>;
  44104. /** Session manager used to keep track of xr session */
  44105. sessionManager: WebXRSessionManager;
  44106. /** A features manager for this xr session */
  44107. featuresManager: WebXRFeaturesManager;
  44108. private _nonVRCamera;
  44109. private _originalSceneAutoClear;
  44110. private _supported;
  44111. /**
  44112. * Creates the experience helper
  44113. * @param scene the scene to attach the experience helper to
  44114. * @returns a promise for the experience helper
  44115. */
  44116. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44117. /**
  44118. * Creates a WebXRExperienceHelper
  44119. * @param scene The scene the helper should be created in
  44120. */
  44121. private constructor();
  44122. /**
  44123. * Exits XR mode and returns the scene to its original state
  44124. * @returns promise that resolves after xr mode has exited
  44125. */
  44126. exitXRAsync(): Promise<void>;
  44127. /**
  44128. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44129. * @param sessionMode options for the XR session
  44130. * @param referenceSpaceType frame of reference of the XR session
  44131. * @param renderTarget the output canvas that will be used to enter XR mode
  44132. * @returns promise that resolves after xr mode has entered
  44133. */
  44134. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44135. /**
  44136. * Updates the global position of the camera by moving the camera's container
  44137. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  44138. * @param position The desired global position of the camera
  44139. */
  44140. setPositionOfCameraUsingContainer(position: Vector3): void;
  44141. /**
  44142. * Rotates the xr camera by rotating the camera's container around the camera's position
  44143. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  44144. * @param rotation the desired quaternion rotation to apply to the camera
  44145. */
  44146. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  44147. /**
  44148. * Disposes of the experience helper
  44149. */
  44150. dispose(): void;
  44151. }
  44152. }
  44153. declare module "babylonjs/Cameras/XR/webXRController" {
  44154. import { Nullable } from "babylonjs/types";
  44155. import { Observable } from "babylonjs/Misc/observable";
  44156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44157. import { Ray } from "babylonjs/Culling/ray";
  44158. import { Scene } from "babylonjs/scene";
  44159. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44160. /**
  44161. * Represents an XR input
  44162. */
  44163. export class WebXRController {
  44164. private scene;
  44165. /** The underlying input source for the controller */
  44166. inputSource: XRInputSource;
  44167. private parentContainer;
  44168. /**
  44169. * 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
  44170. */
  44171. grip?: AbstractMesh;
  44172. /**
  44173. * Pointer which can be used to select objects or attach a visible laser to
  44174. */
  44175. pointer: AbstractMesh;
  44176. private _gamepadMode;
  44177. /**
  44178. * If available, this is the gamepad object related to this controller.
  44179. * Using this object it is possible to get click events and trackpad changes of the
  44180. * webxr controller that is currently being used.
  44181. */
  44182. gamepadController?: WebVRController;
  44183. /**
  44184. * Event that fires when the controller is removed/disposed
  44185. */
  44186. onDisposeObservable: Observable<{}>;
  44187. private _tmpQuaternion;
  44188. private _tmpVector;
  44189. /**
  44190. * Creates the controller
  44191. * @see https://doc.babylonjs.com/how_to/webxr
  44192. * @param scene the scene which the controller should be associated to
  44193. * @param inputSource the underlying input source for the controller
  44194. * @param parentContainer parent that the controller meshes should be children of
  44195. */
  44196. constructor(scene: Scene,
  44197. /** The underlying input source for the controller */
  44198. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  44199. /**
  44200. * Updates the controller pose based on the given XRFrame
  44201. * @param xrFrame xr frame to update the pose with
  44202. * @param referenceSpace reference space to use
  44203. */
  44204. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44205. /**
  44206. * Gets a world space ray coming from the controller
  44207. * @param result the resulting ray
  44208. */
  44209. getWorldPointerRayToRef(result: Ray): void;
  44210. /**
  44211. * Get the scene associated with this controller
  44212. * @returns the scene object
  44213. */
  44214. getScene(): Scene;
  44215. /**
  44216. * Disposes of the object
  44217. */
  44218. dispose(): void;
  44219. }
  44220. }
  44221. declare module "babylonjs/Cameras/XR/webXRInput" {
  44222. import { Observable } from "babylonjs/Misc/observable";
  44223. import { IDisposable } from "babylonjs/scene";
  44224. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44225. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  44226. /**
  44227. * XR input used to track XR inputs such as controllers/rays
  44228. */
  44229. export class WebXRInput implements IDisposable {
  44230. /**
  44231. * Base experience the input listens to
  44232. */
  44233. baseExperience: WebXRExperienceHelper;
  44234. /**
  44235. * XR controllers being tracked
  44236. */
  44237. controllers: Array<WebXRController>;
  44238. private _frameObserver;
  44239. private _stateObserver;
  44240. /**
  44241. * Event when a controller has been connected/added
  44242. */
  44243. onControllerAddedObservable: Observable<WebXRController>;
  44244. /**
  44245. * Event when a controller has been removed/disconnected
  44246. */
  44247. onControllerRemovedObservable: Observable<WebXRController>;
  44248. /**
  44249. * Initializes the WebXRInput
  44250. * @param baseExperience experience helper which the input should be created for
  44251. */
  44252. constructor(
  44253. /**
  44254. * Base experience the input listens to
  44255. */
  44256. baseExperience: WebXRExperienceHelper);
  44257. private _onInputSourcesChange;
  44258. private _addAndRemoveControllers;
  44259. /**
  44260. * Disposes of the object
  44261. */
  44262. dispose(): void;
  44263. }
  44264. }
  44265. declare module "babylonjs/Loading/sceneLoader" {
  44266. import { Observable } from "babylonjs/Misc/observable";
  44267. import { Nullable } from "babylonjs/types";
  44268. import { Scene } from "babylonjs/scene";
  44269. import { Engine } from "babylonjs/Engines/engine";
  44270. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44271. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44272. import { AssetContainer } from "babylonjs/assetContainer";
  44273. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44274. import { Skeleton } from "babylonjs/Bones/skeleton";
  44275. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44276. import { WebRequest } from "babylonjs/Misc/webRequest";
  44277. /**
  44278. * Class used to represent data loading progression
  44279. */
  44280. export class SceneLoaderProgressEvent {
  44281. /** defines if data length to load can be evaluated */
  44282. readonly lengthComputable: boolean;
  44283. /** defines the loaded data length */
  44284. readonly loaded: number;
  44285. /** defines the data length to load */
  44286. readonly total: number;
  44287. /**
  44288. * Create a new progress event
  44289. * @param lengthComputable defines if data length to load can be evaluated
  44290. * @param loaded defines the loaded data length
  44291. * @param total defines the data length to load
  44292. */
  44293. constructor(
  44294. /** defines if data length to load can be evaluated */
  44295. lengthComputable: boolean,
  44296. /** defines the loaded data length */
  44297. loaded: number,
  44298. /** defines the data length to load */
  44299. total: number);
  44300. /**
  44301. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44302. * @param event defines the source event
  44303. * @returns a new SceneLoaderProgressEvent
  44304. */
  44305. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44306. }
  44307. /**
  44308. * Interface used by SceneLoader plugins to define supported file extensions
  44309. */
  44310. export interface ISceneLoaderPluginExtensions {
  44311. /**
  44312. * Defines the list of supported extensions
  44313. */
  44314. [extension: string]: {
  44315. isBinary: boolean;
  44316. };
  44317. }
  44318. /**
  44319. * Interface used by SceneLoader plugin factory
  44320. */
  44321. export interface ISceneLoaderPluginFactory {
  44322. /**
  44323. * Defines the name of the factory
  44324. */
  44325. name: string;
  44326. /**
  44327. * Function called to create a new plugin
  44328. * @return the new plugin
  44329. */
  44330. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44331. /**
  44332. * The callback that returns true if the data can be directly loaded.
  44333. * @param data string containing the file data
  44334. * @returns if the data can be loaded directly
  44335. */
  44336. canDirectLoad?(data: string): boolean;
  44337. }
  44338. /**
  44339. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44340. */
  44341. export interface ISceneLoaderPluginBase {
  44342. /**
  44343. * The friendly name of this plugin.
  44344. */
  44345. name: string;
  44346. /**
  44347. * The file extensions supported by this plugin.
  44348. */
  44349. extensions: string | ISceneLoaderPluginExtensions;
  44350. /**
  44351. * The callback called when loading from a url.
  44352. * @param scene scene loading this url
  44353. * @param url url to load
  44354. * @param onSuccess callback called when the file successfully loads
  44355. * @param onProgress callback called while file is loading (if the server supports this mode)
  44356. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44357. * @param onError callback called when the file fails to load
  44358. * @returns a file request object
  44359. */
  44360. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44361. /**
  44362. * The callback called when loading from a file object.
  44363. * @param scene scene loading this file
  44364. * @param file defines the file to load
  44365. * @param onSuccess defines the callback to call when data is loaded
  44366. * @param onProgress defines the callback to call during loading process
  44367. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44368. * @param onError defines the callback to call when an error occurs
  44369. * @returns a file request object
  44370. */
  44371. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44372. /**
  44373. * The callback that returns true if the data can be directly loaded.
  44374. * @param data string containing the file data
  44375. * @returns if the data can be loaded directly
  44376. */
  44377. canDirectLoad?(data: string): boolean;
  44378. /**
  44379. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44380. * @param scene scene loading this data
  44381. * @param data string containing the data
  44382. * @returns data to pass to the plugin
  44383. */
  44384. directLoad?(scene: Scene, data: string): any;
  44385. /**
  44386. * The callback that allows custom handling of the root url based on the response url.
  44387. * @param rootUrl the original root url
  44388. * @param responseURL the response url if available
  44389. * @returns the new root url
  44390. */
  44391. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44392. }
  44393. /**
  44394. * Interface used to define a SceneLoader plugin
  44395. */
  44396. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44397. /**
  44398. * Import meshes into a scene.
  44399. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44400. * @param scene The scene to import into
  44401. * @param data The data to import
  44402. * @param rootUrl The root url for scene and resources
  44403. * @param meshes The meshes array to import into
  44404. * @param particleSystems The particle systems array to import into
  44405. * @param skeletons The skeletons array to import into
  44406. * @param onError The callback when import fails
  44407. * @returns True if successful or false otherwise
  44408. */
  44409. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44410. /**
  44411. * Load into a scene.
  44412. * @param scene The scene to load into
  44413. * @param data The data to import
  44414. * @param rootUrl The root url for scene and resources
  44415. * @param onError The callback when import fails
  44416. * @returns True if successful or false otherwise
  44417. */
  44418. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44419. /**
  44420. * Load into an asset container.
  44421. * @param scene The scene to load into
  44422. * @param data The data to import
  44423. * @param rootUrl The root url for scene and resources
  44424. * @param onError The callback when import fails
  44425. * @returns The loaded asset container
  44426. */
  44427. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44428. }
  44429. /**
  44430. * Interface used to define an async SceneLoader plugin
  44431. */
  44432. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44433. /**
  44434. * Import meshes into a scene.
  44435. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44436. * @param scene The scene to import into
  44437. * @param data The data to import
  44438. * @param rootUrl The root url for scene and resources
  44439. * @param onProgress The callback when the load progresses
  44440. * @param fileName Defines the name of the file to load
  44441. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44442. */
  44443. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44444. meshes: AbstractMesh[];
  44445. particleSystems: IParticleSystem[];
  44446. skeletons: Skeleton[];
  44447. animationGroups: AnimationGroup[];
  44448. }>;
  44449. /**
  44450. * Load into a scene.
  44451. * @param scene The scene to load into
  44452. * @param data The data to import
  44453. * @param rootUrl The root url for scene and resources
  44454. * @param onProgress The callback when the load progresses
  44455. * @param fileName Defines the name of the file to load
  44456. * @returns Nothing
  44457. */
  44458. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44459. /**
  44460. * Load into an asset container.
  44461. * @param scene The scene to load into
  44462. * @param data The data to import
  44463. * @param rootUrl The root url for scene and resources
  44464. * @param onProgress The callback when the load progresses
  44465. * @param fileName Defines the name of the file to load
  44466. * @returns The loaded asset container
  44467. */
  44468. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44469. }
  44470. /**
  44471. * Mode that determines how to handle old animation groups before loading new ones.
  44472. */
  44473. export enum SceneLoaderAnimationGroupLoadingMode {
  44474. /**
  44475. * Reset all old animations to initial state then dispose them.
  44476. */
  44477. Clean = 0,
  44478. /**
  44479. * Stop all old animations.
  44480. */
  44481. Stop = 1,
  44482. /**
  44483. * Restart old animations from first frame.
  44484. */
  44485. Sync = 2,
  44486. /**
  44487. * Old animations remains untouched.
  44488. */
  44489. NoSync = 3
  44490. }
  44491. /**
  44492. * Class used to load scene from various file formats using registered plugins
  44493. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44494. */
  44495. export class SceneLoader {
  44496. /**
  44497. * No logging while loading
  44498. */
  44499. static readonly NO_LOGGING: number;
  44500. /**
  44501. * Minimal logging while loading
  44502. */
  44503. static readonly MINIMAL_LOGGING: number;
  44504. /**
  44505. * Summary logging while loading
  44506. */
  44507. static readonly SUMMARY_LOGGING: number;
  44508. /**
  44509. * Detailled logging while loading
  44510. */
  44511. static readonly DETAILED_LOGGING: number;
  44512. /**
  44513. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44514. */
  44515. static get ForceFullSceneLoadingForIncremental(): boolean;
  44516. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44517. /**
  44518. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44519. */
  44520. static get ShowLoadingScreen(): boolean;
  44521. static set ShowLoadingScreen(value: boolean);
  44522. /**
  44523. * Defines the current logging level (while loading the scene)
  44524. * @ignorenaming
  44525. */
  44526. static get loggingLevel(): number;
  44527. static set loggingLevel(value: number);
  44528. /**
  44529. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44530. */
  44531. static get CleanBoneMatrixWeights(): boolean;
  44532. static set CleanBoneMatrixWeights(value: boolean);
  44533. /**
  44534. * Event raised when a plugin is used to load a scene
  44535. */
  44536. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44537. private static _registeredPlugins;
  44538. private static _getDefaultPlugin;
  44539. private static _getPluginForExtension;
  44540. private static _getPluginForDirectLoad;
  44541. private static _getPluginForFilename;
  44542. private static _getDirectLoad;
  44543. private static _loadData;
  44544. private static _getFileInfo;
  44545. /**
  44546. * Gets a plugin that can load the given extension
  44547. * @param extension defines the extension to load
  44548. * @returns a plugin or null if none works
  44549. */
  44550. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44551. /**
  44552. * Gets a boolean indicating that the given extension can be loaded
  44553. * @param extension defines the extension to load
  44554. * @returns true if the extension is supported
  44555. */
  44556. static IsPluginForExtensionAvailable(extension: string): boolean;
  44557. /**
  44558. * Adds a new plugin to the list of registered plugins
  44559. * @param plugin defines the plugin to add
  44560. */
  44561. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44562. /**
  44563. * Import meshes into a scene
  44564. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44565. * @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)
  44566. * @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)
  44567. * @param scene the instance of BABYLON.Scene to append to
  44568. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44569. * @param onProgress a callback with a progress event for each file being loaded
  44570. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44571. * @param pluginExtension the extension used to determine the plugin
  44572. * @returns The loaded plugin
  44573. */
  44574. 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>;
  44575. /**
  44576. * Import meshes into a scene
  44577. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44578. * @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)
  44579. * @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)
  44580. * @param scene the instance of BABYLON.Scene to append to
  44581. * @param onProgress a callback with a progress event for each file being loaded
  44582. * @param pluginExtension the extension used to determine the plugin
  44583. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44584. */
  44585. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44586. meshes: AbstractMesh[];
  44587. particleSystems: IParticleSystem[];
  44588. skeletons: Skeleton[];
  44589. animationGroups: AnimationGroup[];
  44590. }>;
  44591. /**
  44592. * Load a scene
  44593. * @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)
  44594. * @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)
  44595. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44596. * @param onSuccess a callback with the scene when import succeeds
  44597. * @param onProgress a callback with a progress event for each file being loaded
  44598. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44599. * @param pluginExtension the extension used to determine the plugin
  44600. * @returns The loaded plugin
  44601. */
  44602. 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>;
  44603. /**
  44604. * Load a scene
  44605. * @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)
  44606. * @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)
  44607. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44608. * @param onProgress a callback with a progress event for each file being loaded
  44609. * @param pluginExtension the extension used to determine the plugin
  44610. * @returns The loaded scene
  44611. */
  44612. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44613. /**
  44614. * Append a scene
  44615. * @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)
  44616. * @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)
  44617. * @param scene is the instance of BABYLON.Scene to append to
  44618. * @param onSuccess a callback with the scene when import succeeds
  44619. * @param onProgress a callback with a progress event for each file being loaded
  44620. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44621. * @param pluginExtension the extension used to determine the plugin
  44622. * @returns The loaded plugin
  44623. */
  44624. 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>;
  44625. /**
  44626. * Append a scene
  44627. * @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)
  44628. * @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)
  44629. * @param scene is the instance of BABYLON.Scene to append to
  44630. * @param onProgress a callback with a progress event for each file being loaded
  44631. * @param pluginExtension the extension used to determine the plugin
  44632. * @returns The given scene
  44633. */
  44634. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44635. /**
  44636. * Load a scene into an asset container
  44637. * @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)
  44638. * @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)
  44639. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44640. * @param onSuccess a callback with the scene when import succeeds
  44641. * @param onProgress a callback with a progress event for each file being loaded
  44642. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44643. * @param pluginExtension the extension used to determine the plugin
  44644. * @returns The loaded plugin
  44645. */
  44646. 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>;
  44647. /**
  44648. * Load a scene into an asset container
  44649. * @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)
  44650. * @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)
  44651. * @param scene is the instance of Scene to append to
  44652. * @param onProgress a callback with a progress event for each file being loaded
  44653. * @param pluginExtension the extension used to determine the plugin
  44654. * @returns The loaded asset container
  44655. */
  44656. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44657. /**
  44658. * Import animations from a file into a scene
  44659. * @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)
  44660. * @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)
  44661. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44662. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44663. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44664. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44665. * @param onSuccess a callback with the scene when import succeeds
  44666. * @param onProgress a callback with a progress event for each file being loaded
  44667. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44668. */
  44669. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  44670. /**
  44671. * Import animations from a file into a scene
  44672. * @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)
  44673. * @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)
  44674. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44675. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44676. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44677. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44678. * @param onSuccess a callback with the scene when import succeeds
  44679. * @param onProgress a callback with a progress event for each file being loaded
  44680. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44681. * @returns the updated scene with imported animations
  44682. */
  44683. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  44684. }
  44685. }
  44686. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44687. import { Scene } from "babylonjs/scene";
  44688. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44689. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44690. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44691. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44692. /**
  44693. * Generic Controller
  44694. */
  44695. export class GenericController extends WebVRController {
  44696. /**
  44697. * Base Url for the controller model.
  44698. */
  44699. static readonly MODEL_BASE_URL: string;
  44700. /**
  44701. * File name for the controller model.
  44702. */
  44703. static readonly MODEL_FILENAME: string;
  44704. /**
  44705. * Creates a new GenericController from a gamepad
  44706. * @param vrGamepad the gamepad that the controller should be created from
  44707. */
  44708. constructor(vrGamepad: any);
  44709. /**
  44710. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44711. * @param scene scene in which to add meshes
  44712. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44713. */
  44714. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44715. /**
  44716. * Called once for each button that changed state since the last frame
  44717. * @param buttonIdx Which button index changed
  44718. * @param state New state of the button
  44719. * @param changes Which properties on the state changed since last frame
  44720. */
  44721. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44722. }
  44723. }
  44724. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44725. import { Observable } from "babylonjs/Misc/observable";
  44726. import { Scene } from "babylonjs/scene";
  44727. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44728. import { Ray } from "babylonjs/Culling/ray";
  44729. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44730. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44731. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44732. /**
  44733. * Defines the WindowsMotionController object that the state of the windows motion controller
  44734. */
  44735. export class WindowsMotionController extends WebVRController {
  44736. /**
  44737. * The base url used to load the left and right controller models
  44738. */
  44739. static MODEL_BASE_URL: string;
  44740. /**
  44741. * The name of the left controller model file
  44742. */
  44743. static MODEL_LEFT_FILENAME: string;
  44744. /**
  44745. * The name of the right controller model file
  44746. */
  44747. static MODEL_RIGHT_FILENAME: string;
  44748. /**
  44749. * The controller name prefix for this controller type
  44750. */
  44751. static readonly GAMEPAD_ID_PREFIX: string;
  44752. /**
  44753. * The controller id pattern for this controller type
  44754. */
  44755. private static readonly GAMEPAD_ID_PATTERN;
  44756. private _loadedMeshInfo;
  44757. protected readonly _mapping: {
  44758. buttons: string[];
  44759. buttonMeshNames: {
  44760. 'trigger': string;
  44761. 'menu': string;
  44762. 'grip': string;
  44763. 'thumbstick': string;
  44764. 'trackpad': string;
  44765. };
  44766. buttonObservableNames: {
  44767. 'trigger': string;
  44768. 'menu': string;
  44769. 'grip': string;
  44770. 'thumbstick': string;
  44771. 'trackpad': string;
  44772. };
  44773. axisMeshNames: string[];
  44774. pointingPoseMeshName: string;
  44775. };
  44776. /**
  44777. * Fired when the trackpad on this controller is clicked
  44778. */
  44779. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44780. /**
  44781. * Fired when the trackpad on this controller is modified
  44782. */
  44783. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44784. /**
  44785. * The current x and y values of this controller's trackpad
  44786. */
  44787. trackpad: StickValues;
  44788. /**
  44789. * Creates a new WindowsMotionController from a gamepad
  44790. * @param vrGamepad the gamepad that the controller should be created from
  44791. */
  44792. constructor(vrGamepad: any);
  44793. /**
  44794. * Fired when the trigger on this controller is modified
  44795. */
  44796. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44797. /**
  44798. * Fired when the menu button on this controller is modified
  44799. */
  44800. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44801. /**
  44802. * Fired when the grip button on this controller is modified
  44803. */
  44804. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44805. /**
  44806. * Fired when the thumbstick button on this controller is modified
  44807. */
  44808. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44809. /**
  44810. * Fired when the touchpad button on this controller is modified
  44811. */
  44812. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44813. /**
  44814. * Fired when the touchpad values on this controller are modified
  44815. */
  44816. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  44817. protected _updateTrackpad(): void;
  44818. /**
  44819. * Called once per frame by the engine.
  44820. */
  44821. update(): void;
  44822. /**
  44823. * Called once for each button that changed state since the last frame
  44824. * @param buttonIdx Which button index changed
  44825. * @param state New state of the button
  44826. * @param changes Which properties on the state changed since last frame
  44827. */
  44828. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44829. /**
  44830. * Moves the buttons on the controller mesh based on their current state
  44831. * @param buttonName the name of the button to move
  44832. * @param buttonValue the value of the button which determines the buttons new position
  44833. */
  44834. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44835. /**
  44836. * Moves the axis on the controller mesh based on its current state
  44837. * @param axis the index of the axis
  44838. * @param axisValue the value of the axis which determines the meshes new position
  44839. * @hidden
  44840. */
  44841. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44842. /**
  44843. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44844. * @param scene scene in which to add meshes
  44845. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44846. */
  44847. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44848. /**
  44849. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44850. * can be transformed by button presses and axes values, based on this._mapping.
  44851. *
  44852. * @param scene scene in which the meshes exist
  44853. * @param meshes list of meshes that make up the controller model to process
  44854. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44855. */
  44856. private processModel;
  44857. private createMeshInfo;
  44858. /**
  44859. * Gets the ray of the controller in the direction the controller is pointing
  44860. * @param length the length the resulting ray should be
  44861. * @returns a ray in the direction the controller is pointing
  44862. */
  44863. getForwardRay(length?: number): Ray;
  44864. /**
  44865. * Disposes of the controller
  44866. */
  44867. dispose(): void;
  44868. }
  44869. /**
  44870. * This class represents a new windows motion controller in XR.
  44871. */
  44872. export class XRWindowsMotionController extends WindowsMotionController {
  44873. /**
  44874. * Changing the original WIndowsMotionController mapping to fir the new mapping
  44875. */
  44876. protected readonly _mapping: {
  44877. buttons: string[];
  44878. buttonMeshNames: {
  44879. 'trigger': string;
  44880. 'menu': string;
  44881. 'grip': string;
  44882. 'thumbstick': string;
  44883. 'trackpad': string;
  44884. };
  44885. buttonObservableNames: {
  44886. 'trigger': string;
  44887. 'menu': string;
  44888. 'grip': string;
  44889. 'thumbstick': string;
  44890. 'trackpad': string;
  44891. };
  44892. axisMeshNames: string[];
  44893. pointingPoseMeshName: string;
  44894. };
  44895. /**
  44896. * Construct a new XR-Based windows motion controller
  44897. *
  44898. * @param gamepadInfo the gamepad object from the browser
  44899. */
  44900. constructor(gamepadInfo: any);
  44901. /**
  44902. * holds the thumbstick values (X,Y)
  44903. */
  44904. thumbstickValues: StickValues;
  44905. /**
  44906. * Fired when the thumbstick on this controller is clicked
  44907. */
  44908. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  44909. /**
  44910. * Fired when the thumbstick on this controller is modified
  44911. */
  44912. onThumbstickValuesChangedObservable: Observable<StickValues>;
  44913. /**
  44914. * Fired when the touchpad button on this controller is modified
  44915. */
  44916. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44917. /**
  44918. * Fired when the touchpad values on this controller are modified
  44919. */
  44920. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44921. /**
  44922. * Fired when the thumbstick button on this controller is modified
  44923. * here to prevent breaking changes
  44924. */
  44925. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44926. /**
  44927. * updating the thumbstick(!) and not the trackpad.
  44928. * This is named this way due to the difference between WebVR and XR and to avoid
  44929. * changing the parent class.
  44930. */
  44931. protected _updateTrackpad(): void;
  44932. /**
  44933. * Disposes the class with joy
  44934. */
  44935. dispose(): void;
  44936. }
  44937. }
  44938. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44939. import { Observable } from "babylonjs/Misc/observable";
  44940. import { Scene } from "babylonjs/scene";
  44941. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44942. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44943. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44944. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44945. /**
  44946. * Oculus Touch Controller
  44947. */
  44948. export class OculusTouchController extends WebVRController {
  44949. /**
  44950. * Base Url for the controller model.
  44951. */
  44952. static MODEL_BASE_URL: string;
  44953. /**
  44954. * File name for the left controller model.
  44955. */
  44956. static MODEL_LEFT_FILENAME: string;
  44957. /**
  44958. * File name for the right controller model.
  44959. */
  44960. static MODEL_RIGHT_FILENAME: string;
  44961. /**
  44962. * Base Url for the Quest controller model.
  44963. */
  44964. static QUEST_MODEL_BASE_URL: string;
  44965. /**
  44966. * @hidden
  44967. * If the controllers are running on a device that needs the updated Quest controller models
  44968. */
  44969. static _IsQuest: boolean;
  44970. /**
  44971. * Fired when the secondary trigger on this controller is modified
  44972. */
  44973. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44974. /**
  44975. * Fired when the thumb rest on this controller is modified
  44976. */
  44977. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44978. /**
  44979. * Creates a new OculusTouchController from a gamepad
  44980. * @param vrGamepad the gamepad that the controller should be created from
  44981. */
  44982. constructor(vrGamepad: any);
  44983. /**
  44984. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44985. * @param scene scene in which to add meshes
  44986. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44987. */
  44988. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44989. /**
  44990. * Fired when the A button on this controller is modified
  44991. */
  44992. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44993. /**
  44994. * Fired when the B button on this controller is modified
  44995. */
  44996. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  44997. /**
  44998. * Fired when the X button on this controller is modified
  44999. */
  45000. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  45001. /**
  45002. * Fired when the Y button on this controller is modified
  45003. */
  45004. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  45005. /**
  45006. * Called once for each button that changed state since the last frame
  45007. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  45008. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  45009. * 2) secondary trigger (same)
  45010. * 3) A (right) X (left), touch, pressed = value
  45011. * 4) B / Y
  45012. * 5) thumb rest
  45013. * @param buttonIdx Which button index changed
  45014. * @param state New state of the button
  45015. * @param changes Which properties on the state changed since last frame
  45016. */
  45017. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45018. }
  45019. }
  45020. declare module "babylonjs/Gamepads/Controllers/viveController" {
  45021. import { Scene } from "babylonjs/scene";
  45022. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45023. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45024. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45025. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45026. import { Observable } from "babylonjs/Misc/observable";
  45027. /**
  45028. * Vive Controller
  45029. */
  45030. export class ViveController extends WebVRController {
  45031. /**
  45032. * Base Url for the controller model.
  45033. */
  45034. static MODEL_BASE_URL: string;
  45035. /**
  45036. * File name for the controller model.
  45037. */
  45038. static MODEL_FILENAME: string;
  45039. /**
  45040. * Creates a new ViveController from a gamepad
  45041. * @param vrGamepad the gamepad that the controller should be created from
  45042. */
  45043. constructor(vrGamepad: any);
  45044. /**
  45045. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45046. * @param scene scene in which to add meshes
  45047. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45048. */
  45049. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45050. /**
  45051. * Fired when the left button on this controller is modified
  45052. */
  45053. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  45054. /**
  45055. * Fired when the right button on this controller is modified
  45056. */
  45057. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  45058. /**
  45059. * Fired when the menu button on this controller is modified
  45060. */
  45061. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  45062. /**
  45063. * Called once for each button that changed state since the last frame
  45064. * Vive mapping:
  45065. * 0: touchpad
  45066. * 1: trigger
  45067. * 2: left AND right buttons
  45068. * 3: menu button
  45069. * @param buttonIdx Which button index changed
  45070. * @param state New state of the button
  45071. * @param changes Which properties on the state changed since last frame
  45072. */
  45073. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45074. }
  45075. }
  45076. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  45077. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45078. import { Observable } from "babylonjs/Misc/observable";
  45079. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  45080. /**
  45081. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  45082. */
  45083. export class WebXRControllerModelLoader {
  45084. /**
  45085. * an observable that triggers when a new model (the mesh itself) was initialized.
  45086. * To know when the mesh was loaded use the controller's own modelLoaded() method
  45087. */
  45088. onControllerModelLoaded: Observable<WebXRController>;
  45089. /**
  45090. * Creates the WebXRControllerModelLoader
  45091. * @param input xr input that creates the controllers
  45092. */
  45093. constructor(input: WebXRInput);
  45094. }
  45095. }
  45096. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  45097. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45098. /**
  45099. * Handles pointer input automatically for the pointer of XR controllers
  45100. */
  45101. export class WebXRControllerPointerSelection {
  45102. private static _idCounter;
  45103. private _tmpRay;
  45104. /**
  45105. * Creates a WebXRControllerPointerSelection
  45106. * @param input input manager to setup pointer selection
  45107. */
  45108. constructor(input: WebXRInput);
  45109. private _convertNormalToDirectionOfRay;
  45110. private _updatePointerDistance;
  45111. }
  45112. }
  45113. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  45114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45115. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45116. /**
  45117. * Enables teleportation
  45118. */
  45119. export class WebXRControllerTeleportation {
  45120. private _teleportationFillColor;
  45121. private _teleportationBorderColor;
  45122. private _tmpRay;
  45123. private _tmpVector;
  45124. /**
  45125. * when set to true (default) teleportation will wait for thumbstick changes.
  45126. * When set to false teleportation will be disabled.
  45127. *
  45128. * If set to false while teleporting results can be unexpected.
  45129. */
  45130. enabled: boolean;
  45131. /**
  45132. * Creates a WebXRControllerTeleportation
  45133. * @param input input manager to add teleportation to
  45134. * @param floorMeshes floormeshes which can be teleported to
  45135. */
  45136. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  45137. }
  45138. }
  45139. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  45140. import { Nullable } from "babylonjs/types";
  45141. import { Observable } from "babylonjs/Misc/observable";
  45142. import { IDisposable, Scene } from "babylonjs/scene";
  45143. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45144. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  45145. /**
  45146. * Button which can be used to enter a different mode of XR
  45147. */
  45148. export class WebXREnterExitUIButton {
  45149. /** button element */
  45150. element: HTMLElement;
  45151. /** XR initialization options for the button */
  45152. sessionMode: XRSessionMode;
  45153. /** Reference space type */
  45154. referenceSpaceType: XRReferenceSpaceType;
  45155. /**
  45156. * Creates a WebXREnterExitUIButton
  45157. * @param element button element
  45158. * @param sessionMode XR initialization session mode
  45159. * @param referenceSpaceType the type of reference space to be used
  45160. */
  45161. constructor(
  45162. /** button element */
  45163. element: HTMLElement,
  45164. /** XR initialization options for the button */
  45165. sessionMode: XRSessionMode,
  45166. /** Reference space type */
  45167. referenceSpaceType: XRReferenceSpaceType);
  45168. /**
  45169. * Overwritable function which can be used to update the button's visuals when the state changes
  45170. * @param activeButton the current active button in the UI
  45171. */
  45172. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45173. }
  45174. /**
  45175. * Options to create the webXR UI
  45176. */
  45177. export class WebXREnterExitUIOptions {
  45178. /**
  45179. * Context to enter xr with
  45180. */
  45181. renderTarget?: Nullable<WebXRRenderTarget>;
  45182. /**
  45183. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45184. */
  45185. customButtons?: Array<WebXREnterExitUIButton>;
  45186. /**
  45187. * A session mode to use when creating the default button.
  45188. * Default is immersive-vr
  45189. */
  45190. sessionMode?: XRSessionMode;
  45191. /**
  45192. * A reference space type to use when creating the default button.
  45193. * Default is local-floor
  45194. */
  45195. referenceSpaceType?: XRReferenceSpaceType;
  45196. }
  45197. /**
  45198. * UI to allow the user to enter/exit XR mode
  45199. */
  45200. export class WebXREnterExitUI implements IDisposable {
  45201. private scene;
  45202. /** version of the options passed to this UI */
  45203. options: WebXREnterExitUIOptions;
  45204. private _overlay;
  45205. private _buttons;
  45206. private _activeButton;
  45207. /**
  45208. * Fired every time the active button is changed.
  45209. *
  45210. * When xr is entered via a button that launches xr that button will be the callback parameter
  45211. *
  45212. * When exiting xr the callback parameter will be null)
  45213. */
  45214. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45215. /**
  45216. * Creates UI to allow the user to enter/exit XR mode
  45217. * @param scene the scene to add the ui to
  45218. * @param helper the xr experience helper to enter/exit xr with
  45219. * @param options options to configure the UI
  45220. * @returns the created ui
  45221. */
  45222. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45223. /**
  45224. *
  45225. * @param scene babylon scene object to use
  45226. * @param options (read-only) version of the options passed to this UI
  45227. */
  45228. private constructor();
  45229. private _updateButtons;
  45230. /**
  45231. * Disposes of the object
  45232. */
  45233. dispose(): void;
  45234. }
  45235. }
  45236. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  45237. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45238. import { Scene } from "babylonjs/scene";
  45239. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45240. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  45241. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  45242. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  45243. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  45244. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/Cameras/XR/webXREnterExitUI";
  45245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45246. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  45247. /**
  45248. * Options for the default xr helper
  45249. */
  45250. export class WebXRDefaultExperienceOptions {
  45251. /**
  45252. * Floor meshes that should be used for teleporting
  45253. */
  45254. floorMeshes: Array<AbstractMesh>;
  45255. /**
  45256. * Enable or disable default UI to enter XR
  45257. */
  45258. disableDefaultUI?: boolean;
  45259. /**
  45260. * optional configuration for the output canvas
  45261. */
  45262. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45263. /**
  45264. * optional UI options. This can be used among other to change session mode and reference space type
  45265. */
  45266. uiOptions?: WebXREnterExitUIOptions;
  45267. }
  45268. /**
  45269. * Default experience which provides a similar setup to the previous webVRExperience
  45270. */
  45271. export class WebXRDefaultExperience {
  45272. /**
  45273. * Base experience
  45274. */
  45275. baseExperience: WebXRExperienceHelper;
  45276. /**
  45277. * Input experience extension
  45278. */
  45279. input: WebXRInput;
  45280. /**
  45281. * Loads the controller models
  45282. */
  45283. controllerModelLoader: WebXRControllerModelLoader;
  45284. /**
  45285. * Enables laser pointer and selection
  45286. */
  45287. pointerSelection: WebXRControllerPointerSelection;
  45288. /**
  45289. * Enables teleportation
  45290. */
  45291. teleportation: WebXRControllerTeleportation;
  45292. /**
  45293. * Enables ui for entering/exiting xr
  45294. */
  45295. enterExitUI: WebXREnterExitUI;
  45296. /**
  45297. * Default target xr should render to
  45298. */
  45299. renderTarget: WebXRRenderTarget;
  45300. /**
  45301. * Creates the default xr experience
  45302. * @param scene scene
  45303. * @param options options for basic configuration
  45304. * @returns resulting WebXRDefaultExperience
  45305. */
  45306. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45307. private constructor();
  45308. /**
  45309. * DIsposes of the experience helper
  45310. */
  45311. dispose(): void;
  45312. }
  45313. }
  45314. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  45315. import { Observable } from "babylonjs/Misc/observable";
  45316. import { Nullable } from "babylonjs/types";
  45317. import { Camera } from "babylonjs/Cameras/camera";
  45318. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  45319. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  45320. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  45321. import { Scene } from "babylonjs/scene";
  45322. import { Vector3 } from "babylonjs/Maths/math.vector";
  45323. import { Color3 } from "babylonjs/Maths/math.color";
  45324. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45326. import { Mesh } from "babylonjs/Meshes/mesh";
  45327. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  45328. import { EasingFunction } from "babylonjs/Animations/easing";
  45329. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  45330. import "babylonjs/Meshes/Builders/groundBuilder";
  45331. import "babylonjs/Meshes/Builders/torusBuilder";
  45332. import "babylonjs/Meshes/Builders/cylinderBuilder";
  45333. import "babylonjs/Gamepads/gamepadSceneComponent";
  45334. import "babylonjs/Animations/animatable";
  45335. import { WebXRDefaultExperience } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  45336. /**
  45337. * Options to modify the vr teleportation behavior.
  45338. */
  45339. export interface VRTeleportationOptions {
  45340. /**
  45341. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45342. */
  45343. floorMeshName?: string;
  45344. /**
  45345. * A list of meshes to be used as the teleportation floor. (default: empty)
  45346. */
  45347. floorMeshes?: Mesh[];
  45348. /**
  45349. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45350. */
  45351. teleportationMode?: number;
  45352. /**
  45353. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45354. */
  45355. teleportationTime?: number;
  45356. /**
  45357. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45358. */
  45359. teleportationSpeed?: number;
  45360. /**
  45361. * The easing function used in the animation or null for Linear. (default CircleEase)
  45362. */
  45363. easingFunction?: EasingFunction;
  45364. }
  45365. /**
  45366. * Options to modify the vr experience helper's behavior.
  45367. */
  45368. export interface VRExperienceHelperOptions extends WebVROptions {
  45369. /**
  45370. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45371. */
  45372. createDeviceOrientationCamera?: boolean;
  45373. /**
  45374. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45375. */
  45376. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45377. /**
  45378. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45379. */
  45380. laserToggle?: boolean;
  45381. /**
  45382. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45383. */
  45384. floorMeshes?: Mesh[];
  45385. /**
  45386. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45387. */
  45388. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45389. /**
  45390. * Defines if WebXR should be used instead of WebVR (if available)
  45391. */
  45392. useXR?: boolean;
  45393. }
  45394. /**
  45395. * Event containing information after VR has been entered
  45396. */
  45397. export class OnAfterEnteringVRObservableEvent {
  45398. /**
  45399. * If entering vr was successful
  45400. */
  45401. success: boolean;
  45402. }
  45403. /**
  45404. * Helps to quickly add VR support to an existing scene.
  45405. * See http://doc.babylonjs.com/how_to/webvr_helper
  45406. */
  45407. export class VRExperienceHelper {
  45408. /** Options to modify the vr experience helper's behavior. */
  45409. webVROptions: VRExperienceHelperOptions;
  45410. private _scene;
  45411. private _position;
  45412. private _btnVR;
  45413. private _btnVRDisplayed;
  45414. private _webVRsupported;
  45415. private _webVRready;
  45416. private _webVRrequesting;
  45417. private _webVRpresenting;
  45418. private _hasEnteredVR;
  45419. private _fullscreenVRpresenting;
  45420. private _inputElement;
  45421. private _webVRCamera;
  45422. private _vrDeviceOrientationCamera;
  45423. private _deviceOrientationCamera;
  45424. private _existingCamera;
  45425. private _onKeyDown;
  45426. private _onVrDisplayPresentChange;
  45427. private _onVRDisplayChanged;
  45428. private _onVRRequestPresentStart;
  45429. private _onVRRequestPresentComplete;
  45430. /**
  45431. * 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)
  45432. */
  45433. enableGazeEvenWhenNoPointerLock: boolean;
  45434. /**
  45435. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45436. */
  45437. exitVROnDoubleTap: boolean;
  45438. /**
  45439. * Observable raised right before entering VR.
  45440. */
  45441. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45442. /**
  45443. * Observable raised when entering VR has completed.
  45444. */
  45445. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45446. /**
  45447. * Observable raised when exiting VR.
  45448. */
  45449. onExitingVRObservable: Observable<VRExperienceHelper>;
  45450. /**
  45451. * Observable raised when controller mesh is loaded.
  45452. */
  45453. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45454. /** Return this.onEnteringVRObservable
  45455. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45456. */
  45457. get onEnteringVR(): Observable<VRExperienceHelper>;
  45458. /** Return this.onExitingVRObservable
  45459. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45460. */
  45461. get onExitingVR(): Observable<VRExperienceHelper>;
  45462. /** Return this.onControllerMeshLoadedObservable
  45463. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45464. */
  45465. get onControllerMeshLoaded(): Observable<WebVRController>;
  45466. private _rayLength;
  45467. private _useCustomVRButton;
  45468. private _teleportationRequested;
  45469. private _teleportActive;
  45470. private _floorMeshName;
  45471. private _floorMeshesCollection;
  45472. private _teleportationMode;
  45473. private _teleportationTime;
  45474. private _teleportationSpeed;
  45475. private _teleportationEasing;
  45476. private _rotationAllowed;
  45477. private _teleportBackwardsVector;
  45478. private _teleportationTarget;
  45479. private _isDefaultTeleportationTarget;
  45480. private _postProcessMove;
  45481. private _teleportationFillColor;
  45482. private _teleportationBorderColor;
  45483. private _rotationAngle;
  45484. private _haloCenter;
  45485. private _cameraGazer;
  45486. private _padSensibilityUp;
  45487. private _padSensibilityDown;
  45488. private _leftController;
  45489. private _rightController;
  45490. private _gazeColor;
  45491. private _laserColor;
  45492. private _pickedLaserColor;
  45493. private _pickedGazeColor;
  45494. /**
  45495. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45496. */
  45497. onNewMeshSelected: Observable<AbstractMesh>;
  45498. /**
  45499. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45500. * This observable will provide the mesh and the controller used to select the mesh
  45501. */
  45502. onMeshSelectedWithController: Observable<{
  45503. mesh: AbstractMesh;
  45504. controller: WebVRController;
  45505. }>;
  45506. /**
  45507. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45508. */
  45509. onNewMeshPicked: Observable<PickingInfo>;
  45510. private _circleEase;
  45511. /**
  45512. * Observable raised before camera teleportation
  45513. */
  45514. onBeforeCameraTeleport: Observable<Vector3>;
  45515. /**
  45516. * Observable raised after camera teleportation
  45517. */
  45518. onAfterCameraTeleport: Observable<Vector3>;
  45519. /**
  45520. * Observable raised when current selected mesh gets unselected
  45521. */
  45522. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45523. private _raySelectionPredicate;
  45524. /**
  45525. * To be optionaly changed by user to define custom ray selection
  45526. */
  45527. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45528. /**
  45529. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45530. */
  45531. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45532. /**
  45533. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45534. */
  45535. teleportationEnabled: boolean;
  45536. private _defaultHeight;
  45537. private _teleportationInitialized;
  45538. private _interactionsEnabled;
  45539. private _interactionsRequested;
  45540. private _displayGaze;
  45541. private _displayLaserPointer;
  45542. /**
  45543. * The mesh used to display where the user is going to teleport.
  45544. */
  45545. get teleportationTarget(): Mesh;
  45546. /**
  45547. * Sets the mesh to be used to display where the user is going to teleport.
  45548. */
  45549. set teleportationTarget(value: Mesh);
  45550. /**
  45551. * 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
  45552. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45553. * See http://doc.babylonjs.com/resources/baking_transformations
  45554. */
  45555. get gazeTrackerMesh(): Mesh;
  45556. set gazeTrackerMesh(value: Mesh);
  45557. /**
  45558. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45559. */
  45560. updateGazeTrackerScale: boolean;
  45561. /**
  45562. * If the gaze trackers color should be updated when selecting meshes
  45563. */
  45564. updateGazeTrackerColor: boolean;
  45565. /**
  45566. * If the controller laser color should be updated when selecting meshes
  45567. */
  45568. updateControllerLaserColor: boolean;
  45569. /**
  45570. * The gaze tracking mesh corresponding to the left controller
  45571. */
  45572. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45573. /**
  45574. * The gaze tracking mesh corresponding to the right controller
  45575. */
  45576. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45577. /**
  45578. * If the ray of the gaze should be displayed.
  45579. */
  45580. get displayGaze(): boolean;
  45581. /**
  45582. * Sets if the ray of the gaze should be displayed.
  45583. */
  45584. set displayGaze(value: boolean);
  45585. /**
  45586. * If the ray of the LaserPointer should be displayed.
  45587. */
  45588. get displayLaserPointer(): boolean;
  45589. /**
  45590. * Sets if the ray of the LaserPointer should be displayed.
  45591. */
  45592. set displayLaserPointer(value: boolean);
  45593. /**
  45594. * The deviceOrientationCamera used as the camera when not in VR.
  45595. */
  45596. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45597. /**
  45598. * Based on the current WebVR support, returns the current VR camera used.
  45599. */
  45600. get currentVRCamera(): Nullable<Camera>;
  45601. /**
  45602. * The webVRCamera which is used when in VR.
  45603. */
  45604. get webVRCamera(): WebVRFreeCamera;
  45605. /**
  45606. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45607. */
  45608. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45609. /**
  45610. * The html button that is used to trigger entering into VR.
  45611. */
  45612. get vrButton(): Nullable<HTMLButtonElement>;
  45613. private get _teleportationRequestInitiated();
  45614. /**
  45615. * Defines wether or not Pointer lock should be requested when switching to
  45616. * full screen.
  45617. */
  45618. requestPointerLockOnFullScreen: boolean;
  45619. /**
  45620. * If asking to force XR, this will be populated with the default xr experience
  45621. */
  45622. xr: WebXRDefaultExperience;
  45623. /**
  45624. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45625. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45626. */
  45627. xrTestDone: boolean;
  45628. /**
  45629. * Instantiates a VRExperienceHelper.
  45630. * Helps to quickly add VR support to an existing scene.
  45631. * @param scene The scene the VRExperienceHelper belongs to.
  45632. * @param webVROptions Options to modify the vr experience helper's behavior.
  45633. */
  45634. constructor(scene: Scene,
  45635. /** Options to modify the vr experience helper's behavior. */
  45636. webVROptions?: VRExperienceHelperOptions);
  45637. private completeVRInit;
  45638. private _onDefaultMeshLoaded;
  45639. private _onResize;
  45640. private _onFullscreenChange;
  45641. /**
  45642. * Gets a value indicating if we are currently in VR mode.
  45643. */
  45644. get isInVRMode(): boolean;
  45645. private onVrDisplayPresentChange;
  45646. private onVRDisplayChanged;
  45647. private moveButtonToBottomRight;
  45648. private displayVRButton;
  45649. private updateButtonVisibility;
  45650. private _cachedAngularSensibility;
  45651. /**
  45652. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45653. * Otherwise, will use the fullscreen API.
  45654. */
  45655. enterVR(): void;
  45656. /**
  45657. * Attempt to exit VR, or fullscreen.
  45658. */
  45659. exitVR(): void;
  45660. /**
  45661. * The position of the vr experience helper.
  45662. */
  45663. get position(): Vector3;
  45664. /**
  45665. * Sets the position of the vr experience helper.
  45666. */
  45667. set position(value: Vector3);
  45668. /**
  45669. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45670. */
  45671. enableInteractions(): void;
  45672. private get _noControllerIsActive();
  45673. private beforeRender;
  45674. private _isTeleportationFloor;
  45675. /**
  45676. * Adds a floor mesh to be used for teleportation.
  45677. * @param floorMesh the mesh to be used for teleportation.
  45678. */
  45679. addFloorMesh(floorMesh: Mesh): void;
  45680. /**
  45681. * Removes a floor mesh from being used for teleportation.
  45682. * @param floorMesh the mesh to be removed.
  45683. */
  45684. removeFloorMesh(floorMesh: Mesh): void;
  45685. /**
  45686. * Enables interactions and teleportation using the VR controllers and gaze.
  45687. * @param vrTeleportationOptions options to modify teleportation behavior.
  45688. */
  45689. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45690. private _onNewGamepadConnected;
  45691. private _tryEnableInteractionOnController;
  45692. private _onNewGamepadDisconnected;
  45693. private _enableInteractionOnController;
  45694. private _checkTeleportWithRay;
  45695. private _checkRotate;
  45696. private _checkTeleportBackwards;
  45697. private _enableTeleportationOnController;
  45698. private _createTeleportationCircles;
  45699. private _displayTeleportationTarget;
  45700. private _hideTeleportationTarget;
  45701. private _rotateCamera;
  45702. private _moveTeleportationSelectorTo;
  45703. private _workingVector;
  45704. private _workingQuaternion;
  45705. private _workingMatrix;
  45706. /**
  45707. * Time Constant Teleportation Mode
  45708. */
  45709. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45710. /**
  45711. * Speed Constant Teleportation Mode
  45712. */
  45713. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45714. /**
  45715. * Teleports the users feet to the desired location
  45716. * @param location The location where the user's feet should be placed
  45717. */
  45718. teleportCamera(location: Vector3): void;
  45719. private _convertNormalToDirectionOfRay;
  45720. private _castRayAndSelectObject;
  45721. private _notifySelectedMeshUnselected;
  45722. /**
  45723. * Permanently set new colors for the laser pointer
  45724. * @param color the new laser color
  45725. * @param pickedColor the new laser color when picked mesh detected
  45726. */
  45727. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45728. /**
  45729. * Permanently set new colors for the gaze pointer
  45730. * @param color the new gaze color
  45731. * @param pickedColor the new gaze color when picked mesh detected
  45732. */
  45733. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45734. /**
  45735. * Sets the color of the laser ray from the vr controllers.
  45736. * @param color new color for the ray.
  45737. */
  45738. changeLaserColor(color: Color3): void;
  45739. /**
  45740. * Sets the color of the ray from the vr headsets gaze.
  45741. * @param color new color for the ray.
  45742. */
  45743. changeGazeColor(color: Color3): void;
  45744. /**
  45745. * Exits VR and disposes of the vr experience helper
  45746. */
  45747. dispose(): void;
  45748. /**
  45749. * Gets the name of the VRExperienceHelper class
  45750. * @returns "VRExperienceHelper"
  45751. */
  45752. getClassName(): string;
  45753. }
  45754. }
  45755. declare module "babylonjs/Cameras/VR/index" {
  45756. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  45757. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  45758. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  45759. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  45760. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  45761. export * from "babylonjs/Cameras/VR/webVRCamera";
  45762. }
  45763. declare module "babylonjs/Cameras/XR/features/WebXRHitTestLegacy" {
  45764. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45765. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45766. import { Observable } from "babylonjs/Misc/observable";
  45767. import { Matrix } from "babylonjs/Maths/math.vector";
  45768. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45769. /**
  45770. * Options used for hit testing
  45771. */
  45772. export interface IWebXRHitTestOptions {
  45773. /**
  45774. * Only test when user interacted with the scene. Default - hit test every frame
  45775. */
  45776. testOnPointerDownOnly?: boolean;
  45777. /**
  45778. * The node to use to transform the local results to world coordinates
  45779. */
  45780. worldParentNode?: TransformNode;
  45781. }
  45782. /**
  45783. * Interface defining the babylon result of raycasting/hit-test
  45784. */
  45785. export interface IWebXRHitResult {
  45786. /**
  45787. * The native hit test result
  45788. */
  45789. xrHitResult: XRHitResult;
  45790. /**
  45791. * Transformation matrix that can be applied to a node that will put it in the hit point location
  45792. */
  45793. transformationMatrix: Matrix;
  45794. }
  45795. /**
  45796. * The currently-working hit-test module.
  45797. * Hit test (or raycasting) is used to interact with the real world.
  45798. * For further information read here - https://github.com/immersive-web/hit-test
  45799. */
  45800. export class WebXRHitTestLegacy implements IWebXRFeature {
  45801. private _xrSessionManager;
  45802. /**
  45803. * options to use when constructing this feature
  45804. */
  45805. readonly options: IWebXRHitTestOptions;
  45806. /**
  45807. * The module's name
  45808. */
  45809. static readonly Name: string;
  45810. /**
  45811. * The (Babylon) version of this module.
  45812. * This is an integer representing the implementation version.
  45813. * This number does not correspond to the webxr specs version
  45814. */
  45815. static readonly Version: number;
  45816. /**
  45817. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  45818. * @param event the (select) event to use to select with
  45819. * @param referenceSpace the reference space to use for this hit test
  45820. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  45821. */
  45822. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  45823. /**
  45824. * execute a hit test with an XR Ray
  45825. *
  45826. * @param xrSession a native xrSession that will execute this hit test
  45827. * @param xrRay the ray (position and direction) to use for raycasting
  45828. * @param referenceSpace native XR reference space to use for the hit-test
  45829. * @param filter filter function that will filter the results
  45830. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  45831. */
  45832. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  45833. /**
  45834. * Triggered when new babylon (transformed) hit test results are available
  45835. */
  45836. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  45837. /**
  45838. * Creates a new instance of the (legacy version) hit test feature
  45839. * @param _xrSessionManager an instance of WebXRSessionManager
  45840. * @param options options to use when constructing this feature
  45841. */
  45842. constructor(_xrSessionManager: WebXRSessionManager,
  45843. /**
  45844. * options to use when constructing this feature
  45845. */
  45846. options?: IWebXRHitTestOptions);
  45847. private _onSelectEnabled;
  45848. private _xrFrameObserver;
  45849. private _attached;
  45850. /**
  45851. * Populated with the last native XR Hit Results
  45852. */
  45853. lastNativeXRHitResults: XRHitResult[];
  45854. /**
  45855. * attach this feature
  45856. * Will usually be called by the features manager
  45857. *
  45858. * @returns true if successful.
  45859. */
  45860. attach(): boolean;
  45861. /**
  45862. * detach this feature.
  45863. * Will usually be called by the features manager
  45864. *
  45865. * @returns true if successful.
  45866. */
  45867. detach(): boolean;
  45868. private _onHitTestResults;
  45869. private _onSelect;
  45870. /**
  45871. * Dispose this feature and all of the resources attached
  45872. */
  45873. dispose(): void;
  45874. }
  45875. }
  45876. declare module "babylonjs/Cameras/XR/features/WebXRPlaneDetector" {
  45877. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45878. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45879. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45880. import { Observable } from "babylonjs/Misc/observable";
  45881. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  45882. /**
  45883. * Options used in the plane detector module
  45884. */
  45885. export interface IWebXRPlaneDetectorOptions {
  45886. /**
  45887. * The node to use to transform the local results to world coordinates
  45888. */
  45889. worldParentNode?: TransformNode;
  45890. }
  45891. /**
  45892. * A babylon interface for a webxr plane.
  45893. * A Plane is actually a polygon, built from N points in space
  45894. */
  45895. export interface IWebXRPlane {
  45896. /**
  45897. * a babylon-assigned ID for this polygon
  45898. */
  45899. id: number;
  45900. /**
  45901. * the native xr-plane object
  45902. */
  45903. xrPlane: XRPlane;
  45904. /**
  45905. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  45906. */
  45907. polygonDefinition: Array<Vector3>;
  45908. /**
  45909. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  45910. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  45911. */
  45912. transformationMatrix: Matrix;
  45913. }
  45914. /**
  45915. * The plane detector is used to detect planes in the real world when in AR
  45916. * For more information see https://github.com/immersive-web/real-world-geometry/
  45917. */
  45918. export class WebXRPlaneDetector implements IWebXRFeature {
  45919. private _xrSessionManager;
  45920. private _options;
  45921. /**
  45922. * The module's name
  45923. */
  45924. static readonly Name: string;
  45925. /**
  45926. * The (Babylon) version of this module.
  45927. * This is an integer representing the implementation version.
  45928. * This number does not correspond to the webxr specs version
  45929. */
  45930. static readonly Version: number;
  45931. /**
  45932. * Observers registered here will be executed when a new plane was added to the session
  45933. */
  45934. onPlaneAddedObservable: Observable<IWebXRPlane>;
  45935. /**
  45936. * Observers registered here will be executed when a plane is no longer detected in the session
  45937. */
  45938. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  45939. /**
  45940. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  45941. * This can execute N times every frame
  45942. */
  45943. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  45944. private _enabled;
  45945. private _attached;
  45946. private _detectedPlanes;
  45947. private _lastFrameDetected;
  45948. private _observerTracked;
  45949. /**
  45950. * construct a new Plane Detector
  45951. * @param _xrSessionManager an instance of xr Session manager
  45952. * @param _options configuration to use when constructing this feature
  45953. */
  45954. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  45955. /**
  45956. * attach this feature
  45957. * Will usually be called by the features manager
  45958. *
  45959. * @returns true if successful.
  45960. */
  45961. attach(): boolean;
  45962. /**
  45963. * detach this feature.
  45964. * Will usually be called by the features manager
  45965. *
  45966. * @returns true if successful.
  45967. */
  45968. detach(): boolean;
  45969. /**
  45970. * Dispose this feature and all of the resources attached
  45971. */
  45972. dispose(): void;
  45973. private _updatePlaneWithXRPlane;
  45974. /**
  45975. * avoiding using Array.find for global support.
  45976. * @param xrPlane the plane to find in the array
  45977. */
  45978. private findIndexInPlaneArray;
  45979. }
  45980. }
  45981. declare module "babylonjs/Cameras/XR/features/WebXRAnchorSystem" {
  45982. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45983. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45984. import { Observable } from "babylonjs/Misc/observable";
  45985. import { Matrix } from "babylonjs/Maths/math.vector";
  45986. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45987. import { WebXRPlaneDetector } from "babylonjs/Cameras/XR/features/WebXRPlaneDetector";
  45988. import { WebXRHitTestLegacy } from "babylonjs/Cameras/XR/features/WebXRHitTestLegacy";
  45989. /**
  45990. * Configuration options of the anchor system
  45991. */
  45992. export interface IWebXRAnchorSystemOptions {
  45993. /**
  45994. * a node that will be used to convert local to world coordinates
  45995. */
  45996. worldParentNode?: TransformNode;
  45997. /**
  45998. * should the anchor system use plane detection.
  45999. * If set to true, the plane-detection feature should be set using setPlaneDetector
  46000. */
  46001. usePlaneDetection?: boolean;
  46002. /**
  46003. * Should a new anchor be added every time a select event is triggered
  46004. */
  46005. addAnchorOnSelect?: boolean;
  46006. }
  46007. /**
  46008. * A babylon container for an XR Anchor
  46009. */
  46010. export interface IWebXRAnchor {
  46011. /**
  46012. * A babylon-assigned ID for this anchor
  46013. */
  46014. id: number;
  46015. /**
  46016. * The native anchor object
  46017. */
  46018. xrAnchor: XRAnchor;
  46019. /**
  46020. * Transformation matrix to apply to an object attached to this anchor
  46021. */
  46022. transformationMatrix: Matrix;
  46023. }
  46024. /**
  46025. * An implementation of the anchor system of WebXR.
  46026. * Note that the current documented implementation is not available in any browser. Future implementations
  46027. * will use the frame to create an anchor and not the session or a detected plane
  46028. * For further information see https://github.com/immersive-web/anchors/
  46029. */
  46030. export class WebXRAnchorSystem implements IWebXRFeature {
  46031. private _xrSessionManager;
  46032. private _options;
  46033. /**
  46034. * The module's name
  46035. */
  46036. static readonly Name: string;
  46037. /**
  46038. * The (Babylon) version of this module.
  46039. * This is an integer representing the implementation version.
  46040. * This number does not correspond to the webxr specs version
  46041. */
  46042. static readonly Version: number;
  46043. /**
  46044. * Observers registered here will be executed when a new anchor was added to the session
  46045. */
  46046. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  46047. /**
  46048. * Observers registered here will be executed when an existing anchor updates
  46049. * This can execute N times every frame
  46050. */
  46051. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  46052. /**
  46053. * Observers registered here will be executed when an anchor was removed from the session
  46054. */
  46055. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  46056. private _planeDetector;
  46057. private _hitTestModule;
  46058. private _enabled;
  46059. private _attached;
  46060. private _trackedAnchors;
  46061. private _lastFrameDetected;
  46062. private _observerTracked;
  46063. /**
  46064. * constructs a new anchor system
  46065. * @param _xrSessionManager an instance of WebXRSessionManager
  46066. * @param _options configuration object for this feature
  46067. */
  46068. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  46069. /**
  46070. * set the plane detector to use in order to create anchors from frames
  46071. * @param planeDetector the plane-detector module to use
  46072. * @param enable enable plane-anchors. default is true
  46073. */
  46074. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  46075. /**
  46076. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  46077. * @param hitTestModule the hit-test module to use.
  46078. */
  46079. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  46080. /**
  46081. * attach this feature
  46082. * Will usually be called by the features manager
  46083. *
  46084. * @returns true if successful.
  46085. */
  46086. attach(): boolean;
  46087. /**
  46088. * detach this feature.
  46089. * Will usually be called by the features manager
  46090. *
  46091. * @returns true if successful.
  46092. */
  46093. detach(): boolean;
  46094. /**
  46095. * Dispose this feature and all of the resources attached
  46096. */
  46097. dispose(): void;
  46098. private _onSelect;
  46099. /**
  46100. * Add anchor at a specific XR point.
  46101. *
  46102. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  46103. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  46104. * @returns a promise the fulfills when the anchor was created
  46105. */
  46106. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  46107. private _updateAnchorWithXRFrame;
  46108. /**
  46109. * avoiding using Array.find for global support.
  46110. * @param xrAnchor the plane to find in the array
  46111. */
  46112. private _findIndexInAnchorArray;
  46113. }
  46114. }
  46115. declare module "babylonjs/Cameras/XR/features/WebXRBackgroundRemover" {
  46116. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46117. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46119. import { Observable } from "babylonjs/Misc/observable";
  46120. /**
  46121. * Options interface for the background remover plugin
  46122. */
  46123. export interface IWebXRBackgroundRemoverOptions {
  46124. /**
  46125. * don't disable the environment helper
  46126. */
  46127. ignoreEnvironmentHelper?: boolean;
  46128. /**
  46129. * flags to configure the removal of the environment helper.
  46130. * If not set, the entire background will be removed. If set, flags should be set as well.
  46131. */
  46132. environmentHelperRemovalFlags?: {
  46133. /**
  46134. * Should the skybox be removed (default false)
  46135. */
  46136. skyBox?: boolean;
  46137. /**
  46138. * Should the ground be removed (default false)
  46139. */
  46140. ground?: boolean;
  46141. };
  46142. /**
  46143. * Further background meshes to disable when entering AR
  46144. */
  46145. backgroundMeshes?: AbstractMesh[];
  46146. }
  46147. /**
  46148. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  46149. */
  46150. export class WebXRBackgroundRemover implements IWebXRFeature {
  46151. private _xrSessionManager;
  46152. /**
  46153. * read-only options to be used in this module
  46154. */
  46155. readonly options: IWebXRBackgroundRemoverOptions;
  46156. /**
  46157. * The module's name
  46158. */
  46159. static readonly Name: string;
  46160. /**
  46161. * The (Babylon) version of this module.
  46162. * This is an integer representing the implementation version.
  46163. * This number does not correspond to the webxr specs version
  46164. */
  46165. static readonly Version: number;
  46166. /**
  46167. * registered observers will be triggered when the background state changes
  46168. */
  46169. onBackgroundStateChangedObservable: Observable<boolean>;
  46170. /**
  46171. * constructs a new background remover module
  46172. * @param _xrSessionManager the session manager for this module
  46173. * @param options read-only options to be used in this module
  46174. */
  46175. constructor(_xrSessionManager: WebXRSessionManager,
  46176. /**
  46177. * read-only options to be used in this module
  46178. */
  46179. options?: IWebXRBackgroundRemoverOptions);
  46180. /**
  46181. * attach this feature
  46182. * Will usually be called by the features manager
  46183. *
  46184. * @returns true if successful.
  46185. */
  46186. attach(): boolean;
  46187. /**
  46188. * detach this feature.
  46189. * Will usually be called by the features manager
  46190. *
  46191. * @returns true if successful.
  46192. */
  46193. detach(): boolean;
  46194. private _setBackgroundState;
  46195. /**
  46196. * Dispose this feature and all of the resources attached
  46197. */
  46198. dispose(): void;
  46199. }
  46200. }
  46201. declare module "babylonjs/Cameras/XR/features/index" {
  46202. export * from "babylonjs/Cameras/XR/features/WebXRHitTestLegacy";
  46203. export * from "babylonjs/Cameras/XR/features/WebXRAnchorSystem";
  46204. export * from "babylonjs/Cameras/XR/features/WebXRPlaneDetector";
  46205. export * from "babylonjs/Cameras/XR/features/WebXRBackgroundRemover";
  46206. }
  46207. declare module "babylonjs/Cameras/XR/index" {
  46208. export * from "babylonjs/Cameras/XR/webXRCamera";
  46209. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  46210. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  46211. export * from "babylonjs/Cameras/XR/webXRInput";
  46212. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  46213. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  46214. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  46215. export * from "babylonjs/Cameras/XR/webXRController";
  46216. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  46217. export * from "babylonjs/Cameras/XR/webXRTypes";
  46218. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  46219. export * from "babylonjs/Cameras/XR/webXRDefaultExperience";
  46220. export * from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46221. export * from "babylonjs/Cameras/XR/features/index";
  46222. }
  46223. declare module "babylonjs/Cameras/RigModes/index" {
  46224. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46225. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46226. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  46227. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  46228. }
  46229. declare module "babylonjs/Cameras/index" {
  46230. export * from "babylonjs/Cameras/Inputs/index";
  46231. export * from "babylonjs/Cameras/cameraInputsManager";
  46232. export * from "babylonjs/Cameras/camera";
  46233. export * from "babylonjs/Cameras/targetCamera";
  46234. export * from "babylonjs/Cameras/freeCamera";
  46235. export * from "babylonjs/Cameras/freeCameraInputsManager";
  46236. export * from "babylonjs/Cameras/touchCamera";
  46237. export * from "babylonjs/Cameras/arcRotateCamera";
  46238. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  46239. export * from "babylonjs/Cameras/deviceOrientationCamera";
  46240. export * from "babylonjs/Cameras/flyCamera";
  46241. export * from "babylonjs/Cameras/flyCameraInputsManager";
  46242. export * from "babylonjs/Cameras/followCamera";
  46243. export * from "babylonjs/Cameras/followCameraInputsManager";
  46244. export * from "babylonjs/Cameras/gamepadCamera";
  46245. export * from "babylonjs/Cameras/Stereoscopic/index";
  46246. export * from "babylonjs/Cameras/universalCamera";
  46247. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  46248. export * from "babylonjs/Cameras/VR/index";
  46249. export * from "babylonjs/Cameras/XR/index";
  46250. export * from "babylonjs/Cameras/RigModes/index";
  46251. }
  46252. declare module "babylonjs/Collisions/index" {
  46253. export * from "babylonjs/Collisions/collider";
  46254. export * from "babylonjs/Collisions/collisionCoordinator";
  46255. export * from "babylonjs/Collisions/pickingInfo";
  46256. export * from "babylonjs/Collisions/intersectionInfo";
  46257. export * from "babylonjs/Collisions/meshCollisionData";
  46258. }
  46259. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  46260. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  46261. import { Vector3 } from "babylonjs/Maths/math.vector";
  46262. import { Ray } from "babylonjs/Culling/ray";
  46263. import { Plane } from "babylonjs/Maths/math.plane";
  46264. /**
  46265. * Contains an array of blocks representing the octree
  46266. */
  46267. export interface IOctreeContainer<T> {
  46268. /**
  46269. * Blocks within the octree
  46270. */
  46271. blocks: Array<OctreeBlock<T>>;
  46272. }
  46273. /**
  46274. * Class used to store a cell in an octree
  46275. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46276. */
  46277. export class OctreeBlock<T> {
  46278. /**
  46279. * Gets the content of the current block
  46280. */
  46281. entries: T[];
  46282. /**
  46283. * Gets the list of block children
  46284. */
  46285. blocks: Array<OctreeBlock<T>>;
  46286. private _depth;
  46287. private _maxDepth;
  46288. private _capacity;
  46289. private _minPoint;
  46290. private _maxPoint;
  46291. private _boundingVectors;
  46292. private _creationFunc;
  46293. /**
  46294. * Creates a new block
  46295. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  46296. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  46297. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46298. * @param depth defines the current depth of this block in the octree
  46299. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  46300. * @param creationFunc defines a callback to call when an element is added to the block
  46301. */
  46302. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  46303. /**
  46304. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46305. */
  46306. get capacity(): number;
  46307. /**
  46308. * Gets the minimum vector (in world space) of the block's bounding box
  46309. */
  46310. get minPoint(): Vector3;
  46311. /**
  46312. * Gets the maximum vector (in world space) of the block's bounding box
  46313. */
  46314. get maxPoint(): Vector3;
  46315. /**
  46316. * Add a new element to this block
  46317. * @param entry defines the element to add
  46318. */
  46319. addEntry(entry: T): void;
  46320. /**
  46321. * Remove an element from this block
  46322. * @param entry defines the element to remove
  46323. */
  46324. removeEntry(entry: T): void;
  46325. /**
  46326. * Add an array of elements to this block
  46327. * @param entries defines the array of elements to add
  46328. */
  46329. addEntries(entries: T[]): void;
  46330. /**
  46331. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  46332. * @param frustumPlanes defines the frustum planes to test
  46333. * @param selection defines the array to store current content if selection is positive
  46334. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46335. */
  46336. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46337. /**
  46338. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  46339. * @param sphereCenter defines the bounding sphere center
  46340. * @param sphereRadius defines the bounding sphere radius
  46341. * @param selection defines the array to store current content if selection is positive
  46342. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46343. */
  46344. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46345. /**
  46346. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  46347. * @param ray defines the ray to test with
  46348. * @param selection defines the array to store current content if selection is positive
  46349. */
  46350. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  46351. /**
  46352. * Subdivide the content into child blocks (this block will then be empty)
  46353. */
  46354. createInnerBlocks(): void;
  46355. /**
  46356. * @hidden
  46357. */
  46358. 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;
  46359. }
  46360. }
  46361. declare module "babylonjs/Culling/Octrees/octree" {
  46362. import { SmartArray } from "babylonjs/Misc/smartArray";
  46363. import { Vector3 } from "babylonjs/Maths/math.vector";
  46364. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46365. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46366. import { Ray } from "babylonjs/Culling/ray";
  46367. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  46368. import { Plane } from "babylonjs/Maths/math.plane";
  46369. /**
  46370. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  46371. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46372. */
  46373. export class Octree<T> {
  46374. /** 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.) */
  46375. maxDepth: number;
  46376. /**
  46377. * Blocks within the octree containing objects
  46378. */
  46379. blocks: Array<OctreeBlock<T>>;
  46380. /**
  46381. * Content stored in the octree
  46382. */
  46383. dynamicContent: T[];
  46384. private _maxBlockCapacity;
  46385. private _selectionContent;
  46386. private _creationFunc;
  46387. /**
  46388. * Creates a octree
  46389. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46390. * @param creationFunc function to be used to instatiate the octree
  46391. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  46392. * @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.)
  46393. */
  46394. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  46395. /** 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.) */
  46396. maxDepth?: number);
  46397. /**
  46398. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  46399. * @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);
  46400. * @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);
  46401. * @param entries meshes to be added to the octree blocks
  46402. */
  46403. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  46404. /**
  46405. * Adds a mesh to the octree
  46406. * @param entry Mesh to add to the octree
  46407. */
  46408. addMesh(entry: T): void;
  46409. /**
  46410. * Remove an element from the octree
  46411. * @param entry defines the element to remove
  46412. */
  46413. removeMesh(entry: T): void;
  46414. /**
  46415. * Selects an array of meshes within the frustum
  46416. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  46417. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  46418. * @returns array of meshes within the frustum
  46419. */
  46420. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  46421. /**
  46422. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  46423. * @param sphereCenter defines the bounding sphere center
  46424. * @param sphereRadius defines the bounding sphere radius
  46425. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46426. * @returns an array of objects that intersect the sphere
  46427. */
  46428. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  46429. /**
  46430. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  46431. * @param ray defines the ray to test with
  46432. * @returns array of intersected objects
  46433. */
  46434. intersectsRay(ray: Ray): SmartArray<T>;
  46435. /**
  46436. * Adds a mesh into the octree block if it intersects the block
  46437. */
  46438. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  46439. /**
  46440. * Adds a submesh into the octree block if it intersects the block
  46441. */
  46442. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46443. }
  46444. }
  46445. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  46446. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  46447. import { Scene } from "babylonjs/scene";
  46448. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46449. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46450. import { Ray } from "babylonjs/Culling/ray";
  46451. import { Octree } from "babylonjs/Culling/Octrees/octree";
  46452. import { Collider } from "babylonjs/Collisions/collider";
  46453. module "babylonjs/scene" {
  46454. interface Scene {
  46455. /**
  46456. * @hidden
  46457. * Backing Filed
  46458. */
  46459. _selectionOctree: Octree<AbstractMesh>;
  46460. /**
  46461. * Gets the octree used to boost mesh selection (picking)
  46462. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46463. */
  46464. selectionOctree: Octree<AbstractMesh>;
  46465. /**
  46466. * Creates or updates the octree used to boost selection (picking)
  46467. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46468. * @param maxCapacity defines the maximum capacity per leaf
  46469. * @param maxDepth defines the maximum depth of the octree
  46470. * @returns an octree of AbstractMesh
  46471. */
  46472. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46473. }
  46474. }
  46475. module "babylonjs/Meshes/abstractMesh" {
  46476. interface AbstractMesh {
  46477. /**
  46478. * @hidden
  46479. * Backing Field
  46480. */
  46481. _submeshesOctree: Octree<SubMesh>;
  46482. /**
  46483. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46484. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46485. * @param maxCapacity defines the maximum size of each block (64 by default)
  46486. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46487. * @returns the new octree
  46488. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46489. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46490. */
  46491. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46492. }
  46493. }
  46494. /**
  46495. * Defines the octree scene component responsible to manage any octrees
  46496. * in a given scene.
  46497. */
  46498. export class OctreeSceneComponent {
  46499. /**
  46500. * The component name help to identify the component in the list of scene components.
  46501. */
  46502. readonly name: string;
  46503. /**
  46504. * The scene the component belongs to.
  46505. */
  46506. scene: Scene;
  46507. /**
  46508. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46509. */
  46510. readonly checksIsEnabled: boolean;
  46511. /**
  46512. * Creates a new instance of the component for the given scene
  46513. * @param scene Defines the scene to register the component in
  46514. */
  46515. constructor(scene: Scene);
  46516. /**
  46517. * Registers the component in a given scene
  46518. */
  46519. register(): void;
  46520. /**
  46521. * Return the list of active meshes
  46522. * @returns the list of active meshes
  46523. */
  46524. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46525. /**
  46526. * Return the list of active sub meshes
  46527. * @param mesh The mesh to get the candidates sub meshes from
  46528. * @returns the list of active sub meshes
  46529. */
  46530. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46531. private _tempRay;
  46532. /**
  46533. * Return the list of sub meshes intersecting with a given local ray
  46534. * @param mesh defines the mesh to find the submesh for
  46535. * @param localRay defines the ray in local space
  46536. * @returns the list of intersecting sub meshes
  46537. */
  46538. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46539. /**
  46540. * Return the list of sub meshes colliding with a collider
  46541. * @param mesh defines the mesh to find the submesh for
  46542. * @param collider defines the collider to evaluate the collision against
  46543. * @returns the list of colliding sub meshes
  46544. */
  46545. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46546. /**
  46547. * Rebuilds the elements related to this component in case of
  46548. * context lost for instance.
  46549. */
  46550. rebuild(): void;
  46551. /**
  46552. * Disposes the component and the associated ressources.
  46553. */
  46554. dispose(): void;
  46555. }
  46556. }
  46557. declare module "babylonjs/Culling/Octrees/index" {
  46558. export * from "babylonjs/Culling/Octrees/octree";
  46559. export * from "babylonjs/Culling/Octrees/octreeBlock";
  46560. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  46561. }
  46562. declare module "babylonjs/Culling/index" {
  46563. export * from "babylonjs/Culling/boundingBox";
  46564. export * from "babylonjs/Culling/boundingInfo";
  46565. export * from "babylonjs/Culling/boundingSphere";
  46566. export * from "babylonjs/Culling/Octrees/index";
  46567. export * from "babylonjs/Culling/ray";
  46568. }
  46569. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  46570. import { IDisposable, Scene } from "babylonjs/scene";
  46571. import { Nullable } from "babylonjs/types";
  46572. import { Observable } from "babylonjs/Misc/observable";
  46573. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46574. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  46575. import { Camera } from "babylonjs/Cameras/camera";
  46576. /**
  46577. * Renders a layer on top of an existing scene
  46578. */
  46579. export class UtilityLayerRenderer implements IDisposable {
  46580. /** the original scene that will be rendered on top of */
  46581. originalScene: Scene;
  46582. private _pointerCaptures;
  46583. private _lastPointerEvents;
  46584. private static _DefaultUtilityLayer;
  46585. private static _DefaultKeepDepthUtilityLayer;
  46586. private _sharedGizmoLight;
  46587. private _renderCamera;
  46588. /**
  46589. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  46590. * @returns the camera that is used when rendering the utility layer
  46591. */
  46592. getRenderCamera(): Nullable<Camera>;
  46593. /**
  46594. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  46595. * @param cam the camera that should be used when rendering the utility layer
  46596. */
  46597. setRenderCamera(cam: Nullable<Camera>): void;
  46598. /**
  46599. * @hidden
  46600. * Light which used by gizmos to get light shading
  46601. */
  46602. _getSharedGizmoLight(): HemisphericLight;
  46603. /**
  46604. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  46605. */
  46606. pickUtilitySceneFirst: boolean;
  46607. /**
  46608. * 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)
  46609. */
  46610. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  46611. /**
  46612. * 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)
  46613. */
  46614. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  46615. /**
  46616. * The scene that is rendered on top of the original scene
  46617. */
  46618. utilityLayerScene: Scene;
  46619. /**
  46620. * If the utility layer should automatically be rendered on top of existing scene
  46621. */
  46622. shouldRender: boolean;
  46623. /**
  46624. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46625. */
  46626. onlyCheckPointerDownEvents: boolean;
  46627. /**
  46628. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46629. */
  46630. processAllEvents: boolean;
  46631. /**
  46632. * Observable raised when the pointer move from the utility layer scene to the main scene
  46633. */
  46634. onPointerOutObservable: Observable<number>;
  46635. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  46636. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  46637. private _afterRenderObserver;
  46638. private _sceneDisposeObserver;
  46639. private _originalPointerObserver;
  46640. /**
  46641. * Instantiates a UtilityLayerRenderer
  46642. * @param originalScene the original scene that will be rendered on top of
  46643. * @param handleEvents boolean indicating if the utility layer should handle events
  46644. */
  46645. constructor(
  46646. /** the original scene that will be rendered on top of */
  46647. originalScene: Scene, handleEvents?: boolean);
  46648. private _notifyObservers;
  46649. /**
  46650. * Renders the utility layers scene on top of the original scene
  46651. */
  46652. render(): void;
  46653. /**
  46654. * Disposes of the renderer
  46655. */
  46656. dispose(): void;
  46657. private _updateCamera;
  46658. }
  46659. }
  46660. declare module "babylonjs/Gizmos/gizmo" {
  46661. import { Nullable } from "babylonjs/types";
  46662. import { IDisposable } from "babylonjs/scene";
  46663. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46664. import { Mesh } from "babylonjs/Meshes/mesh";
  46665. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46666. /**
  46667. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46668. */
  46669. export class Gizmo implements IDisposable {
  46670. /** The utility layer the gizmo will be added to */
  46671. gizmoLayer: UtilityLayerRenderer;
  46672. /**
  46673. * The root mesh of the gizmo
  46674. */
  46675. _rootMesh: Mesh;
  46676. private _attachedMesh;
  46677. /**
  46678. * Ratio for the scale of the gizmo (Default: 1)
  46679. */
  46680. scaleRatio: number;
  46681. /**
  46682. * If a custom mesh has been set (Default: false)
  46683. */
  46684. protected _customMeshSet: boolean;
  46685. /**
  46686. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46687. * * When set, interactions will be enabled
  46688. */
  46689. get attachedMesh(): Nullable<AbstractMesh>;
  46690. set attachedMesh(value: Nullable<AbstractMesh>);
  46691. /**
  46692. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46693. * @param mesh The mesh to replace the default mesh of the gizmo
  46694. */
  46695. setCustomMesh(mesh: Mesh): void;
  46696. /**
  46697. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46698. */
  46699. updateGizmoRotationToMatchAttachedMesh: boolean;
  46700. /**
  46701. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46702. */
  46703. updateGizmoPositionToMatchAttachedMesh: boolean;
  46704. /**
  46705. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46706. */
  46707. updateScale: boolean;
  46708. protected _interactionsEnabled: boolean;
  46709. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46710. private _beforeRenderObserver;
  46711. private _tempVector;
  46712. /**
  46713. * Creates a gizmo
  46714. * @param gizmoLayer The utility layer the gizmo will be added to
  46715. */
  46716. constructor(
  46717. /** The utility layer the gizmo will be added to */
  46718. gizmoLayer?: UtilityLayerRenderer);
  46719. /**
  46720. * Updates the gizmo to match the attached mesh's position/rotation
  46721. */
  46722. protected _update(): void;
  46723. /**
  46724. * Disposes of the gizmo
  46725. */
  46726. dispose(): void;
  46727. }
  46728. }
  46729. declare module "babylonjs/Gizmos/planeDragGizmo" {
  46730. import { Observable } from "babylonjs/Misc/observable";
  46731. import { Nullable } from "babylonjs/types";
  46732. import { Vector3 } from "babylonjs/Maths/math.vector";
  46733. import { Color3 } from "babylonjs/Maths/math.color";
  46734. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46735. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46736. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46737. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46738. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46739. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46740. import { Scene } from "babylonjs/scene";
  46741. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46742. /**
  46743. * Single plane drag gizmo
  46744. */
  46745. export class PlaneDragGizmo extends Gizmo {
  46746. /**
  46747. * Drag behavior responsible for the gizmos dragging interactions
  46748. */
  46749. dragBehavior: PointerDragBehavior;
  46750. private _pointerObserver;
  46751. /**
  46752. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46753. */
  46754. snapDistance: number;
  46755. /**
  46756. * Event that fires each time the gizmo snaps to a new location.
  46757. * * snapDistance is the the change in distance
  46758. */
  46759. onSnapObservable: Observable<{
  46760. snapDistance: number;
  46761. }>;
  46762. private _plane;
  46763. private _coloredMaterial;
  46764. private _hoverMaterial;
  46765. private _isEnabled;
  46766. private _parent;
  46767. /** @hidden */
  46768. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46769. /** @hidden */
  46770. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46771. /**
  46772. * Creates a PlaneDragGizmo
  46773. * @param gizmoLayer The utility layer the gizmo will be added to
  46774. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46775. * @param color The color of the gizmo
  46776. */
  46777. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46778. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46779. /**
  46780. * If the gizmo is enabled
  46781. */
  46782. set isEnabled(value: boolean);
  46783. get isEnabled(): boolean;
  46784. /**
  46785. * Disposes of the gizmo
  46786. */
  46787. dispose(): void;
  46788. }
  46789. }
  46790. declare module "babylonjs/Gizmos/positionGizmo" {
  46791. import { Observable } from "babylonjs/Misc/observable";
  46792. import { Nullable } from "babylonjs/types";
  46793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46794. import { Mesh } from "babylonjs/Meshes/mesh";
  46795. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46796. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  46797. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  46798. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46799. /**
  46800. * Gizmo that enables dragging a mesh along 3 axis
  46801. */
  46802. export class PositionGizmo extends Gizmo {
  46803. /**
  46804. * Internal gizmo used for interactions on the x axis
  46805. */
  46806. xGizmo: AxisDragGizmo;
  46807. /**
  46808. * Internal gizmo used for interactions on the y axis
  46809. */
  46810. yGizmo: AxisDragGizmo;
  46811. /**
  46812. * Internal gizmo used for interactions on the z axis
  46813. */
  46814. zGizmo: AxisDragGizmo;
  46815. /**
  46816. * Internal gizmo used for interactions on the yz plane
  46817. */
  46818. xPlaneGizmo: PlaneDragGizmo;
  46819. /**
  46820. * Internal gizmo used for interactions on the xz plane
  46821. */
  46822. yPlaneGizmo: PlaneDragGizmo;
  46823. /**
  46824. * Internal gizmo used for interactions on the xy plane
  46825. */
  46826. zPlaneGizmo: PlaneDragGizmo;
  46827. /**
  46828. * private variables
  46829. */
  46830. private _meshAttached;
  46831. private _updateGizmoRotationToMatchAttachedMesh;
  46832. private _snapDistance;
  46833. private _scaleRatio;
  46834. /** Fires an event when any of it's sub gizmos are dragged */
  46835. onDragStartObservable: Observable<unknown>;
  46836. /** Fires an event when any of it's sub gizmos are released from dragging */
  46837. onDragEndObservable: Observable<unknown>;
  46838. /**
  46839. * If set to true, planar drag is enabled
  46840. */
  46841. private _planarGizmoEnabled;
  46842. get attachedMesh(): Nullable<AbstractMesh>;
  46843. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46844. /**
  46845. * Creates a PositionGizmo
  46846. * @param gizmoLayer The utility layer the gizmo will be added to
  46847. */
  46848. constructor(gizmoLayer?: UtilityLayerRenderer);
  46849. /**
  46850. * If the planar drag gizmo is enabled
  46851. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46852. */
  46853. set planarGizmoEnabled(value: boolean);
  46854. get planarGizmoEnabled(): boolean;
  46855. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46856. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46857. /**
  46858. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46859. */
  46860. set snapDistance(value: number);
  46861. get snapDistance(): number;
  46862. /**
  46863. * Ratio for the scale of the gizmo (Default: 1)
  46864. */
  46865. set scaleRatio(value: number);
  46866. get scaleRatio(): number;
  46867. /**
  46868. * Disposes of the gizmo
  46869. */
  46870. dispose(): void;
  46871. /**
  46872. * CustomMeshes are not supported by this gizmo
  46873. * @param mesh The mesh to replace the default mesh of the gizmo
  46874. */
  46875. setCustomMesh(mesh: Mesh): void;
  46876. }
  46877. }
  46878. declare module "babylonjs/Gizmos/axisDragGizmo" {
  46879. import { Observable } from "babylonjs/Misc/observable";
  46880. import { Nullable } from "babylonjs/types";
  46881. import { Vector3 } from "babylonjs/Maths/math.vector";
  46882. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46883. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46884. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46885. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46886. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46887. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46888. import { Scene } from "babylonjs/scene";
  46889. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46890. import { Color3 } from "babylonjs/Maths/math.color";
  46891. /**
  46892. * Single axis drag gizmo
  46893. */
  46894. export class AxisDragGizmo extends Gizmo {
  46895. /**
  46896. * Drag behavior responsible for the gizmos dragging interactions
  46897. */
  46898. dragBehavior: PointerDragBehavior;
  46899. private _pointerObserver;
  46900. /**
  46901. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46902. */
  46903. snapDistance: number;
  46904. /**
  46905. * Event that fires each time the gizmo snaps to a new location.
  46906. * * snapDistance is the the change in distance
  46907. */
  46908. onSnapObservable: Observable<{
  46909. snapDistance: number;
  46910. }>;
  46911. private _isEnabled;
  46912. private _parent;
  46913. private _arrow;
  46914. private _coloredMaterial;
  46915. private _hoverMaterial;
  46916. /** @hidden */
  46917. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46918. /** @hidden */
  46919. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46920. /**
  46921. * Creates an AxisDragGizmo
  46922. * @param gizmoLayer The utility layer the gizmo will be added to
  46923. * @param dragAxis The axis which the gizmo will be able to drag on
  46924. * @param color The color of the gizmo
  46925. */
  46926. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46927. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46928. /**
  46929. * If the gizmo is enabled
  46930. */
  46931. set isEnabled(value: boolean);
  46932. get isEnabled(): boolean;
  46933. /**
  46934. * Disposes of the gizmo
  46935. */
  46936. dispose(): void;
  46937. }
  46938. }
  46939. declare module "babylonjs/Debug/axesViewer" {
  46940. import { Vector3 } from "babylonjs/Maths/math.vector";
  46941. import { Nullable } from "babylonjs/types";
  46942. import { Scene } from "babylonjs/scene";
  46943. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46944. /**
  46945. * The Axes viewer will show 3 axes in a specific point in space
  46946. */
  46947. export class AxesViewer {
  46948. private _xAxis;
  46949. private _yAxis;
  46950. private _zAxis;
  46951. private _scaleLinesFactor;
  46952. private _instanced;
  46953. /**
  46954. * Gets the hosting scene
  46955. */
  46956. scene: Scene;
  46957. /**
  46958. * Gets or sets a number used to scale line length
  46959. */
  46960. scaleLines: number;
  46961. /** Gets the node hierarchy used to render x-axis */
  46962. get xAxis(): TransformNode;
  46963. /** Gets the node hierarchy used to render y-axis */
  46964. get yAxis(): TransformNode;
  46965. /** Gets the node hierarchy used to render z-axis */
  46966. get zAxis(): TransformNode;
  46967. /**
  46968. * Creates a new AxesViewer
  46969. * @param scene defines the hosting scene
  46970. * @param scaleLines defines a number used to scale line length (1 by default)
  46971. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46972. * @param xAxis defines the node hierarchy used to render the x-axis
  46973. * @param yAxis defines the node hierarchy used to render the y-axis
  46974. * @param zAxis defines the node hierarchy used to render the z-axis
  46975. */
  46976. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46977. /**
  46978. * Force the viewer to update
  46979. * @param position defines the position of the viewer
  46980. * @param xaxis defines the x axis of the viewer
  46981. * @param yaxis defines the y axis of the viewer
  46982. * @param zaxis defines the z axis of the viewer
  46983. */
  46984. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46985. /**
  46986. * Creates an instance of this axes viewer.
  46987. * @returns a new axes viewer with instanced meshes
  46988. */
  46989. createInstance(): AxesViewer;
  46990. /** Releases resources */
  46991. dispose(): void;
  46992. private static _SetRenderingGroupId;
  46993. }
  46994. }
  46995. declare module "babylonjs/Debug/boneAxesViewer" {
  46996. import { Nullable } from "babylonjs/types";
  46997. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  46998. import { Vector3 } from "babylonjs/Maths/math.vector";
  46999. import { Mesh } from "babylonjs/Meshes/mesh";
  47000. import { Bone } from "babylonjs/Bones/bone";
  47001. import { Scene } from "babylonjs/scene";
  47002. /**
  47003. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47004. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47005. */
  47006. export class BoneAxesViewer extends AxesViewer {
  47007. /**
  47008. * Gets or sets the target mesh where to display the axes viewer
  47009. */
  47010. mesh: Nullable<Mesh>;
  47011. /**
  47012. * Gets or sets the target bone where to display the axes viewer
  47013. */
  47014. bone: Nullable<Bone>;
  47015. /** Gets current position */
  47016. pos: Vector3;
  47017. /** Gets direction of X axis */
  47018. xaxis: Vector3;
  47019. /** Gets direction of Y axis */
  47020. yaxis: Vector3;
  47021. /** Gets direction of Z axis */
  47022. zaxis: Vector3;
  47023. /**
  47024. * Creates a new BoneAxesViewer
  47025. * @param scene defines the hosting scene
  47026. * @param bone defines the target bone
  47027. * @param mesh defines the target mesh
  47028. * @param scaleLines defines a scaling factor for line length (1 by default)
  47029. */
  47030. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47031. /**
  47032. * Force the viewer to update
  47033. */
  47034. update(): void;
  47035. /** Releases resources */
  47036. dispose(): void;
  47037. }
  47038. }
  47039. declare module "babylonjs/Debug/debugLayer" {
  47040. import { Scene } from "babylonjs/scene";
  47041. /**
  47042. * Interface used to define scene explorer extensibility option
  47043. */
  47044. export interface IExplorerExtensibilityOption {
  47045. /**
  47046. * Define the option label
  47047. */
  47048. label: string;
  47049. /**
  47050. * Defines the action to execute on click
  47051. */
  47052. action: (entity: any) => void;
  47053. }
  47054. /**
  47055. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47056. */
  47057. export interface IExplorerExtensibilityGroup {
  47058. /**
  47059. * Defines a predicate to test if a given type mut be extended
  47060. */
  47061. predicate: (entity: any) => boolean;
  47062. /**
  47063. * Gets the list of options added to a type
  47064. */
  47065. entries: IExplorerExtensibilityOption[];
  47066. }
  47067. /**
  47068. * Interface used to define the options to use to create the Inspector
  47069. */
  47070. export interface IInspectorOptions {
  47071. /**
  47072. * Display in overlay mode (default: false)
  47073. */
  47074. overlay?: boolean;
  47075. /**
  47076. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47077. */
  47078. globalRoot?: HTMLElement;
  47079. /**
  47080. * Display the Scene explorer
  47081. */
  47082. showExplorer?: boolean;
  47083. /**
  47084. * Display the property inspector
  47085. */
  47086. showInspector?: boolean;
  47087. /**
  47088. * Display in embed mode (both panes on the right)
  47089. */
  47090. embedMode?: boolean;
  47091. /**
  47092. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47093. */
  47094. handleResize?: boolean;
  47095. /**
  47096. * Allow the panes to popup (default: true)
  47097. */
  47098. enablePopup?: boolean;
  47099. /**
  47100. * Allow the panes to be closed by users (default: true)
  47101. */
  47102. enableClose?: boolean;
  47103. /**
  47104. * Optional list of extensibility entries
  47105. */
  47106. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47107. /**
  47108. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47109. */
  47110. inspectorURL?: string;
  47111. /**
  47112. * Optional initial tab (default to DebugLayerTab.Properties)
  47113. */
  47114. initialTab?: DebugLayerTab;
  47115. }
  47116. module "babylonjs/scene" {
  47117. interface Scene {
  47118. /**
  47119. * @hidden
  47120. * Backing field
  47121. */
  47122. _debugLayer: DebugLayer;
  47123. /**
  47124. * Gets the debug layer (aka Inspector) associated with the scene
  47125. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47126. */
  47127. debugLayer: DebugLayer;
  47128. }
  47129. }
  47130. /**
  47131. * Enum of inspector action tab
  47132. */
  47133. export enum DebugLayerTab {
  47134. /**
  47135. * Properties tag (default)
  47136. */
  47137. Properties = 0,
  47138. /**
  47139. * Debug tab
  47140. */
  47141. Debug = 1,
  47142. /**
  47143. * Statistics tab
  47144. */
  47145. Statistics = 2,
  47146. /**
  47147. * Tools tab
  47148. */
  47149. Tools = 3,
  47150. /**
  47151. * Settings tab
  47152. */
  47153. Settings = 4
  47154. }
  47155. /**
  47156. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47157. * what is happening in your scene
  47158. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47159. */
  47160. export class DebugLayer {
  47161. /**
  47162. * Define the url to get the inspector script from.
  47163. * By default it uses the babylonjs CDN.
  47164. * @ignoreNaming
  47165. */
  47166. static InspectorURL: string;
  47167. private _scene;
  47168. private BJSINSPECTOR;
  47169. private _onPropertyChangedObservable?;
  47170. /**
  47171. * Observable triggered when a property is changed through the inspector.
  47172. */
  47173. get onPropertyChangedObservable(): any;
  47174. /**
  47175. * Instantiates a new debug layer.
  47176. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47177. * what is happening in your scene
  47178. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47179. * @param scene Defines the scene to inspect
  47180. */
  47181. constructor(scene: Scene);
  47182. /** Creates the inspector window. */
  47183. private _createInspector;
  47184. /**
  47185. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  47186. * @param entity defines the entity to select
  47187. * @param lineContainerTitle defines the specific block to highlight
  47188. */
  47189. select(entity: any, lineContainerTitle?: string): void;
  47190. /** Get the inspector from bundle or global */
  47191. private _getGlobalInspector;
  47192. /**
  47193. * Get if the inspector is visible or not.
  47194. * @returns true if visible otherwise, false
  47195. */
  47196. isVisible(): boolean;
  47197. /**
  47198. * Hide the inspector and close its window.
  47199. */
  47200. hide(): void;
  47201. /**
  47202. * Launch the debugLayer.
  47203. * @param config Define the configuration of the inspector
  47204. * @return a promise fulfilled when the debug layer is visible
  47205. */
  47206. show(config?: IInspectorOptions): Promise<DebugLayer>;
  47207. }
  47208. }
  47209. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  47210. import { Nullable } from "babylonjs/types";
  47211. import { Scene } from "babylonjs/scene";
  47212. import { Vector4 } from "babylonjs/Maths/math.vector";
  47213. import { Color4 } from "babylonjs/Maths/math.color";
  47214. import { Mesh } from "babylonjs/Meshes/mesh";
  47215. /**
  47216. * Class containing static functions to help procedurally build meshes
  47217. */
  47218. export class BoxBuilder {
  47219. /**
  47220. * Creates a box mesh
  47221. * * The parameter `size` sets the size (float) of each box side (default 1)
  47222. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  47223. * * 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)
  47224. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47225. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47226. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47228. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  47229. * @param name defines the name of the mesh
  47230. * @param options defines the options used to create the mesh
  47231. * @param scene defines the hosting scene
  47232. * @returns the box mesh
  47233. */
  47234. static CreateBox(name: string, options: {
  47235. size?: number;
  47236. width?: number;
  47237. height?: number;
  47238. depth?: number;
  47239. faceUV?: Vector4[];
  47240. faceColors?: Color4[];
  47241. sideOrientation?: number;
  47242. frontUVs?: Vector4;
  47243. backUVs?: Vector4;
  47244. wrap?: boolean;
  47245. topBaseAt?: number;
  47246. bottomBaseAt?: number;
  47247. updatable?: boolean;
  47248. }, scene?: Nullable<Scene>): Mesh;
  47249. }
  47250. }
  47251. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  47252. import { Vector4 } from "babylonjs/Maths/math.vector";
  47253. import { Mesh } from "babylonjs/Meshes/mesh";
  47254. import { Scene } from "babylonjs/scene";
  47255. import { Nullable } from "babylonjs/types";
  47256. /**
  47257. * Class containing static functions to help procedurally build meshes
  47258. */
  47259. export class SphereBuilder {
  47260. /**
  47261. * Creates a sphere mesh
  47262. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47263. * * 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`)
  47264. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47265. * * 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
  47266. * * 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)
  47267. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47268. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47270. * @param name defines the name of the mesh
  47271. * @param options defines the options used to create the mesh
  47272. * @param scene defines the hosting scene
  47273. * @returns the sphere mesh
  47274. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47275. */
  47276. static CreateSphere(name: string, options: {
  47277. segments?: number;
  47278. diameter?: number;
  47279. diameterX?: number;
  47280. diameterY?: number;
  47281. diameterZ?: number;
  47282. arc?: number;
  47283. slice?: number;
  47284. sideOrientation?: number;
  47285. frontUVs?: Vector4;
  47286. backUVs?: Vector4;
  47287. updatable?: boolean;
  47288. }, scene?: Nullable<Scene>): Mesh;
  47289. }
  47290. }
  47291. declare module "babylonjs/Debug/physicsViewer" {
  47292. import { Nullable } from "babylonjs/types";
  47293. import { Scene } from "babylonjs/scene";
  47294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47295. import { Mesh } from "babylonjs/Meshes/mesh";
  47296. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47297. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47298. /**
  47299. * Used to show the physics impostor around the specific mesh
  47300. */
  47301. export class PhysicsViewer {
  47302. /** @hidden */
  47303. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  47304. /** @hidden */
  47305. protected _meshes: Array<Nullable<AbstractMesh>>;
  47306. /** @hidden */
  47307. protected _scene: Nullable<Scene>;
  47308. /** @hidden */
  47309. protected _numMeshes: number;
  47310. /** @hidden */
  47311. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  47312. private _renderFunction;
  47313. private _utilityLayer;
  47314. private _debugBoxMesh;
  47315. private _debugSphereMesh;
  47316. private _debugCylinderMesh;
  47317. private _debugMaterial;
  47318. private _debugMeshMeshes;
  47319. /**
  47320. * Creates a new PhysicsViewer
  47321. * @param scene defines the hosting scene
  47322. */
  47323. constructor(scene: Scene);
  47324. /** @hidden */
  47325. protected _updateDebugMeshes(): void;
  47326. /**
  47327. * Renders a specified physic impostor
  47328. * @param impostor defines the impostor to render
  47329. * @param targetMesh defines the mesh represented by the impostor
  47330. * @returns the new debug mesh used to render the impostor
  47331. */
  47332. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  47333. /**
  47334. * Hides a specified physic impostor
  47335. * @param impostor defines the impostor to hide
  47336. */
  47337. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  47338. private _getDebugMaterial;
  47339. private _getDebugBoxMesh;
  47340. private _getDebugSphereMesh;
  47341. private _getDebugCylinderMesh;
  47342. private _getDebugMeshMesh;
  47343. private _getDebugMesh;
  47344. /** Releases all resources */
  47345. dispose(): void;
  47346. }
  47347. }
  47348. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  47349. import { Vector3 } from "babylonjs/Maths/math.vector";
  47350. import { Color4 } from "babylonjs/Maths/math.color";
  47351. import { Nullable } from "babylonjs/types";
  47352. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  47353. import { Scene } from "babylonjs/scene";
  47354. /**
  47355. * Class containing static functions to help procedurally build meshes
  47356. */
  47357. export class LinesBuilder {
  47358. /**
  47359. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  47360. * * 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
  47361. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  47362. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  47363. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  47364. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  47365. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47366. * * 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
  47367. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  47368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47369. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  47370. * @param name defines the name of the new line system
  47371. * @param options defines the options used to create the line system
  47372. * @param scene defines the hosting scene
  47373. * @returns a new line system mesh
  47374. */
  47375. static CreateLineSystem(name: string, options: {
  47376. lines: Vector3[][];
  47377. updatable?: boolean;
  47378. instance?: Nullable<LinesMesh>;
  47379. colors?: Nullable<Color4[][]>;
  47380. useVertexAlpha?: boolean;
  47381. }, scene: Nullable<Scene>): LinesMesh;
  47382. /**
  47383. * Creates a line mesh
  47384. * 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
  47385. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47386. * * The parameter `points` is an array successive Vector3
  47387. * * 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
  47388. * * The optional parameter `colors` is an array of successive Color4, one per line point
  47389. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  47390. * * When updating an instance, remember that only point positions can change, not the number of points
  47391. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47392. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  47393. * @param name defines the name of the new line system
  47394. * @param options defines the options used to create the line system
  47395. * @param scene defines the hosting scene
  47396. * @returns a new line mesh
  47397. */
  47398. static CreateLines(name: string, options: {
  47399. points: Vector3[];
  47400. updatable?: boolean;
  47401. instance?: Nullable<LinesMesh>;
  47402. colors?: Color4[];
  47403. useVertexAlpha?: boolean;
  47404. }, scene?: Nullable<Scene>): LinesMesh;
  47405. /**
  47406. * Creates a dashed line mesh
  47407. * * 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
  47408. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47409. * * The parameter `points` is an array successive Vector3
  47410. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  47411. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  47412. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  47413. * * 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
  47414. * * When updating an instance, remember that only point positions can change, not the number of points
  47415. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47416. * @param name defines the name of the mesh
  47417. * @param options defines the options used to create the mesh
  47418. * @param scene defines the hosting scene
  47419. * @returns the dashed line mesh
  47420. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  47421. */
  47422. static CreateDashedLines(name: string, options: {
  47423. points: Vector3[];
  47424. dashSize?: number;
  47425. gapSize?: number;
  47426. dashNb?: number;
  47427. updatable?: boolean;
  47428. instance?: LinesMesh;
  47429. }, scene?: Nullable<Scene>): LinesMesh;
  47430. }
  47431. }
  47432. declare module "babylonjs/Debug/rayHelper" {
  47433. import { Nullable } from "babylonjs/types";
  47434. import { Ray } from "babylonjs/Culling/ray";
  47435. import { Vector3 } from "babylonjs/Maths/math.vector";
  47436. import { Color3 } from "babylonjs/Maths/math.color";
  47437. import { Scene } from "babylonjs/scene";
  47438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47439. import "babylonjs/Meshes/Builders/linesBuilder";
  47440. /**
  47441. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  47442. * in order to better appreciate the issue one might have.
  47443. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  47444. */
  47445. export class RayHelper {
  47446. /**
  47447. * Defines the ray we are currently tryin to visualize.
  47448. */
  47449. ray: Nullable<Ray>;
  47450. private _renderPoints;
  47451. private _renderLine;
  47452. private _renderFunction;
  47453. private _scene;
  47454. private _updateToMeshFunction;
  47455. private _attachedToMesh;
  47456. private _meshSpaceDirection;
  47457. private _meshSpaceOrigin;
  47458. /**
  47459. * Helper function to create a colored helper in a scene in one line.
  47460. * @param ray Defines the ray we are currently tryin to visualize
  47461. * @param scene Defines the scene the ray is used in
  47462. * @param color Defines the color we want to see the ray in
  47463. * @returns The newly created ray helper.
  47464. */
  47465. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  47466. /**
  47467. * Instantiate a new ray helper.
  47468. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  47469. * in order to better appreciate the issue one might have.
  47470. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  47471. * @param ray Defines the ray we are currently tryin to visualize
  47472. */
  47473. constructor(ray: Ray);
  47474. /**
  47475. * Shows the ray we are willing to debug.
  47476. * @param scene Defines the scene the ray needs to be rendered in
  47477. * @param color Defines the color the ray needs to be rendered in
  47478. */
  47479. show(scene: Scene, color?: Color3): void;
  47480. /**
  47481. * Hides the ray we are debugging.
  47482. */
  47483. hide(): void;
  47484. private _render;
  47485. /**
  47486. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  47487. * @param mesh Defines the mesh we want the helper attached to
  47488. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  47489. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  47490. * @param length Defines the length of the ray
  47491. */
  47492. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  47493. /**
  47494. * Detach the ray helper from the mesh it has previously been attached to.
  47495. */
  47496. detachFromMesh(): void;
  47497. private _updateToMesh;
  47498. /**
  47499. * Dispose the helper and release its associated resources.
  47500. */
  47501. dispose(): void;
  47502. }
  47503. }
  47504. declare module "babylonjs/Debug/skeletonViewer" {
  47505. import { Color3 } from "babylonjs/Maths/math.color";
  47506. import { Scene } from "babylonjs/scene";
  47507. import { Nullable } from "babylonjs/types";
  47508. import { Skeleton } from "babylonjs/Bones/skeleton";
  47509. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47510. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  47511. /**
  47512. * Class used to render a debug view of a given skeleton
  47513. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  47514. */
  47515. export class SkeletonViewer {
  47516. /** defines the skeleton to render */
  47517. skeleton: Skeleton;
  47518. /** defines the mesh attached to the skeleton */
  47519. mesh: AbstractMesh;
  47520. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47521. autoUpdateBonesMatrices: boolean;
  47522. /** defines the rendering group id to use with the viewer */
  47523. renderingGroupId: number;
  47524. /** Gets or sets the color used to render the skeleton */
  47525. color: Color3;
  47526. private _scene;
  47527. private _debugLines;
  47528. private _debugMesh;
  47529. private _isEnabled;
  47530. private _renderFunction;
  47531. private _utilityLayer;
  47532. /**
  47533. * Returns the mesh used to render the bones
  47534. */
  47535. get debugMesh(): Nullable<LinesMesh>;
  47536. /**
  47537. * Creates a new SkeletonViewer
  47538. * @param skeleton defines the skeleton to render
  47539. * @param mesh defines the mesh attached to the skeleton
  47540. * @param scene defines the hosting scene
  47541. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  47542. * @param renderingGroupId defines the rendering group id to use with the viewer
  47543. */
  47544. constructor(
  47545. /** defines the skeleton to render */
  47546. skeleton: Skeleton,
  47547. /** defines the mesh attached to the skeleton */
  47548. mesh: AbstractMesh, scene: Scene,
  47549. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47550. autoUpdateBonesMatrices?: boolean,
  47551. /** defines the rendering group id to use with the viewer */
  47552. renderingGroupId?: number);
  47553. /** Gets or sets a boolean indicating if the viewer is enabled */
  47554. set isEnabled(value: boolean);
  47555. get isEnabled(): boolean;
  47556. private _getBonePosition;
  47557. private _getLinesForBonesWithLength;
  47558. private _getLinesForBonesNoLength;
  47559. /** Update the viewer to sync with current skeleton state */
  47560. update(): void;
  47561. /** Release associated resources */
  47562. dispose(): void;
  47563. }
  47564. }
  47565. declare module "babylonjs/Debug/index" {
  47566. export * from "babylonjs/Debug/axesViewer";
  47567. export * from "babylonjs/Debug/boneAxesViewer";
  47568. export * from "babylonjs/Debug/debugLayer";
  47569. export * from "babylonjs/Debug/physicsViewer";
  47570. export * from "babylonjs/Debug/rayHelper";
  47571. export * from "babylonjs/Debug/skeletonViewer";
  47572. }
  47573. declare module "babylonjs/Engines/nullEngine" {
  47574. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  47575. import { Scene } from "babylonjs/scene";
  47576. import { Engine } from "babylonjs/Engines/engine";
  47577. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  47578. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  47579. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47580. import { Effect } from "babylonjs/Materials/effect";
  47581. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  47582. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  47583. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  47584. /**
  47585. * Options to create the null engine
  47586. */
  47587. export class NullEngineOptions {
  47588. /**
  47589. * Render width (Default: 512)
  47590. */
  47591. renderWidth: number;
  47592. /**
  47593. * Render height (Default: 256)
  47594. */
  47595. renderHeight: number;
  47596. /**
  47597. * Texture size (Default: 512)
  47598. */
  47599. textureSize: number;
  47600. /**
  47601. * If delta time between frames should be constant
  47602. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47603. */
  47604. deterministicLockstep: boolean;
  47605. /**
  47606. * Maximum about of steps between frames (Default: 4)
  47607. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47608. */
  47609. lockstepMaxSteps: number;
  47610. }
  47611. /**
  47612. * The null engine class provides support for headless version of babylon.js.
  47613. * This can be used in server side scenario or for testing purposes
  47614. */
  47615. export class NullEngine extends Engine {
  47616. private _options;
  47617. /**
  47618. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  47619. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47620. * @returns true if engine is in deterministic lock step mode
  47621. */
  47622. isDeterministicLockStep(): boolean;
  47623. /**
  47624. * Gets the max steps when engine is running in deterministic lock step
  47625. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47626. * @returns the max steps
  47627. */
  47628. getLockstepMaxSteps(): number;
  47629. /**
  47630. * Gets the current hardware scaling level.
  47631. * By default the hardware scaling level is computed from the window device ratio.
  47632. * 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.
  47633. * @returns a number indicating the current hardware scaling level
  47634. */
  47635. getHardwareScalingLevel(): number;
  47636. constructor(options?: NullEngineOptions);
  47637. /**
  47638. * Creates a vertex buffer
  47639. * @param vertices the data for the vertex buffer
  47640. * @returns the new WebGL static buffer
  47641. */
  47642. createVertexBuffer(vertices: FloatArray): DataBuffer;
  47643. /**
  47644. * Creates a new index buffer
  47645. * @param indices defines the content of the index buffer
  47646. * @param updatable defines if the index buffer must be updatable
  47647. * @returns a new webGL buffer
  47648. */
  47649. createIndexBuffer(indices: IndicesArray): DataBuffer;
  47650. /**
  47651. * Clear the current render buffer or the current render target (if any is set up)
  47652. * @param color defines the color to use
  47653. * @param backBuffer defines if the back buffer must be cleared
  47654. * @param depth defines if the depth buffer must be cleared
  47655. * @param stencil defines if the stencil buffer must be cleared
  47656. */
  47657. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47658. /**
  47659. * Gets the current render width
  47660. * @param useScreen defines if screen size must be used (or the current render target if any)
  47661. * @returns a number defining the current render width
  47662. */
  47663. getRenderWidth(useScreen?: boolean): number;
  47664. /**
  47665. * Gets the current render height
  47666. * @param useScreen defines if screen size must be used (or the current render target if any)
  47667. * @returns a number defining the current render height
  47668. */
  47669. getRenderHeight(useScreen?: boolean): number;
  47670. /**
  47671. * Set the WebGL's viewport
  47672. * @param viewport defines the viewport element to be used
  47673. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  47674. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  47675. */
  47676. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  47677. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  47678. /**
  47679. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  47680. * @param pipelineContext defines the pipeline context to use
  47681. * @param uniformsNames defines the list of uniform names
  47682. * @returns an array of webGL uniform locations
  47683. */
  47684. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  47685. /**
  47686. * Gets the lsit of active attributes for a given webGL program
  47687. * @param pipelineContext defines the pipeline context to use
  47688. * @param attributesNames defines the list of attribute names to get
  47689. * @returns an array of indices indicating the offset of each attribute
  47690. */
  47691. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47692. /**
  47693. * Binds an effect to the webGL context
  47694. * @param effect defines the effect to bind
  47695. */
  47696. bindSamplers(effect: Effect): void;
  47697. /**
  47698. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  47699. * @param effect defines the effect to activate
  47700. */
  47701. enableEffect(effect: Effect): void;
  47702. /**
  47703. * Set various states to the webGL context
  47704. * @param culling defines backface culling state
  47705. * @param zOffset defines the value to apply to zOffset (0 by default)
  47706. * @param force defines if states must be applied even if cache is up to date
  47707. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  47708. */
  47709. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47710. /**
  47711. * Set the value of an uniform to an array of int32
  47712. * @param uniform defines the webGL uniform location where to store the value
  47713. * @param array defines the array of int32 to store
  47714. */
  47715. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47716. /**
  47717. * Set the value of an uniform to an array of int32 (stored as vec2)
  47718. * @param uniform defines the webGL uniform location where to store the value
  47719. * @param array defines the array of int32 to store
  47720. */
  47721. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47722. /**
  47723. * Set the value of an uniform to an array of int32 (stored as vec3)
  47724. * @param uniform defines the webGL uniform location where to store the value
  47725. * @param array defines the array of int32 to store
  47726. */
  47727. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47728. /**
  47729. * Set the value of an uniform to an array of int32 (stored as vec4)
  47730. * @param uniform defines the webGL uniform location where to store the value
  47731. * @param array defines the array of int32 to store
  47732. */
  47733. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47734. /**
  47735. * Set the value of an uniform to an array of float32
  47736. * @param uniform defines the webGL uniform location where to store the value
  47737. * @param array defines the array of float32 to store
  47738. */
  47739. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47740. /**
  47741. * Set the value of an uniform to an array of float32 (stored as vec2)
  47742. * @param uniform defines the webGL uniform location where to store the value
  47743. * @param array defines the array of float32 to store
  47744. */
  47745. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47746. /**
  47747. * Set the value of an uniform to an array of float32 (stored as vec3)
  47748. * @param uniform defines the webGL uniform location where to store the value
  47749. * @param array defines the array of float32 to store
  47750. */
  47751. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47752. /**
  47753. * Set the value of an uniform to an array of float32 (stored as vec4)
  47754. * @param uniform defines the webGL uniform location where to store the value
  47755. * @param array defines the array of float32 to store
  47756. */
  47757. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47758. /**
  47759. * Set the value of an uniform to an array of number
  47760. * @param uniform defines the webGL uniform location where to store the value
  47761. * @param array defines the array of number to store
  47762. */
  47763. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47764. /**
  47765. * Set the value of an uniform to an array of number (stored as vec2)
  47766. * @param uniform defines the webGL uniform location where to store the value
  47767. * @param array defines the array of number to store
  47768. */
  47769. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47770. /**
  47771. * Set the value of an uniform to an array of number (stored as vec3)
  47772. * @param uniform defines the webGL uniform location where to store the value
  47773. * @param array defines the array of number to store
  47774. */
  47775. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47776. /**
  47777. * Set the value of an uniform to an array of number (stored as vec4)
  47778. * @param uniform defines the webGL uniform location where to store the value
  47779. * @param array defines the array of number to store
  47780. */
  47781. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47782. /**
  47783. * Set the value of an uniform to an array of float32 (stored as matrices)
  47784. * @param uniform defines the webGL uniform location where to store the value
  47785. * @param matrices defines the array of float32 to store
  47786. */
  47787. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47788. /**
  47789. * Set the value of an uniform to a matrix (3x3)
  47790. * @param uniform defines the webGL uniform location where to store the value
  47791. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47792. */
  47793. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47794. /**
  47795. * Set the value of an uniform to a matrix (2x2)
  47796. * @param uniform defines the webGL uniform location where to store the value
  47797. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47798. */
  47799. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47800. /**
  47801. * Set the value of an uniform to a number (float)
  47802. * @param uniform defines the webGL uniform location where to store the value
  47803. * @param value defines the float number to store
  47804. */
  47805. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47806. /**
  47807. * Set the value of an uniform to a vec2
  47808. * @param uniform defines the webGL uniform location where to store the value
  47809. * @param x defines the 1st component of the value
  47810. * @param y defines the 2nd component of the value
  47811. */
  47812. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47813. /**
  47814. * Set the value of an uniform to a vec3
  47815. * @param uniform defines the webGL uniform location where to store the value
  47816. * @param x defines the 1st component of the value
  47817. * @param y defines the 2nd component of the value
  47818. * @param z defines the 3rd component of the value
  47819. */
  47820. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47821. /**
  47822. * Set the value of an uniform to a boolean
  47823. * @param uniform defines the webGL uniform location where to store the value
  47824. * @param bool defines the boolean to store
  47825. */
  47826. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47827. /**
  47828. * Set the value of an uniform to a vec4
  47829. * @param uniform defines the webGL uniform location where to store the value
  47830. * @param x defines the 1st component of the value
  47831. * @param y defines the 2nd component of the value
  47832. * @param z defines the 3rd component of the value
  47833. * @param w defines the 4th component of the value
  47834. */
  47835. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47836. /**
  47837. * Sets the current alpha mode
  47838. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47839. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47840. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47841. */
  47842. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47843. /**
  47844. * Bind webGl buffers directly to the webGL context
  47845. * @param vertexBuffers defines the vertex buffer to bind
  47846. * @param indexBuffer defines the index buffer to bind
  47847. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47848. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47849. * @param effect defines the effect associated with the vertex buffer
  47850. */
  47851. bindBuffers(vertexBuffers: {
  47852. [key: string]: VertexBuffer;
  47853. }, indexBuffer: DataBuffer, effect: Effect): void;
  47854. /**
  47855. * Force the entire cache to be cleared
  47856. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47857. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47858. */
  47859. wipeCaches(bruteForce?: boolean): void;
  47860. /**
  47861. * Send a draw order
  47862. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47863. * @param indexStart defines the starting index
  47864. * @param indexCount defines the number of index to draw
  47865. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47866. */
  47867. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47868. /**
  47869. * Draw a list of indexed primitives
  47870. * @param fillMode defines the primitive to use
  47871. * @param indexStart defines the starting index
  47872. * @param indexCount defines the number of index to draw
  47873. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47874. */
  47875. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47876. /**
  47877. * Draw a list of unindexed primitives
  47878. * @param fillMode defines the primitive to use
  47879. * @param verticesStart defines the index of first vertex to draw
  47880. * @param verticesCount defines the count of vertices to draw
  47881. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47882. */
  47883. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47884. /** @hidden */
  47885. _createTexture(): WebGLTexture;
  47886. /** @hidden */
  47887. _releaseTexture(texture: InternalTexture): void;
  47888. /**
  47889. * Usually called from Texture.ts.
  47890. * Passed information to create a WebGLTexture
  47891. * @param urlArg defines a value which contains one of the following:
  47892. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47893. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47894. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47895. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47896. * @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)
  47897. * @param scene needed for loading to the correct scene
  47898. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47899. * @param onLoad optional callback to be called upon successful completion
  47900. * @param onError optional callback to be called upon failure
  47901. * @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
  47902. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47903. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47904. * @param forcedExtension defines the extension to use to pick the right loader
  47905. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  47906. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47907. */
  47908. 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;
  47909. /**
  47910. * Creates a new render target texture
  47911. * @param size defines the size of the texture
  47912. * @param options defines the options used to create the texture
  47913. * @returns a new render target texture stored in an InternalTexture
  47914. */
  47915. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47916. /**
  47917. * Update the sampling mode of a given texture
  47918. * @param samplingMode defines the required sampling mode
  47919. * @param texture defines the texture to update
  47920. */
  47921. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47922. /**
  47923. * Binds the frame buffer to the specified texture.
  47924. * @param texture The texture to render to or null for the default canvas
  47925. * @param faceIndex The face of the texture to render to in case of cube texture
  47926. * @param requiredWidth The width of the target to render to
  47927. * @param requiredHeight The height of the target to render to
  47928. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47929. * @param depthStencilTexture The depth stencil texture to use to render
  47930. * @param lodLevel defines le lod level to bind to the frame buffer
  47931. */
  47932. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47933. /**
  47934. * Unbind the current render target texture from the webGL context
  47935. * @param texture defines the render target texture to unbind
  47936. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47937. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47938. */
  47939. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47940. /**
  47941. * Creates a dynamic vertex buffer
  47942. * @param vertices the data for the dynamic vertex buffer
  47943. * @returns the new WebGL dynamic buffer
  47944. */
  47945. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47946. /**
  47947. * Update the content of a dynamic texture
  47948. * @param texture defines the texture to update
  47949. * @param canvas defines the canvas containing the source
  47950. * @param invertY defines if data must be stored with Y axis inverted
  47951. * @param premulAlpha defines if alpha is stored as premultiplied
  47952. * @param format defines the format of the data
  47953. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47954. */
  47955. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47956. /**
  47957. * Gets a boolean indicating if all created effects are ready
  47958. * @returns true if all effects are ready
  47959. */
  47960. areAllEffectsReady(): boolean;
  47961. /**
  47962. * @hidden
  47963. * Get the current error code of the webGL context
  47964. * @returns the error code
  47965. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47966. */
  47967. getError(): number;
  47968. /** @hidden */
  47969. _getUnpackAlignement(): number;
  47970. /** @hidden */
  47971. _unpackFlipY(value: boolean): void;
  47972. /**
  47973. * Update a dynamic index buffer
  47974. * @param indexBuffer defines the target index buffer
  47975. * @param indices defines the data to update
  47976. * @param offset defines the offset in the target index buffer where update should start
  47977. */
  47978. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47979. /**
  47980. * Updates a dynamic vertex buffer.
  47981. * @param vertexBuffer the vertex buffer to update
  47982. * @param vertices the data used to update the vertex buffer
  47983. * @param byteOffset the byte offset of the data (optional)
  47984. * @param byteLength the byte length of the data (optional)
  47985. */
  47986. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47987. /** @hidden */
  47988. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47989. /** @hidden */
  47990. _bindTexture(channel: number, texture: InternalTexture): void;
  47991. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47992. /**
  47993. * 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
  47994. */
  47995. releaseEffects(): void;
  47996. displayLoadingUI(): void;
  47997. hideLoadingUI(): void;
  47998. /** @hidden */
  47999. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48000. /** @hidden */
  48001. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48002. /** @hidden */
  48003. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48004. /** @hidden */
  48005. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48006. }
  48007. }
  48008. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48009. import { Nullable, int } from "babylonjs/types";
  48010. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48011. /** @hidden */
  48012. export class _OcclusionDataStorage {
  48013. /** @hidden */
  48014. occlusionInternalRetryCounter: number;
  48015. /** @hidden */
  48016. isOcclusionQueryInProgress: boolean;
  48017. /** @hidden */
  48018. isOccluded: boolean;
  48019. /** @hidden */
  48020. occlusionRetryCount: number;
  48021. /** @hidden */
  48022. occlusionType: number;
  48023. /** @hidden */
  48024. occlusionQueryAlgorithmType: number;
  48025. }
  48026. module "babylonjs/Engines/engine" {
  48027. interface Engine {
  48028. /**
  48029. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48030. * @return the new query
  48031. */
  48032. createQuery(): WebGLQuery;
  48033. /**
  48034. * Delete and release a webGL query
  48035. * @param query defines the query to delete
  48036. * @return the current engine
  48037. */
  48038. deleteQuery(query: WebGLQuery): Engine;
  48039. /**
  48040. * Check if a given query has resolved and got its value
  48041. * @param query defines the query to check
  48042. * @returns true if the query got its value
  48043. */
  48044. isQueryResultAvailable(query: WebGLQuery): boolean;
  48045. /**
  48046. * Gets the value of a given query
  48047. * @param query defines the query to check
  48048. * @returns the value of the query
  48049. */
  48050. getQueryResult(query: WebGLQuery): number;
  48051. /**
  48052. * Initiates an occlusion query
  48053. * @param algorithmType defines the algorithm to use
  48054. * @param query defines the query to use
  48055. * @returns the current engine
  48056. * @see http://doc.babylonjs.com/features/occlusionquery
  48057. */
  48058. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48059. /**
  48060. * Ends an occlusion query
  48061. * @see http://doc.babylonjs.com/features/occlusionquery
  48062. * @param algorithmType defines the algorithm to use
  48063. * @returns the current engine
  48064. */
  48065. endOcclusionQuery(algorithmType: number): Engine;
  48066. /**
  48067. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48068. * Please note that only one query can be issued at a time
  48069. * @returns a time token used to track the time span
  48070. */
  48071. startTimeQuery(): Nullable<_TimeToken>;
  48072. /**
  48073. * Ends a time query
  48074. * @param token defines the token used to measure the time span
  48075. * @returns the time spent (in ns)
  48076. */
  48077. endTimeQuery(token: _TimeToken): int;
  48078. /** @hidden */
  48079. _currentNonTimestampToken: Nullable<_TimeToken>;
  48080. /** @hidden */
  48081. _createTimeQuery(): WebGLQuery;
  48082. /** @hidden */
  48083. _deleteTimeQuery(query: WebGLQuery): void;
  48084. /** @hidden */
  48085. _getGlAlgorithmType(algorithmType: number): number;
  48086. /** @hidden */
  48087. _getTimeQueryResult(query: WebGLQuery): any;
  48088. /** @hidden */
  48089. _getTimeQueryAvailability(query: WebGLQuery): any;
  48090. }
  48091. }
  48092. module "babylonjs/Meshes/abstractMesh" {
  48093. interface AbstractMesh {
  48094. /**
  48095. * Backing filed
  48096. * @hidden
  48097. */
  48098. __occlusionDataStorage: _OcclusionDataStorage;
  48099. /**
  48100. * Access property
  48101. * @hidden
  48102. */
  48103. _occlusionDataStorage: _OcclusionDataStorage;
  48104. /**
  48105. * 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.
  48106. * The default value is -1 which means don't break the query and wait till the result
  48107. * @see http://doc.babylonjs.com/features/occlusionquery
  48108. */
  48109. occlusionRetryCount: number;
  48110. /**
  48111. * 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:
  48112. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48113. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48114. * * 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.
  48115. * @see http://doc.babylonjs.com/features/occlusionquery
  48116. */
  48117. occlusionType: number;
  48118. /**
  48119. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48120. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48121. * * 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.
  48122. * @see http://doc.babylonjs.com/features/occlusionquery
  48123. */
  48124. occlusionQueryAlgorithmType: number;
  48125. /**
  48126. * 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
  48127. * @see http://doc.babylonjs.com/features/occlusionquery
  48128. */
  48129. isOccluded: boolean;
  48130. /**
  48131. * Flag to check the progress status of the query
  48132. * @see http://doc.babylonjs.com/features/occlusionquery
  48133. */
  48134. isOcclusionQueryInProgress: boolean;
  48135. }
  48136. }
  48137. }
  48138. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48139. import { Nullable } from "babylonjs/types";
  48140. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48141. /** @hidden */
  48142. export var _forceTransformFeedbackToBundle: boolean;
  48143. module "babylonjs/Engines/engine" {
  48144. interface Engine {
  48145. /**
  48146. * Creates a webGL transform feedback object
  48147. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48148. * @returns the webGL transform feedback object
  48149. */
  48150. createTransformFeedback(): WebGLTransformFeedback;
  48151. /**
  48152. * Delete a webGL transform feedback object
  48153. * @param value defines the webGL transform feedback object to delete
  48154. */
  48155. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48156. /**
  48157. * Bind a webGL transform feedback object to the webgl context
  48158. * @param value defines the webGL transform feedback object to bind
  48159. */
  48160. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48161. /**
  48162. * Begins a transform feedback operation
  48163. * @param usePoints defines if points or triangles must be used
  48164. */
  48165. beginTransformFeedback(usePoints: boolean): void;
  48166. /**
  48167. * Ends a transform feedback operation
  48168. */
  48169. endTransformFeedback(): void;
  48170. /**
  48171. * Specify the varyings to use with transform feedback
  48172. * @param program defines the associated webGL program
  48173. * @param value defines the list of strings representing the varying names
  48174. */
  48175. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48176. /**
  48177. * Bind a webGL buffer for a transform feedback operation
  48178. * @param value defines the webGL buffer to bind
  48179. */
  48180. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48181. }
  48182. }
  48183. }
  48184. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48185. import { Scene } from "babylonjs/scene";
  48186. import { Engine } from "babylonjs/Engines/engine";
  48187. import { Texture } from "babylonjs/Materials/Textures/texture";
  48188. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48189. import "babylonjs/Engines/Extensions/engine.multiRender";
  48190. /**
  48191. * Creation options of the multi render target texture.
  48192. */
  48193. export interface IMultiRenderTargetOptions {
  48194. /**
  48195. * Define if the texture needs to create mip maps after render.
  48196. */
  48197. generateMipMaps?: boolean;
  48198. /**
  48199. * Define the types of all the draw buffers we want to create
  48200. */
  48201. types?: number[];
  48202. /**
  48203. * Define the sampling modes of all the draw buffers we want to create
  48204. */
  48205. samplingModes?: number[];
  48206. /**
  48207. * Define if a depth buffer is required
  48208. */
  48209. generateDepthBuffer?: boolean;
  48210. /**
  48211. * Define if a stencil buffer is required
  48212. */
  48213. generateStencilBuffer?: boolean;
  48214. /**
  48215. * Define if a depth texture is required instead of a depth buffer
  48216. */
  48217. generateDepthTexture?: boolean;
  48218. /**
  48219. * Define the number of desired draw buffers
  48220. */
  48221. textureCount?: number;
  48222. /**
  48223. * Define if aspect ratio should be adapted to the texture or stay the scene one
  48224. */
  48225. doNotChangeAspectRatio?: boolean;
  48226. /**
  48227. * Define the default type of the buffers we are creating
  48228. */
  48229. defaultType?: number;
  48230. }
  48231. /**
  48232. * A multi render target, like a render target provides the ability to render to a texture.
  48233. * Unlike the render target, it can render to several draw buffers in one draw.
  48234. * This is specially interesting in deferred rendering or for any effects requiring more than
  48235. * just one color from a single pass.
  48236. */
  48237. export class MultiRenderTarget extends RenderTargetTexture {
  48238. private _internalTextures;
  48239. private _textures;
  48240. private _multiRenderTargetOptions;
  48241. /**
  48242. * Get if draw buffers are currently supported by the used hardware and browser.
  48243. */
  48244. get isSupported(): boolean;
  48245. /**
  48246. * Get the list of textures generated by the multi render target.
  48247. */
  48248. get textures(): Texture[];
  48249. /**
  48250. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  48251. */
  48252. get depthTexture(): Texture;
  48253. /**
  48254. * Set the wrapping mode on U of all the textures we are rendering to.
  48255. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48256. */
  48257. set wrapU(wrap: number);
  48258. /**
  48259. * Set the wrapping mode on V of all the textures we are rendering to.
  48260. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48261. */
  48262. set wrapV(wrap: number);
  48263. /**
  48264. * Instantiate a new multi render target texture.
  48265. * A multi render target, like a render target provides the ability to render to a texture.
  48266. * Unlike the render target, it can render to several draw buffers in one draw.
  48267. * This is specially interesting in deferred rendering or for any effects requiring more than
  48268. * just one color from a single pass.
  48269. * @param name Define the name of the texture
  48270. * @param size Define the size of the buffers to render to
  48271. * @param count Define the number of target we are rendering into
  48272. * @param scene Define the scene the texture belongs to
  48273. * @param options Define the options used to create the multi render target
  48274. */
  48275. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  48276. /** @hidden */
  48277. _rebuild(): void;
  48278. private _createInternalTextures;
  48279. private _createTextures;
  48280. /**
  48281. * Define the number of samples used if MSAA is enabled.
  48282. */
  48283. get samples(): number;
  48284. set samples(value: number);
  48285. /**
  48286. * Resize all the textures in the multi render target.
  48287. * Be carrefull as it will recreate all the data in the new texture.
  48288. * @param size Define the new size
  48289. */
  48290. resize(size: any): void;
  48291. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48292. /**
  48293. * Dispose the render targets and their associated resources
  48294. */
  48295. dispose(): void;
  48296. /**
  48297. * Release all the underlying texture used as draw buffers.
  48298. */
  48299. releaseInternalTextures(): void;
  48300. }
  48301. }
  48302. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  48303. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48304. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  48305. import { Nullable } from "babylonjs/types";
  48306. module "babylonjs/Engines/thinEngine" {
  48307. interface ThinEngine {
  48308. /**
  48309. * Unbind a list of render target textures from the webGL context
  48310. * This is used only when drawBuffer extension or webGL2 are active
  48311. * @param textures defines the render target textures to unbind
  48312. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48313. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48314. */
  48315. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  48316. /**
  48317. * Create a multi render target texture
  48318. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  48319. * @param size defines the size of the texture
  48320. * @param options defines the creation options
  48321. * @returns the cube texture as an InternalTexture
  48322. */
  48323. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  48324. /**
  48325. * Update the sample count for a given multiple render target texture
  48326. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  48327. * @param textures defines the textures to update
  48328. * @param samples defines the sample count to set
  48329. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  48330. */
  48331. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  48332. }
  48333. }
  48334. }
  48335. declare module "babylonjs/Engines/Extensions/engine.views" {
  48336. import { Camera } from "babylonjs/Cameras/camera";
  48337. import { Nullable } from "babylonjs/types";
  48338. /**
  48339. * Class used to define an additional view for the engine
  48340. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48341. */
  48342. export class EngineView {
  48343. /** Defines the canvas where to render the view */
  48344. target: HTMLCanvasElement;
  48345. /** Defines an optional camera used to render the view (will use active camera else) */
  48346. camera?: Camera;
  48347. }
  48348. module "babylonjs/Engines/engine" {
  48349. interface Engine {
  48350. /**
  48351. * Gets or sets the HTML element to use for attaching events
  48352. */
  48353. inputElement: Nullable<HTMLElement>;
  48354. /**
  48355. * Gets the current engine view
  48356. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48357. */
  48358. activeView: Nullable<EngineView>;
  48359. /** Gets or sets the list of views */
  48360. views: EngineView[];
  48361. /**
  48362. * Register a new child canvas
  48363. * @param canvas defines the canvas to register
  48364. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  48365. * @returns the associated view
  48366. */
  48367. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  48368. /**
  48369. * Remove a registered child canvas
  48370. * @param canvas defines the canvas to remove
  48371. * @returns the current engine
  48372. */
  48373. unRegisterView(canvas: HTMLCanvasElement): Engine;
  48374. }
  48375. }
  48376. }
  48377. declare module "babylonjs/Engines/Extensions/index" {
  48378. export * from "babylonjs/Engines/Extensions/engine.alpha";
  48379. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  48380. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  48381. export * from "babylonjs/Engines/Extensions/engine.multiview";
  48382. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  48383. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48384. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  48385. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  48386. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  48387. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  48388. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  48389. export * from "babylonjs/Engines/Extensions/engine.webVR";
  48390. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  48391. export * from "babylonjs/Engines/Extensions/engine.views";
  48392. }
  48393. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  48394. import { Nullable } from "babylonjs/types";
  48395. /**
  48396. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  48397. */
  48398. export interface CubeMapInfo {
  48399. /**
  48400. * The pixel array for the front face.
  48401. * This is stored in format, left to right, up to down format.
  48402. */
  48403. front: Nullable<ArrayBufferView>;
  48404. /**
  48405. * The pixel array for the back face.
  48406. * This is stored in format, left to right, up to down format.
  48407. */
  48408. back: Nullable<ArrayBufferView>;
  48409. /**
  48410. * The pixel array for the left face.
  48411. * This is stored in format, left to right, up to down format.
  48412. */
  48413. left: Nullable<ArrayBufferView>;
  48414. /**
  48415. * The pixel array for the right face.
  48416. * This is stored in format, left to right, up to down format.
  48417. */
  48418. right: Nullable<ArrayBufferView>;
  48419. /**
  48420. * The pixel array for the up face.
  48421. * This is stored in format, left to right, up to down format.
  48422. */
  48423. up: Nullable<ArrayBufferView>;
  48424. /**
  48425. * The pixel array for the down face.
  48426. * This is stored in format, left to right, up to down format.
  48427. */
  48428. down: Nullable<ArrayBufferView>;
  48429. /**
  48430. * The size of the cubemap stored.
  48431. *
  48432. * Each faces will be size * size pixels.
  48433. */
  48434. size: number;
  48435. /**
  48436. * The format of the texture.
  48437. *
  48438. * RGBA, RGB.
  48439. */
  48440. format: number;
  48441. /**
  48442. * The type of the texture data.
  48443. *
  48444. * UNSIGNED_INT, FLOAT.
  48445. */
  48446. type: number;
  48447. /**
  48448. * Specifies whether the texture is in gamma space.
  48449. */
  48450. gammaSpace: boolean;
  48451. }
  48452. /**
  48453. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  48454. */
  48455. export class PanoramaToCubeMapTools {
  48456. private static FACE_FRONT;
  48457. private static FACE_BACK;
  48458. private static FACE_RIGHT;
  48459. private static FACE_LEFT;
  48460. private static FACE_DOWN;
  48461. private static FACE_UP;
  48462. /**
  48463. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  48464. *
  48465. * @param float32Array The source data.
  48466. * @param inputWidth The width of the input panorama.
  48467. * @param inputHeight The height of the input panorama.
  48468. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  48469. * @return The cubemap data
  48470. */
  48471. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  48472. private static CreateCubemapTexture;
  48473. private static CalcProjectionSpherical;
  48474. }
  48475. }
  48476. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  48477. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48478. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48479. import { Nullable } from "babylonjs/types";
  48480. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  48481. /**
  48482. * Helper class dealing with the extraction of spherical polynomial dataArray
  48483. * from a cube map.
  48484. */
  48485. export class CubeMapToSphericalPolynomialTools {
  48486. private static FileFaces;
  48487. /**
  48488. * Converts a texture to the according Spherical Polynomial data.
  48489. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48490. *
  48491. * @param texture The texture to extract the information from.
  48492. * @return The Spherical Polynomial data.
  48493. */
  48494. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  48495. /**
  48496. * Converts a cubemap to the according Spherical Polynomial data.
  48497. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48498. *
  48499. * @param cubeInfo The Cube map to extract the information from.
  48500. * @return The Spherical Polynomial data.
  48501. */
  48502. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  48503. }
  48504. }
  48505. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  48506. import { Nullable } from "babylonjs/types";
  48507. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48508. module "babylonjs/Materials/Textures/baseTexture" {
  48509. interface BaseTexture {
  48510. /**
  48511. * Get the polynomial representation of the texture data.
  48512. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  48513. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  48514. */
  48515. sphericalPolynomial: Nullable<SphericalPolynomial>;
  48516. }
  48517. }
  48518. }
  48519. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48520. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48521. /** @hidden */
  48522. export var rgbdEncodePixelShader: {
  48523. name: string;
  48524. shader: string;
  48525. };
  48526. }
  48527. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  48528. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48529. /** @hidden */
  48530. export var rgbdDecodePixelShader: {
  48531. name: string;
  48532. shader: string;
  48533. };
  48534. }
  48535. declare module "babylonjs/Misc/environmentTextureTools" {
  48536. import { Nullable } from "babylonjs/types";
  48537. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48538. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48539. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48540. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  48541. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  48542. import "babylonjs/Shaders/rgbdEncode.fragment";
  48543. import "babylonjs/Shaders/rgbdDecode.fragment";
  48544. /**
  48545. * Raw texture data and descriptor sufficient for WebGL texture upload
  48546. */
  48547. export interface EnvironmentTextureInfo {
  48548. /**
  48549. * Version of the environment map
  48550. */
  48551. version: number;
  48552. /**
  48553. * Width of image
  48554. */
  48555. width: number;
  48556. /**
  48557. * Irradiance information stored in the file.
  48558. */
  48559. irradiance: any;
  48560. /**
  48561. * Specular information stored in the file.
  48562. */
  48563. specular: any;
  48564. }
  48565. /**
  48566. * Defines One Image in the file. It requires only the position in the file
  48567. * as well as the length.
  48568. */
  48569. interface BufferImageData {
  48570. /**
  48571. * Length of the image data.
  48572. */
  48573. length: number;
  48574. /**
  48575. * Position of the data from the null terminator delimiting the end of the JSON.
  48576. */
  48577. position: number;
  48578. }
  48579. /**
  48580. * Defines the specular data enclosed in the file.
  48581. * This corresponds to the version 1 of the data.
  48582. */
  48583. export interface EnvironmentTextureSpecularInfoV1 {
  48584. /**
  48585. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  48586. */
  48587. specularDataPosition?: number;
  48588. /**
  48589. * This contains all the images data needed to reconstruct the cubemap.
  48590. */
  48591. mipmaps: Array<BufferImageData>;
  48592. /**
  48593. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  48594. */
  48595. lodGenerationScale: number;
  48596. }
  48597. /**
  48598. * Sets of helpers addressing the serialization and deserialization of environment texture
  48599. * stored in a BabylonJS env file.
  48600. * Those files are usually stored as .env files.
  48601. */
  48602. export class EnvironmentTextureTools {
  48603. /**
  48604. * Magic number identifying the env file.
  48605. */
  48606. private static _MagicBytes;
  48607. /**
  48608. * Gets the environment info from an env file.
  48609. * @param data The array buffer containing the .env bytes.
  48610. * @returns the environment file info (the json header) if successfully parsed.
  48611. */
  48612. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48613. /**
  48614. * Creates an environment texture from a loaded cube texture.
  48615. * @param texture defines the cube texture to convert in env file
  48616. * @return a promise containing the environment data if succesfull.
  48617. */
  48618. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48619. /**
  48620. * Creates a JSON representation of the spherical data.
  48621. * @param texture defines the texture containing the polynomials
  48622. * @return the JSON representation of the spherical info
  48623. */
  48624. private static _CreateEnvTextureIrradiance;
  48625. /**
  48626. * Creates the ArrayBufferViews used for initializing environment texture image data.
  48627. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  48628. * @param info parameters that determine what views will be created for accessing the underlying buffer
  48629. * @return the views described by info providing access to the underlying buffer
  48630. */
  48631. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  48632. /**
  48633. * Uploads the texture info contained in the env file to the GPU.
  48634. * @param texture defines the internal texture to upload to
  48635. * @param arrayBuffer defines the buffer cotaining the data to load
  48636. * @param info defines the texture info retrieved through the GetEnvInfo method
  48637. * @returns a promise
  48638. */
  48639. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48640. private static _OnImageReadyAsync;
  48641. /**
  48642. * Uploads the levels of image data to the GPU.
  48643. * @param texture defines the internal texture to upload to
  48644. * @param imageData defines the array buffer views of image data [mipmap][face]
  48645. * @returns a promise
  48646. */
  48647. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48648. /**
  48649. * Uploads spherical polynomials information to the texture.
  48650. * @param texture defines the texture we are trying to upload the information to
  48651. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48652. */
  48653. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48654. /** @hidden */
  48655. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48656. }
  48657. }
  48658. declare module "babylonjs/Maths/math.vertexFormat" {
  48659. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  48660. /**
  48661. * Contains position and normal vectors for a vertex
  48662. */
  48663. export class PositionNormalVertex {
  48664. /** the position of the vertex (defaut: 0,0,0) */
  48665. position: Vector3;
  48666. /** the normal of the vertex (defaut: 0,1,0) */
  48667. normal: Vector3;
  48668. /**
  48669. * Creates a PositionNormalVertex
  48670. * @param position the position of the vertex (defaut: 0,0,0)
  48671. * @param normal the normal of the vertex (defaut: 0,1,0)
  48672. */
  48673. constructor(
  48674. /** the position of the vertex (defaut: 0,0,0) */
  48675. position?: Vector3,
  48676. /** the normal of the vertex (defaut: 0,1,0) */
  48677. normal?: Vector3);
  48678. /**
  48679. * Clones the PositionNormalVertex
  48680. * @returns the cloned PositionNormalVertex
  48681. */
  48682. clone(): PositionNormalVertex;
  48683. }
  48684. /**
  48685. * Contains position, normal and uv vectors for a vertex
  48686. */
  48687. export class PositionNormalTextureVertex {
  48688. /** the position of the vertex (defaut: 0,0,0) */
  48689. position: Vector3;
  48690. /** the normal of the vertex (defaut: 0,1,0) */
  48691. normal: Vector3;
  48692. /** the uv of the vertex (default: 0,0) */
  48693. uv: Vector2;
  48694. /**
  48695. * Creates a PositionNormalTextureVertex
  48696. * @param position the position of the vertex (defaut: 0,0,0)
  48697. * @param normal the normal of the vertex (defaut: 0,1,0)
  48698. * @param uv the uv of the vertex (default: 0,0)
  48699. */
  48700. constructor(
  48701. /** the position of the vertex (defaut: 0,0,0) */
  48702. position?: Vector3,
  48703. /** the normal of the vertex (defaut: 0,1,0) */
  48704. normal?: Vector3,
  48705. /** the uv of the vertex (default: 0,0) */
  48706. uv?: Vector2);
  48707. /**
  48708. * Clones the PositionNormalTextureVertex
  48709. * @returns the cloned PositionNormalTextureVertex
  48710. */
  48711. clone(): PositionNormalTextureVertex;
  48712. }
  48713. }
  48714. declare module "babylonjs/Maths/math" {
  48715. export * from "babylonjs/Maths/math.axis";
  48716. export * from "babylonjs/Maths/math.color";
  48717. export * from "babylonjs/Maths/math.constants";
  48718. export * from "babylonjs/Maths/math.frustum";
  48719. export * from "babylonjs/Maths/math.path";
  48720. export * from "babylonjs/Maths/math.plane";
  48721. export * from "babylonjs/Maths/math.size";
  48722. export * from "babylonjs/Maths/math.vector";
  48723. export * from "babylonjs/Maths/math.vertexFormat";
  48724. export * from "babylonjs/Maths/math.viewport";
  48725. }
  48726. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  48727. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  48728. /** @hidden */
  48729. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  48730. private _genericAttributeLocation;
  48731. private _varyingLocationCount;
  48732. private _varyingLocationMap;
  48733. private _replacements;
  48734. private _textureCount;
  48735. private _uniforms;
  48736. lineProcessor(line: string): string;
  48737. attributeProcessor(attribute: string): string;
  48738. varyingProcessor(varying: string, isFragment: boolean): string;
  48739. uniformProcessor(uniform: string): string;
  48740. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  48741. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  48742. }
  48743. }
  48744. declare module "babylonjs/Engines/nativeEngine" {
  48745. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  48746. import { Engine } from "babylonjs/Engines/engine";
  48747. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48748. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48749. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48750. import { Effect } from "babylonjs/Materials/effect";
  48751. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48752. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  48753. import { IColor4Like } from "babylonjs/Maths/math.like";
  48754. import { Scene } from "babylonjs/scene";
  48755. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48756. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48757. /**
  48758. * Container for accessors for natively-stored mesh data buffers.
  48759. */
  48760. class NativeDataBuffer extends DataBuffer {
  48761. /**
  48762. * Accessor value used to identify/retrieve a natively-stored index buffer.
  48763. */
  48764. nativeIndexBuffer?: any;
  48765. /**
  48766. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  48767. */
  48768. nativeVertexBuffer?: any;
  48769. }
  48770. /** @hidden */
  48771. class NativeTexture extends InternalTexture {
  48772. getInternalTexture(): InternalTexture;
  48773. getViewCount(): number;
  48774. }
  48775. /** @hidden */
  48776. export class NativeEngine extends Engine {
  48777. private readonly _native;
  48778. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  48779. private readonly INVALID_HANDLE;
  48780. getHardwareScalingLevel(): number;
  48781. constructor();
  48782. /**
  48783. * Can be used to override the current requestAnimationFrame requester.
  48784. * @hidden
  48785. */
  48786. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  48787. /**
  48788. * Override default engine behavior.
  48789. * @param color
  48790. * @param backBuffer
  48791. * @param depth
  48792. * @param stencil
  48793. */
  48794. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  48795. /**
  48796. * Gets host document
  48797. * @returns the host document object
  48798. */
  48799. getHostDocument(): Nullable<Document>;
  48800. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48801. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  48802. createVertexBuffer(data: DataArray): NativeDataBuffer;
  48803. recordVertexArrayObject(vertexBuffers: {
  48804. [key: string]: VertexBuffer;
  48805. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  48806. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48807. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48808. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48809. /**
  48810. * Draw a list of indexed primitives
  48811. * @param fillMode defines the primitive to use
  48812. * @param indexStart defines the starting index
  48813. * @param indexCount defines the number of index to draw
  48814. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48815. */
  48816. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48817. /**
  48818. * Draw a list of unindexed primitives
  48819. * @param fillMode defines the primitive to use
  48820. * @param verticesStart defines the index of first vertex to draw
  48821. * @param verticesCount defines the count of vertices to draw
  48822. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48823. */
  48824. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48825. createPipelineContext(): IPipelineContext;
  48826. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  48827. /** @hidden */
  48828. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  48829. /** @hidden */
  48830. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  48831. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48832. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48833. protected _setProgram(program: WebGLProgram): void;
  48834. _releaseEffect(effect: Effect): void;
  48835. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  48836. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  48837. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  48838. bindSamplers(effect: Effect): void;
  48839. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  48840. getRenderWidth(useScreen?: boolean): number;
  48841. getRenderHeight(useScreen?: boolean): number;
  48842. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  48843. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48844. /**
  48845. * Set the z offset to apply to current rendering
  48846. * @param value defines the offset to apply
  48847. */
  48848. setZOffset(value: number): void;
  48849. /**
  48850. * Gets the current value of the zOffset
  48851. * @returns the current zOffset state
  48852. */
  48853. getZOffset(): number;
  48854. /**
  48855. * Enable or disable depth buffering
  48856. * @param enable defines the state to set
  48857. */
  48858. setDepthBuffer(enable: boolean): void;
  48859. /**
  48860. * Gets a boolean indicating if depth writing is enabled
  48861. * @returns the current depth writing state
  48862. */
  48863. getDepthWrite(): boolean;
  48864. /**
  48865. * Enable or disable depth writing
  48866. * @param enable defines the state to set
  48867. */
  48868. setDepthWrite(enable: boolean): void;
  48869. /**
  48870. * Enable or disable color writing
  48871. * @param enable defines the state to set
  48872. */
  48873. setColorWrite(enable: boolean): void;
  48874. /**
  48875. * Gets a boolean indicating if color writing is enabled
  48876. * @returns the current color writing state
  48877. */
  48878. getColorWrite(): boolean;
  48879. /**
  48880. * Sets alpha constants used by some alpha blending modes
  48881. * @param r defines the red component
  48882. * @param g defines the green component
  48883. * @param b defines the blue component
  48884. * @param a defines the alpha component
  48885. */
  48886. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48887. /**
  48888. * Sets the current alpha mode
  48889. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48890. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48891. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48892. */
  48893. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48894. /**
  48895. * Gets the current alpha mode
  48896. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48897. * @returns the current alpha mode
  48898. */
  48899. getAlphaMode(): number;
  48900. setInt(uniform: WebGLUniformLocation, int: number): void;
  48901. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48902. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48903. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48904. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48905. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48906. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48907. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48908. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48909. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48910. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48911. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48912. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48913. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48914. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48915. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48916. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48917. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48918. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48919. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48920. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48921. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48922. wipeCaches(bruteForce?: boolean): void;
  48923. _createTexture(): WebGLTexture;
  48924. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48925. /**
  48926. * Usually called from BABYLON.Texture.ts.
  48927. * Passed information to create a WebGLTexture
  48928. * @param urlArg defines a value which contains one of the following:
  48929. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48930. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48931. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48932. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48933. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  48934. * @param scene needed for loading to the correct scene
  48935. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  48936. * @param onLoad optional callback to be called upon successful completion
  48937. * @param onError optional callback to be called upon failure
  48938. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  48939. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48940. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48941. * @param forcedExtension defines the extension to use to pick the right loader
  48942. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48943. */
  48944. 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;
  48945. /**
  48946. * Creates a cube texture
  48947. * @param rootUrl defines the url where the files to load is located
  48948. * @param scene defines the current scene
  48949. * @param files defines the list of files to load (1 per face)
  48950. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48951. * @param onLoad defines an optional callback raised when the texture is loaded
  48952. * @param onError defines an optional callback raised if there is an issue to load the texture
  48953. * @param format defines the format of the data
  48954. * @param forcedExtension defines the extension to use to pick the right loader
  48955. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48956. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48957. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48958. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48959. * @returns the cube texture as an InternalTexture
  48960. */
  48961. 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;
  48962. private _getSamplingFilter;
  48963. private static _GetNativeTextureFormat;
  48964. createRenderTargetTexture(size: number | {
  48965. width: number;
  48966. height: number;
  48967. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48968. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48969. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48970. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48971. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48972. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48973. /**
  48974. * Updates a dynamic vertex buffer.
  48975. * @param vertexBuffer the vertex buffer to update
  48976. * @param data the data used to update the vertex buffer
  48977. * @param byteOffset the byte offset of the data (optional)
  48978. * @param byteLength the byte length of the data (optional)
  48979. */
  48980. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48981. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48982. private _updateAnisotropicLevel;
  48983. private _getAddressMode;
  48984. /** @hidden */
  48985. _bindTexture(channel: number, texture: InternalTexture): void;
  48986. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48987. releaseEffects(): void;
  48988. /** @hidden */
  48989. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48990. /** @hidden */
  48991. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48992. /** @hidden */
  48993. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48994. /** @hidden */
  48995. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48996. }
  48997. }
  48998. declare module "babylonjs/Engines/index" {
  48999. export * from "babylonjs/Engines/constants";
  49000. export * from "babylonjs/Engines/engineCapabilities";
  49001. export * from "babylonjs/Engines/instancingAttributeInfo";
  49002. export * from "babylonjs/Engines/thinEngine";
  49003. export * from "babylonjs/Engines/engine";
  49004. export * from "babylonjs/Engines/engineStore";
  49005. export * from "babylonjs/Engines/nullEngine";
  49006. export * from "babylonjs/Engines/Extensions/index";
  49007. export * from "babylonjs/Engines/IPipelineContext";
  49008. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49009. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49010. export * from "babylonjs/Engines/nativeEngine";
  49011. }
  49012. declare module "babylonjs/Events/clipboardEvents" {
  49013. /**
  49014. * Gather the list of clipboard event types as constants.
  49015. */
  49016. export class ClipboardEventTypes {
  49017. /**
  49018. * The clipboard event is fired when a copy command is active (pressed).
  49019. */
  49020. static readonly COPY: number;
  49021. /**
  49022. * The clipboard event is fired when a cut command is active (pressed).
  49023. */
  49024. static readonly CUT: number;
  49025. /**
  49026. * The clipboard event is fired when a paste command is active (pressed).
  49027. */
  49028. static readonly PASTE: number;
  49029. }
  49030. /**
  49031. * This class is used to store clipboard related info for the onClipboardObservable event.
  49032. */
  49033. export class ClipboardInfo {
  49034. /**
  49035. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49036. */
  49037. type: number;
  49038. /**
  49039. * Defines the related dom event
  49040. */
  49041. event: ClipboardEvent;
  49042. /**
  49043. *Creates an instance of ClipboardInfo.
  49044. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49045. * @param event Defines the related dom event
  49046. */
  49047. constructor(
  49048. /**
  49049. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49050. */
  49051. type: number,
  49052. /**
  49053. * Defines the related dom event
  49054. */
  49055. event: ClipboardEvent);
  49056. /**
  49057. * Get the clipboard event's type from the keycode.
  49058. * @param keyCode Defines the keyCode for the current keyboard event.
  49059. * @return {number}
  49060. */
  49061. static GetTypeFromCharacter(keyCode: number): number;
  49062. }
  49063. }
  49064. declare module "babylonjs/Events/index" {
  49065. export * from "babylonjs/Events/keyboardEvents";
  49066. export * from "babylonjs/Events/pointerEvents";
  49067. export * from "babylonjs/Events/clipboardEvents";
  49068. }
  49069. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49070. import { Scene } from "babylonjs/scene";
  49071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49072. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49073. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49074. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49075. /**
  49076. * Google Daydream controller
  49077. */
  49078. export class DaydreamController extends WebVRController {
  49079. /**
  49080. * Base Url for the controller model.
  49081. */
  49082. static MODEL_BASE_URL: string;
  49083. /**
  49084. * File name for the controller model.
  49085. */
  49086. static MODEL_FILENAME: string;
  49087. /**
  49088. * Gamepad Id prefix used to identify Daydream Controller.
  49089. */
  49090. static readonly GAMEPAD_ID_PREFIX: string;
  49091. /**
  49092. * Creates a new DaydreamController from a gamepad
  49093. * @param vrGamepad the gamepad that the controller should be created from
  49094. */
  49095. constructor(vrGamepad: any);
  49096. /**
  49097. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49098. * @param scene scene in which to add meshes
  49099. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49100. */
  49101. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49102. /**
  49103. * Called once for each button that changed state since the last frame
  49104. * @param buttonIdx Which button index changed
  49105. * @param state New state of the button
  49106. * @param changes Which properties on the state changed since last frame
  49107. */
  49108. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49109. }
  49110. }
  49111. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49112. import { Scene } from "babylonjs/scene";
  49113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49114. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49115. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49116. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49117. /**
  49118. * Gear VR Controller
  49119. */
  49120. export class GearVRController extends WebVRController {
  49121. /**
  49122. * Base Url for the controller model.
  49123. */
  49124. static MODEL_BASE_URL: string;
  49125. /**
  49126. * File name for the controller model.
  49127. */
  49128. static MODEL_FILENAME: string;
  49129. /**
  49130. * Gamepad Id prefix used to identify this controller.
  49131. */
  49132. static readonly GAMEPAD_ID_PREFIX: string;
  49133. private readonly _buttonIndexToObservableNameMap;
  49134. /**
  49135. * Creates a new GearVRController from a gamepad
  49136. * @param vrGamepad the gamepad that the controller should be created from
  49137. */
  49138. constructor(vrGamepad: any);
  49139. /**
  49140. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49141. * @param scene scene in which to add meshes
  49142. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49143. */
  49144. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49145. /**
  49146. * Called once for each button that changed state since the last frame
  49147. * @param buttonIdx Which button index changed
  49148. * @param state New state of the button
  49149. * @param changes Which properties on the state changed since last frame
  49150. */
  49151. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49152. }
  49153. }
  49154. declare module "babylonjs/Gamepads/Controllers/index" {
  49155. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  49156. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  49157. export * from "babylonjs/Gamepads/Controllers/genericController";
  49158. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  49159. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49160. export * from "babylonjs/Gamepads/Controllers/viveController";
  49161. export * from "babylonjs/Gamepads/Controllers/webVRController";
  49162. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  49163. }
  49164. declare module "babylonjs/Gamepads/index" {
  49165. export * from "babylonjs/Gamepads/Controllers/index";
  49166. export * from "babylonjs/Gamepads/gamepad";
  49167. export * from "babylonjs/Gamepads/gamepadManager";
  49168. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  49169. export * from "babylonjs/Gamepads/xboxGamepad";
  49170. export * from "babylonjs/Gamepads/dualShockGamepad";
  49171. }
  49172. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  49173. import { Scene } from "babylonjs/scene";
  49174. import { Vector4 } from "babylonjs/Maths/math.vector";
  49175. import { Color4 } from "babylonjs/Maths/math.color";
  49176. import { Mesh } from "babylonjs/Meshes/mesh";
  49177. import { Nullable } from "babylonjs/types";
  49178. /**
  49179. * Class containing static functions to help procedurally build meshes
  49180. */
  49181. export class PolyhedronBuilder {
  49182. /**
  49183. * Creates a polyhedron mesh
  49184. * * 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
  49185. * * The parameter `size` (positive float, default 1) sets the polygon size
  49186. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  49187. * * 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`
  49188. * * 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
  49189. * * 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)`)
  49190. * * 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
  49191. * * 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
  49192. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49193. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49195. * @param name defines the name of the mesh
  49196. * @param options defines the options used to create the mesh
  49197. * @param scene defines the hosting scene
  49198. * @returns the polyhedron mesh
  49199. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  49200. */
  49201. static CreatePolyhedron(name: string, options: {
  49202. type?: number;
  49203. size?: number;
  49204. sizeX?: number;
  49205. sizeY?: number;
  49206. sizeZ?: number;
  49207. custom?: any;
  49208. faceUV?: Vector4[];
  49209. faceColors?: Color4[];
  49210. flat?: boolean;
  49211. updatable?: boolean;
  49212. sideOrientation?: number;
  49213. frontUVs?: Vector4;
  49214. backUVs?: Vector4;
  49215. }, scene?: Nullable<Scene>): Mesh;
  49216. }
  49217. }
  49218. declare module "babylonjs/Gizmos/scaleGizmo" {
  49219. import { Observable } from "babylonjs/Misc/observable";
  49220. import { Nullable } from "babylonjs/types";
  49221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49222. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49223. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  49224. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49225. /**
  49226. * Gizmo that enables scaling a mesh along 3 axis
  49227. */
  49228. export class ScaleGizmo extends Gizmo {
  49229. /**
  49230. * Internal gizmo used for interactions on the x axis
  49231. */
  49232. xGizmo: AxisScaleGizmo;
  49233. /**
  49234. * Internal gizmo used for interactions on the y axis
  49235. */
  49236. yGizmo: AxisScaleGizmo;
  49237. /**
  49238. * Internal gizmo used for interactions on the z axis
  49239. */
  49240. zGizmo: AxisScaleGizmo;
  49241. /**
  49242. * Internal gizmo used to scale all axis equally
  49243. */
  49244. uniformScaleGizmo: AxisScaleGizmo;
  49245. private _meshAttached;
  49246. private _updateGizmoRotationToMatchAttachedMesh;
  49247. private _snapDistance;
  49248. private _scaleRatio;
  49249. private _uniformScalingMesh;
  49250. private _octahedron;
  49251. private _sensitivity;
  49252. /** Fires an event when any of it's sub gizmos are dragged */
  49253. onDragStartObservable: Observable<unknown>;
  49254. /** Fires an event when any of it's sub gizmos are released from dragging */
  49255. onDragEndObservable: Observable<unknown>;
  49256. get attachedMesh(): Nullable<AbstractMesh>;
  49257. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49258. /**
  49259. * Creates a ScaleGizmo
  49260. * @param gizmoLayer The utility layer the gizmo will be added to
  49261. */
  49262. constructor(gizmoLayer?: UtilityLayerRenderer);
  49263. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49264. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49265. /**
  49266. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49267. */
  49268. set snapDistance(value: number);
  49269. get snapDistance(): number;
  49270. /**
  49271. * Ratio for the scale of the gizmo (Default: 1)
  49272. */
  49273. set scaleRatio(value: number);
  49274. get scaleRatio(): number;
  49275. /**
  49276. * Sensitivity factor for dragging (Default: 1)
  49277. */
  49278. set sensitivity(value: number);
  49279. get sensitivity(): number;
  49280. /**
  49281. * Disposes of the gizmo
  49282. */
  49283. dispose(): void;
  49284. }
  49285. }
  49286. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  49287. import { Observable } from "babylonjs/Misc/observable";
  49288. import { Nullable } from "babylonjs/types";
  49289. import { Vector3 } from "babylonjs/Maths/math.vector";
  49290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49291. import { Mesh } from "babylonjs/Meshes/mesh";
  49292. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  49293. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49294. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49295. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  49296. import { Color3 } from "babylonjs/Maths/math.color";
  49297. /**
  49298. * Single axis scale gizmo
  49299. */
  49300. export class AxisScaleGizmo extends Gizmo {
  49301. /**
  49302. * Drag behavior responsible for the gizmos dragging interactions
  49303. */
  49304. dragBehavior: PointerDragBehavior;
  49305. private _pointerObserver;
  49306. /**
  49307. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49308. */
  49309. snapDistance: number;
  49310. /**
  49311. * Event that fires each time the gizmo snaps to a new location.
  49312. * * snapDistance is the the change in distance
  49313. */
  49314. onSnapObservable: Observable<{
  49315. snapDistance: number;
  49316. }>;
  49317. /**
  49318. * If the scaling operation should be done on all axis (default: false)
  49319. */
  49320. uniformScaling: boolean;
  49321. /**
  49322. * Custom sensitivity value for the drag strength
  49323. */
  49324. sensitivity: number;
  49325. private _isEnabled;
  49326. private _parent;
  49327. private _arrow;
  49328. private _coloredMaterial;
  49329. private _hoverMaterial;
  49330. /**
  49331. * Creates an AxisScaleGizmo
  49332. * @param gizmoLayer The utility layer the gizmo will be added to
  49333. * @param dragAxis The axis which the gizmo will be able to scale on
  49334. * @param color The color of the gizmo
  49335. */
  49336. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  49337. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49338. /**
  49339. * If the gizmo is enabled
  49340. */
  49341. set isEnabled(value: boolean);
  49342. get isEnabled(): boolean;
  49343. /**
  49344. * Disposes of the gizmo
  49345. */
  49346. dispose(): void;
  49347. /**
  49348. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49349. * @param mesh The mesh to replace the default mesh of the gizmo
  49350. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  49351. */
  49352. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  49353. }
  49354. }
  49355. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  49356. import { Observable } from "babylonjs/Misc/observable";
  49357. import { Nullable } from "babylonjs/types";
  49358. import { Vector3 } from "babylonjs/Maths/math.vector";
  49359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49360. import { Mesh } from "babylonjs/Meshes/mesh";
  49361. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49362. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49363. import { Color3 } from "babylonjs/Maths/math.color";
  49364. import "babylonjs/Meshes/Builders/boxBuilder";
  49365. /**
  49366. * Bounding box gizmo
  49367. */
  49368. export class BoundingBoxGizmo extends Gizmo {
  49369. private _lineBoundingBox;
  49370. private _rotateSpheresParent;
  49371. private _scaleBoxesParent;
  49372. private _boundingDimensions;
  49373. private _renderObserver;
  49374. private _pointerObserver;
  49375. private _scaleDragSpeed;
  49376. private _tmpQuaternion;
  49377. private _tmpVector;
  49378. private _tmpRotationMatrix;
  49379. /**
  49380. * 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)
  49381. */
  49382. ignoreChildren: boolean;
  49383. /**
  49384. * 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)
  49385. */
  49386. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  49387. /**
  49388. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  49389. */
  49390. rotationSphereSize: number;
  49391. /**
  49392. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  49393. */
  49394. scaleBoxSize: number;
  49395. /**
  49396. * 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)
  49397. */
  49398. fixedDragMeshScreenSize: boolean;
  49399. /**
  49400. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  49401. */
  49402. fixedDragMeshScreenSizeDistanceFactor: number;
  49403. /**
  49404. * Fired when a rotation sphere or scale box is dragged
  49405. */
  49406. onDragStartObservable: Observable<{}>;
  49407. /**
  49408. * Fired when a scale box is dragged
  49409. */
  49410. onScaleBoxDragObservable: Observable<{}>;
  49411. /**
  49412. * Fired when a scale box drag is ended
  49413. */
  49414. onScaleBoxDragEndObservable: Observable<{}>;
  49415. /**
  49416. * Fired when a rotation sphere is dragged
  49417. */
  49418. onRotationSphereDragObservable: Observable<{}>;
  49419. /**
  49420. * Fired when a rotation sphere drag is ended
  49421. */
  49422. onRotationSphereDragEndObservable: Observable<{}>;
  49423. /**
  49424. * 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)
  49425. */
  49426. scalePivot: Nullable<Vector3>;
  49427. /**
  49428. * Mesh used as a pivot to rotate the attached mesh
  49429. */
  49430. private _anchorMesh;
  49431. private _existingMeshScale;
  49432. private _dragMesh;
  49433. private pointerDragBehavior;
  49434. private coloredMaterial;
  49435. private hoverColoredMaterial;
  49436. /**
  49437. * Sets the color of the bounding box gizmo
  49438. * @param color the color to set
  49439. */
  49440. setColor(color: Color3): void;
  49441. /**
  49442. * Creates an BoundingBoxGizmo
  49443. * @param gizmoLayer The utility layer the gizmo will be added to
  49444. * @param color The color of the gizmo
  49445. */
  49446. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  49447. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49448. private _selectNode;
  49449. /**
  49450. * Updates the bounding box information for the Gizmo
  49451. */
  49452. updateBoundingBox(): void;
  49453. private _updateRotationSpheres;
  49454. private _updateScaleBoxes;
  49455. /**
  49456. * Enables rotation on the specified axis and disables rotation on the others
  49457. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  49458. */
  49459. setEnabledRotationAxis(axis: string): void;
  49460. /**
  49461. * Enables/disables scaling
  49462. * @param enable if scaling should be enabled
  49463. */
  49464. setEnabledScaling(enable: boolean): void;
  49465. private _updateDummy;
  49466. /**
  49467. * Enables a pointer drag behavior on the bounding box of the gizmo
  49468. */
  49469. enableDragBehavior(): void;
  49470. /**
  49471. * Disposes of the gizmo
  49472. */
  49473. dispose(): void;
  49474. /**
  49475. * 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)
  49476. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  49477. * @returns the bounding box mesh with the passed in mesh as a child
  49478. */
  49479. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  49480. /**
  49481. * CustomMeshes are not supported by this gizmo
  49482. * @param mesh The mesh to replace the default mesh of the gizmo
  49483. */
  49484. setCustomMesh(mesh: Mesh): void;
  49485. }
  49486. }
  49487. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  49488. import { Observable } from "babylonjs/Misc/observable";
  49489. import { Nullable } from "babylonjs/types";
  49490. import { Vector3 } from "babylonjs/Maths/math.vector";
  49491. import { Color3 } from "babylonjs/Maths/math.color";
  49492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49493. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  49494. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49495. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49496. import "babylonjs/Meshes/Builders/linesBuilder";
  49497. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  49498. /**
  49499. * Single plane rotation gizmo
  49500. */
  49501. export class PlaneRotationGizmo extends Gizmo {
  49502. /**
  49503. * Drag behavior responsible for the gizmos dragging interactions
  49504. */
  49505. dragBehavior: PointerDragBehavior;
  49506. private _pointerObserver;
  49507. /**
  49508. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  49509. */
  49510. snapDistance: number;
  49511. /**
  49512. * Event that fires each time the gizmo snaps to a new location.
  49513. * * snapDistance is the the change in distance
  49514. */
  49515. onSnapObservable: Observable<{
  49516. snapDistance: number;
  49517. }>;
  49518. private _isEnabled;
  49519. private _parent;
  49520. /**
  49521. * Creates a PlaneRotationGizmo
  49522. * @param gizmoLayer The utility layer the gizmo will be added to
  49523. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  49524. * @param color The color of the gizmo
  49525. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49526. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49527. */
  49528. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  49529. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49530. /**
  49531. * If the gizmo is enabled
  49532. */
  49533. set isEnabled(value: boolean);
  49534. get isEnabled(): boolean;
  49535. /**
  49536. * Disposes of the gizmo
  49537. */
  49538. dispose(): void;
  49539. }
  49540. }
  49541. declare module "babylonjs/Gizmos/rotationGizmo" {
  49542. import { Observable } from "babylonjs/Misc/observable";
  49543. import { Nullable } from "babylonjs/types";
  49544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49545. import { Mesh } from "babylonjs/Meshes/mesh";
  49546. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49547. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  49548. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49549. /**
  49550. * Gizmo that enables rotating a mesh along 3 axis
  49551. */
  49552. export class RotationGizmo extends Gizmo {
  49553. /**
  49554. * Internal gizmo used for interactions on the x axis
  49555. */
  49556. xGizmo: PlaneRotationGizmo;
  49557. /**
  49558. * Internal gizmo used for interactions on the y axis
  49559. */
  49560. yGizmo: PlaneRotationGizmo;
  49561. /**
  49562. * Internal gizmo used for interactions on the z axis
  49563. */
  49564. zGizmo: PlaneRotationGizmo;
  49565. /** Fires an event when any of it's sub gizmos are dragged */
  49566. onDragStartObservable: Observable<unknown>;
  49567. /** Fires an event when any of it's sub gizmos are released from dragging */
  49568. onDragEndObservable: Observable<unknown>;
  49569. private _meshAttached;
  49570. get attachedMesh(): Nullable<AbstractMesh>;
  49571. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49572. /**
  49573. * Creates a RotationGizmo
  49574. * @param gizmoLayer The utility layer the gizmo will be added to
  49575. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49576. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49577. */
  49578. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49579. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49580. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49581. /**
  49582. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49583. */
  49584. set snapDistance(value: number);
  49585. get snapDistance(): number;
  49586. /**
  49587. * Ratio for the scale of the gizmo (Default: 1)
  49588. */
  49589. set scaleRatio(value: number);
  49590. get scaleRatio(): number;
  49591. /**
  49592. * Disposes of the gizmo
  49593. */
  49594. dispose(): void;
  49595. /**
  49596. * CustomMeshes are not supported by this gizmo
  49597. * @param mesh The mesh to replace the default mesh of the gizmo
  49598. */
  49599. setCustomMesh(mesh: Mesh): void;
  49600. }
  49601. }
  49602. declare module "babylonjs/Gizmos/gizmoManager" {
  49603. import { Observable } from "babylonjs/Misc/observable";
  49604. import { Nullable } from "babylonjs/types";
  49605. import { Scene, IDisposable } from "babylonjs/scene";
  49606. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49607. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49608. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  49609. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  49610. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  49611. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  49612. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  49613. /**
  49614. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49615. */
  49616. export class GizmoManager implements IDisposable {
  49617. private scene;
  49618. /**
  49619. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49620. */
  49621. gizmos: {
  49622. positionGizmo: Nullable<PositionGizmo>;
  49623. rotationGizmo: Nullable<RotationGizmo>;
  49624. scaleGizmo: Nullable<ScaleGizmo>;
  49625. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49626. };
  49627. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49628. clearGizmoOnEmptyPointerEvent: boolean;
  49629. /** Fires an event when the manager is attached to a mesh */
  49630. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49631. private _gizmosEnabled;
  49632. private _pointerObserver;
  49633. private _attachedMesh;
  49634. private _boundingBoxColor;
  49635. private _defaultUtilityLayer;
  49636. private _defaultKeepDepthUtilityLayer;
  49637. /**
  49638. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49639. */
  49640. boundingBoxDragBehavior: SixDofDragBehavior;
  49641. /**
  49642. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49643. */
  49644. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49645. /**
  49646. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49647. */
  49648. usePointerToAttachGizmos: boolean;
  49649. /**
  49650. * Utility layer that the bounding box gizmo belongs to
  49651. */
  49652. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49653. /**
  49654. * Utility layer that all gizmos besides bounding box belong to
  49655. */
  49656. get utilityLayer(): UtilityLayerRenderer;
  49657. /**
  49658. * Instatiates a gizmo manager
  49659. * @param scene the scene to overlay the gizmos on top of
  49660. */
  49661. constructor(scene: Scene);
  49662. /**
  49663. * Attaches a set of gizmos to the specified mesh
  49664. * @param mesh The mesh the gizmo's should be attached to
  49665. */
  49666. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49667. /**
  49668. * If the position gizmo is enabled
  49669. */
  49670. set positionGizmoEnabled(value: boolean);
  49671. get positionGizmoEnabled(): boolean;
  49672. /**
  49673. * If the rotation gizmo is enabled
  49674. */
  49675. set rotationGizmoEnabled(value: boolean);
  49676. get rotationGizmoEnabled(): boolean;
  49677. /**
  49678. * If the scale gizmo is enabled
  49679. */
  49680. set scaleGizmoEnabled(value: boolean);
  49681. get scaleGizmoEnabled(): boolean;
  49682. /**
  49683. * If the boundingBox gizmo is enabled
  49684. */
  49685. set boundingBoxGizmoEnabled(value: boolean);
  49686. get boundingBoxGizmoEnabled(): boolean;
  49687. /**
  49688. * Disposes of the gizmo manager
  49689. */
  49690. dispose(): void;
  49691. }
  49692. }
  49693. declare module "babylonjs/Lights/directionalLight" {
  49694. import { Camera } from "babylonjs/Cameras/camera";
  49695. import { Scene } from "babylonjs/scene";
  49696. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  49697. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49698. import { Light } from "babylonjs/Lights/light";
  49699. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49700. import { Effect } from "babylonjs/Materials/effect";
  49701. /**
  49702. * A directional light is defined by a direction (what a surprise!).
  49703. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49704. * 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.
  49705. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49706. */
  49707. export class DirectionalLight extends ShadowLight {
  49708. private _shadowFrustumSize;
  49709. /**
  49710. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49711. */
  49712. get shadowFrustumSize(): number;
  49713. /**
  49714. * Specifies a fix frustum size for the shadow generation.
  49715. */
  49716. set shadowFrustumSize(value: number);
  49717. private _shadowOrthoScale;
  49718. /**
  49719. * Gets the shadow projection scale against the optimal computed one.
  49720. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49721. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49722. */
  49723. get shadowOrthoScale(): number;
  49724. /**
  49725. * Sets the shadow projection scale against the optimal computed one.
  49726. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49727. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49728. */
  49729. set shadowOrthoScale(value: number);
  49730. /**
  49731. * Automatically compute the projection matrix to best fit (including all the casters)
  49732. * on each frame.
  49733. */
  49734. autoUpdateExtends: boolean;
  49735. private _orthoLeft;
  49736. private _orthoRight;
  49737. private _orthoTop;
  49738. private _orthoBottom;
  49739. /**
  49740. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49741. * The directional light is emitted from everywhere in the given direction.
  49742. * It can cast shadows.
  49743. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49744. * @param name The friendly name of the light
  49745. * @param direction The direction of the light
  49746. * @param scene The scene the light belongs to
  49747. */
  49748. constructor(name: string, direction: Vector3, scene: Scene);
  49749. /**
  49750. * Returns the string "DirectionalLight".
  49751. * @return The class name
  49752. */
  49753. getClassName(): string;
  49754. /**
  49755. * Returns the integer 1.
  49756. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49757. */
  49758. getTypeID(): number;
  49759. /**
  49760. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49761. * Returns the DirectionalLight Shadow projection matrix.
  49762. */
  49763. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49764. /**
  49765. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49766. * Returns the DirectionalLight Shadow projection matrix.
  49767. */
  49768. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49769. /**
  49770. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49771. * Returns the DirectionalLight Shadow projection matrix.
  49772. */
  49773. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49774. protected _buildUniformLayout(): void;
  49775. /**
  49776. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49777. * @param effect The effect to update
  49778. * @param lightIndex The index of the light in the effect to update
  49779. * @returns The directional light
  49780. */
  49781. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49782. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49783. /**
  49784. * Gets the minZ used for shadow according to both the scene and the light.
  49785. *
  49786. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49787. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49788. * @param activeCamera The camera we are returning the min for
  49789. * @returns the depth min z
  49790. */
  49791. getDepthMinZ(activeCamera: Camera): number;
  49792. /**
  49793. * Gets the maxZ used for shadow according to both the scene and the light.
  49794. *
  49795. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49796. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49797. * @param activeCamera The camera we are returning the max for
  49798. * @returns the depth max z
  49799. */
  49800. getDepthMaxZ(activeCamera: Camera): number;
  49801. /**
  49802. * Prepares the list of defines specific to the light type.
  49803. * @param defines the list of defines
  49804. * @param lightIndex defines the index of the light for the effect
  49805. */
  49806. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49807. }
  49808. }
  49809. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  49810. import { Mesh } from "babylonjs/Meshes/mesh";
  49811. /**
  49812. * Class containing static functions to help procedurally build meshes
  49813. */
  49814. export class HemisphereBuilder {
  49815. /**
  49816. * Creates a hemisphere mesh
  49817. * @param name defines the name of the mesh
  49818. * @param options defines the options used to create the mesh
  49819. * @param scene defines the hosting scene
  49820. * @returns the hemisphere mesh
  49821. */
  49822. static CreateHemisphere(name: string, options: {
  49823. segments?: number;
  49824. diameter?: number;
  49825. sideOrientation?: number;
  49826. }, scene: any): Mesh;
  49827. }
  49828. }
  49829. declare module "babylonjs/Lights/spotLight" {
  49830. import { Nullable } from "babylonjs/types";
  49831. import { Scene } from "babylonjs/scene";
  49832. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  49833. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49834. import { Effect } from "babylonjs/Materials/effect";
  49835. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49836. import { Light } from "babylonjs/Lights/light";
  49837. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49838. /**
  49839. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49840. * These values define a cone of light starting from the position, emitting toward the direction.
  49841. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49842. * and the exponent defines the speed of the decay of the light with distance (reach).
  49843. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49844. */
  49845. export class SpotLight extends ShadowLight {
  49846. private _angle;
  49847. private _innerAngle;
  49848. private _cosHalfAngle;
  49849. private _lightAngleScale;
  49850. private _lightAngleOffset;
  49851. /**
  49852. * Gets the cone angle of the spot light in Radians.
  49853. */
  49854. get angle(): number;
  49855. /**
  49856. * Sets the cone angle of the spot light in Radians.
  49857. */
  49858. set angle(value: number);
  49859. /**
  49860. * Only used in gltf falloff mode, this defines the angle where
  49861. * the directional falloff will start before cutting at angle which could be seen
  49862. * as outer angle.
  49863. */
  49864. get innerAngle(): number;
  49865. /**
  49866. * Only used in gltf falloff mode, this defines the angle where
  49867. * the directional falloff will start before cutting at angle which could be seen
  49868. * as outer angle.
  49869. */
  49870. set innerAngle(value: number);
  49871. private _shadowAngleScale;
  49872. /**
  49873. * Allows scaling the angle of the light for shadow generation only.
  49874. */
  49875. get shadowAngleScale(): number;
  49876. /**
  49877. * Allows scaling the angle of the light for shadow generation only.
  49878. */
  49879. set shadowAngleScale(value: number);
  49880. /**
  49881. * The light decay speed with the distance from the emission spot.
  49882. */
  49883. exponent: number;
  49884. private _projectionTextureMatrix;
  49885. /**
  49886. * Allows reading the projecton texture
  49887. */
  49888. get projectionTextureMatrix(): Matrix;
  49889. protected _projectionTextureLightNear: number;
  49890. /**
  49891. * Gets the near clip of the Spotlight for texture projection.
  49892. */
  49893. get projectionTextureLightNear(): number;
  49894. /**
  49895. * Sets the near clip of the Spotlight for texture projection.
  49896. */
  49897. set projectionTextureLightNear(value: number);
  49898. protected _projectionTextureLightFar: number;
  49899. /**
  49900. * Gets the far clip of the Spotlight for texture projection.
  49901. */
  49902. get projectionTextureLightFar(): number;
  49903. /**
  49904. * Sets the far clip of the Spotlight for texture projection.
  49905. */
  49906. set projectionTextureLightFar(value: number);
  49907. protected _projectionTextureUpDirection: Vector3;
  49908. /**
  49909. * Gets the Up vector of the Spotlight for texture projection.
  49910. */
  49911. get projectionTextureUpDirection(): Vector3;
  49912. /**
  49913. * Sets the Up vector of the Spotlight for texture projection.
  49914. */
  49915. set projectionTextureUpDirection(value: Vector3);
  49916. private _projectionTexture;
  49917. /**
  49918. * Gets the projection texture of the light.
  49919. */
  49920. get projectionTexture(): Nullable<BaseTexture>;
  49921. /**
  49922. * Sets the projection texture of the light.
  49923. */
  49924. set projectionTexture(value: Nullable<BaseTexture>);
  49925. private _projectionTextureViewLightDirty;
  49926. private _projectionTextureProjectionLightDirty;
  49927. private _projectionTextureDirty;
  49928. private _projectionTextureViewTargetVector;
  49929. private _projectionTextureViewLightMatrix;
  49930. private _projectionTextureProjectionLightMatrix;
  49931. private _projectionTextureScalingMatrix;
  49932. /**
  49933. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49934. * It can cast shadows.
  49935. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49936. * @param name The light friendly name
  49937. * @param position The position of the spot light in the scene
  49938. * @param direction The direction of the light in the scene
  49939. * @param angle The cone angle of the light in Radians
  49940. * @param exponent The light decay speed with the distance from the emission spot
  49941. * @param scene The scene the lights belongs to
  49942. */
  49943. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49944. /**
  49945. * Returns the string "SpotLight".
  49946. * @returns the class name
  49947. */
  49948. getClassName(): string;
  49949. /**
  49950. * Returns the integer 2.
  49951. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49952. */
  49953. getTypeID(): number;
  49954. /**
  49955. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49956. */
  49957. protected _setDirection(value: Vector3): void;
  49958. /**
  49959. * Overrides the position setter to recompute the projection texture view light Matrix.
  49960. */
  49961. protected _setPosition(value: Vector3): void;
  49962. /**
  49963. * 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.
  49964. * Returns the SpotLight.
  49965. */
  49966. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49967. protected _computeProjectionTextureViewLightMatrix(): void;
  49968. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49969. /**
  49970. * Main function for light texture projection matrix computing.
  49971. */
  49972. protected _computeProjectionTextureMatrix(): void;
  49973. protected _buildUniformLayout(): void;
  49974. private _computeAngleValues;
  49975. /**
  49976. * Sets the passed Effect "effect" with the Light textures.
  49977. * @param effect The effect to update
  49978. * @param lightIndex The index of the light in the effect to update
  49979. * @returns The light
  49980. */
  49981. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49982. /**
  49983. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49984. * @param effect The effect to update
  49985. * @param lightIndex The index of the light in the effect to update
  49986. * @returns The spot light
  49987. */
  49988. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49989. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49990. /**
  49991. * Disposes the light and the associated resources.
  49992. */
  49993. dispose(): void;
  49994. /**
  49995. * Prepares the list of defines specific to the light type.
  49996. * @param defines the list of defines
  49997. * @param lightIndex defines the index of the light for the effect
  49998. */
  49999. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50000. }
  50001. }
  50002. declare module "babylonjs/Gizmos/lightGizmo" {
  50003. import { Nullable } from "babylonjs/types";
  50004. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50005. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50006. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  50007. import { Light } from "babylonjs/Lights/light";
  50008. /**
  50009. * Gizmo that enables viewing a light
  50010. */
  50011. export class LightGizmo extends Gizmo {
  50012. private _lightMesh;
  50013. private _material;
  50014. private _cachedPosition;
  50015. private _cachedForward;
  50016. private _attachedMeshParent;
  50017. /**
  50018. * Creates a LightGizmo
  50019. * @param gizmoLayer The utility layer the gizmo will be added to
  50020. */
  50021. constructor(gizmoLayer?: UtilityLayerRenderer);
  50022. private _light;
  50023. /**
  50024. * The light that the gizmo is attached to
  50025. */
  50026. set light(light: Nullable<Light>);
  50027. get light(): Nullable<Light>;
  50028. /**
  50029. * Gets the material used to render the light gizmo
  50030. */
  50031. get material(): StandardMaterial;
  50032. /**
  50033. * @hidden
  50034. * Updates the gizmo to match the attached mesh's position/rotation
  50035. */
  50036. protected _update(): void;
  50037. private static _Scale;
  50038. /**
  50039. * Creates the lines for a light mesh
  50040. */
  50041. private static _CreateLightLines;
  50042. /**
  50043. * Disposes of the light gizmo
  50044. */
  50045. dispose(): void;
  50046. private static _CreateHemisphericLightMesh;
  50047. private static _CreatePointLightMesh;
  50048. private static _CreateSpotLightMesh;
  50049. private static _CreateDirectionalLightMesh;
  50050. }
  50051. }
  50052. declare module "babylonjs/Gizmos/index" {
  50053. export * from "babylonjs/Gizmos/axisDragGizmo";
  50054. export * from "babylonjs/Gizmos/axisScaleGizmo";
  50055. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  50056. export * from "babylonjs/Gizmos/gizmo";
  50057. export * from "babylonjs/Gizmos/gizmoManager";
  50058. export * from "babylonjs/Gizmos/planeRotationGizmo";
  50059. export * from "babylonjs/Gizmos/positionGizmo";
  50060. export * from "babylonjs/Gizmos/rotationGizmo";
  50061. export * from "babylonjs/Gizmos/scaleGizmo";
  50062. export * from "babylonjs/Gizmos/lightGizmo";
  50063. export * from "babylonjs/Gizmos/planeDragGizmo";
  50064. }
  50065. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  50066. /** @hidden */
  50067. export var backgroundFragmentDeclaration: {
  50068. name: string;
  50069. shader: string;
  50070. };
  50071. }
  50072. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  50073. /** @hidden */
  50074. export var backgroundUboDeclaration: {
  50075. name: string;
  50076. shader: string;
  50077. };
  50078. }
  50079. declare module "babylonjs/Shaders/background.fragment" {
  50080. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  50081. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  50082. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  50083. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50084. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50085. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50086. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50087. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  50088. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  50089. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50090. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  50091. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  50092. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50093. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  50094. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  50095. /** @hidden */
  50096. export var backgroundPixelShader: {
  50097. name: string;
  50098. shader: string;
  50099. };
  50100. }
  50101. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  50102. /** @hidden */
  50103. export var backgroundVertexDeclaration: {
  50104. name: string;
  50105. shader: string;
  50106. };
  50107. }
  50108. declare module "babylonjs/Shaders/background.vertex" {
  50109. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  50110. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  50111. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50112. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50113. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50114. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50115. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50116. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50117. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50118. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50119. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50120. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50121. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50122. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50123. /** @hidden */
  50124. export var backgroundVertexShader: {
  50125. name: string;
  50126. shader: string;
  50127. };
  50128. }
  50129. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  50130. import { Nullable, int, float } from "babylonjs/types";
  50131. import { Scene } from "babylonjs/scene";
  50132. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50133. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50134. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50135. import { Mesh } from "babylonjs/Meshes/mesh";
  50136. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  50137. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50138. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50139. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50140. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  50141. import { Color3 } from "babylonjs/Maths/math.color";
  50142. import "babylonjs/Shaders/background.fragment";
  50143. import "babylonjs/Shaders/background.vertex";
  50144. /**
  50145. * Background material used to create an efficient environement around your scene.
  50146. */
  50147. export class BackgroundMaterial extends PushMaterial {
  50148. /**
  50149. * Standard reflectance value at parallel view angle.
  50150. */
  50151. static StandardReflectance0: number;
  50152. /**
  50153. * Standard reflectance value at grazing angle.
  50154. */
  50155. static StandardReflectance90: number;
  50156. protected _primaryColor: Color3;
  50157. /**
  50158. * Key light Color (multiply against the environement texture)
  50159. */
  50160. primaryColor: Color3;
  50161. protected __perceptualColor: Nullable<Color3>;
  50162. /**
  50163. * Experimental Internal Use Only.
  50164. *
  50165. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  50166. * This acts as a helper to set the primary color to a more "human friendly" value.
  50167. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  50168. * output color as close as possible from the chosen value.
  50169. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  50170. * part of lighting setup.)
  50171. */
  50172. get _perceptualColor(): Nullable<Color3>;
  50173. set _perceptualColor(value: Nullable<Color3>);
  50174. protected _primaryColorShadowLevel: float;
  50175. /**
  50176. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  50177. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  50178. */
  50179. get primaryColorShadowLevel(): float;
  50180. set primaryColorShadowLevel(value: float);
  50181. protected _primaryColorHighlightLevel: float;
  50182. /**
  50183. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  50184. * The primary color is used at the level chosen to define what the white area would look.
  50185. */
  50186. get primaryColorHighlightLevel(): float;
  50187. set primaryColorHighlightLevel(value: float);
  50188. protected _reflectionTexture: Nullable<BaseTexture>;
  50189. /**
  50190. * Reflection Texture used in the material.
  50191. * Should be author in a specific way for the best result (refer to the documentation).
  50192. */
  50193. reflectionTexture: Nullable<BaseTexture>;
  50194. protected _reflectionBlur: float;
  50195. /**
  50196. * Reflection Texture level of blur.
  50197. *
  50198. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  50199. * texture twice.
  50200. */
  50201. reflectionBlur: float;
  50202. protected _diffuseTexture: Nullable<BaseTexture>;
  50203. /**
  50204. * Diffuse Texture used in the material.
  50205. * Should be author in a specific way for the best result (refer to the documentation).
  50206. */
  50207. diffuseTexture: Nullable<BaseTexture>;
  50208. protected _shadowLights: Nullable<IShadowLight[]>;
  50209. /**
  50210. * Specify the list of lights casting shadow on the material.
  50211. * All scene shadow lights will be included if null.
  50212. */
  50213. shadowLights: Nullable<IShadowLight[]>;
  50214. protected _shadowLevel: float;
  50215. /**
  50216. * Helps adjusting the shadow to a softer level if required.
  50217. * 0 means black shadows and 1 means no shadows.
  50218. */
  50219. shadowLevel: float;
  50220. protected _sceneCenter: Vector3;
  50221. /**
  50222. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  50223. * It is usually zero but might be interesting to modify according to your setup.
  50224. */
  50225. sceneCenter: Vector3;
  50226. protected _opacityFresnel: boolean;
  50227. /**
  50228. * This helps specifying that the material is falling off to the sky box at grazing angle.
  50229. * This helps ensuring a nice transition when the camera goes under the ground.
  50230. */
  50231. opacityFresnel: boolean;
  50232. protected _reflectionFresnel: boolean;
  50233. /**
  50234. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  50235. * This helps adding a mirror texture on the ground.
  50236. */
  50237. reflectionFresnel: boolean;
  50238. protected _reflectionFalloffDistance: number;
  50239. /**
  50240. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  50241. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  50242. */
  50243. reflectionFalloffDistance: number;
  50244. protected _reflectionAmount: number;
  50245. /**
  50246. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  50247. */
  50248. reflectionAmount: number;
  50249. protected _reflectionReflectance0: number;
  50250. /**
  50251. * This specifies the weight of the reflection at grazing angle.
  50252. */
  50253. reflectionReflectance0: number;
  50254. protected _reflectionReflectance90: number;
  50255. /**
  50256. * This specifies the weight of the reflection at a perpendicular point of view.
  50257. */
  50258. reflectionReflectance90: number;
  50259. /**
  50260. * Sets the reflection reflectance fresnel values according to the default standard
  50261. * empirically know to work well :-)
  50262. */
  50263. set reflectionStandardFresnelWeight(value: number);
  50264. protected _useRGBColor: boolean;
  50265. /**
  50266. * Helps to directly use the maps channels instead of their level.
  50267. */
  50268. useRGBColor: boolean;
  50269. protected _enableNoise: boolean;
  50270. /**
  50271. * This helps reducing the banding effect that could occur on the background.
  50272. */
  50273. enableNoise: boolean;
  50274. /**
  50275. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50276. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  50277. * Recommended to be keep at 1.0 except for special cases.
  50278. */
  50279. get fovMultiplier(): number;
  50280. set fovMultiplier(value: number);
  50281. private _fovMultiplier;
  50282. /**
  50283. * Enable the FOV adjustment feature controlled by fovMultiplier.
  50284. */
  50285. useEquirectangularFOV: boolean;
  50286. private _maxSimultaneousLights;
  50287. /**
  50288. * Number of Simultaneous lights allowed on the material.
  50289. */
  50290. maxSimultaneousLights: int;
  50291. /**
  50292. * Default configuration related to image processing available in the Background Material.
  50293. */
  50294. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50295. /**
  50296. * Keep track of the image processing observer to allow dispose and replace.
  50297. */
  50298. private _imageProcessingObserver;
  50299. /**
  50300. * Attaches a new image processing configuration to the PBR Material.
  50301. * @param configuration (if null the scene configuration will be use)
  50302. */
  50303. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50304. /**
  50305. * Gets the image processing configuration used either in this material.
  50306. */
  50307. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  50308. /**
  50309. * Sets the Default image processing configuration used either in the this material.
  50310. *
  50311. * If sets to null, the scene one is in use.
  50312. */
  50313. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  50314. /**
  50315. * Gets wether the color curves effect is enabled.
  50316. */
  50317. get cameraColorCurvesEnabled(): boolean;
  50318. /**
  50319. * Sets wether the color curves effect is enabled.
  50320. */
  50321. set cameraColorCurvesEnabled(value: boolean);
  50322. /**
  50323. * Gets wether the color grading effect is enabled.
  50324. */
  50325. get cameraColorGradingEnabled(): boolean;
  50326. /**
  50327. * Gets wether the color grading effect is enabled.
  50328. */
  50329. set cameraColorGradingEnabled(value: boolean);
  50330. /**
  50331. * Gets wether tonemapping is enabled or not.
  50332. */
  50333. get cameraToneMappingEnabled(): boolean;
  50334. /**
  50335. * Sets wether tonemapping is enabled or not
  50336. */
  50337. set cameraToneMappingEnabled(value: boolean);
  50338. /**
  50339. * The camera exposure used on this material.
  50340. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50341. * This corresponds to a photographic exposure.
  50342. */
  50343. get cameraExposure(): float;
  50344. /**
  50345. * The camera exposure used on this material.
  50346. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50347. * This corresponds to a photographic exposure.
  50348. */
  50349. set cameraExposure(value: float);
  50350. /**
  50351. * Gets The camera contrast used on this material.
  50352. */
  50353. get cameraContrast(): float;
  50354. /**
  50355. * Sets The camera contrast used on this material.
  50356. */
  50357. set cameraContrast(value: float);
  50358. /**
  50359. * Gets the Color Grading 2D Lookup Texture.
  50360. */
  50361. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  50362. /**
  50363. * Sets the Color Grading 2D Lookup Texture.
  50364. */
  50365. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  50366. /**
  50367. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50368. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50369. * 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;
  50370. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50371. */
  50372. get cameraColorCurves(): Nullable<ColorCurves>;
  50373. /**
  50374. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50375. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50376. * 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;
  50377. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50378. */
  50379. set cameraColorCurves(value: Nullable<ColorCurves>);
  50380. /**
  50381. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  50382. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  50383. */
  50384. switchToBGR: boolean;
  50385. private _renderTargets;
  50386. private _reflectionControls;
  50387. private _white;
  50388. private _primaryShadowColor;
  50389. private _primaryHighlightColor;
  50390. /**
  50391. * Instantiates a Background Material in the given scene
  50392. * @param name The friendly name of the material
  50393. * @param scene The scene to add the material to
  50394. */
  50395. constructor(name: string, scene: Scene);
  50396. /**
  50397. * Gets a boolean indicating that current material needs to register RTT
  50398. */
  50399. get hasRenderTargetTextures(): boolean;
  50400. /**
  50401. * The entire material has been created in order to prevent overdraw.
  50402. * @returns false
  50403. */
  50404. needAlphaTesting(): boolean;
  50405. /**
  50406. * The entire material has been created in order to prevent overdraw.
  50407. * @returns true if blending is enable
  50408. */
  50409. needAlphaBlending(): boolean;
  50410. /**
  50411. * Checks wether the material is ready to be rendered for a given mesh.
  50412. * @param mesh The mesh to render
  50413. * @param subMesh The submesh to check against
  50414. * @param useInstances Specify wether or not the material is used with instances
  50415. * @returns true if all the dependencies are ready (Textures, Effects...)
  50416. */
  50417. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50418. /**
  50419. * Compute the primary color according to the chosen perceptual color.
  50420. */
  50421. private _computePrimaryColorFromPerceptualColor;
  50422. /**
  50423. * Compute the highlights and shadow colors according to their chosen levels.
  50424. */
  50425. private _computePrimaryColors;
  50426. /**
  50427. * Build the uniform buffer used in the material.
  50428. */
  50429. buildUniformLayout(): void;
  50430. /**
  50431. * Unbind the material.
  50432. */
  50433. unbind(): void;
  50434. /**
  50435. * Bind only the world matrix to the material.
  50436. * @param world The world matrix to bind.
  50437. */
  50438. bindOnlyWorldMatrix(world: Matrix): void;
  50439. /**
  50440. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  50441. * @param world The world matrix to bind.
  50442. * @param subMesh The submesh to bind for.
  50443. */
  50444. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50445. /**
  50446. * Checks to see if a texture is used in the material.
  50447. * @param texture - Base texture to use.
  50448. * @returns - Boolean specifying if a texture is used in the material.
  50449. */
  50450. hasTexture(texture: BaseTexture): boolean;
  50451. /**
  50452. * Dispose the material.
  50453. * @param forceDisposeEffect Force disposal of the associated effect.
  50454. * @param forceDisposeTextures Force disposal of the associated textures.
  50455. */
  50456. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50457. /**
  50458. * Clones the material.
  50459. * @param name The cloned name.
  50460. * @returns The cloned material.
  50461. */
  50462. clone(name: string): BackgroundMaterial;
  50463. /**
  50464. * Serializes the current material to its JSON representation.
  50465. * @returns The JSON representation.
  50466. */
  50467. serialize(): any;
  50468. /**
  50469. * Gets the class name of the material
  50470. * @returns "BackgroundMaterial"
  50471. */
  50472. getClassName(): string;
  50473. /**
  50474. * Parse a JSON input to create back a background material.
  50475. * @param source The JSON data to parse
  50476. * @param scene The scene to create the parsed material in
  50477. * @param rootUrl The root url of the assets the material depends upon
  50478. * @returns the instantiated BackgroundMaterial.
  50479. */
  50480. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  50481. }
  50482. }
  50483. declare module "babylonjs/Helpers/environmentHelper" {
  50484. import { Observable } from "babylonjs/Misc/observable";
  50485. import { Nullable } from "babylonjs/types";
  50486. import { Scene } from "babylonjs/scene";
  50487. import { Vector3 } from "babylonjs/Maths/math.vector";
  50488. import { Color3 } from "babylonjs/Maths/math.color";
  50489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50490. import { Mesh } from "babylonjs/Meshes/mesh";
  50491. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50492. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  50493. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50494. import "babylonjs/Meshes/Builders/planeBuilder";
  50495. import "babylonjs/Meshes/Builders/boxBuilder";
  50496. /**
  50497. * Represents the different options available during the creation of
  50498. * a Environment helper.
  50499. *
  50500. * This can control the default ground, skybox and image processing setup of your scene.
  50501. */
  50502. export interface IEnvironmentHelperOptions {
  50503. /**
  50504. * Specifies wether or not to create a ground.
  50505. * True by default.
  50506. */
  50507. createGround: boolean;
  50508. /**
  50509. * Specifies the ground size.
  50510. * 15 by default.
  50511. */
  50512. groundSize: number;
  50513. /**
  50514. * The texture used on the ground for the main color.
  50515. * Comes from the BabylonJS CDN by default.
  50516. *
  50517. * Remarks: Can be either a texture or a url.
  50518. */
  50519. groundTexture: string | BaseTexture;
  50520. /**
  50521. * The color mixed in the ground texture by default.
  50522. * BabylonJS clearColor by default.
  50523. */
  50524. groundColor: Color3;
  50525. /**
  50526. * Specifies the ground opacity.
  50527. * 1 by default.
  50528. */
  50529. groundOpacity: number;
  50530. /**
  50531. * Enables the ground to receive shadows.
  50532. * True by default.
  50533. */
  50534. enableGroundShadow: boolean;
  50535. /**
  50536. * Helps preventing the shadow to be fully black on the ground.
  50537. * 0.5 by default.
  50538. */
  50539. groundShadowLevel: number;
  50540. /**
  50541. * Creates a mirror texture attach to the ground.
  50542. * false by default.
  50543. */
  50544. enableGroundMirror: boolean;
  50545. /**
  50546. * Specifies the ground mirror size ratio.
  50547. * 0.3 by default as the default kernel is 64.
  50548. */
  50549. groundMirrorSizeRatio: number;
  50550. /**
  50551. * Specifies the ground mirror blur kernel size.
  50552. * 64 by default.
  50553. */
  50554. groundMirrorBlurKernel: number;
  50555. /**
  50556. * Specifies the ground mirror visibility amount.
  50557. * 1 by default
  50558. */
  50559. groundMirrorAmount: number;
  50560. /**
  50561. * Specifies the ground mirror reflectance weight.
  50562. * This uses the standard weight of the background material to setup the fresnel effect
  50563. * of the mirror.
  50564. * 1 by default.
  50565. */
  50566. groundMirrorFresnelWeight: number;
  50567. /**
  50568. * Specifies the ground mirror Falloff distance.
  50569. * This can helps reducing the size of the reflection.
  50570. * 0 by Default.
  50571. */
  50572. groundMirrorFallOffDistance: number;
  50573. /**
  50574. * Specifies the ground mirror texture type.
  50575. * Unsigned Int by Default.
  50576. */
  50577. groundMirrorTextureType: number;
  50578. /**
  50579. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  50580. * the shown objects.
  50581. */
  50582. groundYBias: number;
  50583. /**
  50584. * Specifies wether or not to create a skybox.
  50585. * True by default.
  50586. */
  50587. createSkybox: boolean;
  50588. /**
  50589. * Specifies the skybox size.
  50590. * 20 by default.
  50591. */
  50592. skyboxSize: number;
  50593. /**
  50594. * The texture used on the skybox for the main color.
  50595. * Comes from the BabylonJS CDN by default.
  50596. *
  50597. * Remarks: Can be either a texture or a url.
  50598. */
  50599. skyboxTexture: string | BaseTexture;
  50600. /**
  50601. * The color mixed in the skybox texture by default.
  50602. * BabylonJS clearColor by default.
  50603. */
  50604. skyboxColor: Color3;
  50605. /**
  50606. * The background rotation around the Y axis of the scene.
  50607. * This helps aligning the key lights of your scene with the background.
  50608. * 0 by default.
  50609. */
  50610. backgroundYRotation: number;
  50611. /**
  50612. * Compute automatically the size of the elements to best fit with the scene.
  50613. */
  50614. sizeAuto: boolean;
  50615. /**
  50616. * Default position of the rootMesh if autoSize is not true.
  50617. */
  50618. rootPosition: Vector3;
  50619. /**
  50620. * Sets up the image processing in the scene.
  50621. * true by default.
  50622. */
  50623. setupImageProcessing: boolean;
  50624. /**
  50625. * The texture used as your environment texture in the scene.
  50626. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  50627. *
  50628. * Remarks: Can be either a texture or a url.
  50629. */
  50630. environmentTexture: string | BaseTexture;
  50631. /**
  50632. * The value of the exposure to apply to the scene.
  50633. * 0.6 by default if setupImageProcessing is true.
  50634. */
  50635. cameraExposure: number;
  50636. /**
  50637. * The value of the contrast to apply to the scene.
  50638. * 1.6 by default if setupImageProcessing is true.
  50639. */
  50640. cameraContrast: number;
  50641. /**
  50642. * Specifies wether or not tonemapping should be enabled in the scene.
  50643. * true by default if setupImageProcessing is true.
  50644. */
  50645. toneMappingEnabled: boolean;
  50646. }
  50647. /**
  50648. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  50649. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  50650. * It also helps with the default setup of your imageProcessing configuration.
  50651. */
  50652. export class EnvironmentHelper {
  50653. /**
  50654. * Default ground texture URL.
  50655. */
  50656. private static _groundTextureCDNUrl;
  50657. /**
  50658. * Default skybox texture URL.
  50659. */
  50660. private static _skyboxTextureCDNUrl;
  50661. /**
  50662. * Default environment texture URL.
  50663. */
  50664. private static _environmentTextureCDNUrl;
  50665. /**
  50666. * Creates the default options for the helper.
  50667. */
  50668. private static _getDefaultOptions;
  50669. private _rootMesh;
  50670. /**
  50671. * Gets the root mesh created by the helper.
  50672. */
  50673. get rootMesh(): Mesh;
  50674. private _skybox;
  50675. /**
  50676. * Gets the skybox created by the helper.
  50677. */
  50678. get skybox(): Nullable<Mesh>;
  50679. private _skyboxTexture;
  50680. /**
  50681. * Gets the skybox texture created by the helper.
  50682. */
  50683. get skyboxTexture(): Nullable<BaseTexture>;
  50684. private _skyboxMaterial;
  50685. /**
  50686. * Gets the skybox material created by the helper.
  50687. */
  50688. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  50689. private _ground;
  50690. /**
  50691. * Gets the ground mesh created by the helper.
  50692. */
  50693. get ground(): Nullable<Mesh>;
  50694. private _groundTexture;
  50695. /**
  50696. * Gets the ground texture created by the helper.
  50697. */
  50698. get groundTexture(): Nullable<BaseTexture>;
  50699. private _groundMirror;
  50700. /**
  50701. * Gets the ground mirror created by the helper.
  50702. */
  50703. get groundMirror(): Nullable<MirrorTexture>;
  50704. /**
  50705. * Gets the ground mirror render list to helps pushing the meshes
  50706. * you wish in the ground reflection.
  50707. */
  50708. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50709. private _groundMaterial;
  50710. /**
  50711. * Gets the ground material created by the helper.
  50712. */
  50713. get groundMaterial(): Nullable<BackgroundMaterial>;
  50714. /**
  50715. * Stores the creation options.
  50716. */
  50717. private readonly _scene;
  50718. private _options;
  50719. /**
  50720. * This observable will be notified with any error during the creation of the environment,
  50721. * mainly texture creation errors.
  50722. */
  50723. onErrorObservable: Observable<{
  50724. message?: string;
  50725. exception?: any;
  50726. }>;
  50727. /**
  50728. * constructor
  50729. * @param options Defines the options we want to customize the helper
  50730. * @param scene The scene to add the material to
  50731. */
  50732. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50733. /**
  50734. * Updates the background according to the new options
  50735. * @param options
  50736. */
  50737. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50738. /**
  50739. * Sets the primary color of all the available elements.
  50740. * @param color the main color to affect to the ground and the background
  50741. */
  50742. setMainColor(color: Color3): void;
  50743. /**
  50744. * Setup the image processing according to the specified options.
  50745. */
  50746. private _setupImageProcessing;
  50747. /**
  50748. * Setup the environment texture according to the specified options.
  50749. */
  50750. private _setupEnvironmentTexture;
  50751. /**
  50752. * Setup the background according to the specified options.
  50753. */
  50754. private _setupBackground;
  50755. /**
  50756. * Get the scene sizes according to the setup.
  50757. */
  50758. private _getSceneSize;
  50759. /**
  50760. * Setup the ground according to the specified options.
  50761. */
  50762. private _setupGround;
  50763. /**
  50764. * Setup the ground material according to the specified options.
  50765. */
  50766. private _setupGroundMaterial;
  50767. /**
  50768. * Setup the ground diffuse texture according to the specified options.
  50769. */
  50770. private _setupGroundDiffuseTexture;
  50771. /**
  50772. * Setup the ground mirror texture according to the specified options.
  50773. */
  50774. private _setupGroundMirrorTexture;
  50775. /**
  50776. * Setup the ground to receive the mirror texture.
  50777. */
  50778. private _setupMirrorInGroundMaterial;
  50779. /**
  50780. * Setup the skybox according to the specified options.
  50781. */
  50782. private _setupSkybox;
  50783. /**
  50784. * Setup the skybox material according to the specified options.
  50785. */
  50786. private _setupSkyboxMaterial;
  50787. /**
  50788. * Setup the skybox reflection texture according to the specified options.
  50789. */
  50790. private _setupSkyboxReflectionTexture;
  50791. private _errorHandler;
  50792. /**
  50793. * Dispose all the elements created by the Helper.
  50794. */
  50795. dispose(): void;
  50796. }
  50797. }
  50798. declare module "babylonjs/Helpers/photoDome" {
  50799. import { Observable } from "babylonjs/Misc/observable";
  50800. import { Nullable } from "babylonjs/types";
  50801. import { Scene } from "babylonjs/scene";
  50802. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50803. import { Mesh } from "babylonjs/Meshes/mesh";
  50804. import { Texture } from "babylonjs/Materials/Textures/texture";
  50805. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50806. import "babylonjs/Meshes/Builders/sphereBuilder";
  50807. /**
  50808. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50809. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50810. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50811. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50812. */
  50813. export class PhotoDome extends TransformNode {
  50814. /**
  50815. * Define the image as a Monoscopic panoramic 360 image.
  50816. */
  50817. static readonly MODE_MONOSCOPIC: number;
  50818. /**
  50819. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50820. */
  50821. static readonly MODE_TOPBOTTOM: number;
  50822. /**
  50823. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50824. */
  50825. static readonly MODE_SIDEBYSIDE: number;
  50826. private _useDirectMapping;
  50827. /**
  50828. * The texture being displayed on the sphere
  50829. */
  50830. protected _photoTexture: Texture;
  50831. /**
  50832. * Gets or sets the texture being displayed on the sphere
  50833. */
  50834. get photoTexture(): Texture;
  50835. set photoTexture(value: Texture);
  50836. /**
  50837. * Observable raised when an error occured while loading the 360 image
  50838. */
  50839. onLoadErrorObservable: Observable<string>;
  50840. /**
  50841. * The skybox material
  50842. */
  50843. protected _material: BackgroundMaterial;
  50844. /**
  50845. * The surface used for the skybox
  50846. */
  50847. protected _mesh: Mesh;
  50848. /**
  50849. * Gets the mesh used for the skybox.
  50850. */
  50851. get mesh(): Mesh;
  50852. /**
  50853. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50854. * Also see the options.resolution property.
  50855. */
  50856. get fovMultiplier(): number;
  50857. set fovMultiplier(value: number);
  50858. private _imageMode;
  50859. /**
  50860. * Gets or set the current video mode for the video. It can be:
  50861. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50862. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50863. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50864. */
  50865. get imageMode(): number;
  50866. set imageMode(value: number);
  50867. /**
  50868. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50869. * @param name Element's name, child elements will append suffixes for their own names.
  50870. * @param urlsOfPhoto defines the url of the photo to display
  50871. * @param options defines an object containing optional or exposed sub element properties
  50872. * @param onError defines a callback called when an error occured while loading the texture
  50873. */
  50874. constructor(name: string, urlOfPhoto: string, options: {
  50875. resolution?: number;
  50876. size?: number;
  50877. useDirectMapping?: boolean;
  50878. faceForward?: boolean;
  50879. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50880. private _onBeforeCameraRenderObserver;
  50881. private _changeImageMode;
  50882. /**
  50883. * Releases resources associated with this node.
  50884. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50885. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50886. */
  50887. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50888. }
  50889. }
  50890. declare module "babylonjs/Misc/rgbdTextureTools" {
  50891. import "babylonjs/Shaders/rgbdDecode.fragment";
  50892. import "babylonjs/Engines/Extensions/engine.renderTarget";
  50893. import { Texture } from "babylonjs/Materials/Textures/texture";
  50894. /**
  50895. * Class used to host RGBD texture specific utilities
  50896. */
  50897. export class RGBDTextureTools {
  50898. /**
  50899. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50900. * @param texture the texture to expand.
  50901. */
  50902. static ExpandRGBDTexture(texture: Texture): void;
  50903. }
  50904. }
  50905. declare module "babylonjs/Misc/brdfTextureTools" {
  50906. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50907. import { Scene } from "babylonjs/scene";
  50908. /**
  50909. * Class used to host texture specific utilities
  50910. */
  50911. export class BRDFTextureTools {
  50912. /**
  50913. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50914. * @param scene defines the hosting scene
  50915. * @returns the environment BRDF texture
  50916. */
  50917. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50918. private static _environmentBRDFBase64Texture;
  50919. }
  50920. }
  50921. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  50922. import { Nullable } from "babylonjs/types";
  50923. import { Color3 } from "babylonjs/Maths/math.color";
  50924. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50925. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  50926. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50927. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  50928. import { Engine } from "babylonjs/Engines/engine";
  50929. import { Scene } from "babylonjs/scene";
  50930. /**
  50931. * @hidden
  50932. */
  50933. export interface IMaterialClearCoatDefines {
  50934. CLEARCOAT: boolean;
  50935. CLEARCOAT_DEFAULTIOR: boolean;
  50936. CLEARCOAT_TEXTURE: boolean;
  50937. CLEARCOAT_TEXTUREDIRECTUV: number;
  50938. CLEARCOAT_BUMP: boolean;
  50939. CLEARCOAT_BUMPDIRECTUV: number;
  50940. CLEARCOAT_TINT: boolean;
  50941. CLEARCOAT_TINT_TEXTURE: boolean;
  50942. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50943. /** @hidden */
  50944. _areTexturesDirty: boolean;
  50945. }
  50946. /**
  50947. * Define the code related to the clear coat parameters of the pbr material.
  50948. */
  50949. export class PBRClearCoatConfiguration {
  50950. /**
  50951. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50952. * The default fits with a polyurethane material.
  50953. */
  50954. private static readonly _DefaultIndexOfRefraction;
  50955. private _isEnabled;
  50956. /**
  50957. * Defines if the clear coat is enabled in the material.
  50958. */
  50959. isEnabled: boolean;
  50960. /**
  50961. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50962. */
  50963. intensity: number;
  50964. /**
  50965. * Defines the clear coat layer roughness.
  50966. */
  50967. roughness: number;
  50968. private _indexOfRefraction;
  50969. /**
  50970. * Defines the index of refraction of the clear coat.
  50971. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50972. * The default fits with a polyurethane material.
  50973. * Changing the default value is more performance intensive.
  50974. */
  50975. indexOfRefraction: number;
  50976. private _texture;
  50977. /**
  50978. * Stores the clear coat values in a texture.
  50979. */
  50980. texture: Nullable<BaseTexture>;
  50981. private _bumpTexture;
  50982. /**
  50983. * Define the clear coat specific bump texture.
  50984. */
  50985. bumpTexture: Nullable<BaseTexture>;
  50986. private _isTintEnabled;
  50987. /**
  50988. * Defines if the clear coat tint is enabled in the material.
  50989. */
  50990. isTintEnabled: boolean;
  50991. /**
  50992. * Defines the clear coat tint of the material.
  50993. * This is only use if tint is enabled
  50994. */
  50995. tintColor: Color3;
  50996. /**
  50997. * Defines the distance at which the tint color should be found in the
  50998. * clear coat media.
  50999. * This is only use if tint is enabled
  51000. */
  51001. tintColorAtDistance: number;
  51002. /**
  51003. * Defines the clear coat layer thickness.
  51004. * This is only use if tint is enabled
  51005. */
  51006. tintThickness: number;
  51007. private _tintTexture;
  51008. /**
  51009. * Stores the clear tint values in a texture.
  51010. * rgb is tint
  51011. * a is a thickness factor
  51012. */
  51013. tintTexture: Nullable<BaseTexture>;
  51014. /** @hidden */
  51015. private _internalMarkAllSubMeshesAsTexturesDirty;
  51016. /** @hidden */
  51017. _markAllSubMeshesAsTexturesDirty(): void;
  51018. /**
  51019. * Instantiate a new istance of clear coat configuration.
  51020. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51021. */
  51022. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51023. /**
  51024. * Gets wehter the submesh is ready to be used or not.
  51025. * @param defines the list of "defines" to update.
  51026. * @param scene defines the scene the material belongs to.
  51027. * @param engine defines the engine the material belongs to.
  51028. * @param disableBumpMap defines wether the material disables bump or not.
  51029. * @returns - boolean indicating that the submesh is ready or not.
  51030. */
  51031. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  51032. /**
  51033. * Checks to see if a texture is used in the material.
  51034. * @param defines the list of "defines" to update.
  51035. * @param scene defines the scene to the material belongs to.
  51036. */
  51037. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  51038. /**
  51039. * Binds the material data.
  51040. * @param uniformBuffer defines the Uniform buffer to fill in.
  51041. * @param scene defines the scene the material belongs to.
  51042. * @param engine defines the engine the material belongs to.
  51043. * @param disableBumpMap defines wether the material disables bump or not.
  51044. * @param isFrozen defines wether the material is frozen or not.
  51045. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51046. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51047. */
  51048. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  51049. /**
  51050. * Checks to see if a texture is used in the material.
  51051. * @param texture - Base texture to use.
  51052. * @returns - Boolean specifying if a texture is used in the material.
  51053. */
  51054. hasTexture(texture: BaseTexture): boolean;
  51055. /**
  51056. * Returns an array of the actively used textures.
  51057. * @param activeTextures Array of BaseTextures
  51058. */
  51059. getActiveTextures(activeTextures: BaseTexture[]): void;
  51060. /**
  51061. * Returns the animatable textures.
  51062. * @param animatables Array of animatable textures.
  51063. */
  51064. getAnimatables(animatables: IAnimatable[]): void;
  51065. /**
  51066. * Disposes the resources of the material.
  51067. * @param forceDisposeTextures - Forces the disposal of all textures.
  51068. */
  51069. dispose(forceDisposeTextures?: boolean): void;
  51070. /**
  51071. * Get the current class name of the texture useful for serialization or dynamic coding.
  51072. * @returns "PBRClearCoatConfiguration"
  51073. */
  51074. getClassName(): string;
  51075. /**
  51076. * Add fallbacks to the effect fallbacks list.
  51077. * @param defines defines the Base texture to use.
  51078. * @param fallbacks defines the current fallback list.
  51079. * @param currentRank defines the current fallback rank.
  51080. * @returns the new fallback rank.
  51081. */
  51082. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51083. /**
  51084. * Add the required uniforms to the current list.
  51085. * @param uniforms defines the current uniform list.
  51086. */
  51087. static AddUniforms(uniforms: string[]): void;
  51088. /**
  51089. * Add the required samplers to the current list.
  51090. * @param samplers defines the current sampler list.
  51091. */
  51092. static AddSamplers(samplers: string[]): void;
  51093. /**
  51094. * Add the required uniforms to the current buffer.
  51095. * @param uniformBuffer defines the current uniform buffer.
  51096. */
  51097. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51098. /**
  51099. * Makes a duplicate of the current configuration into another one.
  51100. * @param clearCoatConfiguration define the config where to copy the info
  51101. */
  51102. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  51103. /**
  51104. * Serializes this clear coat configuration.
  51105. * @returns - An object with the serialized config.
  51106. */
  51107. serialize(): any;
  51108. /**
  51109. * Parses a anisotropy Configuration from a serialized object.
  51110. * @param source - Serialized object.
  51111. * @param scene Defines the scene we are parsing for
  51112. * @param rootUrl Defines the rootUrl to load from
  51113. */
  51114. parse(source: any, scene: Scene, rootUrl: string): void;
  51115. }
  51116. }
  51117. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  51118. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51120. import { Vector2 } from "babylonjs/Maths/math.vector";
  51121. import { Scene } from "babylonjs/scene";
  51122. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51123. import { Nullable } from "babylonjs/types";
  51124. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51125. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51126. /**
  51127. * @hidden
  51128. */
  51129. export interface IMaterialAnisotropicDefines {
  51130. ANISOTROPIC: boolean;
  51131. ANISOTROPIC_TEXTURE: boolean;
  51132. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51133. MAINUV1: boolean;
  51134. _areTexturesDirty: boolean;
  51135. _needUVs: boolean;
  51136. }
  51137. /**
  51138. * Define the code related to the anisotropic parameters of the pbr material.
  51139. */
  51140. export class PBRAnisotropicConfiguration {
  51141. private _isEnabled;
  51142. /**
  51143. * Defines if the anisotropy is enabled in the material.
  51144. */
  51145. isEnabled: boolean;
  51146. /**
  51147. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  51148. */
  51149. intensity: number;
  51150. /**
  51151. * Defines if the effect is along the tangents, bitangents or in between.
  51152. * By default, the effect is "strectching" the highlights along the tangents.
  51153. */
  51154. direction: Vector2;
  51155. private _texture;
  51156. /**
  51157. * Stores the anisotropy values in a texture.
  51158. * rg is direction (like normal from -1 to 1)
  51159. * b is a intensity
  51160. */
  51161. texture: Nullable<BaseTexture>;
  51162. /** @hidden */
  51163. private _internalMarkAllSubMeshesAsTexturesDirty;
  51164. /** @hidden */
  51165. _markAllSubMeshesAsTexturesDirty(): void;
  51166. /**
  51167. * Instantiate a new istance of anisotropy configuration.
  51168. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51169. */
  51170. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51171. /**
  51172. * Specifies that the submesh is ready to be used.
  51173. * @param defines the list of "defines" to update.
  51174. * @param scene defines the scene the material belongs to.
  51175. * @returns - boolean indicating that the submesh is ready or not.
  51176. */
  51177. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  51178. /**
  51179. * Checks to see if a texture is used in the material.
  51180. * @param defines the list of "defines" to update.
  51181. * @param mesh the mesh we are preparing the defines for.
  51182. * @param scene defines the scene the material belongs to.
  51183. */
  51184. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  51185. /**
  51186. * Binds the material data.
  51187. * @param uniformBuffer defines the Uniform buffer to fill in.
  51188. * @param scene defines the scene the material belongs to.
  51189. * @param isFrozen defines wether the material is frozen or not.
  51190. */
  51191. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  51192. /**
  51193. * Checks to see if a texture is used in the material.
  51194. * @param texture - Base texture to use.
  51195. * @returns - Boolean specifying if a texture is used in the material.
  51196. */
  51197. hasTexture(texture: BaseTexture): boolean;
  51198. /**
  51199. * Returns an array of the actively used textures.
  51200. * @param activeTextures Array of BaseTextures
  51201. */
  51202. getActiveTextures(activeTextures: BaseTexture[]): void;
  51203. /**
  51204. * Returns the animatable textures.
  51205. * @param animatables Array of animatable textures.
  51206. */
  51207. getAnimatables(animatables: IAnimatable[]): void;
  51208. /**
  51209. * Disposes the resources of the material.
  51210. * @param forceDisposeTextures - Forces the disposal of all textures.
  51211. */
  51212. dispose(forceDisposeTextures?: boolean): void;
  51213. /**
  51214. * Get the current class name of the texture useful for serialization or dynamic coding.
  51215. * @returns "PBRAnisotropicConfiguration"
  51216. */
  51217. getClassName(): string;
  51218. /**
  51219. * Add fallbacks to the effect fallbacks list.
  51220. * @param defines defines the Base texture to use.
  51221. * @param fallbacks defines the current fallback list.
  51222. * @param currentRank defines the current fallback rank.
  51223. * @returns the new fallback rank.
  51224. */
  51225. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51226. /**
  51227. * Add the required uniforms to the current list.
  51228. * @param uniforms defines the current uniform list.
  51229. */
  51230. static AddUniforms(uniforms: string[]): void;
  51231. /**
  51232. * Add the required uniforms to the current buffer.
  51233. * @param uniformBuffer defines the current uniform buffer.
  51234. */
  51235. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51236. /**
  51237. * Add the required samplers to the current list.
  51238. * @param samplers defines the current sampler list.
  51239. */
  51240. static AddSamplers(samplers: string[]): void;
  51241. /**
  51242. * Makes a duplicate of the current configuration into another one.
  51243. * @param anisotropicConfiguration define the config where to copy the info
  51244. */
  51245. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  51246. /**
  51247. * Serializes this anisotropy configuration.
  51248. * @returns - An object with the serialized config.
  51249. */
  51250. serialize(): any;
  51251. /**
  51252. * Parses a anisotropy Configuration from a serialized object.
  51253. * @param source - Serialized object.
  51254. * @param scene Defines the scene we are parsing for
  51255. * @param rootUrl Defines the rootUrl to load from
  51256. */
  51257. parse(source: any, scene: Scene, rootUrl: string): void;
  51258. }
  51259. }
  51260. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  51261. import { Scene } from "babylonjs/scene";
  51262. /**
  51263. * @hidden
  51264. */
  51265. export interface IMaterialBRDFDefines {
  51266. BRDF_V_HEIGHT_CORRELATED: boolean;
  51267. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51268. SPHERICAL_HARMONICS: boolean;
  51269. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51270. /** @hidden */
  51271. _areMiscDirty: boolean;
  51272. }
  51273. /**
  51274. * Define the code related to the BRDF parameters of the pbr material.
  51275. */
  51276. export class PBRBRDFConfiguration {
  51277. /**
  51278. * Default value used for the energy conservation.
  51279. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  51280. */
  51281. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  51282. /**
  51283. * Default value used for the Smith Visibility Height Correlated mode.
  51284. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  51285. */
  51286. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  51287. /**
  51288. * Default value used for the IBL diffuse part.
  51289. * This can help switching back to the polynomials mode globally which is a tiny bit
  51290. * less GPU intensive at the drawback of a lower quality.
  51291. */
  51292. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  51293. /**
  51294. * Default value used for activating energy conservation for the specular workflow.
  51295. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  51296. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  51297. */
  51298. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  51299. private _useEnergyConservation;
  51300. /**
  51301. * Defines if the material uses energy conservation.
  51302. */
  51303. useEnergyConservation: boolean;
  51304. private _useSmithVisibilityHeightCorrelated;
  51305. /**
  51306. * LEGACY Mode set to false
  51307. * Defines if the material uses height smith correlated visibility term.
  51308. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  51309. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  51310. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  51311. * Not relying on height correlated will also disable energy conservation.
  51312. */
  51313. useSmithVisibilityHeightCorrelated: boolean;
  51314. private _useSphericalHarmonics;
  51315. /**
  51316. * LEGACY Mode set to false
  51317. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  51318. * diffuse part of the IBL.
  51319. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  51320. * to the ground truth.
  51321. */
  51322. useSphericalHarmonics: boolean;
  51323. private _useSpecularGlossinessInputEnergyConservation;
  51324. /**
  51325. * Defines if the material uses energy conservation, when the specular workflow is active.
  51326. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  51327. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  51328. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  51329. */
  51330. useSpecularGlossinessInputEnergyConservation: boolean;
  51331. /** @hidden */
  51332. private _internalMarkAllSubMeshesAsMiscDirty;
  51333. /** @hidden */
  51334. _markAllSubMeshesAsMiscDirty(): void;
  51335. /**
  51336. * Instantiate a new istance of clear coat configuration.
  51337. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  51338. */
  51339. constructor(markAllSubMeshesAsMiscDirty: () => void);
  51340. /**
  51341. * Checks to see if a texture is used in the material.
  51342. * @param defines the list of "defines" to update.
  51343. */
  51344. prepareDefines(defines: IMaterialBRDFDefines): void;
  51345. /**
  51346. * Get the current class name of the texture useful for serialization or dynamic coding.
  51347. * @returns "PBRClearCoatConfiguration"
  51348. */
  51349. getClassName(): string;
  51350. /**
  51351. * Makes a duplicate of the current configuration into another one.
  51352. * @param brdfConfiguration define the config where to copy the info
  51353. */
  51354. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  51355. /**
  51356. * Serializes this BRDF configuration.
  51357. * @returns - An object with the serialized config.
  51358. */
  51359. serialize(): any;
  51360. /**
  51361. * Parses a anisotropy Configuration from a serialized object.
  51362. * @param source - Serialized object.
  51363. * @param scene Defines the scene we are parsing for
  51364. * @param rootUrl Defines the rootUrl to load from
  51365. */
  51366. parse(source: any, scene: Scene, rootUrl: string): void;
  51367. }
  51368. }
  51369. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  51370. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51371. import { Color3 } from "babylonjs/Maths/math.color";
  51372. import { Scene } from "babylonjs/scene";
  51373. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51374. import { Nullable } from "babylonjs/types";
  51375. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51376. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51377. /**
  51378. * @hidden
  51379. */
  51380. export interface IMaterialSheenDefines {
  51381. SHEEN: boolean;
  51382. SHEEN_TEXTURE: boolean;
  51383. SHEEN_TEXTUREDIRECTUV: number;
  51384. SHEEN_LINKWITHALBEDO: boolean;
  51385. /** @hidden */
  51386. _areTexturesDirty: boolean;
  51387. }
  51388. /**
  51389. * Define the code related to the Sheen parameters of the pbr material.
  51390. */
  51391. export class PBRSheenConfiguration {
  51392. private _isEnabled;
  51393. /**
  51394. * Defines if the material uses sheen.
  51395. */
  51396. isEnabled: boolean;
  51397. private _linkSheenWithAlbedo;
  51398. /**
  51399. * Defines if the sheen is linked to the sheen color.
  51400. */
  51401. linkSheenWithAlbedo: boolean;
  51402. /**
  51403. * Defines the sheen intensity.
  51404. */
  51405. intensity: number;
  51406. /**
  51407. * Defines the sheen color.
  51408. */
  51409. color: Color3;
  51410. private _texture;
  51411. /**
  51412. * Stores the sheen tint values in a texture.
  51413. * rgb is tint
  51414. * a is a intensity
  51415. */
  51416. texture: Nullable<BaseTexture>;
  51417. /** @hidden */
  51418. private _internalMarkAllSubMeshesAsTexturesDirty;
  51419. /** @hidden */
  51420. _markAllSubMeshesAsTexturesDirty(): void;
  51421. /**
  51422. * Instantiate a new istance of clear coat configuration.
  51423. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51424. */
  51425. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51426. /**
  51427. * Specifies that the submesh is ready to be used.
  51428. * @param defines the list of "defines" to update.
  51429. * @param scene defines the scene the material belongs to.
  51430. * @returns - boolean indicating that the submesh is ready or not.
  51431. */
  51432. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  51433. /**
  51434. * Checks to see if a texture is used in the material.
  51435. * @param defines the list of "defines" to update.
  51436. * @param scene defines the scene the material belongs to.
  51437. */
  51438. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  51439. /**
  51440. * Binds the material data.
  51441. * @param uniformBuffer defines the Uniform buffer to fill in.
  51442. * @param scene defines the scene the material belongs to.
  51443. * @param isFrozen defines wether the material is frozen or not.
  51444. */
  51445. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  51446. /**
  51447. * Checks to see if a texture is used in the material.
  51448. * @param texture - Base texture to use.
  51449. * @returns - Boolean specifying if a texture is used in the material.
  51450. */
  51451. hasTexture(texture: BaseTexture): boolean;
  51452. /**
  51453. * Returns an array of the actively used textures.
  51454. * @param activeTextures Array of BaseTextures
  51455. */
  51456. getActiveTextures(activeTextures: BaseTexture[]): void;
  51457. /**
  51458. * Returns the animatable textures.
  51459. * @param animatables Array of animatable textures.
  51460. */
  51461. getAnimatables(animatables: IAnimatable[]): void;
  51462. /**
  51463. * Disposes the resources of the material.
  51464. * @param forceDisposeTextures - Forces the disposal of all textures.
  51465. */
  51466. dispose(forceDisposeTextures?: boolean): void;
  51467. /**
  51468. * Get the current class name of the texture useful for serialization or dynamic coding.
  51469. * @returns "PBRSheenConfiguration"
  51470. */
  51471. getClassName(): string;
  51472. /**
  51473. * Add fallbacks to the effect fallbacks list.
  51474. * @param defines defines the Base texture to use.
  51475. * @param fallbacks defines the current fallback list.
  51476. * @param currentRank defines the current fallback rank.
  51477. * @returns the new fallback rank.
  51478. */
  51479. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51480. /**
  51481. * Add the required uniforms to the current list.
  51482. * @param uniforms defines the current uniform list.
  51483. */
  51484. static AddUniforms(uniforms: string[]): void;
  51485. /**
  51486. * Add the required uniforms to the current buffer.
  51487. * @param uniformBuffer defines the current uniform buffer.
  51488. */
  51489. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51490. /**
  51491. * Add the required samplers to the current list.
  51492. * @param samplers defines the current sampler list.
  51493. */
  51494. static AddSamplers(samplers: string[]): void;
  51495. /**
  51496. * Makes a duplicate of the current configuration into another one.
  51497. * @param sheenConfiguration define the config where to copy the info
  51498. */
  51499. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  51500. /**
  51501. * Serializes this BRDF configuration.
  51502. * @returns - An object with the serialized config.
  51503. */
  51504. serialize(): any;
  51505. /**
  51506. * Parses a anisotropy Configuration from a serialized object.
  51507. * @param source - Serialized object.
  51508. * @param scene Defines the scene we are parsing for
  51509. * @param rootUrl Defines the rootUrl to load from
  51510. */
  51511. parse(source: any, scene: Scene, rootUrl: string): void;
  51512. }
  51513. }
  51514. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  51515. import { Nullable } from "babylonjs/types";
  51516. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51517. import { Color3 } from "babylonjs/Maths/math.color";
  51518. import { SmartArray } from "babylonjs/Misc/smartArray";
  51519. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51520. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51521. import { Effect } from "babylonjs/Materials/effect";
  51522. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51523. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51524. import { Engine } from "babylonjs/Engines/engine";
  51525. import { Scene } from "babylonjs/scene";
  51526. /**
  51527. * @hidden
  51528. */
  51529. export interface IMaterialSubSurfaceDefines {
  51530. SUBSURFACE: boolean;
  51531. SS_REFRACTION: boolean;
  51532. SS_TRANSLUCENCY: boolean;
  51533. SS_SCATERRING: boolean;
  51534. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51535. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51536. SS_REFRACTIONMAP_3D: boolean;
  51537. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51538. SS_LODINREFRACTIONALPHA: boolean;
  51539. SS_GAMMAREFRACTION: boolean;
  51540. SS_RGBDREFRACTION: boolean;
  51541. SS_LINEARSPECULARREFRACTION: boolean;
  51542. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51543. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51544. /** @hidden */
  51545. _areTexturesDirty: boolean;
  51546. }
  51547. /**
  51548. * Define the code related to the sub surface parameters of the pbr material.
  51549. */
  51550. export class PBRSubSurfaceConfiguration {
  51551. private _isRefractionEnabled;
  51552. /**
  51553. * Defines if the refraction is enabled in the material.
  51554. */
  51555. isRefractionEnabled: boolean;
  51556. private _isTranslucencyEnabled;
  51557. /**
  51558. * Defines if the translucency is enabled in the material.
  51559. */
  51560. isTranslucencyEnabled: boolean;
  51561. private _isScatteringEnabled;
  51562. /**
  51563. * Defines the refraction intensity of the material.
  51564. * The refraction when enabled replaces the Diffuse part of the material.
  51565. * The intensity helps transitionning between diffuse and refraction.
  51566. */
  51567. refractionIntensity: number;
  51568. /**
  51569. * Defines the translucency intensity of the material.
  51570. * When translucency has been enabled, this defines how much of the "translucency"
  51571. * is addded to the diffuse part of the material.
  51572. */
  51573. translucencyIntensity: number;
  51574. /**
  51575. * Defines the scattering intensity of the material.
  51576. * When scattering has been enabled, this defines how much of the "scattered light"
  51577. * is addded to the diffuse part of the material.
  51578. */
  51579. scatteringIntensity: number;
  51580. private _thicknessTexture;
  51581. /**
  51582. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  51583. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  51584. * 0 would mean minimumThickness
  51585. * 1 would mean maximumThickness
  51586. * The other channels might be use as a mask to vary the different effects intensity.
  51587. */
  51588. thicknessTexture: Nullable<BaseTexture>;
  51589. private _refractionTexture;
  51590. /**
  51591. * Defines the texture to use for refraction.
  51592. */
  51593. refractionTexture: Nullable<BaseTexture>;
  51594. private _indexOfRefraction;
  51595. /**
  51596. * Defines the index of refraction used in the material.
  51597. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  51598. */
  51599. indexOfRefraction: number;
  51600. private _invertRefractionY;
  51601. /**
  51602. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51603. */
  51604. invertRefractionY: boolean;
  51605. private _linkRefractionWithTransparency;
  51606. /**
  51607. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51608. * Materials half opaque for instance using refraction could benefit from this control.
  51609. */
  51610. linkRefractionWithTransparency: boolean;
  51611. /**
  51612. * Defines the minimum thickness stored in the thickness map.
  51613. * If no thickness map is defined, this value will be used to simulate thickness.
  51614. */
  51615. minimumThickness: number;
  51616. /**
  51617. * Defines the maximum thickness stored in the thickness map.
  51618. */
  51619. maximumThickness: number;
  51620. /**
  51621. * Defines the volume tint of the material.
  51622. * This is used for both translucency and scattering.
  51623. */
  51624. tintColor: Color3;
  51625. /**
  51626. * Defines the distance at which the tint color should be found in the media.
  51627. * This is used for refraction only.
  51628. */
  51629. tintColorAtDistance: number;
  51630. /**
  51631. * Defines how far each channel transmit through the media.
  51632. * It is defined as a color to simplify it selection.
  51633. */
  51634. diffusionDistance: Color3;
  51635. private _useMaskFromThicknessTexture;
  51636. /**
  51637. * Stores the intensity of the different subsurface effects in the thickness texture.
  51638. * * the green channel is the translucency intensity.
  51639. * * the blue channel is the scattering intensity.
  51640. * * the alpha channel is the refraction intensity.
  51641. */
  51642. useMaskFromThicknessTexture: boolean;
  51643. /** @hidden */
  51644. private _internalMarkAllSubMeshesAsTexturesDirty;
  51645. /** @hidden */
  51646. _markAllSubMeshesAsTexturesDirty(): void;
  51647. /**
  51648. * Instantiate a new istance of sub surface configuration.
  51649. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51650. */
  51651. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51652. /**
  51653. * Gets wehter the submesh is ready to be used or not.
  51654. * @param defines the list of "defines" to update.
  51655. * @param scene defines the scene the material belongs to.
  51656. * @returns - boolean indicating that the submesh is ready or not.
  51657. */
  51658. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  51659. /**
  51660. * Checks to see if a texture is used in the material.
  51661. * @param defines the list of "defines" to update.
  51662. * @param scene defines the scene to the material belongs to.
  51663. */
  51664. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  51665. /**
  51666. * Binds the material data.
  51667. * @param uniformBuffer defines the Uniform buffer to fill in.
  51668. * @param scene defines the scene the material belongs to.
  51669. * @param engine defines the engine the material belongs to.
  51670. * @param isFrozen defines wether the material is frozen or not.
  51671. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  51672. */
  51673. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  51674. /**
  51675. * Unbinds the material from the mesh.
  51676. * @param activeEffect defines the effect that should be unbound from.
  51677. * @returns true if unbound, otherwise false
  51678. */
  51679. unbind(activeEffect: Effect): boolean;
  51680. /**
  51681. * Returns the texture used for refraction or null if none is used.
  51682. * @param scene defines the scene the material belongs to.
  51683. * @returns - Refraction texture if present. If no refraction texture and refraction
  51684. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51685. */
  51686. private _getRefractionTexture;
  51687. /**
  51688. * Returns true if alpha blending should be disabled.
  51689. */
  51690. get disableAlphaBlending(): boolean;
  51691. /**
  51692. * Fills the list of render target textures.
  51693. * @param renderTargets the list of render targets to update
  51694. */
  51695. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  51696. /**
  51697. * Checks to see if a texture is used in the material.
  51698. * @param texture - Base texture to use.
  51699. * @returns - Boolean specifying if a texture is used in the material.
  51700. */
  51701. hasTexture(texture: BaseTexture): boolean;
  51702. /**
  51703. * Gets a boolean indicating that current material needs to register RTT
  51704. * @returns true if this uses a render target otherwise false.
  51705. */
  51706. hasRenderTargetTextures(): boolean;
  51707. /**
  51708. * Returns an array of the actively used textures.
  51709. * @param activeTextures Array of BaseTextures
  51710. */
  51711. getActiveTextures(activeTextures: BaseTexture[]): void;
  51712. /**
  51713. * Returns the animatable textures.
  51714. * @param animatables Array of animatable textures.
  51715. */
  51716. getAnimatables(animatables: IAnimatable[]): void;
  51717. /**
  51718. * Disposes the resources of the material.
  51719. * @param forceDisposeTextures - Forces the disposal of all textures.
  51720. */
  51721. dispose(forceDisposeTextures?: boolean): void;
  51722. /**
  51723. * Get the current class name of the texture useful for serialization or dynamic coding.
  51724. * @returns "PBRSubSurfaceConfiguration"
  51725. */
  51726. getClassName(): string;
  51727. /**
  51728. * Add fallbacks to the effect fallbacks list.
  51729. * @param defines defines the Base texture to use.
  51730. * @param fallbacks defines the current fallback list.
  51731. * @param currentRank defines the current fallback rank.
  51732. * @returns the new fallback rank.
  51733. */
  51734. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51735. /**
  51736. * Add the required uniforms to the current list.
  51737. * @param uniforms defines the current uniform list.
  51738. */
  51739. static AddUniforms(uniforms: string[]): void;
  51740. /**
  51741. * Add the required samplers to the current list.
  51742. * @param samplers defines the current sampler list.
  51743. */
  51744. static AddSamplers(samplers: string[]): void;
  51745. /**
  51746. * Add the required uniforms to the current buffer.
  51747. * @param uniformBuffer defines the current uniform buffer.
  51748. */
  51749. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51750. /**
  51751. * Makes a duplicate of the current configuration into another one.
  51752. * @param configuration define the config where to copy the info
  51753. */
  51754. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51755. /**
  51756. * Serializes this Sub Surface configuration.
  51757. * @returns - An object with the serialized config.
  51758. */
  51759. serialize(): any;
  51760. /**
  51761. * Parses a anisotropy Configuration from a serialized object.
  51762. * @param source - Serialized object.
  51763. * @param scene Defines the scene we are parsing for
  51764. * @param rootUrl Defines the rootUrl to load from
  51765. */
  51766. parse(source: any, scene: Scene, rootUrl: string): void;
  51767. }
  51768. }
  51769. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  51770. /** @hidden */
  51771. export var pbrFragmentDeclaration: {
  51772. name: string;
  51773. shader: string;
  51774. };
  51775. }
  51776. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  51777. /** @hidden */
  51778. export var pbrUboDeclaration: {
  51779. name: string;
  51780. shader: string;
  51781. };
  51782. }
  51783. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  51784. /** @hidden */
  51785. export var pbrFragmentExtraDeclaration: {
  51786. name: string;
  51787. shader: string;
  51788. };
  51789. }
  51790. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  51791. /** @hidden */
  51792. export var pbrFragmentSamplersDeclaration: {
  51793. name: string;
  51794. shader: string;
  51795. };
  51796. }
  51797. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  51798. /** @hidden */
  51799. export var pbrHelperFunctions: {
  51800. name: string;
  51801. shader: string;
  51802. };
  51803. }
  51804. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  51805. /** @hidden */
  51806. export var harmonicsFunctions: {
  51807. name: string;
  51808. shader: string;
  51809. };
  51810. }
  51811. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  51812. /** @hidden */
  51813. export var pbrDirectLightingSetupFunctions: {
  51814. name: string;
  51815. shader: string;
  51816. };
  51817. }
  51818. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  51819. /** @hidden */
  51820. export var pbrDirectLightingFalloffFunctions: {
  51821. name: string;
  51822. shader: string;
  51823. };
  51824. }
  51825. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  51826. /** @hidden */
  51827. export var pbrBRDFFunctions: {
  51828. name: string;
  51829. shader: string;
  51830. };
  51831. }
  51832. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  51833. /** @hidden */
  51834. export var pbrDirectLightingFunctions: {
  51835. name: string;
  51836. shader: string;
  51837. };
  51838. }
  51839. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  51840. /** @hidden */
  51841. export var pbrIBLFunctions: {
  51842. name: string;
  51843. shader: string;
  51844. };
  51845. }
  51846. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  51847. /** @hidden */
  51848. export var pbrDebug: {
  51849. name: string;
  51850. shader: string;
  51851. };
  51852. }
  51853. declare module "babylonjs/Shaders/pbr.fragment" {
  51854. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  51855. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  51856. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  51857. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51858. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51859. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  51860. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51861. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51862. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  51863. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51864. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51865. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  51866. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51867. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51868. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  51869. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  51870. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  51871. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  51872. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  51873. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  51874. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  51875. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51876. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51877. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  51878. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  51879. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51880. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  51881. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51882. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  51883. /** @hidden */
  51884. export var pbrPixelShader: {
  51885. name: string;
  51886. shader: string;
  51887. };
  51888. }
  51889. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  51890. /** @hidden */
  51891. export var pbrVertexDeclaration: {
  51892. name: string;
  51893. shader: string;
  51894. };
  51895. }
  51896. declare module "babylonjs/Shaders/pbr.vertex" {
  51897. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  51898. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  51899. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51900. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51901. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51902. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  51903. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  51904. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51905. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51906. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51907. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51908. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51909. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51910. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  51911. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51912. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51913. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51914. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  51915. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51916. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51917. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51918. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  51919. /** @hidden */
  51920. export var pbrVertexShader: {
  51921. name: string;
  51922. shader: string;
  51923. };
  51924. }
  51925. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  51926. import { Nullable } from "babylonjs/types";
  51927. import { Scene } from "babylonjs/scene";
  51928. import { Matrix } from "babylonjs/Maths/math.vector";
  51929. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51931. import { Mesh } from "babylonjs/Meshes/mesh";
  51932. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  51933. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  51934. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  51935. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  51936. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  51937. import { Color3 } from "babylonjs/Maths/math.color";
  51938. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  51939. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  51940. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  51941. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51942. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51943. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51944. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  51945. import "babylonjs/Shaders/pbr.fragment";
  51946. import "babylonjs/Shaders/pbr.vertex";
  51947. /**
  51948. * Manages the defines for the PBR Material.
  51949. * @hidden
  51950. */
  51951. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51952. PBR: boolean;
  51953. MAINUV1: boolean;
  51954. MAINUV2: boolean;
  51955. UV1: boolean;
  51956. UV2: boolean;
  51957. ALBEDO: boolean;
  51958. ALBEDODIRECTUV: number;
  51959. VERTEXCOLOR: boolean;
  51960. AMBIENT: boolean;
  51961. AMBIENTDIRECTUV: number;
  51962. AMBIENTINGRAYSCALE: boolean;
  51963. OPACITY: boolean;
  51964. VERTEXALPHA: boolean;
  51965. OPACITYDIRECTUV: number;
  51966. OPACITYRGB: boolean;
  51967. ALPHATEST: boolean;
  51968. DEPTHPREPASS: boolean;
  51969. ALPHABLEND: boolean;
  51970. ALPHAFROMALBEDO: boolean;
  51971. ALPHATESTVALUE: string;
  51972. SPECULAROVERALPHA: boolean;
  51973. RADIANCEOVERALPHA: boolean;
  51974. ALPHAFRESNEL: boolean;
  51975. LINEARALPHAFRESNEL: boolean;
  51976. PREMULTIPLYALPHA: boolean;
  51977. EMISSIVE: boolean;
  51978. EMISSIVEDIRECTUV: number;
  51979. REFLECTIVITY: boolean;
  51980. REFLECTIVITYDIRECTUV: number;
  51981. SPECULARTERM: boolean;
  51982. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51983. MICROSURFACEAUTOMATIC: boolean;
  51984. LODBASEDMICROSFURACE: boolean;
  51985. MICROSURFACEMAP: boolean;
  51986. MICROSURFACEMAPDIRECTUV: number;
  51987. METALLICWORKFLOW: boolean;
  51988. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51989. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51990. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51991. AOSTOREINMETALMAPRED: boolean;
  51992. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51993. ENVIRONMENTBRDF: boolean;
  51994. ENVIRONMENTBRDF_RGBD: boolean;
  51995. NORMAL: boolean;
  51996. TANGENT: boolean;
  51997. BUMP: boolean;
  51998. BUMPDIRECTUV: number;
  51999. OBJECTSPACE_NORMALMAP: boolean;
  52000. PARALLAX: boolean;
  52001. PARALLAXOCCLUSION: boolean;
  52002. NORMALXYSCALE: boolean;
  52003. LIGHTMAP: boolean;
  52004. LIGHTMAPDIRECTUV: number;
  52005. USELIGHTMAPASSHADOWMAP: boolean;
  52006. GAMMALIGHTMAP: boolean;
  52007. RGBDLIGHTMAP: boolean;
  52008. REFLECTION: boolean;
  52009. REFLECTIONMAP_3D: boolean;
  52010. REFLECTIONMAP_SPHERICAL: boolean;
  52011. REFLECTIONMAP_PLANAR: boolean;
  52012. REFLECTIONMAP_CUBIC: boolean;
  52013. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  52014. REFLECTIONMAP_PROJECTION: boolean;
  52015. REFLECTIONMAP_SKYBOX: boolean;
  52016. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  52017. REFLECTIONMAP_EXPLICIT: boolean;
  52018. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  52019. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  52020. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  52021. INVERTCUBICMAP: boolean;
  52022. USESPHERICALFROMREFLECTIONMAP: boolean;
  52023. USEIRRADIANCEMAP: boolean;
  52024. SPHERICAL_HARMONICS: boolean;
  52025. USESPHERICALINVERTEX: boolean;
  52026. REFLECTIONMAP_OPPOSITEZ: boolean;
  52027. LODINREFLECTIONALPHA: boolean;
  52028. GAMMAREFLECTION: boolean;
  52029. RGBDREFLECTION: boolean;
  52030. LINEARSPECULARREFLECTION: boolean;
  52031. RADIANCEOCCLUSION: boolean;
  52032. HORIZONOCCLUSION: boolean;
  52033. INSTANCES: boolean;
  52034. NUM_BONE_INFLUENCERS: number;
  52035. BonesPerMesh: number;
  52036. BONETEXTURE: boolean;
  52037. NONUNIFORMSCALING: boolean;
  52038. MORPHTARGETS: boolean;
  52039. MORPHTARGETS_NORMAL: boolean;
  52040. MORPHTARGETS_TANGENT: boolean;
  52041. MORPHTARGETS_UV: boolean;
  52042. NUM_MORPH_INFLUENCERS: number;
  52043. IMAGEPROCESSING: boolean;
  52044. VIGNETTE: boolean;
  52045. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52046. VIGNETTEBLENDMODEOPAQUE: boolean;
  52047. TONEMAPPING: boolean;
  52048. TONEMAPPING_ACES: boolean;
  52049. CONTRAST: boolean;
  52050. COLORCURVES: boolean;
  52051. COLORGRADING: boolean;
  52052. COLORGRADING3D: boolean;
  52053. SAMPLER3DGREENDEPTH: boolean;
  52054. SAMPLER3DBGRMAP: boolean;
  52055. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52056. EXPOSURE: boolean;
  52057. MULTIVIEW: boolean;
  52058. USEPHYSICALLIGHTFALLOFF: boolean;
  52059. USEGLTFLIGHTFALLOFF: boolean;
  52060. TWOSIDEDLIGHTING: boolean;
  52061. SHADOWFLOAT: boolean;
  52062. CLIPPLANE: boolean;
  52063. CLIPPLANE2: boolean;
  52064. CLIPPLANE3: boolean;
  52065. CLIPPLANE4: boolean;
  52066. CLIPPLANE5: boolean;
  52067. CLIPPLANE6: boolean;
  52068. POINTSIZE: boolean;
  52069. FOG: boolean;
  52070. LOGARITHMICDEPTH: boolean;
  52071. FORCENORMALFORWARD: boolean;
  52072. SPECULARAA: boolean;
  52073. CLEARCOAT: boolean;
  52074. CLEARCOAT_DEFAULTIOR: boolean;
  52075. CLEARCOAT_TEXTURE: boolean;
  52076. CLEARCOAT_TEXTUREDIRECTUV: number;
  52077. CLEARCOAT_BUMP: boolean;
  52078. CLEARCOAT_BUMPDIRECTUV: number;
  52079. CLEARCOAT_TINT: boolean;
  52080. CLEARCOAT_TINT_TEXTURE: boolean;
  52081. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52082. ANISOTROPIC: boolean;
  52083. ANISOTROPIC_TEXTURE: boolean;
  52084. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52085. BRDF_V_HEIGHT_CORRELATED: boolean;
  52086. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52087. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52088. SHEEN: boolean;
  52089. SHEEN_TEXTURE: boolean;
  52090. SHEEN_TEXTUREDIRECTUV: number;
  52091. SHEEN_LINKWITHALBEDO: boolean;
  52092. SUBSURFACE: boolean;
  52093. SS_REFRACTION: boolean;
  52094. SS_TRANSLUCENCY: boolean;
  52095. SS_SCATERRING: boolean;
  52096. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52097. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52098. SS_REFRACTIONMAP_3D: boolean;
  52099. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52100. SS_LODINREFRACTIONALPHA: boolean;
  52101. SS_GAMMAREFRACTION: boolean;
  52102. SS_RGBDREFRACTION: boolean;
  52103. SS_LINEARSPECULARREFRACTION: boolean;
  52104. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52105. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52106. UNLIT: boolean;
  52107. DEBUGMODE: number;
  52108. /**
  52109. * Initializes the PBR Material defines.
  52110. */
  52111. constructor();
  52112. /**
  52113. * Resets the PBR Material defines.
  52114. */
  52115. reset(): void;
  52116. }
  52117. /**
  52118. * The Physically based material base class of BJS.
  52119. *
  52120. * This offers the main features of a standard PBR material.
  52121. * For more information, please refer to the documentation :
  52122. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52123. */
  52124. export abstract class PBRBaseMaterial extends PushMaterial {
  52125. /**
  52126. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52127. */
  52128. static readonly PBRMATERIAL_OPAQUE: number;
  52129. /**
  52130. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52131. */
  52132. static readonly PBRMATERIAL_ALPHATEST: number;
  52133. /**
  52134. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52135. */
  52136. static readonly PBRMATERIAL_ALPHABLEND: number;
  52137. /**
  52138. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52139. * They are also discarded below the alpha cutoff threshold to improve performances.
  52140. */
  52141. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52142. /**
  52143. * Defines the default value of how much AO map is occluding the analytical lights
  52144. * (point spot...).
  52145. */
  52146. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52147. /**
  52148. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  52149. */
  52150. static readonly LIGHTFALLOFF_PHYSICAL: number;
  52151. /**
  52152. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  52153. * to enhance interoperability with other engines.
  52154. */
  52155. static readonly LIGHTFALLOFF_GLTF: number;
  52156. /**
  52157. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  52158. * to enhance interoperability with other materials.
  52159. */
  52160. static readonly LIGHTFALLOFF_STANDARD: number;
  52161. /**
  52162. * Intensity of the direct lights e.g. the four lights available in your scene.
  52163. * This impacts both the direct diffuse and specular highlights.
  52164. */
  52165. protected _directIntensity: number;
  52166. /**
  52167. * Intensity of the emissive part of the material.
  52168. * This helps controlling the emissive effect without modifying the emissive color.
  52169. */
  52170. protected _emissiveIntensity: number;
  52171. /**
  52172. * Intensity of the environment e.g. how much the environment will light the object
  52173. * either through harmonics for rough material or through the refelction for shiny ones.
  52174. */
  52175. protected _environmentIntensity: number;
  52176. /**
  52177. * This is a special control allowing the reduction of the specular highlights coming from the
  52178. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52179. */
  52180. protected _specularIntensity: number;
  52181. /**
  52182. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  52183. */
  52184. private _lightingInfos;
  52185. /**
  52186. * Debug Control allowing disabling the bump map on this material.
  52187. */
  52188. protected _disableBumpMap: boolean;
  52189. /**
  52190. * AKA Diffuse Texture in standard nomenclature.
  52191. */
  52192. protected _albedoTexture: Nullable<BaseTexture>;
  52193. /**
  52194. * AKA Occlusion Texture in other nomenclature.
  52195. */
  52196. protected _ambientTexture: Nullable<BaseTexture>;
  52197. /**
  52198. * AKA Occlusion Texture Intensity in other nomenclature.
  52199. */
  52200. protected _ambientTextureStrength: number;
  52201. /**
  52202. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52203. * 1 means it completely occludes it
  52204. * 0 mean it has no impact
  52205. */
  52206. protected _ambientTextureImpactOnAnalyticalLights: number;
  52207. /**
  52208. * Stores the alpha values in a texture.
  52209. */
  52210. protected _opacityTexture: Nullable<BaseTexture>;
  52211. /**
  52212. * Stores the reflection values in a texture.
  52213. */
  52214. protected _reflectionTexture: Nullable<BaseTexture>;
  52215. /**
  52216. * Stores the emissive values in a texture.
  52217. */
  52218. protected _emissiveTexture: Nullable<BaseTexture>;
  52219. /**
  52220. * AKA Specular texture in other nomenclature.
  52221. */
  52222. protected _reflectivityTexture: Nullable<BaseTexture>;
  52223. /**
  52224. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52225. */
  52226. protected _metallicTexture: Nullable<BaseTexture>;
  52227. /**
  52228. * Specifies the metallic scalar of the metallic/roughness workflow.
  52229. * Can also be used to scale the metalness values of the metallic texture.
  52230. */
  52231. protected _metallic: Nullable<number>;
  52232. /**
  52233. * Specifies the roughness scalar of the metallic/roughness workflow.
  52234. * Can also be used to scale the roughness values of the metallic texture.
  52235. */
  52236. protected _roughness: Nullable<number>;
  52237. /**
  52238. * Specifies the an F0 factor to help configuring the material F0.
  52239. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52240. * to 0.5 the previously hard coded value stays the same.
  52241. * Can also be used to scale the F0 values of the metallic texture.
  52242. */
  52243. protected _metallicF0Factor: number;
  52244. /**
  52245. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52246. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52247. * your expectation as it multiplies with the texture data.
  52248. */
  52249. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  52250. /**
  52251. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52252. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52253. */
  52254. protected _microSurfaceTexture: Nullable<BaseTexture>;
  52255. /**
  52256. * Stores surface normal data used to displace a mesh in a texture.
  52257. */
  52258. protected _bumpTexture: Nullable<BaseTexture>;
  52259. /**
  52260. * Stores the pre-calculated light information of a mesh in a texture.
  52261. */
  52262. protected _lightmapTexture: Nullable<BaseTexture>;
  52263. /**
  52264. * The color of a material in ambient lighting.
  52265. */
  52266. protected _ambientColor: Color3;
  52267. /**
  52268. * AKA Diffuse Color in other nomenclature.
  52269. */
  52270. protected _albedoColor: Color3;
  52271. /**
  52272. * AKA Specular Color in other nomenclature.
  52273. */
  52274. protected _reflectivityColor: Color3;
  52275. /**
  52276. * The color applied when light is reflected from a material.
  52277. */
  52278. protected _reflectionColor: Color3;
  52279. /**
  52280. * The color applied when light is emitted from a material.
  52281. */
  52282. protected _emissiveColor: Color3;
  52283. /**
  52284. * AKA Glossiness in other nomenclature.
  52285. */
  52286. protected _microSurface: number;
  52287. /**
  52288. * Specifies that the material will use the light map as a show map.
  52289. */
  52290. protected _useLightmapAsShadowmap: boolean;
  52291. /**
  52292. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52293. * makes the reflect vector face the model (under horizon).
  52294. */
  52295. protected _useHorizonOcclusion: boolean;
  52296. /**
  52297. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52298. * too much the area relying on ambient texture to define their ambient occlusion.
  52299. */
  52300. protected _useRadianceOcclusion: boolean;
  52301. /**
  52302. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52303. */
  52304. protected _useAlphaFromAlbedoTexture: boolean;
  52305. /**
  52306. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  52307. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52308. */
  52309. protected _useSpecularOverAlpha: boolean;
  52310. /**
  52311. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52312. */
  52313. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52314. /**
  52315. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52316. */
  52317. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  52318. /**
  52319. * Specifies if the metallic texture contains the roughness information in its green channel.
  52320. */
  52321. protected _useRoughnessFromMetallicTextureGreen: boolean;
  52322. /**
  52323. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52324. */
  52325. protected _useMetallnessFromMetallicTextureBlue: boolean;
  52326. /**
  52327. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52328. */
  52329. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  52330. /**
  52331. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52332. */
  52333. protected _useAmbientInGrayScale: boolean;
  52334. /**
  52335. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52336. * The material will try to infer what glossiness each pixel should be.
  52337. */
  52338. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  52339. /**
  52340. * Defines the falloff type used in this material.
  52341. * It by default is Physical.
  52342. */
  52343. protected _lightFalloff: number;
  52344. /**
  52345. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52346. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52347. */
  52348. protected _useRadianceOverAlpha: boolean;
  52349. /**
  52350. * Allows using an object space normal map (instead of tangent space).
  52351. */
  52352. protected _useObjectSpaceNormalMap: boolean;
  52353. /**
  52354. * Allows using the bump map in parallax mode.
  52355. */
  52356. protected _useParallax: boolean;
  52357. /**
  52358. * Allows using the bump map in parallax occlusion mode.
  52359. */
  52360. protected _useParallaxOcclusion: boolean;
  52361. /**
  52362. * Controls the scale bias of the parallax mode.
  52363. */
  52364. protected _parallaxScaleBias: number;
  52365. /**
  52366. * If sets to true, disables all the lights affecting the material.
  52367. */
  52368. protected _disableLighting: boolean;
  52369. /**
  52370. * Number of Simultaneous lights allowed on the material.
  52371. */
  52372. protected _maxSimultaneousLights: number;
  52373. /**
  52374. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52375. */
  52376. protected _invertNormalMapX: boolean;
  52377. /**
  52378. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52379. */
  52380. protected _invertNormalMapY: boolean;
  52381. /**
  52382. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52383. */
  52384. protected _twoSidedLighting: boolean;
  52385. /**
  52386. * Defines the alpha limits in alpha test mode.
  52387. */
  52388. protected _alphaCutOff: number;
  52389. /**
  52390. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52391. */
  52392. protected _forceAlphaTest: boolean;
  52393. /**
  52394. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52395. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52396. */
  52397. protected _useAlphaFresnel: boolean;
  52398. /**
  52399. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52400. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52401. */
  52402. protected _useLinearAlphaFresnel: boolean;
  52403. /**
  52404. * The transparency mode of the material.
  52405. */
  52406. protected _transparencyMode: Nullable<number>;
  52407. /**
  52408. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  52409. * from cos thetav and roughness:
  52410. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  52411. */
  52412. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  52413. /**
  52414. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52415. */
  52416. protected _forceIrradianceInFragment: boolean;
  52417. /**
  52418. * Force normal to face away from face.
  52419. */
  52420. protected _forceNormalForward: boolean;
  52421. /**
  52422. * Enables specular anti aliasing in the PBR shader.
  52423. * It will both interacts on the Geometry for analytical and IBL lighting.
  52424. * It also prefilter the roughness map based on the bump values.
  52425. */
  52426. protected _enableSpecularAntiAliasing: boolean;
  52427. /**
  52428. * Default configuration related to image processing available in the PBR Material.
  52429. */
  52430. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52431. /**
  52432. * Keep track of the image processing observer to allow dispose and replace.
  52433. */
  52434. private _imageProcessingObserver;
  52435. /**
  52436. * Attaches a new image processing configuration to the PBR Material.
  52437. * @param configuration
  52438. */
  52439. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52440. /**
  52441. * Stores the available render targets.
  52442. */
  52443. private _renderTargets;
  52444. /**
  52445. * Sets the global ambient color for the material used in lighting calculations.
  52446. */
  52447. private _globalAmbientColor;
  52448. /**
  52449. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  52450. */
  52451. private _useLogarithmicDepth;
  52452. /**
  52453. * If set to true, no lighting calculations will be applied.
  52454. */
  52455. private _unlit;
  52456. private _debugMode;
  52457. /**
  52458. * @hidden
  52459. * This is reserved for the inspector.
  52460. * Defines the material debug mode.
  52461. * It helps seeing only some components of the material while troubleshooting.
  52462. */
  52463. debugMode: number;
  52464. /**
  52465. * @hidden
  52466. * This is reserved for the inspector.
  52467. * Specify from where on screen the debug mode should start.
  52468. * The value goes from -1 (full screen) to 1 (not visible)
  52469. * It helps with side by side comparison against the final render
  52470. * This defaults to -1
  52471. */
  52472. private debugLimit;
  52473. /**
  52474. * @hidden
  52475. * This is reserved for the inspector.
  52476. * As the default viewing range might not be enough (if the ambient is really small for instance)
  52477. * You can use the factor to better multiply the final value.
  52478. */
  52479. private debugFactor;
  52480. /**
  52481. * Defines the clear coat layer parameters for the material.
  52482. */
  52483. readonly clearCoat: PBRClearCoatConfiguration;
  52484. /**
  52485. * Defines the anisotropic parameters for the material.
  52486. */
  52487. readonly anisotropy: PBRAnisotropicConfiguration;
  52488. /**
  52489. * Defines the BRDF parameters for the material.
  52490. */
  52491. readonly brdf: PBRBRDFConfiguration;
  52492. /**
  52493. * Defines the Sheen parameters for the material.
  52494. */
  52495. readonly sheen: PBRSheenConfiguration;
  52496. /**
  52497. * Defines the SubSurface parameters for the material.
  52498. */
  52499. readonly subSurface: PBRSubSurfaceConfiguration;
  52500. /**
  52501. * Custom callback helping to override the default shader used in the material.
  52502. */
  52503. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  52504. protected _rebuildInParallel: boolean;
  52505. /**
  52506. * Instantiates a new PBRMaterial instance.
  52507. *
  52508. * @param name The material name
  52509. * @param scene The scene the material will be use in.
  52510. */
  52511. constructor(name: string, scene: Scene);
  52512. /**
  52513. * Gets a boolean indicating that current material needs to register RTT
  52514. */
  52515. get hasRenderTargetTextures(): boolean;
  52516. /**
  52517. * Gets the name of the material class.
  52518. */
  52519. getClassName(): string;
  52520. /**
  52521. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52522. */
  52523. get useLogarithmicDepth(): boolean;
  52524. /**
  52525. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52526. */
  52527. set useLogarithmicDepth(value: boolean);
  52528. /**
  52529. * Gets the current transparency mode.
  52530. */
  52531. get transparencyMode(): Nullable<number>;
  52532. /**
  52533. * Sets the transparency mode of the material.
  52534. *
  52535. * | Value | Type | Description |
  52536. * | ----- | ----------------------------------- | ----------- |
  52537. * | 0 | OPAQUE | |
  52538. * | 1 | ALPHATEST | |
  52539. * | 2 | ALPHABLEND | |
  52540. * | 3 | ALPHATESTANDBLEND | |
  52541. *
  52542. */
  52543. set transparencyMode(value: Nullable<number>);
  52544. /**
  52545. * Returns true if alpha blending should be disabled.
  52546. */
  52547. private get _disableAlphaBlending();
  52548. /**
  52549. * Specifies whether or not this material should be rendered in alpha blend mode.
  52550. */
  52551. needAlphaBlending(): boolean;
  52552. /**
  52553. * Specifies if the mesh will require alpha blending.
  52554. * @param mesh - BJS mesh.
  52555. */
  52556. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  52557. /**
  52558. * Specifies whether or not this material should be rendered in alpha test mode.
  52559. */
  52560. needAlphaTesting(): boolean;
  52561. /**
  52562. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  52563. */
  52564. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  52565. /**
  52566. * Gets the texture used for the alpha test.
  52567. */
  52568. getAlphaTestTexture(): Nullable<BaseTexture>;
  52569. /**
  52570. * Specifies that the submesh is ready to be used.
  52571. * @param mesh - BJS mesh.
  52572. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  52573. * @param useInstances - Specifies that instances should be used.
  52574. * @returns - boolean indicating that the submesh is ready or not.
  52575. */
  52576. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52577. /**
  52578. * Specifies if the material uses metallic roughness workflow.
  52579. * @returns boolean specifiying if the material uses metallic roughness workflow.
  52580. */
  52581. isMetallicWorkflow(): boolean;
  52582. private _prepareEffect;
  52583. private _prepareDefines;
  52584. /**
  52585. * Force shader compilation
  52586. */
  52587. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  52588. /**
  52589. * Initializes the uniform buffer layout for the shader.
  52590. */
  52591. buildUniformLayout(): void;
  52592. /**
  52593. * Unbinds the material from the mesh
  52594. */
  52595. unbind(): void;
  52596. /**
  52597. * Binds the submesh data.
  52598. * @param world - The world matrix.
  52599. * @param mesh - The BJS mesh.
  52600. * @param subMesh - A submesh of the BJS mesh.
  52601. */
  52602. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52603. /**
  52604. * Returns the animatable textures.
  52605. * @returns - Array of animatable textures.
  52606. */
  52607. getAnimatables(): IAnimatable[];
  52608. /**
  52609. * Returns the texture used for reflections.
  52610. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  52611. */
  52612. private _getReflectionTexture;
  52613. /**
  52614. * Returns an array of the actively used textures.
  52615. * @returns - Array of BaseTextures
  52616. */
  52617. getActiveTextures(): BaseTexture[];
  52618. /**
  52619. * Checks to see if a texture is used in the material.
  52620. * @param texture - Base texture to use.
  52621. * @returns - Boolean specifying if a texture is used in the material.
  52622. */
  52623. hasTexture(texture: BaseTexture): boolean;
  52624. /**
  52625. * Disposes the resources of the material.
  52626. * @param forceDisposeEffect - Forces the disposal of effects.
  52627. * @param forceDisposeTextures - Forces the disposal of all textures.
  52628. */
  52629. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52630. }
  52631. }
  52632. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  52633. import { Nullable } from "babylonjs/types";
  52634. import { Scene } from "babylonjs/scene";
  52635. import { Color3 } from "babylonjs/Maths/math.color";
  52636. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  52637. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  52638. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52639. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52640. /**
  52641. * The Physically based material of BJS.
  52642. *
  52643. * This offers the main features of a standard PBR material.
  52644. * For more information, please refer to the documentation :
  52645. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52646. */
  52647. export class PBRMaterial extends PBRBaseMaterial {
  52648. /**
  52649. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52650. */
  52651. static readonly PBRMATERIAL_OPAQUE: number;
  52652. /**
  52653. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52654. */
  52655. static readonly PBRMATERIAL_ALPHATEST: number;
  52656. /**
  52657. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52658. */
  52659. static readonly PBRMATERIAL_ALPHABLEND: number;
  52660. /**
  52661. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52662. * They are also discarded below the alpha cutoff threshold to improve performances.
  52663. */
  52664. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52665. /**
  52666. * Defines the default value of how much AO map is occluding the analytical lights
  52667. * (point spot...).
  52668. */
  52669. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52670. /**
  52671. * Intensity of the direct lights e.g. the four lights available in your scene.
  52672. * This impacts both the direct diffuse and specular highlights.
  52673. */
  52674. directIntensity: number;
  52675. /**
  52676. * Intensity of the emissive part of the material.
  52677. * This helps controlling the emissive effect without modifying the emissive color.
  52678. */
  52679. emissiveIntensity: number;
  52680. /**
  52681. * Intensity of the environment e.g. how much the environment will light the object
  52682. * either through harmonics for rough material or through the refelction for shiny ones.
  52683. */
  52684. environmentIntensity: number;
  52685. /**
  52686. * This is a special control allowing the reduction of the specular highlights coming from the
  52687. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52688. */
  52689. specularIntensity: number;
  52690. /**
  52691. * Debug Control allowing disabling the bump map on this material.
  52692. */
  52693. disableBumpMap: boolean;
  52694. /**
  52695. * AKA Diffuse Texture in standard nomenclature.
  52696. */
  52697. albedoTexture: BaseTexture;
  52698. /**
  52699. * AKA Occlusion Texture in other nomenclature.
  52700. */
  52701. ambientTexture: BaseTexture;
  52702. /**
  52703. * AKA Occlusion Texture Intensity in other nomenclature.
  52704. */
  52705. ambientTextureStrength: number;
  52706. /**
  52707. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52708. * 1 means it completely occludes it
  52709. * 0 mean it has no impact
  52710. */
  52711. ambientTextureImpactOnAnalyticalLights: number;
  52712. /**
  52713. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  52714. */
  52715. opacityTexture: BaseTexture;
  52716. /**
  52717. * Stores the reflection values in a texture.
  52718. */
  52719. reflectionTexture: Nullable<BaseTexture>;
  52720. /**
  52721. * Stores the emissive values in a texture.
  52722. */
  52723. emissiveTexture: BaseTexture;
  52724. /**
  52725. * AKA Specular texture in other nomenclature.
  52726. */
  52727. reflectivityTexture: BaseTexture;
  52728. /**
  52729. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52730. */
  52731. metallicTexture: BaseTexture;
  52732. /**
  52733. * Specifies the metallic scalar of the metallic/roughness workflow.
  52734. * Can also be used to scale the metalness values of the metallic texture.
  52735. */
  52736. metallic: Nullable<number>;
  52737. /**
  52738. * Specifies the roughness scalar of the metallic/roughness workflow.
  52739. * Can also be used to scale the roughness values of the metallic texture.
  52740. */
  52741. roughness: Nullable<number>;
  52742. /**
  52743. * Specifies the an F0 factor to help configuring the material F0.
  52744. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52745. * to 0.5 the previously hard coded value stays the same.
  52746. * Can also be used to scale the F0 values of the metallic texture.
  52747. */
  52748. metallicF0Factor: number;
  52749. /**
  52750. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52751. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52752. * your expectation as it multiplies with the texture data.
  52753. */
  52754. useMetallicF0FactorFromMetallicTexture: boolean;
  52755. /**
  52756. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52757. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52758. */
  52759. microSurfaceTexture: BaseTexture;
  52760. /**
  52761. * Stores surface normal data used to displace a mesh in a texture.
  52762. */
  52763. bumpTexture: BaseTexture;
  52764. /**
  52765. * Stores the pre-calculated light information of a mesh in a texture.
  52766. */
  52767. lightmapTexture: BaseTexture;
  52768. /**
  52769. * Stores the refracted light information in a texture.
  52770. */
  52771. get refractionTexture(): Nullable<BaseTexture>;
  52772. set refractionTexture(value: Nullable<BaseTexture>);
  52773. /**
  52774. * The color of a material in ambient lighting.
  52775. */
  52776. ambientColor: Color3;
  52777. /**
  52778. * AKA Diffuse Color in other nomenclature.
  52779. */
  52780. albedoColor: Color3;
  52781. /**
  52782. * AKA Specular Color in other nomenclature.
  52783. */
  52784. reflectivityColor: Color3;
  52785. /**
  52786. * The color reflected from the material.
  52787. */
  52788. reflectionColor: Color3;
  52789. /**
  52790. * The color emitted from the material.
  52791. */
  52792. emissiveColor: Color3;
  52793. /**
  52794. * AKA Glossiness in other nomenclature.
  52795. */
  52796. microSurface: number;
  52797. /**
  52798. * source material index of refraction (IOR)' / 'destination material IOR.
  52799. */
  52800. get indexOfRefraction(): number;
  52801. set indexOfRefraction(value: number);
  52802. /**
  52803. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52804. */
  52805. get invertRefractionY(): boolean;
  52806. set invertRefractionY(value: boolean);
  52807. /**
  52808. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52809. * Materials half opaque for instance using refraction could benefit from this control.
  52810. */
  52811. get linkRefractionWithTransparency(): boolean;
  52812. set linkRefractionWithTransparency(value: boolean);
  52813. /**
  52814. * If true, the light map contains occlusion information instead of lighting info.
  52815. */
  52816. useLightmapAsShadowmap: boolean;
  52817. /**
  52818. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52819. */
  52820. useAlphaFromAlbedoTexture: boolean;
  52821. /**
  52822. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52823. */
  52824. forceAlphaTest: boolean;
  52825. /**
  52826. * Defines the alpha limits in alpha test mode.
  52827. */
  52828. alphaCutOff: number;
  52829. /**
  52830. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52831. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52832. */
  52833. useSpecularOverAlpha: boolean;
  52834. /**
  52835. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52836. */
  52837. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52838. /**
  52839. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52840. */
  52841. useRoughnessFromMetallicTextureAlpha: boolean;
  52842. /**
  52843. * Specifies if the metallic texture contains the roughness information in its green channel.
  52844. */
  52845. useRoughnessFromMetallicTextureGreen: boolean;
  52846. /**
  52847. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52848. */
  52849. useMetallnessFromMetallicTextureBlue: boolean;
  52850. /**
  52851. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52852. */
  52853. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52854. /**
  52855. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52856. */
  52857. useAmbientInGrayScale: boolean;
  52858. /**
  52859. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52860. * The material will try to infer what glossiness each pixel should be.
  52861. */
  52862. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52863. /**
  52864. * BJS is using an harcoded light falloff based on a manually sets up range.
  52865. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52866. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52867. */
  52868. get usePhysicalLightFalloff(): boolean;
  52869. /**
  52870. * BJS is using an harcoded light falloff based on a manually sets up range.
  52871. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52872. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52873. */
  52874. set usePhysicalLightFalloff(value: boolean);
  52875. /**
  52876. * In order to support the falloff compatibility with gltf, a special mode has been added
  52877. * to reproduce the gltf light falloff.
  52878. */
  52879. get useGLTFLightFalloff(): boolean;
  52880. /**
  52881. * In order to support the falloff compatibility with gltf, a special mode has been added
  52882. * to reproduce the gltf light falloff.
  52883. */
  52884. set useGLTFLightFalloff(value: boolean);
  52885. /**
  52886. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52887. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52888. */
  52889. useRadianceOverAlpha: boolean;
  52890. /**
  52891. * Allows using an object space normal map (instead of tangent space).
  52892. */
  52893. useObjectSpaceNormalMap: boolean;
  52894. /**
  52895. * Allows using the bump map in parallax mode.
  52896. */
  52897. useParallax: boolean;
  52898. /**
  52899. * Allows using the bump map in parallax occlusion mode.
  52900. */
  52901. useParallaxOcclusion: boolean;
  52902. /**
  52903. * Controls the scale bias of the parallax mode.
  52904. */
  52905. parallaxScaleBias: number;
  52906. /**
  52907. * If sets to true, disables all the lights affecting the material.
  52908. */
  52909. disableLighting: boolean;
  52910. /**
  52911. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52912. */
  52913. forceIrradianceInFragment: boolean;
  52914. /**
  52915. * Number of Simultaneous lights allowed on the material.
  52916. */
  52917. maxSimultaneousLights: number;
  52918. /**
  52919. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52920. */
  52921. invertNormalMapX: boolean;
  52922. /**
  52923. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52924. */
  52925. invertNormalMapY: boolean;
  52926. /**
  52927. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52928. */
  52929. twoSidedLighting: boolean;
  52930. /**
  52931. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52932. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52933. */
  52934. useAlphaFresnel: boolean;
  52935. /**
  52936. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52937. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52938. */
  52939. useLinearAlphaFresnel: boolean;
  52940. /**
  52941. * Let user defines the brdf lookup texture used for IBL.
  52942. * A default 8bit version is embedded but you could point at :
  52943. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52944. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52945. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52946. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52947. */
  52948. environmentBRDFTexture: Nullable<BaseTexture>;
  52949. /**
  52950. * Force normal to face away from face.
  52951. */
  52952. forceNormalForward: boolean;
  52953. /**
  52954. * Enables specular anti aliasing in the PBR shader.
  52955. * It will both interacts on the Geometry for analytical and IBL lighting.
  52956. * It also prefilter the roughness map based on the bump values.
  52957. */
  52958. enableSpecularAntiAliasing: boolean;
  52959. /**
  52960. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52961. * makes the reflect vector face the model (under horizon).
  52962. */
  52963. useHorizonOcclusion: boolean;
  52964. /**
  52965. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52966. * too much the area relying on ambient texture to define their ambient occlusion.
  52967. */
  52968. useRadianceOcclusion: boolean;
  52969. /**
  52970. * If set to true, no lighting calculations will be applied.
  52971. */
  52972. unlit: boolean;
  52973. /**
  52974. * Gets the image processing configuration used either in this material.
  52975. */
  52976. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52977. /**
  52978. * Sets the Default image processing configuration used either in the this material.
  52979. *
  52980. * If sets to null, the scene one is in use.
  52981. */
  52982. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52983. /**
  52984. * Gets wether the color curves effect is enabled.
  52985. */
  52986. get cameraColorCurvesEnabled(): boolean;
  52987. /**
  52988. * Sets wether the color curves effect is enabled.
  52989. */
  52990. set cameraColorCurvesEnabled(value: boolean);
  52991. /**
  52992. * Gets wether the color grading effect is enabled.
  52993. */
  52994. get cameraColorGradingEnabled(): boolean;
  52995. /**
  52996. * Gets wether the color grading effect is enabled.
  52997. */
  52998. set cameraColorGradingEnabled(value: boolean);
  52999. /**
  53000. * Gets wether tonemapping is enabled or not.
  53001. */
  53002. get cameraToneMappingEnabled(): boolean;
  53003. /**
  53004. * Sets wether tonemapping is enabled or not
  53005. */
  53006. set cameraToneMappingEnabled(value: boolean);
  53007. /**
  53008. * The camera exposure used on this material.
  53009. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53010. * This corresponds to a photographic exposure.
  53011. */
  53012. get cameraExposure(): number;
  53013. /**
  53014. * The camera exposure used on this material.
  53015. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53016. * This corresponds to a photographic exposure.
  53017. */
  53018. set cameraExposure(value: number);
  53019. /**
  53020. * Gets The camera contrast used on this material.
  53021. */
  53022. get cameraContrast(): number;
  53023. /**
  53024. * Sets The camera contrast used on this material.
  53025. */
  53026. set cameraContrast(value: number);
  53027. /**
  53028. * Gets the Color Grading 2D Lookup Texture.
  53029. */
  53030. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  53031. /**
  53032. * Sets the Color Grading 2D Lookup Texture.
  53033. */
  53034. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  53035. /**
  53036. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53037. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53038. * 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;
  53039. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53040. */
  53041. get cameraColorCurves(): Nullable<ColorCurves>;
  53042. /**
  53043. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53044. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53045. * 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;
  53046. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53047. */
  53048. set cameraColorCurves(value: Nullable<ColorCurves>);
  53049. /**
  53050. * Instantiates a new PBRMaterial instance.
  53051. *
  53052. * @param name The material name
  53053. * @param scene The scene the material will be use in.
  53054. */
  53055. constructor(name: string, scene: Scene);
  53056. /**
  53057. * Returns the name of this material class.
  53058. */
  53059. getClassName(): string;
  53060. /**
  53061. * Makes a duplicate of the current material.
  53062. * @param name - name to use for the new material.
  53063. */
  53064. clone(name: string): PBRMaterial;
  53065. /**
  53066. * Serializes this PBR Material.
  53067. * @returns - An object with the serialized material.
  53068. */
  53069. serialize(): any;
  53070. /**
  53071. * Parses a PBR Material from a serialized object.
  53072. * @param source - Serialized object.
  53073. * @param scene - BJS scene instance.
  53074. * @param rootUrl - url for the scene object
  53075. * @returns - PBRMaterial
  53076. */
  53077. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  53078. }
  53079. }
  53080. declare module "babylonjs/Misc/dds" {
  53081. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53082. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53083. import { Nullable } from "babylonjs/types";
  53084. import { Scene } from "babylonjs/scene";
  53085. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  53086. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  53087. /**
  53088. * Direct draw surface info
  53089. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  53090. */
  53091. export interface DDSInfo {
  53092. /**
  53093. * Width of the texture
  53094. */
  53095. width: number;
  53096. /**
  53097. * Width of the texture
  53098. */
  53099. height: number;
  53100. /**
  53101. * Number of Mipmaps for the texture
  53102. * @see https://en.wikipedia.org/wiki/Mipmap
  53103. */
  53104. mipmapCount: number;
  53105. /**
  53106. * If the textures format is a known fourCC format
  53107. * @see https://www.fourcc.org/
  53108. */
  53109. isFourCC: boolean;
  53110. /**
  53111. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  53112. */
  53113. isRGB: boolean;
  53114. /**
  53115. * If the texture is a lumincance format
  53116. */
  53117. isLuminance: boolean;
  53118. /**
  53119. * If this is a cube texture
  53120. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  53121. */
  53122. isCube: boolean;
  53123. /**
  53124. * If the texture is a compressed format eg. FOURCC_DXT1
  53125. */
  53126. isCompressed: boolean;
  53127. /**
  53128. * The dxgiFormat of the texture
  53129. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  53130. */
  53131. dxgiFormat: number;
  53132. /**
  53133. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  53134. */
  53135. textureType: number;
  53136. /**
  53137. * Sphericle polynomial created for the dds texture
  53138. */
  53139. sphericalPolynomial?: SphericalPolynomial;
  53140. }
  53141. /**
  53142. * Class used to provide DDS decompression tools
  53143. */
  53144. export class DDSTools {
  53145. /**
  53146. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  53147. */
  53148. static StoreLODInAlphaChannel: boolean;
  53149. /**
  53150. * Gets DDS information from an array buffer
  53151. * @param arrayBuffer defines the array buffer to read data from
  53152. * @returns the DDS information
  53153. */
  53154. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  53155. private static _FloatView;
  53156. private static _Int32View;
  53157. private static _ToHalfFloat;
  53158. private static _FromHalfFloat;
  53159. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  53160. private static _GetHalfFloatRGBAArrayBuffer;
  53161. private static _GetFloatRGBAArrayBuffer;
  53162. private static _GetFloatAsUIntRGBAArrayBuffer;
  53163. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  53164. private static _GetRGBAArrayBuffer;
  53165. private static _ExtractLongWordOrder;
  53166. private static _GetRGBArrayBuffer;
  53167. private static _GetLuminanceArrayBuffer;
  53168. /**
  53169. * Uploads DDS Levels to a Babylon Texture
  53170. * @hidden
  53171. */
  53172. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  53173. }
  53174. module "babylonjs/Engines/thinEngine" {
  53175. interface ThinEngine {
  53176. /**
  53177. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  53178. * @param rootUrl defines the url where the file to load is located
  53179. * @param scene defines the current scene
  53180. * @param lodScale defines scale to apply to the mip map selection
  53181. * @param lodOffset defines offset to apply to the mip map selection
  53182. * @param onLoad defines an optional callback raised when the texture is loaded
  53183. * @param onError defines an optional callback raised if there is an issue to load the texture
  53184. * @param format defines the format of the data
  53185. * @param forcedExtension defines the extension to use to pick the right loader
  53186. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  53187. * @returns the cube texture as an InternalTexture
  53188. */
  53189. 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;
  53190. }
  53191. }
  53192. }
  53193. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  53194. import { Nullable } from "babylonjs/types";
  53195. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53196. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53197. /**
  53198. * Implementation of the DDS Texture Loader.
  53199. * @hidden
  53200. */
  53201. export class _DDSTextureLoader implements IInternalTextureLoader {
  53202. /**
  53203. * Defines wether the loader supports cascade loading the different faces.
  53204. */
  53205. readonly supportCascades: boolean;
  53206. /**
  53207. * This returns if the loader support the current file information.
  53208. * @param extension defines the file extension of the file being loaded
  53209. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53210. * @param fallback defines the fallback internal texture if any
  53211. * @param isBase64 defines whether the texture is encoded as a base64
  53212. * @param isBuffer defines whether the texture data are stored as a buffer
  53213. * @returns true if the loader can load the specified file
  53214. */
  53215. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53216. /**
  53217. * Transform the url before loading if required.
  53218. * @param rootUrl the url of the texture
  53219. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53220. * @returns the transformed texture
  53221. */
  53222. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53223. /**
  53224. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53225. * @param rootUrl the url of the texture
  53226. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53227. * @returns the fallback texture
  53228. */
  53229. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53230. /**
  53231. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53232. * @param data contains the texture data
  53233. * @param texture defines the BabylonJS internal texture
  53234. * @param createPolynomials will be true if polynomials have been requested
  53235. * @param onLoad defines the callback to trigger once the texture is ready
  53236. * @param onError defines the callback to trigger in case of error
  53237. */
  53238. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53239. /**
  53240. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53241. * @param data contains the texture data
  53242. * @param texture defines the BabylonJS internal texture
  53243. * @param callback defines the method to call once ready to upload
  53244. */
  53245. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53246. }
  53247. }
  53248. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  53249. import { Nullable } from "babylonjs/types";
  53250. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53251. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53252. /**
  53253. * Implementation of the ENV Texture Loader.
  53254. * @hidden
  53255. */
  53256. export class _ENVTextureLoader implements IInternalTextureLoader {
  53257. /**
  53258. * Defines wether the loader supports cascade loading the different faces.
  53259. */
  53260. readonly supportCascades: boolean;
  53261. /**
  53262. * This returns if the loader support the current file information.
  53263. * @param extension defines the file extension of the file being loaded
  53264. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53265. * @param fallback defines the fallback internal texture if any
  53266. * @param isBase64 defines whether the texture is encoded as a base64
  53267. * @param isBuffer defines whether the texture data are stored as a buffer
  53268. * @returns true if the loader can load the specified file
  53269. */
  53270. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53271. /**
  53272. * Transform the url before loading if required.
  53273. * @param rootUrl the url of the texture
  53274. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53275. * @returns the transformed texture
  53276. */
  53277. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53278. /**
  53279. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53280. * @param rootUrl the url of the texture
  53281. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53282. * @returns the fallback texture
  53283. */
  53284. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53285. /**
  53286. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53287. * @param data contains the texture data
  53288. * @param texture defines the BabylonJS internal texture
  53289. * @param createPolynomials will be true if polynomials have been requested
  53290. * @param onLoad defines the callback to trigger once the texture is ready
  53291. * @param onError defines the callback to trigger in case of error
  53292. */
  53293. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53294. /**
  53295. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53296. * @param data contains the texture data
  53297. * @param texture defines the BabylonJS internal texture
  53298. * @param callback defines the method to call once ready to upload
  53299. */
  53300. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53301. }
  53302. }
  53303. declare module "babylonjs/Misc/khronosTextureContainer" {
  53304. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53305. /**
  53306. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  53307. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  53308. */
  53309. export class KhronosTextureContainer {
  53310. /** contents of the KTX container file */
  53311. arrayBuffer: any;
  53312. private static HEADER_LEN;
  53313. private static COMPRESSED_2D;
  53314. private static COMPRESSED_3D;
  53315. private static TEX_2D;
  53316. private static TEX_3D;
  53317. /**
  53318. * Gets the openGL type
  53319. */
  53320. glType: number;
  53321. /**
  53322. * Gets the openGL type size
  53323. */
  53324. glTypeSize: number;
  53325. /**
  53326. * Gets the openGL format
  53327. */
  53328. glFormat: number;
  53329. /**
  53330. * Gets the openGL internal format
  53331. */
  53332. glInternalFormat: number;
  53333. /**
  53334. * Gets the base internal format
  53335. */
  53336. glBaseInternalFormat: number;
  53337. /**
  53338. * Gets image width in pixel
  53339. */
  53340. pixelWidth: number;
  53341. /**
  53342. * Gets image height in pixel
  53343. */
  53344. pixelHeight: number;
  53345. /**
  53346. * Gets image depth in pixels
  53347. */
  53348. pixelDepth: number;
  53349. /**
  53350. * Gets the number of array elements
  53351. */
  53352. numberOfArrayElements: number;
  53353. /**
  53354. * Gets the number of faces
  53355. */
  53356. numberOfFaces: number;
  53357. /**
  53358. * Gets the number of mipmap levels
  53359. */
  53360. numberOfMipmapLevels: number;
  53361. /**
  53362. * Gets the bytes of key value data
  53363. */
  53364. bytesOfKeyValueData: number;
  53365. /**
  53366. * Gets the load type
  53367. */
  53368. loadType: number;
  53369. /**
  53370. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  53371. */
  53372. isInvalid: boolean;
  53373. /**
  53374. * Creates a new KhronosTextureContainer
  53375. * @param arrayBuffer contents of the KTX container file
  53376. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  53377. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  53378. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  53379. */
  53380. constructor(
  53381. /** contents of the KTX container file */
  53382. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  53383. /**
  53384. * Uploads KTX content to a Babylon Texture.
  53385. * It is assumed that the texture has already been created & is currently bound
  53386. * @hidden
  53387. */
  53388. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  53389. private _upload2DCompressedLevels;
  53390. }
  53391. }
  53392. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  53393. import { Nullable } from "babylonjs/types";
  53394. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53395. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53396. /**
  53397. * Implementation of the KTX Texture Loader.
  53398. * @hidden
  53399. */
  53400. export class _KTXTextureLoader implements IInternalTextureLoader {
  53401. /**
  53402. * Defines wether the loader supports cascade loading the different faces.
  53403. */
  53404. readonly supportCascades: boolean;
  53405. /**
  53406. * This returns if the loader support the current file information.
  53407. * @param extension defines the file extension of the file being loaded
  53408. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53409. * @param fallback defines the fallback internal texture if any
  53410. * @param isBase64 defines whether the texture is encoded as a base64
  53411. * @param isBuffer defines whether the texture data are stored as a buffer
  53412. * @returns true if the loader can load the specified file
  53413. */
  53414. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53415. /**
  53416. * Transform the url before loading if required.
  53417. * @param rootUrl the url of the texture
  53418. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53419. * @returns the transformed texture
  53420. */
  53421. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53422. /**
  53423. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53424. * @param rootUrl the url of the texture
  53425. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53426. * @returns the fallback texture
  53427. */
  53428. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53429. /**
  53430. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53431. * @param data contains the texture data
  53432. * @param texture defines the BabylonJS internal texture
  53433. * @param createPolynomials will be true if polynomials have been requested
  53434. * @param onLoad defines the callback to trigger once the texture is ready
  53435. * @param onError defines the callback to trigger in case of error
  53436. */
  53437. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53438. /**
  53439. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53440. * @param data contains the texture data
  53441. * @param texture defines the BabylonJS internal texture
  53442. * @param callback defines the method to call once ready to upload
  53443. */
  53444. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  53445. }
  53446. }
  53447. declare module "babylonjs/Helpers/sceneHelpers" {
  53448. import { Nullable } from "babylonjs/types";
  53449. import { Mesh } from "babylonjs/Meshes/mesh";
  53450. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53451. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  53452. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  53453. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  53454. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  53455. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  53456. import "babylonjs/Meshes/Builders/boxBuilder";
  53457. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  53458. /** @hidden */
  53459. export var _forceSceneHelpersToBundle: boolean;
  53460. module "babylonjs/scene" {
  53461. interface Scene {
  53462. /**
  53463. * Creates a default light for the scene.
  53464. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  53465. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  53466. */
  53467. createDefaultLight(replace?: boolean): void;
  53468. /**
  53469. * Creates a default camera for the scene.
  53470. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  53471. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53472. * @param replace has default false, when true replaces the active camera in the scene
  53473. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  53474. */
  53475. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53476. /**
  53477. * Creates a default camera and a default light.
  53478. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  53479. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53480. * @param replace has the default false, when true replaces the active camera/light in the scene
  53481. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  53482. */
  53483. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53484. /**
  53485. * Creates a new sky box
  53486. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  53487. * @param environmentTexture defines the texture to use as environment texture
  53488. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  53489. * @param scale defines the overall scale of the skybox
  53490. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  53491. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  53492. * @returns a new mesh holding the sky box
  53493. */
  53494. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  53495. /**
  53496. * Creates a new environment
  53497. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  53498. * @param options defines the options you can use to configure the environment
  53499. * @returns the new EnvironmentHelper
  53500. */
  53501. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  53502. /**
  53503. * Creates a new VREXperienceHelper
  53504. * @see http://doc.babylonjs.com/how_to/webvr_helper
  53505. * @param webVROptions defines the options used to create the new VREXperienceHelper
  53506. * @returns a new VREXperienceHelper
  53507. */
  53508. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  53509. /**
  53510. * Creates a new WebXRDefaultExperience
  53511. * @see http://doc.babylonjs.com/how_to/webxr
  53512. * @param options experience options
  53513. * @returns a promise for a new WebXRDefaultExperience
  53514. */
  53515. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53516. }
  53517. }
  53518. }
  53519. declare module "babylonjs/Helpers/videoDome" {
  53520. import { Scene } from "babylonjs/scene";
  53521. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53522. import { Mesh } from "babylonjs/Meshes/mesh";
  53523. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  53524. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  53525. import "babylonjs/Meshes/Builders/sphereBuilder";
  53526. /**
  53527. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  53528. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  53529. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  53530. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53531. */
  53532. export class VideoDome extends TransformNode {
  53533. /**
  53534. * Define the video source as a Monoscopic panoramic 360 video.
  53535. */
  53536. static readonly MODE_MONOSCOPIC: number;
  53537. /**
  53538. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53539. */
  53540. static readonly MODE_TOPBOTTOM: number;
  53541. /**
  53542. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53543. */
  53544. static readonly MODE_SIDEBYSIDE: number;
  53545. private _halfDome;
  53546. private _useDirectMapping;
  53547. /**
  53548. * The video texture being displayed on the sphere
  53549. */
  53550. protected _videoTexture: VideoTexture;
  53551. /**
  53552. * Gets the video texture being displayed on the sphere
  53553. */
  53554. get videoTexture(): VideoTexture;
  53555. /**
  53556. * The skybox material
  53557. */
  53558. protected _material: BackgroundMaterial;
  53559. /**
  53560. * The surface used for the skybox
  53561. */
  53562. protected _mesh: Mesh;
  53563. /**
  53564. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  53565. */
  53566. private _halfDomeMask;
  53567. /**
  53568. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53569. * Also see the options.resolution property.
  53570. */
  53571. get fovMultiplier(): number;
  53572. set fovMultiplier(value: number);
  53573. private _videoMode;
  53574. /**
  53575. * Gets or set the current video mode for the video. It can be:
  53576. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  53577. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53578. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53579. */
  53580. get videoMode(): number;
  53581. set videoMode(value: number);
  53582. /**
  53583. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  53584. *
  53585. */
  53586. get halfDome(): boolean;
  53587. /**
  53588. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  53589. */
  53590. set halfDome(enabled: boolean);
  53591. /**
  53592. * Oberserver used in Stereoscopic VR Mode.
  53593. */
  53594. private _onBeforeCameraRenderObserver;
  53595. /**
  53596. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  53597. * @param name Element's name, child elements will append suffixes for their own names.
  53598. * @param urlsOrVideo defines the url(s) or the video element to use
  53599. * @param options An object containing optional or exposed sub element properties
  53600. */
  53601. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  53602. resolution?: number;
  53603. clickToPlay?: boolean;
  53604. autoPlay?: boolean;
  53605. loop?: boolean;
  53606. size?: number;
  53607. poster?: string;
  53608. faceForward?: boolean;
  53609. useDirectMapping?: boolean;
  53610. halfDomeMode?: boolean;
  53611. }, scene: Scene);
  53612. private _changeVideoMode;
  53613. /**
  53614. * Releases resources associated with this node.
  53615. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53616. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53617. */
  53618. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53619. }
  53620. }
  53621. declare module "babylonjs/Helpers/index" {
  53622. export * from "babylonjs/Helpers/environmentHelper";
  53623. export * from "babylonjs/Helpers/photoDome";
  53624. export * from "babylonjs/Helpers/sceneHelpers";
  53625. export * from "babylonjs/Helpers/videoDome";
  53626. }
  53627. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  53628. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  53629. import { IDisposable } from "babylonjs/scene";
  53630. import { Engine } from "babylonjs/Engines/engine";
  53631. /**
  53632. * This class can be used to get instrumentation data from a Babylon engine
  53633. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53634. */
  53635. export class EngineInstrumentation implements IDisposable {
  53636. /**
  53637. * Define the instrumented engine.
  53638. */
  53639. engine: Engine;
  53640. private _captureGPUFrameTime;
  53641. private _gpuFrameTimeToken;
  53642. private _gpuFrameTime;
  53643. private _captureShaderCompilationTime;
  53644. private _shaderCompilationTime;
  53645. private _onBeginFrameObserver;
  53646. private _onEndFrameObserver;
  53647. private _onBeforeShaderCompilationObserver;
  53648. private _onAfterShaderCompilationObserver;
  53649. /**
  53650. * Gets the perf counter used for GPU frame time
  53651. */
  53652. get gpuFrameTimeCounter(): PerfCounter;
  53653. /**
  53654. * Gets the GPU frame time capture status
  53655. */
  53656. get captureGPUFrameTime(): boolean;
  53657. /**
  53658. * Enable or disable the GPU frame time capture
  53659. */
  53660. set captureGPUFrameTime(value: boolean);
  53661. /**
  53662. * Gets the perf counter used for shader compilation time
  53663. */
  53664. get shaderCompilationTimeCounter(): PerfCounter;
  53665. /**
  53666. * Gets the shader compilation time capture status
  53667. */
  53668. get captureShaderCompilationTime(): boolean;
  53669. /**
  53670. * Enable or disable the shader compilation time capture
  53671. */
  53672. set captureShaderCompilationTime(value: boolean);
  53673. /**
  53674. * Instantiates a new engine instrumentation.
  53675. * This class can be used to get instrumentation data from a Babylon engine
  53676. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53677. * @param engine Defines the engine to instrument
  53678. */
  53679. constructor(
  53680. /**
  53681. * Define the instrumented engine.
  53682. */
  53683. engine: Engine);
  53684. /**
  53685. * Dispose and release associated resources.
  53686. */
  53687. dispose(): void;
  53688. }
  53689. }
  53690. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  53691. import { Scene, IDisposable } from "babylonjs/scene";
  53692. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  53693. /**
  53694. * This class can be used to get instrumentation data from a Babylon engine
  53695. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53696. */
  53697. export class SceneInstrumentation implements IDisposable {
  53698. /**
  53699. * Defines the scene to instrument
  53700. */
  53701. scene: Scene;
  53702. private _captureActiveMeshesEvaluationTime;
  53703. private _activeMeshesEvaluationTime;
  53704. private _captureRenderTargetsRenderTime;
  53705. private _renderTargetsRenderTime;
  53706. private _captureFrameTime;
  53707. private _frameTime;
  53708. private _captureRenderTime;
  53709. private _renderTime;
  53710. private _captureInterFrameTime;
  53711. private _interFrameTime;
  53712. private _captureParticlesRenderTime;
  53713. private _particlesRenderTime;
  53714. private _captureSpritesRenderTime;
  53715. private _spritesRenderTime;
  53716. private _capturePhysicsTime;
  53717. private _physicsTime;
  53718. private _captureAnimationsTime;
  53719. private _animationsTime;
  53720. private _captureCameraRenderTime;
  53721. private _cameraRenderTime;
  53722. private _onBeforeActiveMeshesEvaluationObserver;
  53723. private _onAfterActiveMeshesEvaluationObserver;
  53724. private _onBeforeRenderTargetsRenderObserver;
  53725. private _onAfterRenderTargetsRenderObserver;
  53726. private _onAfterRenderObserver;
  53727. private _onBeforeDrawPhaseObserver;
  53728. private _onAfterDrawPhaseObserver;
  53729. private _onBeforeAnimationsObserver;
  53730. private _onBeforeParticlesRenderingObserver;
  53731. private _onAfterParticlesRenderingObserver;
  53732. private _onBeforeSpritesRenderingObserver;
  53733. private _onAfterSpritesRenderingObserver;
  53734. private _onBeforePhysicsObserver;
  53735. private _onAfterPhysicsObserver;
  53736. private _onAfterAnimationsObserver;
  53737. private _onBeforeCameraRenderObserver;
  53738. private _onAfterCameraRenderObserver;
  53739. /**
  53740. * Gets the perf counter used for active meshes evaluation time
  53741. */
  53742. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  53743. /**
  53744. * Gets the active meshes evaluation time capture status
  53745. */
  53746. get captureActiveMeshesEvaluationTime(): boolean;
  53747. /**
  53748. * Enable or disable the active meshes evaluation time capture
  53749. */
  53750. set captureActiveMeshesEvaluationTime(value: boolean);
  53751. /**
  53752. * Gets the perf counter used for render targets render time
  53753. */
  53754. get renderTargetsRenderTimeCounter(): PerfCounter;
  53755. /**
  53756. * Gets the render targets render time capture status
  53757. */
  53758. get captureRenderTargetsRenderTime(): boolean;
  53759. /**
  53760. * Enable or disable the render targets render time capture
  53761. */
  53762. set captureRenderTargetsRenderTime(value: boolean);
  53763. /**
  53764. * Gets the perf counter used for particles render time
  53765. */
  53766. get particlesRenderTimeCounter(): PerfCounter;
  53767. /**
  53768. * Gets the particles render time capture status
  53769. */
  53770. get captureParticlesRenderTime(): boolean;
  53771. /**
  53772. * Enable or disable the particles render time capture
  53773. */
  53774. set captureParticlesRenderTime(value: boolean);
  53775. /**
  53776. * Gets the perf counter used for sprites render time
  53777. */
  53778. get spritesRenderTimeCounter(): PerfCounter;
  53779. /**
  53780. * Gets the sprites render time capture status
  53781. */
  53782. get captureSpritesRenderTime(): boolean;
  53783. /**
  53784. * Enable or disable the sprites render time capture
  53785. */
  53786. set captureSpritesRenderTime(value: boolean);
  53787. /**
  53788. * Gets the perf counter used for physics time
  53789. */
  53790. get physicsTimeCounter(): PerfCounter;
  53791. /**
  53792. * Gets the physics time capture status
  53793. */
  53794. get capturePhysicsTime(): boolean;
  53795. /**
  53796. * Enable or disable the physics time capture
  53797. */
  53798. set capturePhysicsTime(value: boolean);
  53799. /**
  53800. * Gets the perf counter used for animations time
  53801. */
  53802. get animationsTimeCounter(): PerfCounter;
  53803. /**
  53804. * Gets the animations time capture status
  53805. */
  53806. get captureAnimationsTime(): boolean;
  53807. /**
  53808. * Enable or disable the animations time capture
  53809. */
  53810. set captureAnimationsTime(value: boolean);
  53811. /**
  53812. * Gets the perf counter used for frame time capture
  53813. */
  53814. get frameTimeCounter(): PerfCounter;
  53815. /**
  53816. * Gets the frame time capture status
  53817. */
  53818. get captureFrameTime(): boolean;
  53819. /**
  53820. * Enable or disable the frame time capture
  53821. */
  53822. set captureFrameTime(value: boolean);
  53823. /**
  53824. * Gets the perf counter used for inter-frames time capture
  53825. */
  53826. get interFrameTimeCounter(): PerfCounter;
  53827. /**
  53828. * Gets the inter-frames time capture status
  53829. */
  53830. get captureInterFrameTime(): boolean;
  53831. /**
  53832. * Enable or disable the inter-frames time capture
  53833. */
  53834. set captureInterFrameTime(value: boolean);
  53835. /**
  53836. * Gets the perf counter used for render time capture
  53837. */
  53838. get renderTimeCounter(): PerfCounter;
  53839. /**
  53840. * Gets the render time capture status
  53841. */
  53842. get captureRenderTime(): boolean;
  53843. /**
  53844. * Enable or disable the render time capture
  53845. */
  53846. set captureRenderTime(value: boolean);
  53847. /**
  53848. * Gets the perf counter used for camera render time capture
  53849. */
  53850. get cameraRenderTimeCounter(): PerfCounter;
  53851. /**
  53852. * Gets the camera render time capture status
  53853. */
  53854. get captureCameraRenderTime(): boolean;
  53855. /**
  53856. * Enable or disable the camera render time capture
  53857. */
  53858. set captureCameraRenderTime(value: boolean);
  53859. /**
  53860. * Gets the perf counter used for draw calls
  53861. */
  53862. get drawCallsCounter(): PerfCounter;
  53863. /**
  53864. * Instantiates a new scene instrumentation.
  53865. * This class can be used to get instrumentation data from a Babylon engine
  53866. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53867. * @param scene Defines the scene to instrument
  53868. */
  53869. constructor(
  53870. /**
  53871. * Defines the scene to instrument
  53872. */
  53873. scene: Scene);
  53874. /**
  53875. * Dispose and release associated resources.
  53876. */
  53877. dispose(): void;
  53878. }
  53879. }
  53880. declare module "babylonjs/Instrumentation/index" {
  53881. export * from "babylonjs/Instrumentation/engineInstrumentation";
  53882. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  53883. export * from "babylonjs/Instrumentation/timeToken";
  53884. }
  53885. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  53886. /** @hidden */
  53887. export var glowMapGenerationPixelShader: {
  53888. name: string;
  53889. shader: string;
  53890. };
  53891. }
  53892. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  53893. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53894. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  53895. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  53896. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53897. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  53898. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53899. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53900. /** @hidden */
  53901. export var glowMapGenerationVertexShader: {
  53902. name: string;
  53903. shader: string;
  53904. };
  53905. }
  53906. declare module "babylonjs/Layers/effectLayer" {
  53907. import { Observable } from "babylonjs/Misc/observable";
  53908. import { Nullable } from "babylonjs/types";
  53909. import { Camera } from "babylonjs/Cameras/camera";
  53910. import { Scene } from "babylonjs/scene";
  53911. import { ISize } from "babylonjs/Maths/math.size";
  53912. import { Color4 } from "babylonjs/Maths/math.color";
  53913. import { Engine } from "babylonjs/Engines/engine";
  53914. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53915. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53916. import { Mesh } from "babylonjs/Meshes/mesh";
  53917. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53918. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53919. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53920. import { Effect } from "babylonjs/Materials/effect";
  53921. import { Material } from "babylonjs/Materials/material";
  53922. import "babylonjs/Shaders/glowMapGeneration.fragment";
  53923. import "babylonjs/Shaders/glowMapGeneration.vertex";
  53924. /**
  53925. * Effect layer options. This helps customizing the behaviour
  53926. * of the effect layer.
  53927. */
  53928. export interface IEffectLayerOptions {
  53929. /**
  53930. * Multiplication factor apply to the canvas size to compute the render target size
  53931. * used to generated the objects (the smaller the faster).
  53932. */
  53933. mainTextureRatio: number;
  53934. /**
  53935. * Enforces a fixed size texture to ensure effect stability across devices.
  53936. */
  53937. mainTextureFixedSize?: number;
  53938. /**
  53939. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53940. */
  53941. alphaBlendingMode: number;
  53942. /**
  53943. * The camera attached to the layer.
  53944. */
  53945. camera: Nullable<Camera>;
  53946. /**
  53947. * The rendering group to draw the layer in.
  53948. */
  53949. renderingGroupId: number;
  53950. }
  53951. /**
  53952. * The effect layer Helps adding post process effect blended with the main pass.
  53953. *
  53954. * This can be for instance use to generate glow or higlight effects on the scene.
  53955. *
  53956. * The effect layer class can not be used directly and is intented to inherited from to be
  53957. * customized per effects.
  53958. */
  53959. export abstract class EffectLayer {
  53960. private _vertexBuffers;
  53961. private _indexBuffer;
  53962. private _cachedDefines;
  53963. private _effectLayerMapGenerationEffect;
  53964. private _effectLayerOptions;
  53965. private _mergeEffect;
  53966. protected _scene: Scene;
  53967. protected _engine: Engine;
  53968. protected _maxSize: number;
  53969. protected _mainTextureDesiredSize: ISize;
  53970. protected _mainTexture: RenderTargetTexture;
  53971. protected _shouldRender: boolean;
  53972. protected _postProcesses: PostProcess[];
  53973. protected _textures: BaseTexture[];
  53974. protected _emissiveTextureAndColor: {
  53975. texture: Nullable<BaseTexture>;
  53976. color: Color4;
  53977. };
  53978. /**
  53979. * The name of the layer
  53980. */
  53981. name: string;
  53982. /**
  53983. * The clear color of the texture used to generate the glow map.
  53984. */
  53985. neutralColor: Color4;
  53986. /**
  53987. * Specifies wether the highlight layer is enabled or not.
  53988. */
  53989. isEnabled: boolean;
  53990. /**
  53991. * Gets the camera attached to the layer.
  53992. */
  53993. get camera(): Nullable<Camera>;
  53994. /**
  53995. * Gets the rendering group id the layer should render in.
  53996. */
  53997. get renderingGroupId(): number;
  53998. set renderingGroupId(renderingGroupId: number);
  53999. /**
  54000. * An event triggered when the effect layer has been disposed.
  54001. */
  54002. onDisposeObservable: Observable<EffectLayer>;
  54003. /**
  54004. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  54005. */
  54006. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  54007. /**
  54008. * An event triggered when the generated texture is being merged in the scene.
  54009. */
  54010. onBeforeComposeObservable: Observable<EffectLayer>;
  54011. /**
  54012. * An event triggered when the mesh is rendered into the effect render target.
  54013. */
  54014. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  54015. /**
  54016. * An event triggered after the mesh has been rendered into the effect render target.
  54017. */
  54018. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  54019. /**
  54020. * An event triggered when the generated texture has been merged in the scene.
  54021. */
  54022. onAfterComposeObservable: Observable<EffectLayer>;
  54023. /**
  54024. * An event triggered when the efffect layer changes its size.
  54025. */
  54026. onSizeChangedObservable: Observable<EffectLayer>;
  54027. /** @hidden */
  54028. static _SceneComponentInitialization: (scene: Scene) => void;
  54029. /**
  54030. * Instantiates a new effect Layer and references it in the scene.
  54031. * @param name The name of the layer
  54032. * @param scene The scene to use the layer in
  54033. */
  54034. constructor(
  54035. /** The Friendly of the effect in the scene */
  54036. name: string, scene: Scene);
  54037. /**
  54038. * Get the effect name of the layer.
  54039. * @return The effect name
  54040. */
  54041. abstract getEffectName(): string;
  54042. /**
  54043. * Checks for the readiness of the element composing the layer.
  54044. * @param subMesh the mesh to check for
  54045. * @param useInstances specify wether or not to use instances to render the mesh
  54046. * @return true if ready otherwise, false
  54047. */
  54048. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54049. /**
  54050. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54051. * @returns true if the effect requires stencil during the main canvas render pass.
  54052. */
  54053. abstract needStencil(): boolean;
  54054. /**
  54055. * Create the merge effect. This is the shader use to blit the information back
  54056. * to the main canvas at the end of the scene rendering.
  54057. * @returns The effect containing the shader used to merge the effect on the main canvas
  54058. */
  54059. protected abstract _createMergeEffect(): Effect;
  54060. /**
  54061. * Creates the render target textures and post processes used in the effect layer.
  54062. */
  54063. protected abstract _createTextureAndPostProcesses(): void;
  54064. /**
  54065. * Implementation specific of rendering the generating effect on the main canvas.
  54066. * @param effect The effect used to render through
  54067. */
  54068. protected abstract _internalRender(effect: Effect): void;
  54069. /**
  54070. * Sets the required values for both the emissive texture and and the main color.
  54071. */
  54072. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54073. /**
  54074. * Free any resources and references associated to a mesh.
  54075. * Internal use
  54076. * @param mesh The mesh to free.
  54077. */
  54078. abstract _disposeMesh(mesh: Mesh): void;
  54079. /**
  54080. * Serializes this layer (Glow or Highlight for example)
  54081. * @returns a serialized layer object
  54082. */
  54083. abstract serialize?(): any;
  54084. /**
  54085. * Initializes the effect layer with the required options.
  54086. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  54087. */
  54088. protected _init(options: Partial<IEffectLayerOptions>): void;
  54089. /**
  54090. * Generates the index buffer of the full screen quad blending to the main canvas.
  54091. */
  54092. private _generateIndexBuffer;
  54093. /**
  54094. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  54095. */
  54096. private _generateVertexBuffer;
  54097. /**
  54098. * Sets the main texture desired size which is the closest power of two
  54099. * of the engine canvas size.
  54100. */
  54101. private _setMainTextureSize;
  54102. /**
  54103. * Creates the main texture for the effect layer.
  54104. */
  54105. protected _createMainTexture(): void;
  54106. /**
  54107. * Adds specific effects defines.
  54108. * @param defines The defines to add specifics to.
  54109. */
  54110. protected _addCustomEffectDefines(defines: string[]): void;
  54111. /**
  54112. * Checks for the readiness of the element composing the layer.
  54113. * @param subMesh the mesh to check for
  54114. * @param useInstances specify wether or not to use instances to render the mesh
  54115. * @param emissiveTexture the associated emissive texture used to generate the glow
  54116. * @return true if ready otherwise, false
  54117. */
  54118. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  54119. /**
  54120. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  54121. */
  54122. render(): void;
  54123. /**
  54124. * Determine if a given mesh will be used in the current effect.
  54125. * @param mesh mesh to test
  54126. * @returns true if the mesh will be used
  54127. */
  54128. hasMesh(mesh: AbstractMesh): boolean;
  54129. /**
  54130. * Returns true if the layer contains information to display, otherwise false.
  54131. * @returns true if the glow layer should be rendered
  54132. */
  54133. shouldRender(): boolean;
  54134. /**
  54135. * Returns true if the mesh should render, otherwise false.
  54136. * @param mesh The mesh to render
  54137. * @returns true if it should render otherwise false
  54138. */
  54139. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  54140. /**
  54141. * Returns true if the mesh can be rendered, otherwise false.
  54142. * @param mesh The mesh to render
  54143. * @param material The material used on the mesh
  54144. * @returns true if it can be rendered otherwise false
  54145. */
  54146. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  54147. /**
  54148. * Returns true if the mesh should render, otherwise false.
  54149. * @param mesh The mesh to render
  54150. * @returns true if it should render otherwise false
  54151. */
  54152. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  54153. /**
  54154. * Renders the submesh passed in parameter to the generation map.
  54155. */
  54156. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  54157. /**
  54158. * Defines wether the current material of the mesh should be use to render the effect.
  54159. * @param mesh defines the current mesh to render
  54160. */
  54161. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  54162. /**
  54163. * Rebuild the required buffers.
  54164. * @hidden Internal use only.
  54165. */
  54166. _rebuild(): void;
  54167. /**
  54168. * Dispose only the render target textures and post process.
  54169. */
  54170. private _disposeTextureAndPostProcesses;
  54171. /**
  54172. * Dispose the highlight layer and free resources.
  54173. */
  54174. dispose(): void;
  54175. /**
  54176. * Gets the class name of the effect layer
  54177. * @returns the string with the class name of the effect layer
  54178. */
  54179. getClassName(): string;
  54180. /**
  54181. * Creates an effect layer from parsed effect layer data
  54182. * @param parsedEffectLayer defines effect layer data
  54183. * @param scene defines the current scene
  54184. * @param rootUrl defines the root URL containing the effect layer information
  54185. * @returns a parsed effect Layer
  54186. */
  54187. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  54188. }
  54189. }
  54190. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  54191. import { Scene } from "babylonjs/scene";
  54192. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  54193. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  54194. import { AbstractScene } from "babylonjs/abstractScene";
  54195. module "babylonjs/abstractScene" {
  54196. interface AbstractScene {
  54197. /**
  54198. * The list of effect layers (highlights/glow) added to the scene
  54199. * @see http://doc.babylonjs.com/how_to/highlight_layer
  54200. * @see http://doc.babylonjs.com/how_to/glow_layer
  54201. */
  54202. effectLayers: Array<EffectLayer>;
  54203. /**
  54204. * Removes the given effect layer from this scene.
  54205. * @param toRemove defines the effect layer to remove
  54206. * @returns the index of the removed effect layer
  54207. */
  54208. removeEffectLayer(toRemove: EffectLayer): number;
  54209. /**
  54210. * Adds the given effect layer to this scene
  54211. * @param newEffectLayer defines the effect layer to add
  54212. */
  54213. addEffectLayer(newEffectLayer: EffectLayer): void;
  54214. }
  54215. }
  54216. /**
  54217. * Defines the layer scene component responsible to manage any effect layers
  54218. * in a given scene.
  54219. */
  54220. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  54221. /**
  54222. * The component name helpfull to identify the component in the list of scene components.
  54223. */
  54224. readonly name: string;
  54225. /**
  54226. * The scene the component belongs to.
  54227. */
  54228. scene: Scene;
  54229. private _engine;
  54230. private _renderEffects;
  54231. private _needStencil;
  54232. private _previousStencilState;
  54233. /**
  54234. * Creates a new instance of the component for the given scene
  54235. * @param scene Defines the scene to register the component in
  54236. */
  54237. constructor(scene: Scene);
  54238. /**
  54239. * Registers the component in a given scene
  54240. */
  54241. register(): void;
  54242. /**
  54243. * Rebuilds the elements related to this component in case of
  54244. * context lost for instance.
  54245. */
  54246. rebuild(): void;
  54247. /**
  54248. * Serializes the component data to the specified json object
  54249. * @param serializationObject The object to serialize to
  54250. */
  54251. serialize(serializationObject: any): void;
  54252. /**
  54253. * Adds all the elements from the container to the scene
  54254. * @param container the container holding the elements
  54255. */
  54256. addFromContainer(container: AbstractScene): void;
  54257. /**
  54258. * Removes all the elements in the container from the scene
  54259. * @param container contains the elements to remove
  54260. * @param dispose if the removed element should be disposed (default: false)
  54261. */
  54262. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54263. /**
  54264. * Disposes the component and the associated ressources.
  54265. */
  54266. dispose(): void;
  54267. private _isReadyForMesh;
  54268. private _renderMainTexture;
  54269. private _setStencil;
  54270. private _setStencilBack;
  54271. private _draw;
  54272. private _drawCamera;
  54273. private _drawRenderingGroup;
  54274. }
  54275. }
  54276. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  54277. /** @hidden */
  54278. export var glowMapMergePixelShader: {
  54279. name: string;
  54280. shader: string;
  54281. };
  54282. }
  54283. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  54284. /** @hidden */
  54285. export var glowMapMergeVertexShader: {
  54286. name: string;
  54287. shader: string;
  54288. };
  54289. }
  54290. declare module "babylonjs/Layers/glowLayer" {
  54291. import { Nullable } from "babylonjs/types";
  54292. import { Camera } from "babylonjs/Cameras/camera";
  54293. import { Scene } from "babylonjs/scene";
  54294. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54296. import { Mesh } from "babylonjs/Meshes/mesh";
  54297. import { Texture } from "babylonjs/Materials/Textures/texture";
  54298. import { Effect } from "babylonjs/Materials/effect";
  54299. import { Material } from "babylonjs/Materials/material";
  54300. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  54301. import { Color4 } from "babylonjs/Maths/math.color";
  54302. import "babylonjs/Shaders/glowMapMerge.fragment";
  54303. import "babylonjs/Shaders/glowMapMerge.vertex";
  54304. import "babylonjs/Layers/effectLayerSceneComponent";
  54305. module "babylonjs/abstractScene" {
  54306. interface AbstractScene {
  54307. /**
  54308. * Return a the first highlight layer of the scene with a given name.
  54309. * @param name The name of the highlight layer to look for.
  54310. * @return The highlight layer if found otherwise null.
  54311. */
  54312. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  54313. }
  54314. }
  54315. /**
  54316. * Glow layer options. This helps customizing the behaviour
  54317. * of the glow layer.
  54318. */
  54319. export interface IGlowLayerOptions {
  54320. /**
  54321. * Multiplication factor apply to the canvas size to compute the render target size
  54322. * used to generated the glowing objects (the smaller the faster).
  54323. */
  54324. mainTextureRatio: number;
  54325. /**
  54326. * Enforces a fixed size texture to ensure resize independant blur.
  54327. */
  54328. mainTextureFixedSize?: number;
  54329. /**
  54330. * How big is the kernel of the blur texture.
  54331. */
  54332. blurKernelSize: number;
  54333. /**
  54334. * The camera attached to the layer.
  54335. */
  54336. camera: Nullable<Camera>;
  54337. /**
  54338. * Enable MSAA by chosing the number of samples.
  54339. */
  54340. mainTextureSamples?: number;
  54341. /**
  54342. * The rendering group to draw the layer in.
  54343. */
  54344. renderingGroupId: number;
  54345. }
  54346. /**
  54347. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  54348. *
  54349. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  54350. *
  54351. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  54352. */
  54353. export class GlowLayer extends EffectLayer {
  54354. /**
  54355. * Effect Name of the layer.
  54356. */
  54357. static readonly EffectName: string;
  54358. /**
  54359. * The default blur kernel size used for the glow.
  54360. */
  54361. static DefaultBlurKernelSize: number;
  54362. /**
  54363. * The default texture size ratio used for the glow.
  54364. */
  54365. static DefaultTextureRatio: number;
  54366. /**
  54367. * Sets the kernel size of the blur.
  54368. */
  54369. set blurKernelSize(value: number);
  54370. /**
  54371. * Gets the kernel size of the blur.
  54372. */
  54373. get blurKernelSize(): number;
  54374. /**
  54375. * Sets the glow intensity.
  54376. */
  54377. set intensity(value: number);
  54378. /**
  54379. * Gets the glow intensity.
  54380. */
  54381. get intensity(): number;
  54382. private _options;
  54383. private _intensity;
  54384. private _horizontalBlurPostprocess1;
  54385. private _verticalBlurPostprocess1;
  54386. private _horizontalBlurPostprocess2;
  54387. private _verticalBlurPostprocess2;
  54388. private _blurTexture1;
  54389. private _blurTexture2;
  54390. private _postProcesses1;
  54391. private _postProcesses2;
  54392. private _includedOnlyMeshes;
  54393. private _excludedMeshes;
  54394. private _meshesUsingTheirOwnMaterials;
  54395. /**
  54396. * Callback used to let the user override the color selection on a per mesh basis
  54397. */
  54398. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  54399. /**
  54400. * Callback used to let the user override the texture selection on a per mesh basis
  54401. */
  54402. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  54403. /**
  54404. * Instantiates a new glow Layer and references it to the scene.
  54405. * @param name The name of the layer
  54406. * @param scene The scene to use the layer in
  54407. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  54408. */
  54409. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  54410. /**
  54411. * Get the effect name of the layer.
  54412. * @return The effect name
  54413. */
  54414. getEffectName(): string;
  54415. /**
  54416. * Create the merge effect. This is the shader use to blit the information back
  54417. * to the main canvas at the end of the scene rendering.
  54418. */
  54419. protected _createMergeEffect(): Effect;
  54420. /**
  54421. * Creates the render target textures and post processes used in the glow layer.
  54422. */
  54423. protected _createTextureAndPostProcesses(): void;
  54424. /**
  54425. * Checks for the readiness of the element composing the layer.
  54426. * @param subMesh the mesh to check for
  54427. * @param useInstances specify wether or not to use instances to render the mesh
  54428. * @param emissiveTexture the associated emissive texture used to generate the glow
  54429. * @return true if ready otherwise, false
  54430. */
  54431. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54432. /**
  54433. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54434. */
  54435. needStencil(): boolean;
  54436. /**
  54437. * Returns true if the mesh can be rendered, otherwise false.
  54438. * @param mesh The mesh to render
  54439. * @param material The material used on the mesh
  54440. * @returns true if it can be rendered otherwise false
  54441. */
  54442. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  54443. /**
  54444. * Implementation specific of rendering the generating effect on the main canvas.
  54445. * @param effect The effect used to render through
  54446. */
  54447. protected _internalRender(effect: Effect): void;
  54448. /**
  54449. * Sets the required values for both the emissive texture and and the main color.
  54450. */
  54451. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54452. /**
  54453. * Returns true if the mesh should render, otherwise false.
  54454. * @param mesh The mesh to render
  54455. * @returns true if it should render otherwise false
  54456. */
  54457. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54458. /**
  54459. * Adds specific effects defines.
  54460. * @param defines The defines to add specifics to.
  54461. */
  54462. protected _addCustomEffectDefines(defines: string[]): void;
  54463. /**
  54464. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  54465. * @param mesh The mesh to exclude from the glow layer
  54466. */
  54467. addExcludedMesh(mesh: Mesh): void;
  54468. /**
  54469. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  54470. * @param mesh The mesh to remove
  54471. */
  54472. removeExcludedMesh(mesh: Mesh): void;
  54473. /**
  54474. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  54475. * @param mesh The mesh to include in the glow layer
  54476. */
  54477. addIncludedOnlyMesh(mesh: Mesh): void;
  54478. /**
  54479. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  54480. * @param mesh The mesh to remove
  54481. */
  54482. removeIncludedOnlyMesh(mesh: Mesh): void;
  54483. /**
  54484. * Determine if a given mesh will be used in the glow layer
  54485. * @param mesh The mesh to test
  54486. * @returns true if the mesh will be highlighted by the current glow layer
  54487. */
  54488. hasMesh(mesh: AbstractMesh): boolean;
  54489. /**
  54490. * Defines wether the current material of the mesh should be use to render the effect.
  54491. * @param mesh defines the current mesh to render
  54492. */
  54493. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  54494. /**
  54495. * Add a mesh to be rendered through its own material and not with emissive only.
  54496. * @param mesh The mesh for which we need to use its material
  54497. */
  54498. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  54499. /**
  54500. * Remove a mesh from being rendered through its own material and not with emissive only.
  54501. * @param mesh The mesh for which we need to not use its material
  54502. */
  54503. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  54504. /**
  54505. * Free any resources and references associated to a mesh.
  54506. * Internal use
  54507. * @param mesh The mesh to free.
  54508. * @hidden
  54509. */
  54510. _disposeMesh(mesh: Mesh): void;
  54511. /**
  54512. * Gets the class name of the effect layer
  54513. * @returns the string with the class name of the effect layer
  54514. */
  54515. getClassName(): string;
  54516. /**
  54517. * Serializes this glow layer
  54518. * @returns a serialized glow layer object
  54519. */
  54520. serialize(): any;
  54521. /**
  54522. * Creates a Glow Layer from parsed glow layer data
  54523. * @param parsedGlowLayer defines glow layer data
  54524. * @param scene defines the current scene
  54525. * @param rootUrl defines the root URL containing the glow layer information
  54526. * @returns a parsed Glow Layer
  54527. */
  54528. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  54529. }
  54530. }
  54531. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  54532. /** @hidden */
  54533. export var glowBlurPostProcessPixelShader: {
  54534. name: string;
  54535. shader: string;
  54536. };
  54537. }
  54538. declare module "babylonjs/Layers/highlightLayer" {
  54539. import { Observable } from "babylonjs/Misc/observable";
  54540. import { Nullable } from "babylonjs/types";
  54541. import { Camera } from "babylonjs/Cameras/camera";
  54542. import { Scene } from "babylonjs/scene";
  54543. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54545. import { Mesh } from "babylonjs/Meshes/mesh";
  54546. import { Effect } from "babylonjs/Materials/effect";
  54547. import { Material } from "babylonjs/Materials/material";
  54548. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  54549. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  54550. import "babylonjs/Shaders/glowMapMerge.fragment";
  54551. import "babylonjs/Shaders/glowMapMerge.vertex";
  54552. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  54553. module "babylonjs/abstractScene" {
  54554. interface AbstractScene {
  54555. /**
  54556. * Return a the first highlight layer of the scene with a given name.
  54557. * @param name The name of the highlight layer to look for.
  54558. * @return The highlight layer if found otherwise null.
  54559. */
  54560. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  54561. }
  54562. }
  54563. /**
  54564. * Highlight layer options. This helps customizing the behaviour
  54565. * of the highlight layer.
  54566. */
  54567. export interface IHighlightLayerOptions {
  54568. /**
  54569. * Multiplication factor apply to the canvas size to compute the render target size
  54570. * used to generated the glowing objects (the smaller the faster).
  54571. */
  54572. mainTextureRatio: number;
  54573. /**
  54574. * Enforces a fixed size texture to ensure resize independant blur.
  54575. */
  54576. mainTextureFixedSize?: number;
  54577. /**
  54578. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  54579. * of the picture to blur (the smaller the faster).
  54580. */
  54581. blurTextureSizeRatio: number;
  54582. /**
  54583. * How big in texel of the blur texture is the vertical blur.
  54584. */
  54585. blurVerticalSize: number;
  54586. /**
  54587. * How big in texel of the blur texture is the horizontal blur.
  54588. */
  54589. blurHorizontalSize: number;
  54590. /**
  54591. * Alpha blending mode used to apply the blur. Default is combine.
  54592. */
  54593. alphaBlendingMode: number;
  54594. /**
  54595. * The camera attached to the layer.
  54596. */
  54597. camera: Nullable<Camera>;
  54598. /**
  54599. * Should we display highlight as a solid stroke?
  54600. */
  54601. isStroke?: boolean;
  54602. /**
  54603. * The rendering group to draw the layer in.
  54604. */
  54605. renderingGroupId: number;
  54606. }
  54607. /**
  54608. * The highlight layer Helps adding a glow effect around a mesh.
  54609. *
  54610. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  54611. * glowy meshes to your scene.
  54612. *
  54613. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  54614. */
  54615. export class HighlightLayer extends EffectLayer {
  54616. name: string;
  54617. /**
  54618. * Effect Name of the highlight layer.
  54619. */
  54620. static readonly EffectName: string;
  54621. /**
  54622. * The neutral color used during the preparation of the glow effect.
  54623. * This is black by default as the blend operation is a blend operation.
  54624. */
  54625. static NeutralColor: Color4;
  54626. /**
  54627. * Stencil value used for glowing meshes.
  54628. */
  54629. static GlowingMeshStencilReference: number;
  54630. /**
  54631. * Stencil value used for the other meshes in the scene.
  54632. */
  54633. static NormalMeshStencilReference: number;
  54634. /**
  54635. * Specifies whether or not the inner glow is ACTIVE in the layer.
  54636. */
  54637. innerGlow: boolean;
  54638. /**
  54639. * Specifies whether or not the outer glow is ACTIVE in the layer.
  54640. */
  54641. outerGlow: boolean;
  54642. /**
  54643. * Specifies the horizontal size of the blur.
  54644. */
  54645. set blurHorizontalSize(value: number);
  54646. /**
  54647. * Specifies the vertical size of the blur.
  54648. */
  54649. set blurVerticalSize(value: number);
  54650. /**
  54651. * Gets the horizontal size of the blur.
  54652. */
  54653. get blurHorizontalSize(): number;
  54654. /**
  54655. * Gets the vertical size of the blur.
  54656. */
  54657. get blurVerticalSize(): number;
  54658. /**
  54659. * An event triggered when the highlight layer is being blurred.
  54660. */
  54661. onBeforeBlurObservable: Observable<HighlightLayer>;
  54662. /**
  54663. * An event triggered when the highlight layer has been blurred.
  54664. */
  54665. onAfterBlurObservable: Observable<HighlightLayer>;
  54666. private _instanceGlowingMeshStencilReference;
  54667. private _options;
  54668. private _downSamplePostprocess;
  54669. private _horizontalBlurPostprocess;
  54670. private _verticalBlurPostprocess;
  54671. private _blurTexture;
  54672. private _meshes;
  54673. private _excludedMeshes;
  54674. /**
  54675. * Instantiates a new highlight Layer and references it to the scene..
  54676. * @param name The name of the layer
  54677. * @param scene The scene to use the layer in
  54678. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  54679. */
  54680. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  54681. /**
  54682. * Get the effect name of the layer.
  54683. * @return The effect name
  54684. */
  54685. getEffectName(): string;
  54686. /**
  54687. * Create the merge effect. This is the shader use to blit the information back
  54688. * to the main canvas at the end of the scene rendering.
  54689. */
  54690. protected _createMergeEffect(): Effect;
  54691. /**
  54692. * Creates the render target textures and post processes used in the highlight layer.
  54693. */
  54694. protected _createTextureAndPostProcesses(): void;
  54695. /**
  54696. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54697. */
  54698. needStencil(): boolean;
  54699. /**
  54700. * Checks for the readiness of the element composing the layer.
  54701. * @param subMesh the mesh to check for
  54702. * @param useInstances specify wether or not to use instances to render the mesh
  54703. * @param emissiveTexture the associated emissive texture used to generate the glow
  54704. * @return true if ready otherwise, false
  54705. */
  54706. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54707. /**
  54708. * Implementation specific of rendering the generating effect on the main canvas.
  54709. * @param effect The effect used to render through
  54710. */
  54711. protected _internalRender(effect: Effect): void;
  54712. /**
  54713. * Returns true if the layer contains information to display, otherwise false.
  54714. */
  54715. shouldRender(): boolean;
  54716. /**
  54717. * Returns true if the mesh should render, otherwise false.
  54718. * @param mesh The mesh to render
  54719. * @returns true if it should render otherwise false
  54720. */
  54721. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54722. /**
  54723. * Sets the required values for both the emissive texture and and the main color.
  54724. */
  54725. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54726. /**
  54727. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  54728. * @param mesh The mesh to exclude from the highlight layer
  54729. */
  54730. addExcludedMesh(mesh: Mesh): void;
  54731. /**
  54732. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  54733. * @param mesh The mesh to highlight
  54734. */
  54735. removeExcludedMesh(mesh: Mesh): void;
  54736. /**
  54737. * Determine if a given mesh will be highlighted by the current HighlightLayer
  54738. * @param mesh mesh to test
  54739. * @returns true if the mesh will be highlighted by the current HighlightLayer
  54740. */
  54741. hasMesh(mesh: AbstractMesh): boolean;
  54742. /**
  54743. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  54744. * @param mesh The mesh to highlight
  54745. * @param color The color of the highlight
  54746. * @param glowEmissiveOnly Extract the glow from the emissive texture
  54747. */
  54748. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  54749. /**
  54750. * Remove a mesh from the highlight layer in order to make it stop glowing.
  54751. * @param mesh The mesh to highlight
  54752. */
  54753. removeMesh(mesh: Mesh): void;
  54754. /**
  54755. * Force the stencil to the normal expected value for none glowing parts
  54756. */
  54757. private _defaultStencilReference;
  54758. /**
  54759. * Free any resources and references associated to a mesh.
  54760. * Internal use
  54761. * @param mesh The mesh to free.
  54762. * @hidden
  54763. */
  54764. _disposeMesh(mesh: Mesh): void;
  54765. /**
  54766. * Dispose the highlight layer and free resources.
  54767. */
  54768. dispose(): void;
  54769. /**
  54770. * Gets the class name of the effect layer
  54771. * @returns the string with the class name of the effect layer
  54772. */
  54773. getClassName(): string;
  54774. /**
  54775. * Serializes this Highlight layer
  54776. * @returns a serialized Highlight layer object
  54777. */
  54778. serialize(): any;
  54779. /**
  54780. * Creates a Highlight layer from parsed Highlight layer data
  54781. * @param parsedHightlightLayer defines the Highlight layer data
  54782. * @param scene defines the current scene
  54783. * @param rootUrl defines the root URL containing the Highlight layer information
  54784. * @returns a parsed Highlight layer
  54785. */
  54786. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  54787. }
  54788. }
  54789. declare module "babylonjs/Layers/layerSceneComponent" {
  54790. import { Scene } from "babylonjs/scene";
  54791. import { ISceneComponent } from "babylonjs/sceneComponent";
  54792. import { Layer } from "babylonjs/Layers/layer";
  54793. import { AbstractScene } from "babylonjs/abstractScene";
  54794. module "babylonjs/abstractScene" {
  54795. interface AbstractScene {
  54796. /**
  54797. * The list of layers (background and foreground) of the scene
  54798. */
  54799. layers: Array<Layer>;
  54800. }
  54801. }
  54802. /**
  54803. * Defines the layer scene component responsible to manage any layers
  54804. * in a given scene.
  54805. */
  54806. export class LayerSceneComponent implements ISceneComponent {
  54807. /**
  54808. * The component name helpfull to identify the component in the list of scene components.
  54809. */
  54810. readonly name: string;
  54811. /**
  54812. * The scene the component belongs to.
  54813. */
  54814. scene: Scene;
  54815. private _engine;
  54816. /**
  54817. * Creates a new instance of the component for the given scene
  54818. * @param scene Defines the scene to register the component in
  54819. */
  54820. constructor(scene: Scene);
  54821. /**
  54822. * Registers the component in a given scene
  54823. */
  54824. register(): void;
  54825. /**
  54826. * Rebuilds the elements related to this component in case of
  54827. * context lost for instance.
  54828. */
  54829. rebuild(): void;
  54830. /**
  54831. * Disposes the component and the associated ressources.
  54832. */
  54833. dispose(): void;
  54834. private _draw;
  54835. private _drawCameraPredicate;
  54836. private _drawCameraBackground;
  54837. private _drawCameraForeground;
  54838. private _drawRenderTargetPredicate;
  54839. private _drawRenderTargetBackground;
  54840. private _drawRenderTargetForeground;
  54841. /**
  54842. * Adds all the elements from the container to the scene
  54843. * @param container the container holding the elements
  54844. */
  54845. addFromContainer(container: AbstractScene): void;
  54846. /**
  54847. * Removes all the elements in the container from the scene
  54848. * @param container contains the elements to remove
  54849. * @param dispose if the removed element should be disposed (default: false)
  54850. */
  54851. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54852. }
  54853. }
  54854. declare module "babylonjs/Shaders/layer.fragment" {
  54855. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54856. /** @hidden */
  54857. export var layerPixelShader: {
  54858. name: string;
  54859. shader: string;
  54860. };
  54861. }
  54862. declare module "babylonjs/Shaders/layer.vertex" {
  54863. /** @hidden */
  54864. export var layerVertexShader: {
  54865. name: string;
  54866. shader: string;
  54867. };
  54868. }
  54869. declare module "babylonjs/Layers/layer" {
  54870. import { Observable } from "babylonjs/Misc/observable";
  54871. import { Nullable } from "babylonjs/types";
  54872. import { Scene } from "babylonjs/scene";
  54873. import { Vector2 } from "babylonjs/Maths/math.vector";
  54874. import { Color4 } from "babylonjs/Maths/math.color";
  54875. import { Texture } from "babylonjs/Materials/Textures/texture";
  54876. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54877. import "babylonjs/Shaders/layer.fragment";
  54878. import "babylonjs/Shaders/layer.vertex";
  54879. /**
  54880. * This represents a full screen 2d layer.
  54881. * This can be useful to display a picture in the background of your scene for instance.
  54882. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54883. */
  54884. export class Layer {
  54885. /**
  54886. * Define the name of the layer.
  54887. */
  54888. name: string;
  54889. /**
  54890. * Define the texture the layer should display.
  54891. */
  54892. texture: Nullable<Texture>;
  54893. /**
  54894. * Is the layer in background or foreground.
  54895. */
  54896. isBackground: boolean;
  54897. /**
  54898. * Define the color of the layer (instead of texture).
  54899. */
  54900. color: Color4;
  54901. /**
  54902. * Define the scale of the layer in order to zoom in out of the texture.
  54903. */
  54904. scale: Vector2;
  54905. /**
  54906. * Define an offset for the layer in order to shift the texture.
  54907. */
  54908. offset: Vector2;
  54909. /**
  54910. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  54911. */
  54912. alphaBlendingMode: number;
  54913. /**
  54914. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  54915. * Alpha test will not mix with the background color in case of transparency.
  54916. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  54917. */
  54918. alphaTest: boolean;
  54919. /**
  54920. * Define a mask to restrict the layer to only some of the scene cameras.
  54921. */
  54922. layerMask: number;
  54923. /**
  54924. * Define the list of render target the layer is visible into.
  54925. */
  54926. renderTargetTextures: RenderTargetTexture[];
  54927. /**
  54928. * Define if the layer is only used in renderTarget or if it also
  54929. * renders in the main frame buffer of the canvas.
  54930. */
  54931. renderOnlyInRenderTargetTextures: boolean;
  54932. private _scene;
  54933. private _vertexBuffers;
  54934. private _indexBuffer;
  54935. private _effect;
  54936. private _previousDefines;
  54937. /**
  54938. * An event triggered when the layer is disposed.
  54939. */
  54940. onDisposeObservable: Observable<Layer>;
  54941. private _onDisposeObserver;
  54942. /**
  54943. * Back compatibility with callback before the onDisposeObservable existed.
  54944. * The set callback will be triggered when the layer has been disposed.
  54945. */
  54946. set onDispose(callback: () => void);
  54947. /**
  54948. * An event triggered before rendering the scene
  54949. */
  54950. onBeforeRenderObservable: Observable<Layer>;
  54951. private _onBeforeRenderObserver;
  54952. /**
  54953. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54954. * The set callback will be triggered just before rendering the layer.
  54955. */
  54956. set onBeforeRender(callback: () => void);
  54957. /**
  54958. * An event triggered after rendering the scene
  54959. */
  54960. onAfterRenderObservable: Observable<Layer>;
  54961. private _onAfterRenderObserver;
  54962. /**
  54963. * Back compatibility with callback before the onAfterRenderObservable existed.
  54964. * The set callback will be triggered just after rendering the layer.
  54965. */
  54966. set onAfterRender(callback: () => void);
  54967. /**
  54968. * Instantiates a new layer.
  54969. * This represents a full screen 2d layer.
  54970. * This can be useful to display a picture in the background of your scene for instance.
  54971. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54972. * @param name Define the name of the layer in the scene
  54973. * @param imgUrl Define the url of the texture to display in the layer
  54974. * @param scene Define the scene the layer belongs to
  54975. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  54976. * @param color Defines a color for the layer
  54977. */
  54978. constructor(
  54979. /**
  54980. * Define the name of the layer.
  54981. */
  54982. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54983. private _createIndexBuffer;
  54984. /** @hidden */
  54985. _rebuild(): void;
  54986. /**
  54987. * Renders the layer in the scene.
  54988. */
  54989. render(): void;
  54990. /**
  54991. * Disposes and releases the associated ressources.
  54992. */
  54993. dispose(): void;
  54994. }
  54995. }
  54996. declare module "babylonjs/Layers/index" {
  54997. export * from "babylonjs/Layers/effectLayer";
  54998. export * from "babylonjs/Layers/effectLayerSceneComponent";
  54999. export * from "babylonjs/Layers/glowLayer";
  55000. export * from "babylonjs/Layers/highlightLayer";
  55001. export * from "babylonjs/Layers/layer";
  55002. export * from "babylonjs/Layers/layerSceneComponent";
  55003. }
  55004. declare module "babylonjs/Shaders/lensFlare.fragment" {
  55005. /** @hidden */
  55006. export var lensFlarePixelShader: {
  55007. name: string;
  55008. shader: string;
  55009. };
  55010. }
  55011. declare module "babylonjs/Shaders/lensFlare.vertex" {
  55012. /** @hidden */
  55013. export var lensFlareVertexShader: {
  55014. name: string;
  55015. shader: string;
  55016. };
  55017. }
  55018. declare module "babylonjs/LensFlares/lensFlareSystem" {
  55019. import { Scene } from "babylonjs/scene";
  55020. import { Vector3 } from "babylonjs/Maths/math.vector";
  55021. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55022. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  55023. import "babylonjs/Shaders/lensFlare.fragment";
  55024. import "babylonjs/Shaders/lensFlare.vertex";
  55025. import { Viewport } from "babylonjs/Maths/math.viewport";
  55026. /**
  55027. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  55028. * It is usually composed of several `lensFlare`.
  55029. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55030. */
  55031. export class LensFlareSystem {
  55032. /**
  55033. * Define the name of the lens flare system
  55034. */
  55035. name: string;
  55036. /**
  55037. * List of lens flares used in this system.
  55038. */
  55039. lensFlares: LensFlare[];
  55040. /**
  55041. * Define a limit from the border the lens flare can be visible.
  55042. */
  55043. borderLimit: number;
  55044. /**
  55045. * Define a viewport border we do not want to see the lens flare in.
  55046. */
  55047. viewportBorder: number;
  55048. /**
  55049. * Define a predicate which could limit the list of meshes able to occlude the effect.
  55050. */
  55051. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  55052. /**
  55053. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  55054. */
  55055. layerMask: number;
  55056. /**
  55057. * Define the id of the lens flare system in the scene.
  55058. * (equal to name by default)
  55059. */
  55060. id: string;
  55061. private _scene;
  55062. private _emitter;
  55063. private _vertexBuffers;
  55064. private _indexBuffer;
  55065. private _effect;
  55066. private _positionX;
  55067. private _positionY;
  55068. private _isEnabled;
  55069. /** @hidden */
  55070. static _SceneComponentInitialization: (scene: Scene) => void;
  55071. /**
  55072. * Instantiates a lens flare system.
  55073. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  55074. * It is usually composed of several `lensFlare`.
  55075. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55076. * @param name Define the name of the lens flare system in the scene
  55077. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  55078. * @param scene Define the scene the lens flare system belongs to
  55079. */
  55080. constructor(
  55081. /**
  55082. * Define the name of the lens flare system
  55083. */
  55084. name: string, emitter: any, scene: Scene);
  55085. /**
  55086. * Define if the lens flare system is enabled.
  55087. */
  55088. get isEnabled(): boolean;
  55089. set isEnabled(value: boolean);
  55090. /**
  55091. * Get the scene the effects belongs to.
  55092. * @returns the scene holding the lens flare system
  55093. */
  55094. getScene(): Scene;
  55095. /**
  55096. * Get the emitter of the lens flare system.
  55097. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  55098. * @returns the emitter of the lens flare system
  55099. */
  55100. getEmitter(): any;
  55101. /**
  55102. * Set the emitter of the lens flare system.
  55103. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  55104. * @param newEmitter Define the new emitter of the system
  55105. */
  55106. setEmitter(newEmitter: any): void;
  55107. /**
  55108. * Get the lens flare system emitter position.
  55109. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  55110. * @returns the position
  55111. */
  55112. getEmitterPosition(): Vector3;
  55113. /**
  55114. * @hidden
  55115. */
  55116. computeEffectivePosition(globalViewport: Viewport): boolean;
  55117. /** @hidden */
  55118. _isVisible(): boolean;
  55119. /**
  55120. * @hidden
  55121. */
  55122. render(): boolean;
  55123. /**
  55124. * Dispose and release the lens flare with its associated resources.
  55125. */
  55126. dispose(): void;
  55127. /**
  55128. * Parse a lens flare system from a JSON repressentation
  55129. * @param parsedLensFlareSystem Define the JSON to parse
  55130. * @param scene Define the scene the parsed system should be instantiated in
  55131. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  55132. * @returns the parsed system
  55133. */
  55134. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  55135. /**
  55136. * Serialize the current Lens Flare System into a JSON representation.
  55137. * @returns the serialized JSON
  55138. */
  55139. serialize(): any;
  55140. }
  55141. }
  55142. declare module "babylonjs/LensFlares/lensFlare" {
  55143. import { Nullable } from "babylonjs/types";
  55144. import { Color3 } from "babylonjs/Maths/math.color";
  55145. import { Texture } from "babylonjs/Materials/Textures/texture";
  55146. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  55147. /**
  55148. * This represents one of the lens effect in a `lensFlareSystem`.
  55149. * It controls one of the indiviual texture used in the effect.
  55150. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55151. */
  55152. export class LensFlare {
  55153. /**
  55154. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  55155. */
  55156. size: number;
  55157. /**
  55158. * 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.
  55159. */
  55160. position: number;
  55161. /**
  55162. * Define the lens color.
  55163. */
  55164. color: Color3;
  55165. /**
  55166. * Define the lens texture.
  55167. */
  55168. texture: Nullable<Texture>;
  55169. /**
  55170. * Define the alpha mode to render this particular lens.
  55171. */
  55172. alphaMode: number;
  55173. private _system;
  55174. /**
  55175. * Creates a new Lens Flare.
  55176. * This represents one of the lens effect in a `lensFlareSystem`.
  55177. * It controls one of the indiviual texture used in the effect.
  55178. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55179. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  55180. * @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.
  55181. * @param color Define the lens color
  55182. * @param imgUrl Define the lens texture url
  55183. * @param system Define the `lensFlareSystem` this flare is part of
  55184. * @returns The newly created Lens Flare
  55185. */
  55186. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  55187. /**
  55188. * Instantiates a new Lens Flare.
  55189. * This represents one of the lens effect in a `lensFlareSystem`.
  55190. * It controls one of the indiviual texture used in the effect.
  55191. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55192. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  55193. * @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.
  55194. * @param color Define the lens color
  55195. * @param imgUrl Define the lens texture url
  55196. * @param system Define the `lensFlareSystem` this flare is part of
  55197. */
  55198. constructor(
  55199. /**
  55200. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  55201. */
  55202. size: number,
  55203. /**
  55204. * 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.
  55205. */
  55206. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  55207. /**
  55208. * Dispose and release the lens flare with its associated resources.
  55209. */
  55210. dispose(): void;
  55211. }
  55212. }
  55213. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  55214. import { Nullable } from "babylonjs/types";
  55215. import { Scene } from "babylonjs/scene";
  55216. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55217. import { AbstractScene } from "babylonjs/abstractScene";
  55218. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  55219. module "babylonjs/abstractScene" {
  55220. interface AbstractScene {
  55221. /**
  55222. * The list of lens flare system added to the scene
  55223. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55224. */
  55225. lensFlareSystems: Array<LensFlareSystem>;
  55226. /**
  55227. * Removes the given lens flare system from this scene.
  55228. * @param toRemove The lens flare system to remove
  55229. * @returns The index of the removed lens flare system
  55230. */
  55231. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  55232. /**
  55233. * Adds the given lens flare system to this scene
  55234. * @param newLensFlareSystem The lens flare system to add
  55235. */
  55236. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  55237. /**
  55238. * Gets a lens flare system using its name
  55239. * @param name defines the name to look for
  55240. * @returns the lens flare system or null if not found
  55241. */
  55242. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  55243. /**
  55244. * Gets a lens flare system using its id
  55245. * @param id defines the id to look for
  55246. * @returns the lens flare system or null if not found
  55247. */
  55248. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  55249. }
  55250. }
  55251. /**
  55252. * Defines the lens flare scene component responsible to manage any lens flares
  55253. * in a given scene.
  55254. */
  55255. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  55256. /**
  55257. * The component name helpfull to identify the component in the list of scene components.
  55258. */
  55259. readonly name: string;
  55260. /**
  55261. * The scene the component belongs to.
  55262. */
  55263. scene: Scene;
  55264. /**
  55265. * Creates a new instance of the component for the given scene
  55266. * @param scene Defines the scene to register the component in
  55267. */
  55268. constructor(scene: Scene);
  55269. /**
  55270. * Registers the component in a given scene
  55271. */
  55272. register(): void;
  55273. /**
  55274. * Rebuilds the elements related to this component in case of
  55275. * context lost for instance.
  55276. */
  55277. rebuild(): void;
  55278. /**
  55279. * Adds all the elements from the container to the scene
  55280. * @param container the container holding the elements
  55281. */
  55282. addFromContainer(container: AbstractScene): void;
  55283. /**
  55284. * Removes all the elements in the container from the scene
  55285. * @param container contains the elements to remove
  55286. * @param dispose if the removed element should be disposed (default: false)
  55287. */
  55288. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55289. /**
  55290. * Serializes the component data to the specified json object
  55291. * @param serializationObject The object to serialize to
  55292. */
  55293. serialize(serializationObject: any): void;
  55294. /**
  55295. * Disposes the component and the associated ressources.
  55296. */
  55297. dispose(): void;
  55298. private _draw;
  55299. }
  55300. }
  55301. declare module "babylonjs/LensFlares/index" {
  55302. export * from "babylonjs/LensFlares/lensFlare";
  55303. export * from "babylonjs/LensFlares/lensFlareSystem";
  55304. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  55305. }
  55306. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  55307. import { Scene } from "babylonjs/scene";
  55308. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55309. import { AbstractScene } from "babylonjs/abstractScene";
  55310. /**
  55311. * Defines the shadow generator component responsible to manage any shadow generators
  55312. * in a given scene.
  55313. */
  55314. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  55315. /**
  55316. * The component name helpfull to identify the component in the list of scene components.
  55317. */
  55318. readonly name: string;
  55319. /**
  55320. * The scene the component belongs to.
  55321. */
  55322. scene: Scene;
  55323. /**
  55324. * Creates a new instance of the component for the given scene
  55325. * @param scene Defines the scene to register the component in
  55326. */
  55327. constructor(scene: Scene);
  55328. /**
  55329. * Registers the component in a given scene
  55330. */
  55331. register(): void;
  55332. /**
  55333. * Rebuilds the elements related to this component in case of
  55334. * context lost for instance.
  55335. */
  55336. rebuild(): void;
  55337. /**
  55338. * Serializes the component data to the specified json object
  55339. * @param serializationObject The object to serialize to
  55340. */
  55341. serialize(serializationObject: any): void;
  55342. /**
  55343. * Adds all the elements from the container to the scene
  55344. * @param container the container holding the elements
  55345. */
  55346. addFromContainer(container: AbstractScene): void;
  55347. /**
  55348. * Removes all the elements in the container from the scene
  55349. * @param container contains the elements to remove
  55350. * @param dispose if the removed element should be disposed (default: false)
  55351. */
  55352. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55353. /**
  55354. * Rebuilds the elements related to this component in case of
  55355. * context lost for instance.
  55356. */
  55357. dispose(): void;
  55358. private _gatherRenderTargets;
  55359. }
  55360. }
  55361. declare module "babylonjs/Lights/Shadows/index" {
  55362. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  55363. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  55364. }
  55365. declare module "babylonjs/Lights/pointLight" {
  55366. import { Scene } from "babylonjs/scene";
  55367. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55369. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55370. import { Effect } from "babylonjs/Materials/effect";
  55371. /**
  55372. * A point light is a light defined by an unique point in world space.
  55373. * The light is emitted in every direction from this point.
  55374. * A good example of a point light is a standard light bulb.
  55375. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55376. */
  55377. export class PointLight extends ShadowLight {
  55378. private _shadowAngle;
  55379. /**
  55380. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55381. * This specifies what angle the shadow will use to be created.
  55382. *
  55383. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55384. */
  55385. get shadowAngle(): number;
  55386. /**
  55387. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55388. * This specifies what angle the shadow will use to be created.
  55389. *
  55390. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55391. */
  55392. set shadowAngle(value: number);
  55393. /**
  55394. * Gets the direction if it has been set.
  55395. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55396. */
  55397. get direction(): Vector3;
  55398. /**
  55399. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55400. */
  55401. set direction(value: Vector3);
  55402. /**
  55403. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  55404. * A PointLight emits the light in every direction.
  55405. * It can cast shadows.
  55406. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  55407. * ```javascript
  55408. * var pointLight = new PointLight("pl", camera.position, scene);
  55409. * ```
  55410. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55411. * @param name The light friendly name
  55412. * @param position The position of the point light in the scene
  55413. * @param scene The scene the lights belongs to
  55414. */
  55415. constructor(name: string, position: Vector3, scene: Scene);
  55416. /**
  55417. * Returns the string "PointLight"
  55418. * @returns the class name
  55419. */
  55420. getClassName(): string;
  55421. /**
  55422. * Returns the integer 0.
  55423. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55424. */
  55425. getTypeID(): number;
  55426. /**
  55427. * Specifies wether or not the shadowmap should be a cube texture.
  55428. * @returns true if the shadowmap needs to be a cube texture.
  55429. */
  55430. needCube(): boolean;
  55431. /**
  55432. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  55433. * @param faceIndex The index of the face we are computed the direction to generate shadow
  55434. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  55435. */
  55436. getShadowDirection(faceIndex?: number): Vector3;
  55437. /**
  55438. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  55439. * - fov = PI / 2
  55440. * - aspect ratio : 1.0
  55441. * - z-near and far equal to the active camera minZ and maxZ.
  55442. * Returns the PointLight.
  55443. */
  55444. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55445. protected _buildUniformLayout(): void;
  55446. /**
  55447. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  55448. * @param effect The effect to update
  55449. * @param lightIndex The index of the light in the effect to update
  55450. * @returns The point light
  55451. */
  55452. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  55453. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55454. /**
  55455. * Prepares the list of defines specific to the light type.
  55456. * @param defines the list of defines
  55457. * @param lightIndex defines the index of the light for the effect
  55458. */
  55459. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55460. }
  55461. }
  55462. declare module "babylonjs/Lights/index" {
  55463. export * from "babylonjs/Lights/light";
  55464. export * from "babylonjs/Lights/shadowLight";
  55465. export * from "babylonjs/Lights/Shadows/index";
  55466. export * from "babylonjs/Lights/directionalLight";
  55467. export * from "babylonjs/Lights/hemisphericLight";
  55468. export * from "babylonjs/Lights/pointLight";
  55469. export * from "babylonjs/Lights/spotLight";
  55470. }
  55471. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  55472. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  55473. /**
  55474. * Header information of HDR texture files.
  55475. */
  55476. export interface HDRInfo {
  55477. /**
  55478. * The height of the texture in pixels.
  55479. */
  55480. height: number;
  55481. /**
  55482. * The width of the texture in pixels.
  55483. */
  55484. width: number;
  55485. /**
  55486. * The index of the beginning of the data in the binary file.
  55487. */
  55488. dataPosition: number;
  55489. }
  55490. /**
  55491. * This groups tools to convert HDR texture to native colors array.
  55492. */
  55493. export class HDRTools {
  55494. private static Ldexp;
  55495. private static Rgbe2float;
  55496. private static readStringLine;
  55497. /**
  55498. * Reads header information from an RGBE texture stored in a native array.
  55499. * More information on this format are available here:
  55500. * https://en.wikipedia.org/wiki/RGBE_image_format
  55501. *
  55502. * @param uint8array The binary file stored in native array.
  55503. * @return The header information.
  55504. */
  55505. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  55506. /**
  55507. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  55508. * This RGBE texture needs to store the information as a panorama.
  55509. *
  55510. * More information on this format are available here:
  55511. * https://en.wikipedia.org/wiki/RGBE_image_format
  55512. *
  55513. * @param buffer The binary file stored in an array buffer.
  55514. * @param size The expected size of the extracted cubemap.
  55515. * @return The Cube Map information.
  55516. */
  55517. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  55518. /**
  55519. * Returns the pixels data extracted from an RGBE texture.
  55520. * This pixels will be stored left to right up to down in the R G B order in one array.
  55521. *
  55522. * More information on this format are available here:
  55523. * https://en.wikipedia.org/wiki/RGBE_image_format
  55524. *
  55525. * @param uint8array The binary file stored in an array buffer.
  55526. * @param hdrInfo The header information of the file.
  55527. * @return The pixels data in RGB right to left up to down order.
  55528. */
  55529. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  55530. private static RGBE_ReadPixels_RLE;
  55531. }
  55532. }
  55533. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  55534. import { Nullable } from "babylonjs/types";
  55535. import { Scene } from "babylonjs/scene";
  55536. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55537. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55538. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55539. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  55540. /**
  55541. * This represents a texture coming from an HDR input.
  55542. *
  55543. * The only supported format is currently panorama picture stored in RGBE format.
  55544. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55545. */
  55546. export class HDRCubeTexture extends BaseTexture {
  55547. private static _facesMapping;
  55548. private _generateHarmonics;
  55549. private _noMipmap;
  55550. private _textureMatrix;
  55551. private _size;
  55552. private _onLoad;
  55553. private _onError;
  55554. /**
  55555. * The texture URL.
  55556. */
  55557. url: string;
  55558. /**
  55559. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55560. */
  55561. coordinatesMode: number;
  55562. protected _isBlocking: boolean;
  55563. /**
  55564. * Sets wether or not the texture is blocking during loading.
  55565. */
  55566. set isBlocking(value: boolean);
  55567. /**
  55568. * Gets wether or not the texture is blocking during loading.
  55569. */
  55570. get isBlocking(): boolean;
  55571. protected _rotationY: number;
  55572. /**
  55573. * Sets texture matrix rotation angle around Y axis in radians.
  55574. */
  55575. set rotationY(value: number);
  55576. /**
  55577. * Gets texture matrix rotation angle around Y axis radians.
  55578. */
  55579. get rotationY(): number;
  55580. /**
  55581. * Gets or sets the center of the bounding box associated with the cube texture
  55582. * It must define where the camera used to render the texture was set
  55583. */
  55584. boundingBoxPosition: Vector3;
  55585. private _boundingBoxSize;
  55586. /**
  55587. * Gets or sets the size of the bounding box associated with the cube texture
  55588. * When defined, the cubemap will switch to local mode
  55589. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55590. * @example https://www.babylonjs-playground.com/#RNASML
  55591. */
  55592. set boundingBoxSize(value: Vector3);
  55593. get boundingBoxSize(): Vector3;
  55594. /**
  55595. * Instantiates an HDRTexture from the following parameters.
  55596. *
  55597. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55598. * @param scene The scene the texture will be used in
  55599. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55600. * @param noMipmap Forces to not generate the mipmap if true
  55601. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55602. * @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)
  55603. * @param reserved Reserved flag for internal use.
  55604. */
  55605. 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>);
  55606. /**
  55607. * Get the current class name of the texture useful for serialization or dynamic coding.
  55608. * @returns "HDRCubeTexture"
  55609. */
  55610. getClassName(): string;
  55611. /**
  55612. * Occurs when the file is raw .hdr file.
  55613. */
  55614. private loadTexture;
  55615. clone(): HDRCubeTexture;
  55616. delayLoad(): void;
  55617. /**
  55618. * Get the texture reflection matrix used to rotate/transform the reflection.
  55619. * @returns the reflection matrix
  55620. */
  55621. getReflectionTextureMatrix(): Matrix;
  55622. /**
  55623. * Set the texture reflection matrix used to rotate/transform the reflection.
  55624. * @param value Define the reflection matrix to set
  55625. */
  55626. setReflectionTextureMatrix(value: Matrix): void;
  55627. /**
  55628. * Parses a JSON representation of an HDR Texture in order to create the texture
  55629. * @param parsedTexture Define the JSON representation
  55630. * @param scene Define the scene the texture should be created in
  55631. * @param rootUrl Define the root url in case we need to load relative dependencies
  55632. * @returns the newly created texture after parsing
  55633. */
  55634. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55635. serialize(): any;
  55636. }
  55637. }
  55638. declare module "babylonjs/Physics/physicsEngine" {
  55639. import { Nullable } from "babylonjs/types";
  55640. import { Vector3 } from "babylonjs/Maths/math.vector";
  55641. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  55642. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  55643. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  55644. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  55645. /**
  55646. * Class used to control physics engine
  55647. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55648. */
  55649. export class PhysicsEngine implements IPhysicsEngine {
  55650. private _physicsPlugin;
  55651. /**
  55652. * Global value used to control the smallest number supported by the simulation
  55653. */
  55654. static Epsilon: number;
  55655. private _impostors;
  55656. private _joints;
  55657. private _subTimeStep;
  55658. /**
  55659. * Gets the gravity vector used by the simulation
  55660. */
  55661. gravity: Vector3;
  55662. /**
  55663. * Factory used to create the default physics plugin.
  55664. * @returns The default physics plugin
  55665. */
  55666. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55667. /**
  55668. * Creates a new Physics Engine
  55669. * @param gravity defines the gravity vector used by the simulation
  55670. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55671. */
  55672. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55673. /**
  55674. * Sets the gravity vector used by the simulation
  55675. * @param gravity defines the gravity vector to use
  55676. */
  55677. setGravity(gravity: Vector3): void;
  55678. /**
  55679. * Set the time step of the physics engine.
  55680. * Default is 1/60.
  55681. * To slow it down, enter 1/600 for example.
  55682. * To speed it up, 1/30
  55683. * @param newTimeStep defines the new timestep to apply to this world.
  55684. */
  55685. setTimeStep(newTimeStep?: number): void;
  55686. /**
  55687. * Get the time step of the physics engine.
  55688. * @returns the current time step
  55689. */
  55690. getTimeStep(): number;
  55691. /**
  55692. * Set the sub time step of the physics engine.
  55693. * Default is 0 meaning there is no sub steps
  55694. * To increase physics resolution precision, set a small value (like 1 ms)
  55695. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55696. */
  55697. setSubTimeStep(subTimeStep?: number): void;
  55698. /**
  55699. * Get the sub time step of the physics engine.
  55700. * @returns the current sub time step
  55701. */
  55702. getSubTimeStep(): number;
  55703. /**
  55704. * Release all resources
  55705. */
  55706. dispose(): void;
  55707. /**
  55708. * Gets the name of the current physics plugin
  55709. * @returns the name of the plugin
  55710. */
  55711. getPhysicsPluginName(): string;
  55712. /**
  55713. * Adding a new impostor for the impostor tracking.
  55714. * This will be done by the impostor itself.
  55715. * @param impostor the impostor to add
  55716. */
  55717. addImpostor(impostor: PhysicsImpostor): void;
  55718. /**
  55719. * Remove an impostor from the engine.
  55720. * This impostor and its mesh will not longer be updated by the physics engine.
  55721. * @param impostor the impostor to remove
  55722. */
  55723. removeImpostor(impostor: PhysicsImpostor): void;
  55724. /**
  55725. * Add a joint to the physics engine
  55726. * @param mainImpostor defines the main impostor to which the joint is added.
  55727. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55728. * @param joint defines the joint that will connect both impostors.
  55729. */
  55730. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55731. /**
  55732. * Removes a joint from the simulation
  55733. * @param mainImpostor defines the impostor used with the joint
  55734. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55735. * @param joint defines the joint to remove
  55736. */
  55737. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55738. /**
  55739. * Called by the scene. No need to call it.
  55740. * @param delta defines the timespam between frames
  55741. */
  55742. _step(delta: number): void;
  55743. /**
  55744. * Gets the current plugin used to run the simulation
  55745. * @returns current plugin
  55746. */
  55747. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55748. /**
  55749. * Gets the list of physic impostors
  55750. * @returns an array of PhysicsImpostor
  55751. */
  55752. getImpostors(): Array<PhysicsImpostor>;
  55753. /**
  55754. * Gets the impostor for a physics enabled object
  55755. * @param object defines the object impersonated by the impostor
  55756. * @returns the PhysicsImpostor or null if not found
  55757. */
  55758. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55759. /**
  55760. * Gets the impostor for a physics body object
  55761. * @param body defines physics body used by the impostor
  55762. * @returns the PhysicsImpostor or null if not found
  55763. */
  55764. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55765. /**
  55766. * Does a raycast in the physics world
  55767. * @param from when should the ray start?
  55768. * @param to when should the ray end?
  55769. * @returns PhysicsRaycastResult
  55770. */
  55771. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55772. }
  55773. }
  55774. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  55775. import { Nullable } from "babylonjs/types";
  55776. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  55777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55778. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  55779. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  55780. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  55781. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  55782. /** @hidden */
  55783. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55784. private _useDeltaForWorldStep;
  55785. world: any;
  55786. name: string;
  55787. private _physicsMaterials;
  55788. private _fixedTimeStep;
  55789. private _cannonRaycastResult;
  55790. private _raycastResult;
  55791. private _physicsBodysToRemoveAfterStep;
  55792. BJSCANNON: any;
  55793. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55794. setGravity(gravity: Vector3): void;
  55795. setTimeStep(timeStep: number): void;
  55796. getTimeStep(): number;
  55797. executeStep(delta: number): void;
  55798. private _removeMarkedPhysicsBodiesFromWorld;
  55799. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55800. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55801. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55802. private _processChildMeshes;
  55803. removePhysicsBody(impostor: PhysicsImpostor): void;
  55804. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55805. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55806. private _addMaterial;
  55807. private _checkWithEpsilon;
  55808. private _createShape;
  55809. private _createHeightmap;
  55810. private _minus90X;
  55811. private _plus90X;
  55812. private _tmpPosition;
  55813. private _tmpDeltaPosition;
  55814. private _tmpUnityRotation;
  55815. private _updatePhysicsBodyTransformation;
  55816. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55817. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55818. isSupported(): boolean;
  55819. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55820. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55821. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55822. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55823. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55824. getBodyMass(impostor: PhysicsImpostor): number;
  55825. getBodyFriction(impostor: PhysicsImpostor): number;
  55826. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55827. getBodyRestitution(impostor: PhysicsImpostor): number;
  55828. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55829. sleepBody(impostor: PhysicsImpostor): void;
  55830. wakeUpBody(impostor: PhysicsImpostor): void;
  55831. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55832. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55833. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55834. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55835. getRadius(impostor: PhysicsImpostor): number;
  55836. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55837. dispose(): void;
  55838. private _extendNamespace;
  55839. /**
  55840. * Does a raycast in the physics world
  55841. * @param from when should the ray start?
  55842. * @param to when should the ray end?
  55843. * @returns PhysicsRaycastResult
  55844. */
  55845. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55846. }
  55847. }
  55848. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  55849. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  55850. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  55851. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  55852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55853. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  55854. import { Nullable } from "babylonjs/types";
  55855. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  55856. /** @hidden */
  55857. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55858. world: any;
  55859. name: string;
  55860. BJSOIMO: any;
  55861. private _raycastResult;
  55862. constructor(iterations?: number, oimoInjection?: any);
  55863. setGravity(gravity: Vector3): void;
  55864. setTimeStep(timeStep: number): void;
  55865. getTimeStep(): number;
  55866. private _tmpImpostorsArray;
  55867. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55868. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55869. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55870. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55871. private _tmpPositionVector;
  55872. removePhysicsBody(impostor: PhysicsImpostor): void;
  55873. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55874. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55875. isSupported(): boolean;
  55876. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55877. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55878. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55879. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55880. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55881. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55882. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55883. getBodyMass(impostor: PhysicsImpostor): number;
  55884. getBodyFriction(impostor: PhysicsImpostor): number;
  55885. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55886. getBodyRestitution(impostor: PhysicsImpostor): number;
  55887. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55888. sleepBody(impostor: PhysicsImpostor): void;
  55889. wakeUpBody(impostor: PhysicsImpostor): void;
  55890. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55891. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55892. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55893. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55894. getRadius(impostor: PhysicsImpostor): number;
  55895. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55896. dispose(): void;
  55897. /**
  55898. * Does a raycast in the physics world
  55899. * @param from when should the ray start?
  55900. * @param to when should the ray end?
  55901. * @returns PhysicsRaycastResult
  55902. */
  55903. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55904. }
  55905. }
  55906. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  55907. import { Nullable } from "babylonjs/types";
  55908. import { Scene } from "babylonjs/scene";
  55909. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  55910. import { Color4 } from "babylonjs/Maths/math.color";
  55911. import { Mesh } from "babylonjs/Meshes/mesh";
  55912. /**
  55913. * Class containing static functions to help procedurally build meshes
  55914. */
  55915. export class RibbonBuilder {
  55916. /**
  55917. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55918. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55919. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55920. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55921. * * 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
  55922. * * 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
  55923. * * 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
  55924. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55925. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55926. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55927. * * 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
  55928. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55929. * * 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
  55930. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55932. * @param name defines the name of the mesh
  55933. * @param options defines the options used to create the mesh
  55934. * @param scene defines the hosting scene
  55935. * @returns the ribbon mesh
  55936. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55937. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55938. */
  55939. static CreateRibbon(name: string, options: {
  55940. pathArray: Vector3[][];
  55941. closeArray?: boolean;
  55942. closePath?: boolean;
  55943. offset?: number;
  55944. updatable?: boolean;
  55945. sideOrientation?: number;
  55946. frontUVs?: Vector4;
  55947. backUVs?: Vector4;
  55948. instance?: Mesh;
  55949. invertUV?: boolean;
  55950. uvs?: Vector2[];
  55951. colors?: Color4[];
  55952. }, scene?: Nullable<Scene>): Mesh;
  55953. }
  55954. }
  55955. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  55956. import { Nullable } from "babylonjs/types";
  55957. import { Scene } from "babylonjs/scene";
  55958. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  55959. import { Mesh } from "babylonjs/Meshes/mesh";
  55960. /**
  55961. * Class containing static functions to help procedurally build meshes
  55962. */
  55963. export class ShapeBuilder {
  55964. /**
  55965. * 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.
  55966. * * 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.
  55967. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55968. * * 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.
  55969. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55970. * * 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
  55971. * * 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
  55972. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55973. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55974. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55975. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55977. * @param name defines the name of the mesh
  55978. * @param options defines the options used to create the mesh
  55979. * @param scene defines the hosting scene
  55980. * @returns the extruded shape mesh
  55981. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55982. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55983. */
  55984. static ExtrudeShape(name: string, options: {
  55985. shape: Vector3[];
  55986. path: Vector3[];
  55987. scale?: number;
  55988. rotation?: number;
  55989. cap?: number;
  55990. updatable?: boolean;
  55991. sideOrientation?: number;
  55992. frontUVs?: Vector4;
  55993. backUVs?: Vector4;
  55994. instance?: Mesh;
  55995. invertUV?: boolean;
  55996. }, scene?: Nullable<Scene>): Mesh;
  55997. /**
  55998. * Creates an custom extruded shape mesh.
  55999. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56000. * * 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.
  56001. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56002. * * 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
  56003. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56004. * * 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
  56005. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56006. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56007. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56008. * * 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
  56009. * * 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
  56010. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56011. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56012. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56013. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56015. * @param name defines the name of the mesh
  56016. * @param options defines the options used to create the mesh
  56017. * @param scene defines the hosting scene
  56018. * @returns the custom extruded shape mesh
  56019. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56020. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56021. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56022. */
  56023. static ExtrudeShapeCustom(name: string, options: {
  56024. shape: Vector3[];
  56025. path: Vector3[];
  56026. scaleFunction?: any;
  56027. rotationFunction?: any;
  56028. ribbonCloseArray?: boolean;
  56029. ribbonClosePath?: boolean;
  56030. cap?: number;
  56031. updatable?: boolean;
  56032. sideOrientation?: number;
  56033. frontUVs?: Vector4;
  56034. backUVs?: Vector4;
  56035. instance?: Mesh;
  56036. invertUV?: boolean;
  56037. }, scene?: Nullable<Scene>): Mesh;
  56038. private static _ExtrudeShapeGeneric;
  56039. }
  56040. }
  56041. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  56042. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  56043. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  56044. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56045. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  56046. import { Nullable } from "babylonjs/types";
  56047. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56048. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  56049. /**
  56050. * AmmoJS Physics plugin
  56051. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  56052. * @see https://github.com/kripken/ammo.js/
  56053. */
  56054. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  56055. private _useDeltaForWorldStep;
  56056. /**
  56057. * Reference to the Ammo library
  56058. */
  56059. bjsAMMO: any;
  56060. /**
  56061. * Created ammoJS world which physics bodies are added to
  56062. */
  56063. world: any;
  56064. /**
  56065. * Name of the plugin
  56066. */
  56067. name: string;
  56068. private _timeStep;
  56069. private _fixedTimeStep;
  56070. private _maxSteps;
  56071. private _tmpQuaternion;
  56072. private _tmpAmmoTransform;
  56073. private _tmpAmmoQuaternion;
  56074. private _tmpAmmoConcreteContactResultCallback;
  56075. private _collisionConfiguration;
  56076. private _dispatcher;
  56077. private _overlappingPairCache;
  56078. private _solver;
  56079. private _softBodySolver;
  56080. private _tmpAmmoVectorA;
  56081. private _tmpAmmoVectorB;
  56082. private _tmpAmmoVectorC;
  56083. private _tmpAmmoVectorD;
  56084. private _tmpContactCallbackResult;
  56085. private _tmpAmmoVectorRCA;
  56086. private _tmpAmmoVectorRCB;
  56087. private _raycastResult;
  56088. private static readonly DISABLE_COLLISION_FLAG;
  56089. private static readonly KINEMATIC_FLAG;
  56090. private static readonly DISABLE_DEACTIVATION_FLAG;
  56091. /**
  56092. * Initializes the ammoJS plugin
  56093. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  56094. * @param ammoInjection can be used to inject your own ammo reference
  56095. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  56096. */
  56097. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  56098. /**
  56099. * Sets the gravity of the physics world (m/(s^2))
  56100. * @param gravity Gravity to set
  56101. */
  56102. setGravity(gravity: Vector3): void;
  56103. /**
  56104. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  56105. * @param timeStep timestep to use in seconds
  56106. */
  56107. setTimeStep(timeStep: number): void;
  56108. /**
  56109. * 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)
  56110. * @param fixedTimeStep fixedTimeStep to use in seconds
  56111. */
  56112. setFixedTimeStep(fixedTimeStep: number): void;
  56113. /**
  56114. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  56115. * @param maxSteps the maximum number of steps by the physics engine per frame
  56116. */
  56117. setMaxSteps(maxSteps: number): void;
  56118. /**
  56119. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  56120. * @returns the current timestep in seconds
  56121. */
  56122. getTimeStep(): number;
  56123. /**
  56124. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  56125. */
  56126. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  56127. private _isImpostorInContact;
  56128. private _isImpostorPairInContact;
  56129. private _stepSimulation;
  56130. /**
  56131. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  56132. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  56133. * After the step the babylon meshes are set to the position of the physics imposters
  56134. * @param delta amount of time to step forward
  56135. * @param impostors array of imposters to update before/after the step
  56136. */
  56137. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  56138. /**
  56139. * Update babylon mesh to match physics world object
  56140. * @param impostor imposter to match
  56141. */
  56142. private _afterSoftStep;
  56143. /**
  56144. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  56145. * @param impostor imposter to match
  56146. */
  56147. private _ropeStep;
  56148. /**
  56149. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  56150. * @param impostor imposter to match
  56151. */
  56152. private _softbodyOrClothStep;
  56153. private _tmpVector;
  56154. private _tmpMatrix;
  56155. /**
  56156. * Applies an impulse on the imposter
  56157. * @param impostor imposter to apply impulse to
  56158. * @param force amount of force to be applied to the imposter
  56159. * @param contactPoint the location to apply the impulse on the imposter
  56160. */
  56161. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56162. /**
  56163. * Applies a force on the imposter
  56164. * @param impostor imposter to apply force
  56165. * @param force amount of force to be applied to the imposter
  56166. * @param contactPoint the location to apply the force on the imposter
  56167. */
  56168. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56169. /**
  56170. * Creates a physics body using the plugin
  56171. * @param impostor the imposter to create the physics body on
  56172. */
  56173. generatePhysicsBody(impostor: PhysicsImpostor): void;
  56174. /**
  56175. * Removes the physics body from the imposter and disposes of the body's memory
  56176. * @param impostor imposter to remove the physics body from
  56177. */
  56178. removePhysicsBody(impostor: PhysicsImpostor): void;
  56179. /**
  56180. * Generates a joint
  56181. * @param impostorJoint the imposter joint to create the joint with
  56182. */
  56183. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  56184. /**
  56185. * Removes a joint
  56186. * @param impostorJoint the imposter joint to remove the joint from
  56187. */
  56188. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  56189. private _addMeshVerts;
  56190. /**
  56191. * Initialise the soft body vertices to match its object's (mesh) vertices
  56192. * Softbody vertices (nodes) are in world space and to match this
  56193. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  56194. * @param impostor to create the softbody for
  56195. */
  56196. private _softVertexData;
  56197. /**
  56198. * Create an impostor's soft body
  56199. * @param impostor to create the softbody for
  56200. */
  56201. private _createSoftbody;
  56202. /**
  56203. * Create cloth for an impostor
  56204. * @param impostor to create the softbody for
  56205. */
  56206. private _createCloth;
  56207. /**
  56208. * Create rope for an impostor
  56209. * @param impostor to create the softbody for
  56210. */
  56211. private _createRope;
  56212. /**
  56213. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  56214. * @param impostor to create the custom physics shape for
  56215. */
  56216. private _createCustom;
  56217. private _addHullVerts;
  56218. private _createShape;
  56219. /**
  56220. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  56221. * @param impostor imposter containing the physics body and babylon object
  56222. */
  56223. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  56224. /**
  56225. * Sets the babylon object's position/rotation from the physics body's position/rotation
  56226. * @param impostor imposter containing the physics body and babylon object
  56227. * @param newPosition new position
  56228. * @param newRotation new rotation
  56229. */
  56230. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  56231. /**
  56232. * If this plugin is supported
  56233. * @returns true if its supported
  56234. */
  56235. isSupported(): boolean;
  56236. /**
  56237. * Sets the linear velocity of the physics body
  56238. * @param impostor imposter to set the velocity on
  56239. * @param velocity velocity to set
  56240. */
  56241. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56242. /**
  56243. * Sets the angular velocity of the physics body
  56244. * @param impostor imposter to set the velocity on
  56245. * @param velocity velocity to set
  56246. */
  56247. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56248. /**
  56249. * gets the linear velocity
  56250. * @param impostor imposter to get linear velocity from
  56251. * @returns linear velocity
  56252. */
  56253. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56254. /**
  56255. * gets the angular velocity
  56256. * @param impostor imposter to get angular velocity from
  56257. * @returns angular velocity
  56258. */
  56259. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56260. /**
  56261. * Sets the mass of physics body
  56262. * @param impostor imposter to set the mass on
  56263. * @param mass mass to set
  56264. */
  56265. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  56266. /**
  56267. * Gets the mass of the physics body
  56268. * @param impostor imposter to get the mass from
  56269. * @returns mass
  56270. */
  56271. getBodyMass(impostor: PhysicsImpostor): number;
  56272. /**
  56273. * Gets friction of the impostor
  56274. * @param impostor impostor to get friction from
  56275. * @returns friction value
  56276. */
  56277. getBodyFriction(impostor: PhysicsImpostor): number;
  56278. /**
  56279. * Sets friction of the impostor
  56280. * @param impostor impostor to set friction on
  56281. * @param friction friction value
  56282. */
  56283. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  56284. /**
  56285. * Gets restitution of the impostor
  56286. * @param impostor impostor to get restitution from
  56287. * @returns restitution value
  56288. */
  56289. getBodyRestitution(impostor: PhysicsImpostor): number;
  56290. /**
  56291. * Sets resitution of the impostor
  56292. * @param impostor impostor to set resitution on
  56293. * @param restitution resitution value
  56294. */
  56295. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  56296. /**
  56297. * Gets pressure inside the impostor
  56298. * @param impostor impostor to get pressure from
  56299. * @returns pressure value
  56300. */
  56301. getBodyPressure(impostor: PhysicsImpostor): number;
  56302. /**
  56303. * Sets pressure inside a soft body impostor
  56304. * Cloth and rope must remain 0 pressure
  56305. * @param impostor impostor to set pressure on
  56306. * @param pressure pressure value
  56307. */
  56308. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  56309. /**
  56310. * Gets stiffness of the impostor
  56311. * @param impostor impostor to get stiffness from
  56312. * @returns pressure value
  56313. */
  56314. getBodyStiffness(impostor: PhysicsImpostor): number;
  56315. /**
  56316. * Sets stiffness of the impostor
  56317. * @param impostor impostor to set stiffness on
  56318. * @param stiffness stiffness value from 0 to 1
  56319. */
  56320. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  56321. /**
  56322. * Gets velocityIterations of the impostor
  56323. * @param impostor impostor to get velocity iterations from
  56324. * @returns velocityIterations value
  56325. */
  56326. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  56327. /**
  56328. * Sets velocityIterations of the impostor
  56329. * @param impostor impostor to set velocity iterations on
  56330. * @param velocityIterations velocityIterations value
  56331. */
  56332. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  56333. /**
  56334. * Gets positionIterations of the impostor
  56335. * @param impostor impostor to get position iterations from
  56336. * @returns positionIterations value
  56337. */
  56338. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  56339. /**
  56340. * Sets positionIterations of the impostor
  56341. * @param impostor impostor to set position on
  56342. * @param positionIterations positionIterations value
  56343. */
  56344. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  56345. /**
  56346. * Append an anchor to a cloth object
  56347. * @param impostor is the cloth impostor to add anchor to
  56348. * @param otherImpostor is the rigid impostor to anchor to
  56349. * @param width ratio across width from 0 to 1
  56350. * @param height ratio up height from 0 to 1
  56351. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  56352. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56353. */
  56354. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56355. /**
  56356. * Append an hook to a rope object
  56357. * @param impostor is the rope impostor to add hook to
  56358. * @param otherImpostor is the rigid impostor to hook to
  56359. * @param length ratio along the rope from 0 to 1
  56360. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  56361. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56362. */
  56363. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56364. /**
  56365. * Sleeps the physics body and stops it from being active
  56366. * @param impostor impostor to sleep
  56367. */
  56368. sleepBody(impostor: PhysicsImpostor): void;
  56369. /**
  56370. * Activates the physics body
  56371. * @param impostor impostor to activate
  56372. */
  56373. wakeUpBody(impostor: PhysicsImpostor): void;
  56374. /**
  56375. * Updates the distance parameters of the joint
  56376. * @param joint joint to update
  56377. * @param maxDistance maximum distance of the joint
  56378. * @param minDistance minimum distance of the joint
  56379. */
  56380. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  56381. /**
  56382. * Sets a motor on the joint
  56383. * @param joint joint to set motor on
  56384. * @param speed speed of the motor
  56385. * @param maxForce maximum force of the motor
  56386. * @param motorIndex index of the motor
  56387. */
  56388. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  56389. /**
  56390. * Sets the motors limit
  56391. * @param joint joint to set limit on
  56392. * @param upperLimit upper limit
  56393. * @param lowerLimit lower limit
  56394. */
  56395. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  56396. /**
  56397. * Syncs the position and rotation of a mesh with the impostor
  56398. * @param mesh mesh to sync
  56399. * @param impostor impostor to update the mesh with
  56400. */
  56401. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56402. /**
  56403. * Gets the radius of the impostor
  56404. * @param impostor impostor to get radius from
  56405. * @returns the radius
  56406. */
  56407. getRadius(impostor: PhysicsImpostor): number;
  56408. /**
  56409. * Gets the box size of the impostor
  56410. * @param impostor impostor to get box size from
  56411. * @param result the resulting box size
  56412. */
  56413. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56414. /**
  56415. * Disposes of the impostor
  56416. */
  56417. dispose(): void;
  56418. /**
  56419. * Does a raycast in the physics world
  56420. * @param from when should the ray start?
  56421. * @param to when should the ray end?
  56422. * @returns PhysicsRaycastResult
  56423. */
  56424. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56425. }
  56426. }
  56427. declare module "babylonjs/Probes/reflectionProbe" {
  56428. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56429. import { Vector3 } from "babylonjs/Maths/math.vector";
  56430. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56431. import { Nullable } from "babylonjs/types";
  56432. import { Scene } from "babylonjs/scene";
  56433. module "babylonjs/abstractScene" {
  56434. interface AbstractScene {
  56435. /**
  56436. * The list of reflection probes added to the scene
  56437. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56438. */
  56439. reflectionProbes: Array<ReflectionProbe>;
  56440. /**
  56441. * Removes the given reflection probe from this scene.
  56442. * @param toRemove The reflection probe to remove
  56443. * @returns The index of the removed reflection probe
  56444. */
  56445. removeReflectionProbe(toRemove: ReflectionProbe): number;
  56446. /**
  56447. * Adds the given reflection probe to this scene.
  56448. * @param newReflectionProbe The reflection probe to add
  56449. */
  56450. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  56451. }
  56452. }
  56453. /**
  56454. * Class used to generate realtime reflection / refraction cube textures
  56455. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56456. */
  56457. export class ReflectionProbe {
  56458. /** defines the name of the probe */
  56459. name: string;
  56460. private _scene;
  56461. private _renderTargetTexture;
  56462. private _projectionMatrix;
  56463. private _viewMatrix;
  56464. private _target;
  56465. private _add;
  56466. private _attachedMesh;
  56467. private _invertYAxis;
  56468. /** Gets or sets probe position (center of the cube map) */
  56469. position: Vector3;
  56470. /**
  56471. * Creates a new reflection probe
  56472. * @param name defines the name of the probe
  56473. * @param size defines the texture resolution (for each face)
  56474. * @param scene defines the hosting scene
  56475. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  56476. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  56477. */
  56478. constructor(
  56479. /** defines the name of the probe */
  56480. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  56481. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  56482. get samples(): number;
  56483. set samples(value: number);
  56484. /** Gets or sets the refresh rate to use (on every frame by default) */
  56485. get refreshRate(): number;
  56486. set refreshRate(value: number);
  56487. /**
  56488. * Gets the hosting scene
  56489. * @returns a Scene
  56490. */
  56491. getScene(): Scene;
  56492. /** Gets the internal CubeTexture used to render to */
  56493. get cubeTexture(): RenderTargetTexture;
  56494. /** Gets the list of meshes to render */
  56495. get renderList(): Nullable<AbstractMesh[]>;
  56496. /**
  56497. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  56498. * @param mesh defines the mesh to attach to
  56499. */
  56500. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56501. /**
  56502. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  56503. * @param renderingGroupId The rendering group id corresponding to its index
  56504. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  56505. */
  56506. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  56507. /**
  56508. * Clean all associated resources
  56509. */
  56510. dispose(): void;
  56511. /**
  56512. * Converts the reflection probe information to a readable string for debug purpose.
  56513. * @param fullDetails Supports for multiple levels of logging within scene loading
  56514. * @returns the human readable reflection probe info
  56515. */
  56516. toString(fullDetails?: boolean): string;
  56517. /**
  56518. * Get the class name of the relfection probe.
  56519. * @returns "ReflectionProbe"
  56520. */
  56521. getClassName(): string;
  56522. /**
  56523. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  56524. * @returns The JSON representation of the texture
  56525. */
  56526. serialize(): any;
  56527. /**
  56528. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  56529. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  56530. * @param scene Define the scene the parsed reflection probe should be instantiated in
  56531. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  56532. * @returns The parsed reflection probe if successful
  56533. */
  56534. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  56535. }
  56536. }
  56537. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  56538. /** @hidden */
  56539. export var _BabylonLoaderRegistered: boolean;
  56540. /**
  56541. * Helps setting up some configuration for the babylon file loader.
  56542. */
  56543. export class BabylonFileLoaderConfiguration {
  56544. /**
  56545. * The loader does not allow injecting custom physix engine into the plugins.
  56546. * Unfortunately in ES6, we need to manually inject them into the plugin.
  56547. * So you could set this variable to your engine import to make it work.
  56548. */
  56549. static LoaderInjectedPhysicsEngine: any;
  56550. }
  56551. }
  56552. declare module "babylonjs/Loading/Plugins/index" {
  56553. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  56554. }
  56555. declare module "babylonjs/Loading/index" {
  56556. export * from "babylonjs/Loading/loadingScreen";
  56557. export * from "babylonjs/Loading/Plugins/index";
  56558. export * from "babylonjs/Loading/sceneLoader";
  56559. export * from "babylonjs/Loading/sceneLoaderFlags";
  56560. }
  56561. declare module "babylonjs/Materials/Background/index" {
  56562. export * from "babylonjs/Materials/Background/backgroundMaterial";
  56563. }
  56564. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  56565. import { Scene } from "babylonjs/scene";
  56566. import { Color3 } from "babylonjs/Maths/math.color";
  56567. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  56568. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56569. /**
  56570. * The Physically based simple base material of BJS.
  56571. *
  56572. * This enables better naming and convention enforcements on top of the pbrMaterial.
  56573. * It is used as the base class for both the specGloss and metalRough conventions.
  56574. */
  56575. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  56576. /**
  56577. * Number of Simultaneous lights allowed on the material.
  56578. */
  56579. maxSimultaneousLights: number;
  56580. /**
  56581. * If sets to true, disables all the lights affecting the material.
  56582. */
  56583. disableLighting: boolean;
  56584. /**
  56585. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  56586. */
  56587. environmentTexture: BaseTexture;
  56588. /**
  56589. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56590. */
  56591. invertNormalMapX: boolean;
  56592. /**
  56593. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56594. */
  56595. invertNormalMapY: boolean;
  56596. /**
  56597. * Normal map used in the model.
  56598. */
  56599. normalTexture: BaseTexture;
  56600. /**
  56601. * Emissivie color used to self-illuminate the model.
  56602. */
  56603. emissiveColor: Color3;
  56604. /**
  56605. * Emissivie texture used to self-illuminate the model.
  56606. */
  56607. emissiveTexture: BaseTexture;
  56608. /**
  56609. * Occlusion Channel Strenght.
  56610. */
  56611. occlusionStrength: number;
  56612. /**
  56613. * Occlusion Texture of the material (adding extra occlusion effects).
  56614. */
  56615. occlusionTexture: BaseTexture;
  56616. /**
  56617. * Defines the alpha limits in alpha test mode.
  56618. */
  56619. alphaCutOff: number;
  56620. /**
  56621. * Gets the current double sided mode.
  56622. */
  56623. get doubleSided(): boolean;
  56624. /**
  56625. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56626. */
  56627. set doubleSided(value: boolean);
  56628. /**
  56629. * Stores the pre-calculated light information of a mesh in a texture.
  56630. */
  56631. lightmapTexture: BaseTexture;
  56632. /**
  56633. * If true, the light map contains occlusion information instead of lighting info.
  56634. */
  56635. useLightmapAsShadowmap: boolean;
  56636. /**
  56637. * Instantiates a new PBRMaterial instance.
  56638. *
  56639. * @param name The material name
  56640. * @param scene The scene the material will be use in.
  56641. */
  56642. constructor(name: string, scene: Scene);
  56643. getClassName(): string;
  56644. }
  56645. }
  56646. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  56647. import { Scene } from "babylonjs/scene";
  56648. import { Color3 } from "babylonjs/Maths/math.color";
  56649. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56650. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  56651. /**
  56652. * The PBR material of BJS following the metal roughness convention.
  56653. *
  56654. * This fits to the PBR convention in the GLTF definition:
  56655. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56656. */
  56657. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56658. /**
  56659. * The base color has two different interpretations depending on the value of metalness.
  56660. * When the material is a metal, the base color is the specific measured reflectance value
  56661. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56662. * of the material.
  56663. */
  56664. baseColor: Color3;
  56665. /**
  56666. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56667. * well as opacity information in the alpha channel.
  56668. */
  56669. baseTexture: BaseTexture;
  56670. /**
  56671. * Specifies the metallic scalar value of the material.
  56672. * Can also be used to scale the metalness values of the metallic texture.
  56673. */
  56674. metallic: number;
  56675. /**
  56676. * Specifies the roughness scalar value of the material.
  56677. * Can also be used to scale the roughness values of the metallic texture.
  56678. */
  56679. roughness: number;
  56680. /**
  56681. * Texture containing both the metallic value in the B channel and the
  56682. * roughness value in the G channel to keep better precision.
  56683. */
  56684. metallicRoughnessTexture: BaseTexture;
  56685. /**
  56686. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56687. *
  56688. * @param name The material name
  56689. * @param scene The scene the material will be use in.
  56690. */
  56691. constructor(name: string, scene: Scene);
  56692. /**
  56693. * Return the currrent class name of the material.
  56694. */
  56695. getClassName(): string;
  56696. /**
  56697. * Makes a duplicate of the current material.
  56698. * @param name - name to use for the new material.
  56699. */
  56700. clone(name: string): PBRMetallicRoughnessMaterial;
  56701. /**
  56702. * Serialize the material to a parsable JSON object.
  56703. */
  56704. serialize(): any;
  56705. /**
  56706. * Parses a JSON object correponding to the serialize function.
  56707. */
  56708. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56709. }
  56710. }
  56711. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  56712. import { Scene } from "babylonjs/scene";
  56713. import { Color3 } from "babylonjs/Maths/math.color";
  56714. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56715. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  56716. /**
  56717. * The PBR material of BJS following the specular glossiness convention.
  56718. *
  56719. * This fits to the PBR convention in the GLTF definition:
  56720. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56721. */
  56722. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56723. /**
  56724. * Specifies the diffuse color of the material.
  56725. */
  56726. diffuseColor: Color3;
  56727. /**
  56728. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56729. * channel.
  56730. */
  56731. diffuseTexture: BaseTexture;
  56732. /**
  56733. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56734. */
  56735. specularColor: Color3;
  56736. /**
  56737. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56738. */
  56739. glossiness: number;
  56740. /**
  56741. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56742. */
  56743. specularGlossinessTexture: BaseTexture;
  56744. /**
  56745. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56746. *
  56747. * @param name The material name
  56748. * @param scene The scene the material will be use in.
  56749. */
  56750. constructor(name: string, scene: Scene);
  56751. /**
  56752. * Return the currrent class name of the material.
  56753. */
  56754. getClassName(): string;
  56755. /**
  56756. * Makes a duplicate of the current material.
  56757. * @param name - name to use for the new material.
  56758. */
  56759. clone(name: string): PBRSpecularGlossinessMaterial;
  56760. /**
  56761. * Serialize the material to a parsable JSON object.
  56762. */
  56763. serialize(): any;
  56764. /**
  56765. * Parses a JSON object correponding to the serialize function.
  56766. */
  56767. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56768. }
  56769. }
  56770. declare module "babylonjs/Materials/PBR/index" {
  56771. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  56772. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  56773. export * from "babylonjs/Materials/PBR/pbrMaterial";
  56774. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  56775. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  56776. }
  56777. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  56778. import { Nullable } from "babylonjs/types";
  56779. import { Scene } from "babylonjs/scene";
  56780. import { Matrix } from "babylonjs/Maths/math.vector";
  56781. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56782. /**
  56783. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56784. * It can help converting any input color in a desired output one. This can then be used to create effects
  56785. * from sepia, black and white to sixties or futuristic rendering...
  56786. *
  56787. * The only supported format is currently 3dl.
  56788. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56789. */
  56790. export class ColorGradingTexture extends BaseTexture {
  56791. /**
  56792. * The current texture matrix. (will always be identity in color grading texture)
  56793. */
  56794. private _textureMatrix;
  56795. /**
  56796. * The texture URL.
  56797. */
  56798. url: string;
  56799. /**
  56800. * Empty line regex stored for GC.
  56801. */
  56802. private static _noneEmptyLineRegex;
  56803. private _engine;
  56804. /**
  56805. * Instantiates a ColorGradingTexture from the following parameters.
  56806. *
  56807. * @param url The location of the color gradind data (currently only supporting 3dl)
  56808. * @param scene The scene the texture will be used in
  56809. */
  56810. constructor(url: string, scene: Scene);
  56811. /**
  56812. * Returns the texture matrix used in most of the material.
  56813. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56814. */
  56815. getTextureMatrix(): Matrix;
  56816. /**
  56817. * Occurs when the file being loaded is a .3dl LUT file.
  56818. */
  56819. private load3dlTexture;
  56820. /**
  56821. * Starts the loading process of the texture.
  56822. */
  56823. private loadTexture;
  56824. /**
  56825. * Clones the color gradind texture.
  56826. */
  56827. clone(): ColorGradingTexture;
  56828. /**
  56829. * Called during delayed load for textures.
  56830. */
  56831. delayLoad(): void;
  56832. /**
  56833. * Parses a color grading texture serialized by Babylon.
  56834. * @param parsedTexture The texture information being parsedTexture
  56835. * @param scene The scene to load the texture in
  56836. * @param rootUrl The root url of the data assets to load
  56837. * @return A color gradind texture
  56838. */
  56839. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56840. /**
  56841. * Serializes the LUT texture to json format.
  56842. */
  56843. serialize(): any;
  56844. }
  56845. }
  56846. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  56847. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56848. import { Scene } from "babylonjs/scene";
  56849. import { Nullable } from "babylonjs/types";
  56850. import "babylonjs/Engines/Extensions/engine.rawTexture";
  56851. /**
  56852. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56853. */
  56854. export class EquiRectangularCubeTexture extends BaseTexture {
  56855. /** The six faces of the cube. */
  56856. private static _FacesMapping;
  56857. private _noMipmap;
  56858. private _onLoad;
  56859. private _onError;
  56860. /** The size of the cubemap. */
  56861. private _size;
  56862. /** The buffer of the image. */
  56863. private _buffer;
  56864. /** The width of the input image. */
  56865. private _width;
  56866. /** The height of the input image. */
  56867. private _height;
  56868. /** The URL to the image. */
  56869. url: string;
  56870. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56871. coordinatesMode: number;
  56872. /**
  56873. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56874. * @param url The location of the image
  56875. * @param scene The scene the texture will be used in
  56876. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56877. * @param noMipmap Forces to not generate the mipmap if true
  56878. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56879. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56880. * @param onLoad — defines a callback called when texture is loaded
  56881. * @param onError — defines a callback called if there is an error
  56882. */
  56883. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56884. /**
  56885. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56886. */
  56887. private loadImage;
  56888. /**
  56889. * Convert the image buffer into a cubemap and create a CubeTexture.
  56890. */
  56891. private loadTexture;
  56892. /**
  56893. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56894. * @param buffer The ArrayBuffer that should be converted.
  56895. * @returns The buffer as Float32Array.
  56896. */
  56897. private getFloat32ArrayFromArrayBuffer;
  56898. /**
  56899. * Get the current class name of the texture useful for serialization or dynamic coding.
  56900. * @returns "EquiRectangularCubeTexture"
  56901. */
  56902. getClassName(): string;
  56903. /**
  56904. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56905. * @returns A clone of the current EquiRectangularCubeTexture.
  56906. */
  56907. clone(): EquiRectangularCubeTexture;
  56908. }
  56909. }
  56910. declare module "babylonjs/Misc/tga" {
  56911. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  56912. /**
  56913. * Based on jsTGALoader - Javascript loader for TGA file
  56914. * By Vincent Thibault
  56915. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56916. */
  56917. export class TGATools {
  56918. private static _TYPE_INDEXED;
  56919. private static _TYPE_RGB;
  56920. private static _TYPE_GREY;
  56921. private static _TYPE_RLE_INDEXED;
  56922. private static _TYPE_RLE_RGB;
  56923. private static _TYPE_RLE_GREY;
  56924. private static _ORIGIN_MASK;
  56925. private static _ORIGIN_SHIFT;
  56926. private static _ORIGIN_BL;
  56927. private static _ORIGIN_BR;
  56928. private static _ORIGIN_UL;
  56929. private static _ORIGIN_UR;
  56930. /**
  56931. * Gets the header of a TGA file
  56932. * @param data defines the TGA data
  56933. * @returns the header
  56934. */
  56935. static GetTGAHeader(data: Uint8Array): any;
  56936. /**
  56937. * Uploads TGA content to a Babylon Texture
  56938. * @hidden
  56939. */
  56940. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56941. /** @hidden */
  56942. 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;
  56943. /** @hidden */
  56944. 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;
  56945. /** @hidden */
  56946. 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;
  56947. /** @hidden */
  56948. 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;
  56949. /** @hidden */
  56950. 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;
  56951. /** @hidden */
  56952. 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;
  56953. }
  56954. }
  56955. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  56956. import { Nullable } from "babylonjs/types";
  56957. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  56958. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  56959. /**
  56960. * Implementation of the TGA Texture Loader.
  56961. * @hidden
  56962. */
  56963. export class _TGATextureLoader implements IInternalTextureLoader {
  56964. /**
  56965. * Defines wether the loader supports cascade loading the different faces.
  56966. */
  56967. readonly supportCascades: boolean;
  56968. /**
  56969. * This returns if the loader support the current file information.
  56970. * @param extension defines the file extension of the file being loaded
  56971. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56972. * @param fallback defines the fallback internal texture if any
  56973. * @param isBase64 defines whether the texture is encoded as a base64
  56974. * @param isBuffer defines whether the texture data are stored as a buffer
  56975. * @returns true if the loader can load the specified file
  56976. */
  56977. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  56978. /**
  56979. * Transform the url before loading if required.
  56980. * @param rootUrl the url of the texture
  56981. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56982. * @returns the transformed texture
  56983. */
  56984. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  56985. /**
  56986. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56987. * @param rootUrl the url of the texture
  56988. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56989. * @returns the fallback texture
  56990. */
  56991. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  56992. /**
  56993. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  56994. * @param data contains the texture data
  56995. * @param texture defines the BabylonJS internal texture
  56996. * @param createPolynomials will be true if polynomials have been requested
  56997. * @param onLoad defines the callback to trigger once the texture is ready
  56998. * @param onError defines the callback to trigger in case of error
  56999. */
  57000. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57001. /**
  57002. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  57003. * @param data contains the texture data
  57004. * @param texture defines the BabylonJS internal texture
  57005. * @param callback defines the method to call once ready to upload
  57006. */
  57007. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57008. }
  57009. }
  57010. declare module "babylonjs/Misc/basis" {
  57011. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57012. /**
  57013. * Info about the .basis files
  57014. */
  57015. class BasisFileInfo {
  57016. /**
  57017. * If the file has alpha
  57018. */
  57019. hasAlpha: boolean;
  57020. /**
  57021. * Info about each image of the basis file
  57022. */
  57023. images: Array<{
  57024. levels: Array<{
  57025. width: number;
  57026. height: number;
  57027. transcodedPixels: ArrayBufferView;
  57028. }>;
  57029. }>;
  57030. }
  57031. /**
  57032. * Result of transcoding a basis file
  57033. */
  57034. class TranscodeResult {
  57035. /**
  57036. * Info about the .basis file
  57037. */
  57038. fileInfo: BasisFileInfo;
  57039. /**
  57040. * Format to use when loading the file
  57041. */
  57042. format: number;
  57043. }
  57044. /**
  57045. * Configuration options for the Basis transcoder
  57046. */
  57047. export class BasisTranscodeConfiguration {
  57048. /**
  57049. * Supported compression formats used to determine the supported output format of the transcoder
  57050. */
  57051. supportedCompressionFormats?: {
  57052. /**
  57053. * etc1 compression format
  57054. */
  57055. etc1?: boolean;
  57056. /**
  57057. * s3tc compression format
  57058. */
  57059. s3tc?: boolean;
  57060. /**
  57061. * pvrtc compression format
  57062. */
  57063. pvrtc?: boolean;
  57064. /**
  57065. * etc2 compression format
  57066. */
  57067. etc2?: boolean;
  57068. };
  57069. /**
  57070. * If mipmap levels should be loaded for transcoded images (Default: true)
  57071. */
  57072. loadMipmapLevels?: boolean;
  57073. /**
  57074. * Index of a single image to load (Default: all images)
  57075. */
  57076. loadSingleImage?: number;
  57077. }
  57078. /**
  57079. * Used to load .Basis files
  57080. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  57081. */
  57082. export class BasisTools {
  57083. private static _IgnoreSupportedFormats;
  57084. /**
  57085. * URL to use when loading the basis transcoder
  57086. */
  57087. static JSModuleURL: string;
  57088. /**
  57089. * URL to use when loading the wasm module for the transcoder
  57090. */
  57091. static WasmModuleURL: string;
  57092. /**
  57093. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  57094. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  57095. * @returns internal format corresponding to the Basis format
  57096. */
  57097. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  57098. private static _WorkerPromise;
  57099. private static _Worker;
  57100. private static _actionId;
  57101. private static _CreateWorkerAsync;
  57102. /**
  57103. * Transcodes a loaded image file to compressed pixel data
  57104. * @param imageData image data to transcode
  57105. * @param config configuration options for the transcoding
  57106. * @returns a promise resulting in the transcoded image
  57107. */
  57108. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  57109. /**
  57110. * Loads a texture from the transcode result
  57111. * @param texture texture load to
  57112. * @param transcodeResult the result of transcoding the basis file to load from
  57113. */
  57114. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  57115. }
  57116. }
  57117. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  57118. import { Nullable } from "babylonjs/types";
  57119. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57120. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  57121. /**
  57122. * Loader for .basis file format
  57123. */
  57124. export class _BasisTextureLoader implements IInternalTextureLoader {
  57125. /**
  57126. * Defines whether the loader supports cascade loading the different faces.
  57127. */
  57128. readonly supportCascades: boolean;
  57129. /**
  57130. * This returns if the loader support the current file information.
  57131. * @param extension defines the file extension of the file being loaded
  57132. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57133. * @param fallback defines the fallback internal texture if any
  57134. * @param isBase64 defines whether the texture is encoded as a base64
  57135. * @param isBuffer defines whether the texture data are stored as a buffer
  57136. * @returns true if the loader can load the specified file
  57137. */
  57138. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  57139. /**
  57140. * Transform the url before loading if required.
  57141. * @param rootUrl the url of the texture
  57142. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57143. * @returns the transformed texture
  57144. */
  57145. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  57146. /**
  57147. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  57148. * @param rootUrl the url of the texture
  57149. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57150. * @returns the fallback texture
  57151. */
  57152. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  57153. /**
  57154. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  57155. * @param data contains the texture data
  57156. * @param texture defines the BabylonJS internal texture
  57157. * @param createPolynomials will be true if polynomials have been requested
  57158. * @param onLoad defines the callback to trigger once the texture is ready
  57159. * @param onError defines the callback to trigger in case of error
  57160. */
  57161. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57162. /**
  57163. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  57164. * @param data contains the texture data
  57165. * @param texture defines the BabylonJS internal texture
  57166. * @param callback defines the method to call once ready to upload
  57167. */
  57168. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57169. }
  57170. }
  57171. declare module "babylonjs/Materials/Textures/Loaders/index" {
  57172. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  57173. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  57174. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  57175. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  57176. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  57177. }
  57178. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  57179. import { Scene } from "babylonjs/scene";
  57180. import { Texture } from "babylonjs/Materials/Textures/texture";
  57181. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  57182. /**
  57183. * 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.
  57184. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  57185. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  57186. */
  57187. export class CustomProceduralTexture extends ProceduralTexture {
  57188. private _animate;
  57189. private _time;
  57190. private _config;
  57191. private _texturePath;
  57192. /**
  57193. * Instantiates a new Custom Procedural Texture.
  57194. * 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.
  57195. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  57196. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  57197. * @param name Define the name of the texture
  57198. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  57199. * @param size Define the size of the texture to create
  57200. * @param scene Define the scene the texture belongs to
  57201. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  57202. * @param generateMipMaps Define if the texture should creates mip maps or not
  57203. */
  57204. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  57205. private _loadJson;
  57206. /**
  57207. * Is the texture ready to be used ? (rendered at least once)
  57208. * @returns true if ready, otherwise, false.
  57209. */
  57210. isReady(): boolean;
  57211. /**
  57212. * Render the texture to its associated render target.
  57213. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  57214. */
  57215. render(useCameraPostProcess?: boolean): void;
  57216. /**
  57217. * Update the list of dependant textures samplers in the shader.
  57218. */
  57219. updateTextures(): void;
  57220. /**
  57221. * Update the uniform values of the procedural texture in the shader.
  57222. */
  57223. updateShaderUniforms(): void;
  57224. /**
  57225. * Define if the texture animates or not.
  57226. */
  57227. get animate(): boolean;
  57228. set animate(value: boolean);
  57229. }
  57230. }
  57231. declare module "babylonjs/Shaders/noise.fragment" {
  57232. /** @hidden */
  57233. export var noisePixelShader: {
  57234. name: string;
  57235. shader: string;
  57236. };
  57237. }
  57238. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  57239. import { Nullable } from "babylonjs/types";
  57240. import { Scene } from "babylonjs/scene";
  57241. import { Texture } from "babylonjs/Materials/Textures/texture";
  57242. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  57243. import "babylonjs/Shaders/noise.fragment";
  57244. /**
  57245. * Class used to generate noise procedural textures
  57246. */
  57247. export class NoiseProceduralTexture extends ProceduralTexture {
  57248. private _time;
  57249. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  57250. brightness: number;
  57251. /** Defines the number of octaves to process */
  57252. octaves: number;
  57253. /** Defines the level of persistence (0.8 by default) */
  57254. persistence: number;
  57255. /** Gets or sets animation speed factor (default is 1) */
  57256. animationSpeedFactor: number;
  57257. /**
  57258. * Creates a new NoiseProceduralTexture
  57259. * @param name defines the name fo the texture
  57260. * @param size defines the size of the texture (default is 256)
  57261. * @param scene defines the hosting scene
  57262. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  57263. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  57264. */
  57265. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  57266. private _updateShaderUniforms;
  57267. protected _getDefines(): string;
  57268. /** Generate the current state of the procedural texture */
  57269. render(useCameraPostProcess?: boolean): void;
  57270. /**
  57271. * Serializes this noise procedural texture
  57272. * @returns a serialized noise procedural texture object
  57273. */
  57274. serialize(): any;
  57275. /**
  57276. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  57277. * @param parsedTexture defines parsed texture data
  57278. * @param scene defines the current scene
  57279. * @param rootUrl defines the root URL containing noise procedural texture information
  57280. * @returns a parsed NoiseProceduralTexture
  57281. */
  57282. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  57283. }
  57284. }
  57285. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  57286. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  57287. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  57288. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  57289. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  57290. }
  57291. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  57292. import { Nullable } from "babylonjs/types";
  57293. import { Scene } from "babylonjs/scene";
  57294. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  57295. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57296. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  57297. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57298. /**
  57299. * Raw cube texture where the raw buffers are passed in
  57300. */
  57301. export class RawCubeTexture extends CubeTexture {
  57302. /**
  57303. * Creates a cube texture where the raw buffers are passed in.
  57304. * @param scene defines the scene the texture is attached to
  57305. * @param data defines the array of data to use to create each face
  57306. * @param size defines the size of the textures
  57307. * @param format defines the format of the data
  57308. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  57309. * @param generateMipMaps defines if the engine should generate the mip levels
  57310. * @param invertY defines if data must be stored with Y axis inverted
  57311. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  57312. * @param compression defines the compression used (null by default)
  57313. */
  57314. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  57315. /**
  57316. * Updates the raw cube texture.
  57317. * @param data defines the data to store
  57318. * @param format defines the data format
  57319. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57320. * @param invertY defines if data must be stored with Y axis inverted
  57321. * @param compression defines the compression used (null by default)
  57322. * @param level defines which level of the texture to update
  57323. */
  57324. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  57325. /**
  57326. * Updates a raw cube texture with RGBD encoded data.
  57327. * @param data defines the array of data [mipmap][face] to use to create each face
  57328. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  57329. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57330. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57331. * @returns a promsie that resolves when the operation is complete
  57332. */
  57333. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  57334. /**
  57335. * Clones the raw cube texture.
  57336. * @return a new cube texture
  57337. */
  57338. clone(): CubeTexture;
  57339. /** @hidden */
  57340. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  57341. }
  57342. }
  57343. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  57344. import { Scene } from "babylonjs/scene";
  57345. import { Texture } from "babylonjs/Materials/Textures/texture";
  57346. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57347. /**
  57348. * Class used to store 3D textures containing user data
  57349. */
  57350. export class RawTexture3D extends Texture {
  57351. /** Gets or sets the texture format to use */
  57352. format: number;
  57353. private _engine;
  57354. /**
  57355. * Create a new RawTexture3D
  57356. * @param data defines the data of the texture
  57357. * @param width defines the width of the texture
  57358. * @param height defines the height of the texture
  57359. * @param depth defines the depth of the texture
  57360. * @param format defines the texture format to use
  57361. * @param scene defines the hosting scene
  57362. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57363. * @param invertY defines if texture must be stored with Y axis inverted
  57364. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57365. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57366. */
  57367. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57368. /** Gets or sets the texture format to use */
  57369. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57370. /**
  57371. * Update the texture with new data
  57372. * @param data defines the data to store in the texture
  57373. */
  57374. update(data: ArrayBufferView): void;
  57375. }
  57376. }
  57377. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  57378. import { Scene } from "babylonjs/scene";
  57379. import { Texture } from "babylonjs/Materials/Textures/texture";
  57380. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57381. /**
  57382. * Class used to store 2D array textures containing user data
  57383. */
  57384. export class RawTexture2DArray extends Texture {
  57385. /** Gets or sets the texture format to use */
  57386. format: number;
  57387. private _engine;
  57388. /**
  57389. * Create a new RawTexture2DArray
  57390. * @param data defines the data of the texture
  57391. * @param width defines the width of the texture
  57392. * @param height defines the height of the texture
  57393. * @param depth defines the number of layers of the texture
  57394. * @param format defines the texture format to use
  57395. * @param scene defines the hosting scene
  57396. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57397. * @param invertY defines if texture must be stored with Y axis inverted
  57398. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57399. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57400. */
  57401. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57402. /** Gets or sets the texture format to use */
  57403. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57404. /**
  57405. * Update the texture with new data
  57406. * @param data defines the data to store in the texture
  57407. */
  57408. update(data: ArrayBufferView): void;
  57409. }
  57410. }
  57411. declare module "babylonjs/Materials/Textures/refractionTexture" {
  57412. import { Scene } from "babylonjs/scene";
  57413. import { Plane } from "babylonjs/Maths/math.plane";
  57414. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57415. /**
  57416. * Creates a refraction texture used by refraction channel of the standard material.
  57417. * It is like a mirror but to see through a material.
  57418. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57419. */
  57420. export class RefractionTexture extends RenderTargetTexture {
  57421. /**
  57422. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  57423. * 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.
  57424. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57425. */
  57426. refractionPlane: Plane;
  57427. /**
  57428. * Define how deep under the surface we should see.
  57429. */
  57430. depth: number;
  57431. /**
  57432. * Creates a refraction texture used by refraction channel of the standard material.
  57433. * It is like a mirror but to see through a material.
  57434. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57435. * @param name Define the texture name
  57436. * @param size Define the size of the underlying texture
  57437. * @param scene Define the scene the refraction belongs to
  57438. * @param generateMipMaps Define if we need to generate mips level for the refraction
  57439. */
  57440. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  57441. /**
  57442. * Clone the refraction texture.
  57443. * @returns the cloned texture
  57444. */
  57445. clone(): RefractionTexture;
  57446. /**
  57447. * Serialize the texture to a JSON representation you could use in Parse later on
  57448. * @returns the serialized JSON representation
  57449. */
  57450. serialize(): any;
  57451. }
  57452. }
  57453. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  57454. import { Nullable } from "babylonjs/types";
  57455. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57456. import { Matrix } from "babylonjs/Maths/math.vector";
  57457. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  57458. import "babylonjs/Engines/Extensions/engine.videoTexture";
  57459. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  57460. import { Scene } from "babylonjs/scene";
  57461. /**
  57462. * Defines the options related to the creation of an HtmlElementTexture
  57463. */
  57464. export interface IHtmlElementTextureOptions {
  57465. /**
  57466. * Defines wether mip maps should be created or not.
  57467. */
  57468. generateMipMaps?: boolean;
  57469. /**
  57470. * Defines the sampling mode of the texture.
  57471. */
  57472. samplingMode?: number;
  57473. /**
  57474. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  57475. */
  57476. engine: Nullable<ThinEngine>;
  57477. /**
  57478. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  57479. */
  57480. scene: Nullable<Scene>;
  57481. }
  57482. /**
  57483. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  57484. * To be as efficient as possible depending on your constraints nothing aside the first upload
  57485. * is automatically managed.
  57486. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  57487. * in your application.
  57488. *
  57489. * As the update is not automatic, you need to call them manually.
  57490. */
  57491. export class HtmlElementTexture extends BaseTexture {
  57492. /**
  57493. * The texture URL.
  57494. */
  57495. element: HTMLVideoElement | HTMLCanvasElement;
  57496. private static readonly DefaultOptions;
  57497. private _textureMatrix;
  57498. private _engine;
  57499. private _isVideo;
  57500. private _generateMipMaps;
  57501. private _samplingMode;
  57502. /**
  57503. * Instantiates a HtmlElementTexture from the following parameters.
  57504. *
  57505. * @param name Defines the name of the texture
  57506. * @param element Defines the video or canvas the texture is filled with
  57507. * @param options Defines the other none mandatory texture creation options
  57508. */
  57509. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  57510. private _createInternalTexture;
  57511. /**
  57512. * Returns the texture matrix used in most of the material.
  57513. */
  57514. getTextureMatrix(): Matrix;
  57515. /**
  57516. * Updates the content of the texture.
  57517. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  57518. */
  57519. update(invertY?: Nullable<boolean>): void;
  57520. }
  57521. }
  57522. declare module "babylonjs/Materials/Textures/index" {
  57523. export * from "babylonjs/Materials/Textures/baseTexture";
  57524. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  57525. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  57526. export * from "babylonjs/Materials/Textures/cubeTexture";
  57527. export * from "babylonjs/Materials/Textures/dynamicTexture";
  57528. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  57529. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  57530. export * from "babylonjs/Materials/Textures/internalTexture";
  57531. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  57532. export * from "babylonjs/Materials/Textures/Loaders/index";
  57533. export * from "babylonjs/Materials/Textures/mirrorTexture";
  57534. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  57535. export * from "babylonjs/Materials/Textures/Procedurals/index";
  57536. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  57537. export * from "babylonjs/Materials/Textures/rawTexture";
  57538. export * from "babylonjs/Materials/Textures/rawTexture3D";
  57539. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  57540. export * from "babylonjs/Materials/Textures/refractionTexture";
  57541. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  57542. export * from "babylonjs/Materials/Textures/texture";
  57543. export * from "babylonjs/Materials/Textures/videoTexture";
  57544. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  57545. }
  57546. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  57547. /**
  57548. * Enum used to define the target of a block
  57549. */
  57550. export enum NodeMaterialBlockTargets {
  57551. /** Vertex shader */
  57552. Vertex = 1,
  57553. /** Fragment shader */
  57554. Fragment = 2,
  57555. /** Neutral */
  57556. Neutral = 4,
  57557. /** Vertex and Fragment */
  57558. VertexAndFragment = 3
  57559. }
  57560. }
  57561. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  57562. /**
  57563. * Defines the kind of connection point for node based material
  57564. */
  57565. export enum NodeMaterialBlockConnectionPointTypes {
  57566. /** Float */
  57567. Float = 1,
  57568. /** Int */
  57569. Int = 2,
  57570. /** Vector2 */
  57571. Vector2 = 4,
  57572. /** Vector3 */
  57573. Vector3 = 8,
  57574. /** Vector4 */
  57575. Vector4 = 16,
  57576. /** Color3 */
  57577. Color3 = 32,
  57578. /** Color4 */
  57579. Color4 = 64,
  57580. /** Matrix */
  57581. Matrix = 128,
  57582. /** Detect type based on connection */
  57583. AutoDetect = 1024,
  57584. /** Output type that will be defined by input type */
  57585. BasedOnInput = 2048
  57586. }
  57587. }
  57588. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  57589. /**
  57590. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57591. */
  57592. export enum NodeMaterialBlockConnectionPointMode {
  57593. /** Value is an uniform */
  57594. Uniform = 0,
  57595. /** Value is a mesh attribute */
  57596. Attribute = 1,
  57597. /** Value is a varying between vertex and fragment shaders */
  57598. Varying = 2,
  57599. /** Mode is undefined */
  57600. Undefined = 3
  57601. }
  57602. }
  57603. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  57604. /**
  57605. * Enum used to define system values e.g. values automatically provided by the system
  57606. */
  57607. export enum NodeMaterialSystemValues {
  57608. /** World */
  57609. World = 1,
  57610. /** View */
  57611. View = 2,
  57612. /** Projection */
  57613. Projection = 3,
  57614. /** ViewProjection */
  57615. ViewProjection = 4,
  57616. /** WorldView */
  57617. WorldView = 5,
  57618. /** WorldViewProjection */
  57619. WorldViewProjection = 6,
  57620. /** CameraPosition */
  57621. CameraPosition = 7,
  57622. /** Fog Color */
  57623. FogColor = 8,
  57624. /** Delta time */
  57625. DeltaTime = 9
  57626. }
  57627. }
  57628. declare module "babylonjs/Materials/Node/Enums/index" {
  57629. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57630. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57631. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  57632. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  57633. }
  57634. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  57635. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57636. /**
  57637. * Root class for all node material optimizers
  57638. */
  57639. export class NodeMaterialOptimizer {
  57640. /**
  57641. * Function used to optimize a NodeMaterial graph
  57642. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57643. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57644. */
  57645. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57646. }
  57647. }
  57648. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  57649. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57650. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57651. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57652. import { Scene } from "babylonjs/scene";
  57653. /**
  57654. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57655. */
  57656. export class TransformBlock extends NodeMaterialBlock {
  57657. /**
  57658. * Defines the value to use to complement W value to transform it to a Vector4
  57659. */
  57660. complementW: number;
  57661. /**
  57662. * Defines the value to use to complement z value to transform it to a Vector4
  57663. */
  57664. complementZ: number;
  57665. /**
  57666. * Creates a new TransformBlock
  57667. * @param name defines the block name
  57668. */
  57669. constructor(name: string);
  57670. /**
  57671. * Gets the current class name
  57672. * @returns the class name
  57673. */
  57674. getClassName(): string;
  57675. /**
  57676. * Gets the vector input
  57677. */
  57678. get vector(): NodeMaterialConnectionPoint;
  57679. /**
  57680. * Gets the output component
  57681. */
  57682. get output(): NodeMaterialConnectionPoint;
  57683. /**
  57684. * Gets the matrix transform input
  57685. */
  57686. get transform(): NodeMaterialConnectionPoint;
  57687. protected _buildBlock(state: NodeMaterialBuildState): this;
  57688. serialize(): any;
  57689. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57690. protected _dumpPropertiesCode(): string;
  57691. }
  57692. }
  57693. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  57694. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57695. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57696. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57697. /**
  57698. * Block used to output the vertex position
  57699. */
  57700. export class VertexOutputBlock extends NodeMaterialBlock {
  57701. /**
  57702. * Creates a new VertexOutputBlock
  57703. * @param name defines the block name
  57704. */
  57705. constructor(name: string);
  57706. /**
  57707. * Gets the current class name
  57708. * @returns the class name
  57709. */
  57710. getClassName(): string;
  57711. /**
  57712. * Gets the vector input component
  57713. */
  57714. get vector(): NodeMaterialConnectionPoint;
  57715. protected _buildBlock(state: NodeMaterialBuildState): this;
  57716. }
  57717. }
  57718. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  57719. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57720. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57721. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57722. /**
  57723. * Block used to output the final color
  57724. */
  57725. export class FragmentOutputBlock extends NodeMaterialBlock {
  57726. /**
  57727. * Create a new FragmentOutputBlock
  57728. * @param name defines the block name
  57729. */
  57730. constructor(name: string);
  57731. /**
  57732. * Gets the current class name
  57733. * @returns the class name
  57734. */
  57735. getClassName(): string;
  57736. /**
  57737. * Gets the rgba input component
  57738. */
  57739. get rgba(): NodeMaterialConnectionPoint;
  57740. /**
  57741. * Gets the rgb input component
  57742. */
  57743. get rgb(): NodeMaterialConnectionPoint;
  57744. /**
  57745. * Gets the a input component
  57746. */
  57747. get a(): NodeMaterialConnectionPoint;
  57748. protected _buildBlock(state: NodeMaterialBuildState): this;
  57749. }
  57750. }
  57751. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  57752. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57753. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57754. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57755. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57757. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57758. import { Effect } from "babylonjs/Materials/effect";
  57759. import { Mesh } from "babylonjs/Meshes/mesh";
  57760. import { Nullable } from "babylonjs/types";
  57761. import { Scene } from "babylonjs/scene";
  57762. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  57763. /**
  57764. * Block used to read a reflection texture from a sampler
  57765. */
  57766. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57767. private _define3DName;
  57768. private _defineCubicName;
  57769. private _defineExplicitName;
  57770. private _defineProjectionName;
  57771. private _defineLocalCubicName;
  57772. private _defineSphericalName;
  57773. private _definePlanarName;
  57774. private _defineEquirectangularName;
  57775. private _defineMirroredEquirectangularFixedName;
  57776. private _defineEquirectangularFixedName;
  57777. private _defineSkyboxName;
  57778. private _cubeSamplerName;
  57779. private _2DSamplerName;
  57780. private _positionUVWName;
  57781. private _directionWName;
  57782. private _reflectionCoordsName;
  57783. private _reflection2DCoordsName;
  57784. private _reflectionColorName;
  57785. private _reflectionMatrixName;
  57786. /**
  57787. * Gets or sets the texture associated with the node
  57788. */
  57789. texture: Nullable<BaseTexture>;
  57790. /**
  57791. * Create a new TextureBlock
  57792. * @param name defines the block name
  57793. */
  57794. constructor(name: string);
  57795. /**
  57796. * Gets the current class name
  57797. * @returns the class name
  57798. */
  57799. getClassName(): string;
  57800. /**
  57801. * Gets the world position input component
  57802. */
  57803. get position(): NodeMaterialConnectionPoint;
  57804. /**
  57805. * Gets the world position input component
  57806. */
  57807. get worldPosition(): NodeMaterialConnectionPoint;
  57808. /**
  57809. * Gets the world normal input component
  57810. */
  57811. get worldNormal(): NodeMaterialConnectionPoint;
  57812. /**
  57813. * Gets the world input component
  57814. */
  57815. get world(): NodeMaterialConnectionPoint;
  57816. /**
  57817. * Gets the camera (or eye) position component
  57818. */
  57819. get cameraPosition(): NodeMaterialConnectionPoint;
  57820. /**
  57821. * Gets the view input component
  57822. */
  57823. get view(): NodeMaterialConnectionPoint;
  57824. /**
  57825. * Gets the rgb output component
  57826. */
  57827. get rgb(): NodeMaterialConnectionPoint;
  57828. /**
  57829. * Gets the r output component
  57830. */
  57831. get r(): NodeMaterialConnectionPoint;
  57832. /**
  57833. * Gets the g output component
  57834. */
  57835. get g(): NodeMaterialConnectionPoint;
  57836. /**
  57837. * Gets the b output component
  57838. */
  57839. get b(): NodeMaterialConnectionPoint;
  57840. autoConfigure(material: NodeMaterial): void;
  57841. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57842. isReady(): boolean;
  57843. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57844. private _injectVertexCode;
  57845. private _writeOutput;
  57846. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57847. protected _dumpPropertiesCode(): string;
  57848. serialize(): any;
  57849. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57850. }
  57851. }
  57852. declare module "babylonjs/Materials/Node/nodeMaterial" {
  57853. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57854. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  57855. import { Scene } from "babylonjs/scene";
  57856. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57857. import { Matrix } from "babylonjs/Maths/math.vector";
  57858. import { Mesh } from "babylonjs/Meshes/mesh";
  57859. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57860. import { Observable } from "babylonjs/Misc/observable";
  57861. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57862. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  57863. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  57864. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  57865. import { Nullable } from "babylonjs/types";
  57866. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57867. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  57868. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  57869. /**
  57870. * Interface used to configure the node material editor
  57871. */
  57872. export interface INodeMaterialEditorOptions {
  57873. /** Define the URl to load node editor script */
  57874. editorURL?: string;
  57875. }
  57876. /** @hidden */
  57877. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57878. /** BONES */
  57879. NUM_BONE_INFLUENCERS: number;
  57880. BonesPerMesh: number;
  57881. BONETEXTURE: boolean;
  57882. /** MORPH TARGETS */
  57883. MORPHTARGETS: boolean;
  57884. MORPHTARGETS_NORMAL: boolean;
  57885. MORPHTARGETS_TANGENT: boolean;
  57886. MORPHTARGETS_UV: boolean;
  57887. NUM_MORPH_INFLUENCERS: number;
  57888. /** IMAGE PROCESSING */
  57889. IMAGEPROCESSING: boolean;
  57890. VIGNETTE: boolean;
  57891. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57892. VIGNETTEBLENDMODEOPAQUE: boolean;
  57893. TONEMAPPING: boolean;
  57894. TONEMAPPING_ACES: boolean;
  57895. CONTRAST: boolean;
  57896. EXPOSURE: boolean;
  57897. COLORCURVES: boolean;
  57898. COLORGRADING: boolean;
  57899. COLORGRADING3D: boolean;
  57900. SAMPLER3DGREENDEPTH: boolean;
  57901. SAMPLER3DBGRMAP: boolean;
  57902. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57903. /** MISC. */
  57904. BUMPDIRECTUV: number;
  57905. constructor();
  57906. setValue(name: string, value: boolean): void;
  57907. }
  57908. /**
  57909. * Class used to configure NodeMaterial
  57910. */
  57911. export interface INodeMaterialOptions {
  57912. /**
  57913. * Defines if blocks should emit comments
  57914. */
  57915. emitComments: boolean;
  57916. }
  57917. /**
  57918. * Class used to create a node based material built by assembling shader blocks
  57919. */
  57920. export class NodeMaterial extends PushMaterial {
  57921. private static _BuildIdGenerator;
  57922. private _options;
  57923. private _vertexCompilationState;
  57924. private _fragmentCompilationState;
  57925. private _sharedData;
  57926. private _buildId;
  57927. private _buildWasSuccessful;
  57928. private _cachedWorldViewMatrix;
  57929. private _cachedWorldViewProjectionMatrix;
  57930. private _optimizers;
  57931. private _animationFrame;
  57932. /** Define the URl to load node editor script */
  57933. static EditorURL: string;
  57934. private BJSNODEMATERIALEDITOR;
  57935. /** Get the inspector from bundle or global */
  57936. private _getGlobalNodeMaterialEditor;
  57937. /**
  57938. * Gets or sets data used by visual editor
  57939. * @see https://nme.babylonjs.com
  57940. */
  57941. editorData: any;
  57942. /**
  57943. * 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)
  57944. */
  57945. ignoreAlpha: boolean;
  57946. /**
  57947. * Defines the maximum number of lights that can be used in the material
  57948. */
  57949. maxSimultaneousLights: number;
  57950. /**
  57951. * Observable raised when the material is built
  57952. */
  57953. onBuildObservable: Observable<NodeMaterial>;
  57954. /**
  57955. * Gets or sets the root nodes of the material vertex shader
  57956. */
  57957. _vertexOutputNodes: NodeMaterialBlock[];
  57958. /**
  57959. * Gets or sets the root nodes of the material fragment (pixel) shader
  57960. */
  57961. _fragmentOutputNodes: NodeMaterialBlock[];
  57962. /** Gets or sets options to control the node material overall behavior */
  57963. get options(): INodeMaterialOptions;
  57964. set options(options: INodeMaterialOptions);
  57965. /**
  57966. * Default configuration related to image processing available in the standard Material.
  57967. */
  57968. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57969. /**
  57970. * Gets the image processing configuration used either in this material.
  57971. */
  57972. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57973. /**
  57974. * Sets the Default image processing configuration used either in the this material.
  57975. *
  57976. * If sets to null, the scene one is in use.
  57977. */
  57978. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57979. /**
  57980. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57981. */
  57982. attachedBlocks: NodeMaterialBlock[];
  57983. /**
  57984. * Create a new node based material
  57985. * @param name defines the material name
  57986. * @param scene defines the hosting scene
  57987. * @param options defines creation option
  57988. */
  57989. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57990. /**
  57991. * Gets the current class name of the material e.g. "NodeMaterial"
  57992. * @returns the class name
  57993. */
  57994. getClassName(): string;
  57995. /**
  57996. * Keep track of the image processing observer to allow dispose and replace.
  57997. */
  57998. private _imageProcessingObserver;
  57999. /**
  58000. * Attaches a new image processing configuration to the Standard Material.
  58001. * @param configuration
  58002. */
  58003. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58004. /**
  58005. * Get a block by its name
  58006. * @param name defines the name of the block to retrieve
  58007. * @returns the required block or null if not found
  58008. */
  58009. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  58010. /**
  58011. * Get a block by its name
  58012. * @param predicate defines the predicate used to find the good candidate
  58013. * @returns the required block or null if not found
  58014. */
  58015. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  58016. /**
  58017. * Get an input block by its name
  58018. * @param predicate defines the predicate used to find the good candidate
  58019. * @returns the required input block or null if not found
  58020. */
  58021. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  58022. /**
  58023. * Gets the list of input blocks attached to this material
  58024. * @returns an array of InputBlocks
  58025. */
  58026. getInputBlocks(): InputBlock[];
  58027. /**
  58028. * Adds a new optimizer to the list of optimizers
  58029. * @param optimizer defines the optimizers to add
  58030. * @returns the current material
  58031. */
  58032. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  58033. /**
  58034. * Remove an optimizer from the list of optimizers
  58035. * @param optimizer defines the optimizers to remove
  58036. * @returns the current material
  58037. */
  58038. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  58039. /**
  58040. * Add a new block to the list of output nodes
  58041. * @param node defines the node to add
  58042. * @returns the current material
  58043. */
  58044. addOutputNode(node: NodeMaterialBlock): this;
  58045. /**
  58046. * Remove a block from the list of root nodes
  58047. * @param node defines the node to remove
  58048. * @returns the current material
  58049. */
  58050. removeOutputNode(node: NodeMaterialBlock): this;
  58051. private _addVertexOutputNode;
  58052. private _removeVertexOutputNode;
  58053. private _addFragmentOutputNode;
  58054. private _removeFragmentOutputNode;
  58055. /**
  58056. * Specifies if the material will require alpha blending
  58057. * @returns a boolean specifying if alpha blending is needed
  58058. */
  58059. needAlphaBlending(): boolean;
  58060. /**
  58061. * Specifies if this material should be rendered in alpha test mode
  58062. * @returns a boolean specifying if an alpha test is needed.
  58063. */
  58064. needAlphaTesting(): boolean;
  58065. private _initializeBlock;
  58066. private _resetDualBlocks;
  58067. /**
  58068. * Remove a block from the current node material
  58069. * @param block defines the block to remove
  58070. */
  58071. removeBlock(block: NodeMaterialBlock): void;
  58072. /**
  58073. * Build the material and generates the inner effect
  58074. * @param verbose defines if the build should log activity
  58075. */
  58076. build(verbose?: boolean): void;
  58077. /**
  58078. * Runs an otpimization phase to try to improve the shader code
  58079. */
  58080. optimize(): void;
  58081. private _prepareDefinesForAttributes;
  58082. /**
  58083. * Get if the submesh is ready to be used and all its information available.
  58084. * Child classes can use it to update shaders
  58085. * @param mesh defines the mesh to check
  58086. * @param subMesh defines which submesh to check
  58087. * @param useInstances specifies that instances should be used
  58088. * @returns a boolean indicating that the submesh is ready or not
  58089. */
  58090. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58091. /**
  58092. * Get a string representing the shaders built by the current node graph
  58093. */
  58094. get compiledShaders(): string;
  58095. /**
  58096. * Binds the world matrix to the material
  58097. * @param world defines the world transformation matrix
  58098. */
  58099. bindOnlyWorldMatrix(world: Matrix): void;
  58100. /**
  58101. * Binds the submesh to this material by preparing the effect and shader to draw
  58102. * @param world defines the world transformation matrix
  58103. * @param mesh defines the mesh containing the submesh
  58104. * @param subMesh defines the submesh to bind the material to
  58105. */
  58106. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58107. /**
  58108. * Gets the active textures from the material
  58109. * @returns an array of textures
  58110. */
  58111. getActiveTextures(): BaseTexture[];
  58112. /**
  58113. * Gets the list of texture blocks
  58114. * @returns an array of texture blocks
  58115. */
  58116. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  58117. /**
  58118. * Specifies if the material uses a texture
  58119. * @param texture defines the texture to check against the material
  58120. * @returns a boolean specifying if the material uses the texture
  58121. */
  58122. hasTexture(texture: BaseTexture): boolean;
  58123. /**
  58124. * Disposes the material
  58125. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  58126. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  58127. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  58128. */
  58129. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  58130. /** Creates the node editor window. */
  58131. private _createNodeEditor;
  58132. /**
  58133. * Launch the node material editor
  58134. * @param config Define the configuration of the editor
  58135. * @return a promise fulfilled when the node editor is visible
  58136. */
  58137. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  58138. /**
  58139. * Clear the current material
  58140. */
  58141. clear(): void;
  58142. /**
  58143. * Clear the current material and set it to a default state
  58144. */
  58145. setToDefault(): void;
  58146. /**
  58147. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  58148. * @param url defines the url to load from
  58149. * @returns a promise that will fullfil when the material is fully loaded
  58150. */
  58151. loadAsync(url: string): Promise<void>;
  58152. private _gatherBlocks;
  58153. /**
  58154. * Generate a string containing the code declaration required to create an equivalent of this material
  58155. * @returns a string
  58156. */
  58157. generateCode(): string;
  58158. /**
  58159. * Serializes this material in a JSON representation
  58160. * @returns the serialized material object
  58161. */
  58162. serialize(): any;
  58163. private _restoreConnections;
  58164. /**
  58165. * Clear the current graph and load a new one from a serialization object
  58166. * @param source defines the JSON representation of the material
  58167. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58168. */
  58169. loadFromSerialization(source: any, rootUrl?: string): void;
  58170. /**
  58171. * Creates a node material from parsed material data
  58172. * @param source defines the JSON representation of the material
  58173. * @param scene defines the hosting scene
  58174. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58175. * @returns a new node material
  58176. */
  58177. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  58178. /**
  58179. * Creates a new node material set to default basic configuration
  58180. * @param name defines the name of the material
  58181. * @param scene defines the hosting scene
  58182. * @returns a new NodeMaterial
  58183. */
  58184. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  58185. }
  58186. }
  58187. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  58188. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58189. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58190. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58191. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58192. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58193. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58194. import { Effect } from "babylonjs/Materials/effect";
  58195. import { Mesh } from "babylonjs/Meshes/mesh";
  58196. import { Nullable } from "babylonjs/types";
  58197. import { Texture } from "babylonjs/Materials/Textures/texture";
  58198. import { Scene } from "babylonjs/scene";
  58199. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58200. /**
  58201. * Block used to read a texture from a sampler
  58202. */
  58203. export class TextureBlock extends NodeMaterialBlock {
  58204. private _defineName;
  58205. private _linearDefineName;
  58206. private _tempTextureRead;
  58207. private _samplerName;
  58208. private _transformedUVName;
  58209. private _textureTransformName;
  58210. private _textureInfoName;
  58211. private _mainUVName;
  58212. private _mainUVDefineName;
  58213. /**
  58214. * Gets or sets the texture associated with the node
  58215. */
  58216. texture: Nullable<Texture>;
  58217. /**
  58218. * Create a new TextureBlock
  58219. * @param name defines the block name
  58220. */
  58221. constructor(name: string);
  58222. /**
  58223. * Gets the current class name
  58224. * @returns the class name
  58225. */
  58226. getClassName(): string;
  58227. /**
  58228. * Gets the uv input component
  58229. */
  58230. get uv(): NodeMaterialConnectionPoint;
  58231. /**
  58232. * Gets the rgba output component
  58233. */
  58234. get rgba(): NodeMaterialConnectionPoint;
  58235. /**
  58236. * Gets the rgb output component
  58237. */
  58238. get rgb(): NodeMaterialConnectionPoint;
  58239. /**
  58240. * Gets the r output component
  58241. */
  58242. get r(): NodeMaterialConnectionPoint;
  58243. /**
  58244. * Gets the g output component
  58245. */
  58246. get g(): NodeMaterialConnectionPoint;
  58247. /**
  58248. * Gets the b output component
  58249. */
  58250. get b(): NodeMaterialConnectionPoint;
  58251. /**
  58252. * Gets the a output component
  58253. */
  58254. get a(): NodeMaterialConnectionPoint;
  58255. get target(): NodeMaterialBlockTargets;
  58256. autoConfigure(material: NodeMaterial): void;
  58257. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58258. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58259. private _getTextureBase;
  58260. isReady(): boolean;
  58261. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58262. private get _isMixed();
  58263. private _injectVertexCode;
  58264. private _writeTextureRead;
  58265. private _writeOutput;
  58266. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58267. protected _dumpPropertiesCode(): string;
  58268. serialize(): any;
  58269. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58270. }
  58271. }
  58272. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  58273. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58274. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58275. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  58276. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  58277. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  58278. import { Scene } from "babylonjs/scene";
  58279. /**
  58280. * Class used to store shared data between 2 NodeMaterialBuildState
  58281. */
  58282. export class NodeMaterialBuildStateSharedData {
  58283. /**
  58284. * Gets the list of emitted varyings
  58285. */
  58286. temps: string[];
  58287. /**
  58288. * Gets the list of emitted varyings
  58289. */
  58290. varyings: string[];
  58291. /**
  58292. * Gets the varying declaration string
  58293. */
  58294. varyingDeclaration: string;
  58295. /**
  58296. * Input blocks
  58297. */
  58298. inputBlocks: InputBlock[];
  58299. /**
  58300. * Input blocks
  58301. */
  58302. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  58303. /**
  58304. * Bindable blocks (Blocks that need to set data to the effect)
  58305. */
  58306. bindableBlocks: NodeMaterialBlock[];
  58307. /**
  58308. * List of blocks that can provide a compilation fallback
  58309. */
  58310. blocksWithFallbacks: NodeMaterialBlock[];
  58311. /**
  58312. * List of blocks that can provide a define update
  58313. */
  58314. blocksWithDefines: NodeMaterialBlock[];
  58315. /**
  58316. * List of blocks that can provide a repeatable content
  58317. */
  58318. repeatableContentBlocks: NodeMaterialBlock[];
  58319. /**
  58320. * List of blocks that can provide a dynamic list of uniforms
  58321. */
  58322. dynamicUniformBlocks: NodeMaterialBlock[];
  58323. /**
  58324. * List of blocks that can block the isReady function for the material
  58325. */
  58326. blockingBlocks: NodeMaterialBlock[];
  58327. /**
  58328. * Gets the list of animated inputs
  58329. */
  58330. animatedInputs: InputBlock[];
  58331. /**
  58332. * Build Id used to avoid multiple recompilations
  58333. */
  58334. buildId: number;
  58335. /** List of emitted variables */
  58336. variableNames: {
  58337. [key: string]: number;
  58338. };
  58339. /** List of emitted defines */
  58340. defineNames: {
  58341. [key: string]: number;
  58342. };
  58343. /** Should emit comments? */
  58344. emitComments: boolean;
  58345. /** Emit build activity */
  58346. verbose: boolean;
  58347. /** Gets or sets the hosting scene */
  58348. scene: Scene;
  58349. /**
  58350. * Gets the compilation hints emitted at compilation time
  58351. */
  58352. hints: {
  58353. needWorldViewMatrix: boolean;
  58354. needWorldViewProjectionMatrix: boolean;
  58355. needAlphaBlending: boolean;
  58356. needAlphaTesting: boolean;
  58357. };
  58358. /**
  58359. * List of compilation checks
  58360. */
  58361. checks: {
  58362. emitVertex: boolean;
  58363. emitFragment: boolean;
  58364. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  58365. };
  58366. /** Creates a new shared data */
  58367. constructor();
  58368. /**
  58369. * Emits console errors and exceptions if there is a failing check
  58370. */
  58371. emitErrors(): void;
  58372. }
  58373. }
  58374. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  58375. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58376. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58377. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  58378. /**
  58379. * Class used to store node based material build state
  58380. */
  58381. export class NodeMaterialBuildState {
  58382. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  58383. supportUniformBuffers: boolean;
  58384. /**
  58385. * Gets the list of emitted attributes
  58386. */
  58387. attributes: string[];
  58388. /**
  58389. * Gets the list of emitted uniforms
  58390. */
  58391. uniforms: string[];
  58392. /**
  58393. * Gets the list of emitted constants
  58394. */
  58395. constants: string[];
  58396. /**
  58397. * Gets the list of emitted samplers
  58398. */
  58399. samplers: string[];
  58400. /**
  58401. * Gets the list of emitted functions
  58402. */
  58403. functions: {
  58404. [key: string]: string;
  58405. };
  58406. /**
  58407. * Gets the list of emitted extensions
  58408. */
  58409. extensions: {
  58410. [key: string]: string;
  58411. };
  58412. /**
  58413. * Gets the target of the compilation state
  58414. */
  58415. target: NodeMaterialBlockTargets;
  58416. /**
  58417. * Gets the list of emitted counters
  58418. */
  58419. counters: {
  58420. [key: string]: number;
  58421. };
  58422. /**
  58423. * Shared data between multiple NodeMaterialBuildState instances
  58424. */
  58425. sharedData: NodeMaterialBuildStateSharedData;
  58426. /** @hidden */
  58427. _vertexState: NodeMaterialBuildState;
  58428. /** @hidden */
  58429. _attributeDeclaration: string;
  58430. /** @hidden */
  58431. _uniformDeclaration: string;
  58432. /** @hidden */
  58433. _constantDeclaration: string;
  58434. /** @hidden */
  58435. _samplerDeclaration: string;
  58436. /** @hidden */
  58437. _varyingTransfer: string;
  58438. private _repeatableContentAnchorIndex;
  58439. /** @hidden */
  58440. _builtCompilationString: string;
  58441. /**
  58442. * Gets the emitted compilation strings
  58443. */
  58444. compilationString: string;
  58445. /**
  58446. * Finalize the compilation strings
  58447. * @param state defines the current compilation state
  58448. */
  58449. finalize(state: NodeMaterialBuildState): void;
  58450. /** @hidden */
  58451. get _repeatableContentAnchor(): string;
  58452. /** @hidden */
  58453. _getFreeVariableName(prefix: string): string;
  58454. /** @hidden */
  58455. _getFreeDefineName(prefix: string): string;
  58456. /** @hidden */
  58457. _excludeVariableName(name: string): void;
  58458. /** @hidden */
  58459. _emit2DSampler(name: string): void;
  58460. /** @hidden */
  58461. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  58462. /** @hidden */
  58463. _emitExtension(name: string, extension: string): void;
  58464. /** @hidden */
  58465. _emitFunction(name: string, code: string, comments: string): void;
  58466. /** @hidden */
  58467. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  58468. replaceStrings?: {
  58469. search: RegExp;
  58470. replace: string;
  58471. }[];
  58472. repeatKey?: string;
  58473. }): string;
  58474. /** @hidden */
  58475. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  58476. repeatKey?: string;
  58477. removeAttributes?: boolean;
  58478. removeUniforms?: boolean;
  58479. removeVaryings?: boolean;
  58480. removeIfDef?: boolean;
  58481. replaceStrings?: {
  58482. search: RegExp;
  58483. replace: string;
  58484. }[];
  58485. }, storeKey?: string): void;
  58486. /** @hidden */
  58487. _registerTempVariable(name: string): boolean;
  58488. /** @hidden */
  58489. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  58490. /** @hidden */
  58491. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  58492. /** @hidden */
  58493. _emitFloat(value: number): string;
  58494. }
  58495. }
  58496. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  58497. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58498. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58499. import { Nullable } from "babylonjs/types";
  58500. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58501. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58502. import { Effect } from "babylonjs/Materials/effect";
  58503. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58504. import { Mesh } from "babylonjs/Meshes/mesh";
  58505. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58506. import { Scene } from "babylonjs/scene";
  58507. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58508. /**
  58509. * Defines a block that can be used inside a node based material
  58510. */
  58511. export class NodeMaterialBlock {
  58512. private _buildId;
  58513. private _buildTarget;
  58514. private _target;
  58515. private _isFinalMerger;
  58516. private _isInput;
  58517. protected _isUnique: boolean;
  58518. /** @hidden */
  58519. _codeVariableName: string;
  58520. /** @hidden */
  58521. _inputs: NodeMaterialConnectionPoint[];
  58522. /** @hidden */
  58523. _outputs: NodeMaterialConnectionPoint[];
  58524. /** @hidden */
  58525. _preparationId: number;
  58526. /**
  58527. * Gets or sets the name of the block
  58528. */
  58529. name: string;
  58530. /**
  58531. * Gets or sets the unique id of the node
  58532. */
  58533. uniqueId: number;
  58534. /**
  58535. * Gets or sets the comments associated with this block
  58536. */
  58537. comments: string;
  58538. /**
  58539. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  58540. */
  58541. get isUnique(): boolean;
  58542. /**
  58543. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  58544. */
  58545. get isFinalMerger(): boolean;
  58546. /**
  58547. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  58548. */
  58549. get isInput(): boolean;
  58550. /**
  58551. * Gets or sets the build Id
  58552. */
  58553. get buildId(): number;
  58554. set buildId(value: number);
  58555. /**
  58556. * Gets or sets the target of the block
  58557. */
  58558. get target(): NodeMaterialBlockTargets;
  58559. set target(value: NodeMaterialBlockTargets);
  58560. /**
  58561. * Gets the list of input points
  58562. */
  58563. get inputs(): NodeMaterialConnectionPoint[];
  58564. /** Gets the list of output points */
  58565. get outputs(): NodeMaterialConnectionPoint[];
  58566. /**
  58567. * Find an input by its name
  58568. * @param name defines the name of the input to look for
  58569. * @returns the input or null if not found
  58570. */
  58571. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58572. /**
  58573. * Find an output by its name
  58574. * @param name defines the name of the outputto look for
  58575. * @returns the output or null if not found
  58576. */
  58577. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58578. /**
  58579. * Creates a new NodeMaterialBlock
  58580. * @param name defines the block name
  58581. * @param target defines the target of that block (Vertex by default)
  58582. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  58583. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  58584. */
  58585. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  58586. /**
  58587. * Initialize the block and prepare the context for build
  58588. * @param state defines the state that will be used for the build
  58589. */
  58590. initialize(state: NodeMaterialBuildState): void;
  58591. /**
  58592. * Bind data to effect. Will only be called for blocks with isBindable === true
  58593. * @param effect defines the effect to bind data to
  58594. * @param nodeMaterial defines the hosting NodeMaterial
  58595. * @param mesh defines the mesh that will be rendered
  58596. */
  58597. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58598. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  58599. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  58600. protected _writeFloat(value: number): string;
  58601. /**
  58602. * Gets the current class name e.g. "NodeMaterialBlock"
  58603. * @returns the class name
  58604. */
  58605. getClassName(): string;
  58606. /**
  58607. * Register a new input. Must be called inside a block constructor
  58608. * @param name defines the connection point name
  58609. * @param type defines the connection point type
  58610. * @param isOptional defines a boolean indicating that this input can be omitted
  58611. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58612. * @returns the current block
  58613. */
  58614. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  58615. /**
  58616. * Register a new output. Must be called inside a block constructor
  58617. * @param name defines the connection point name
  58618. * @param type defines the connection point type
  58619. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58620. * @returns the current block
  58621. */
  58622. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  58623. /**
  58624. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  58625. * @param forOutput defines an optional connection point to check compatibility with
  58626. * @returns the first available input or null
  58627. */
  58628. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  58629. /**
  58630. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  58631. * @param forBlock defines an optional block to check compatibility with
  58632. * @returns the first available input or null
  58633. */
  58634. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  58635. /**
  58636. * Gets the sibling of the given output
  58637. * @param current defines the current output
  58638. * @returns the next output in the list or null
  58639. */
  58640. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  58641. /**
  58642. * Connect current block with another block
  58643. * @param other defines the block to connect with
  58644. * @param options define the various options to help pick the right connections
  58645. * @returns the current block
  58646. */
  58647. connectTo(other: NodeMaterialBlock, options?: {
  58648. input?: string;
  58649. output?: string;
  58650. outputSwizzle?: string;
  58651. }): this | undefined;
  58652. protected _buildBlock(state: NodeMaterialBuildState): void;
  58653. /**
  58654. * Add uniforms, samplers and uniform buffers at compilation time
  58655. * @param state defines the state to update
  58656. * @param nodeMaterial defines the node material requesting the update
  58657. * @param defines defines the material defines to update
  58658. * @param uniformBuffers defines the list of uniform buffer names
  58659. */
  58660. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58661. /**
  58662. * Add potential fallbacks if shader compilation fails
  58663. * @param mesh defines the mesh to be rendered
  58664. * @param fallbacks defines the current prioritized list of fallbacks
  58665. */
  58666. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58667. /**
  58668. * Initialize defines for shader compilation
  58669. * @param mesh defines the mesh to be rendered
  58670. * @param nodeMaterial defines the node material requesting the update
  58671. * @param defines defines the material defines to update
  58672. * @param useInstances specifies that instances should be used
  58673. */
  58674. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58675. /**
  58676. * Update defines for shader compilation
  58677. * @param mesh defines the mesh to be rendered
  58678. * @param nodeMaterial defines the node material requesting the update
  58679. * @param defines defines the material defines to update
  58680. * @param useInstances specifies that instances should be used
  58681. */
  58682. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58683. /**
  58684. * Lets the block try to connect some inputs automatically
  58685. * @param material defines the hosting NodeMaterial
  58686. */
  58687. autoConfigure(material: NodeMaterial): void;
  58688. /**
  58689. * Function called when a block is declared as repeatable content generator
  58690. * @param vertexShaderState defines the current compilation state for the vertex shader
  58691. * @param fragmentShaderState defines the current compilation state for the fragment shader
  58692. * @param mesh defines the mesh to be rendered
  58693. * @param defines defines the material defines to update
  58694. */
  58695. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58696. /**
  58697. * Checks if the block is ready
  58698. * @param mesh defines the mesh to be rendered
  58699. * @param nodeMaterial defines the node material requesting the update
  58700. * @param defines defines the material defines to update
  58701. * @param useInstances specifies that instances should be used
  58702. * @returns true if the block is ready
  58703. */
  58704. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  58705. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  58706. private _processBuild;
  58707. /**
  58708. * Compile the current node and generate the shader code
  58709. * @param state defines the current compilation state (uniforms, samplers, current string)
  58710. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  58711. * @returns true if already built
  58712. */
  58713. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  58714. protected _inputRename(name: string): string;
  58715. protected _outputRename(name: string): string;
  58716. protected _dumpPropertiesCode(): string;
  58717. /** @hidden */
  58718. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  58719. /** @hidden */
  58720. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  58721. /**
  58722. * Clone the current block to a new identical block
  58723. * @param scene defines the hosting scene
  58724. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58725. * @returns a copy of the current block
  58726. */
  58727. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  58728. /**
  58729. * Serializes this block in a JSON representation
  58730. * @returns the serialized block object
  58731. */
  58732. serialize(): any;
  58733. /** @hidden */
  58734. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58735. /**
  58736. * Release resources
  58737. */
  58738. dispose(): void;
  58739. }
  58740. }
  58741. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  58742. /**
  58743. * Enum defining the type of animations supported by InputBlock
  58744. */
  58745. export enum AnimatedInputBlockTypes {
  58746. /** No animation */
  58747. None = 0,
  58748. /** Time based animation. Will only work for floats */
  58749. Time = 1
  58750. }
  58751. }
  58752. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  58753. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58754. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58755. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  58756. import { Nullable } from "babylonjs/types";
  58757. import { Effect } from "babylonjs/Materials/effect";
  58758. import { Matrix } from "babylonjs/Maths/math.vector";
  58759. import { Scene } from "babylonjs/scene";
  58760. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58761. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58762. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58763. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  58764. /**
  58765. * Block used to expose an input value
  58766. */
  58767. export class InputBlock extends NodeMaterialBlock {
  58768. private _mode;
  58769. private _associatedVariableName;
  58770. private _storedValue;
  58771. private _valueCallback;
  58772. private _type;
  58773. private _animationType;
  58774. /** Gets or set a value used to limit the range of float values */
  58775. min: number;
  58776. /** Gets or set a value used to limit the range of float values */
  58777. max: number;
  58778. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58779. matrixMode: number;
  58780. /** @hidden */
  58781. _systemValue: Nullable<NodeMaterialSystemValues>;
  58782. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58783. visibleInInspector: boolean;
  58784. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58785. isConstant: boolean;
  58786. /** Gets or sets the group to use to display this block in the Inspector */
  58787. groupInInspector: string;
  58788. /**
  58789. * Gets or sets the connection point type (default is float)
  58790. */
  58791. get type(): NodeMaterialBlockConnectionPointTypes;
  58792. /**
  58793. * Creates a new InputBlock
  58794. * @param name defines the block name
  58795. * @param target defines the target of that block (Vertex by default)
  58796. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58797. */
  58798. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58799. /**
  58800. * Gets the output component
  58801. */
  58802. get output(): NodeMaterialConnectionPoint;
  58803. /**
  58804. * Set the source of this connection point to a vertex attribute
  58805. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58806. * @returns the current connection point
  58807. */
  58808. setAsAttribute(attributeName?: string): InputBlock;
  58809. /**
  58810. * Set the source of this connection point to a system value
  58811. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58812. * @returns the current connection point
  58813. */
  58814. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58815. /**
  58816. * Gets or sets the value of that point.
  58817. * Please note that this value will be ignored if valueCallback is defined
  58818. */
  58819. get value(): any;
  58820. set value(value: any);
  58821. /**
  58822. * Gets or sets a callback used to get the value of that point.
  58823. * Please note that setting this value will force the connection point to ignore the value property
  58824. */
  58825. get valueCallback(): () => any;
  58826. set valueCallback(value: () => any);
  58827. /**
  58828. * Gets or sets the associated variable name in the shader
  58829. */
  58830. get associatedVariableName(): string;
  58831. set associatedVariableName(value: string);
  58832. /** Gets or sets the type of animation applied to the input */
  58833. get animationType(): AnimatedInputBlockTypes;
  58834. set animationType(value: AnimatedInputBlockTypes);
  58835. /**
  58836. * Gets a boolean indicating that this connection point not defined yet
  58837. */
  58838. get isUndefined(): boolean;
  58839. /**
  58840. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58841. * In this case the connection point name must be the name of the uniform to use.
  58842. * Can only be set on inputs
  58843. */
  58844. get isUniform(): boolean;
  58845. set isUniform(value: boolean);
  58846. /**
  58847. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58848. * In this case the connection point name must be the name of the attribute to use
  58849. * Can only be set on inputs
  58850. */
  58851. get isAttribute(): boolean;
  58852. set isAttribute(value: boolean);
  58853. /**
  58854. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58855. * Can only be set on exit points
  58856. */
  58857. get isVarying(): boolean;
  58858. set isVarying(value: boolean);
  58859. /**
  58860. * Gets a boolean indicating that the current connection point is a system value
  58861. */
  58862. get isSystemValue(): boolean;
  58863. /**
  58864. * Gets or sets the current well known value or null if not defined as a system value
  58865. */
  58866. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58867. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58868. /**
  58869. * Gets the current class name
  58870. * @returns the class name
  58871. */
  58872. getClassName(): string;
  58873. /**
  58874. * Animate the input if animationType !== None
  58875. * @param scene defines the rendering scene
  58876. */
  58877. animate(scene: Scene): void;
  58878. private _emitDefine;
  58879. initialize(state: NodeMaterialBuildState): void;
  58880. /**
  58881. * Set the input block to its default value (based on its type)
  58882. */
  58883. setDefaultValue(): void;
  58884. private _emitConstant;
  58885. private _emit;
  58886. /** @hidden */
  58887. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58888. /** @hidden */
  58889. _transmit(effect: Effect, scene: Scene): void;
  58890. protected _buildBlock(state: NodeMaterialBuildState): void;
  58891. protected _dumpPropertiesCode(): string;
  58892. serialize(): any;
  58893. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58894. }
  58895. }
  58896. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  58897. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58898. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58899. import { Nullable } from "babylonjs/types";
  58900. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  58901. import { Observable } from "babylonjs/Misc/observable";
  58902. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58903. /**
  58904. * Enum used to define the compatibility state between two connection points
  58905. */
  58906. export enum NodeMaterialConnectionPointCompatibilityStates {
  58907. /** Points are compatibles */
  58908. Compatible = 0,
  58909. /** Points are incompatible because of their types */
  58910. TypeIncompatible = 1,
  58911. /** Points are incompatible because of their targets (vertex vs fragment) */
  58912. TargetIncompatible = 2
  58913. }
  58914. /**
  58915. * Defines the direction of a connection point
  58916. */
  58917. export enum NodeMaterialConnectionPointDirection {
  58918. /** Input */
  58919. Input = 0,
  58920. /** Output */
  58921. Output = 1
  58922. }
  58923. /**
  58924. * Defines a connection point for a block
  58925. */
  58926. export class NodeMaterialConnectionPoint {
  58927. /** @hidden */
  58928. _ownerBlock: NodeMaterialBlock;
  58929. /** @hidden */
  58930. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58931. private _endpoints;
  58932. private _associatedVariableName;
  58933. private _direction;
  58934. /** @hidden */
  58935. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58936. /** @hidden */
  58937. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58938. private _type;
  58939. /** @hidden */
  58940. _enforceAssociatedVariableName: boolean;
  58941. /** Gets the direction of the point */
  58942. get direction(): NodeMaterialConnectionPointDirection;
  58943. /**
  58944. * Gets or sets the additional types supported by this connection point
  58945. */
  58946. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58947. /**
  58948. * Gets or sets the additional types excluded by this connection point
  58949. */
  58950. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58951. /**
  58952. * Observable triggered when this point is connected
  58953. */
  58954. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58955. /**
  58956. * Gets or sets the associated variable name in the shader
  58957. */
  58958. get associatedVariableName(): string;
  58959. set associatedVariableName(value: string);
  58960. /**
  58961. * Gets or sets the connection point type (default is float)
  58962. */
  58963. get type(): NodeMaterialBlockConnectionPointTypes;
  58964. set type(value: NodeMaterialBlockConnectionPointTypes);
  58965. /**
  58966. * Gets or sets the connection point name
  58967. */
  58968. name: string;
  58969. /**
  58970. * Gets or sets a boolean indicating that this connection point can be omitted
  58971. */
  58972. isOptional: boolean;
  58973. /**
  58974. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58975. */
  58976. define: string;
  58977. /** @hidden */
  58978. _prioritizeVertex: boolean;
  58979. private _target;
  58980. /** Gets or sets the target of that connection point */
  58981. get target(): NodeMaterialBlockTargets;
  58982. set target(value: NodeMaterialBlockTargets);
  58983. /**
  58984. * Gets a boolean indicating that the current point is connected
  58985. */
  58986. get isConnected(): boolean;
  58987. /**
  58988. * Gets a boolean indicating that the current point is connected to an input block
  58989. */
  58990. get isConnectedToInputBlock(): boolean;
  58991. /**
  58992. * Gets a the connected input block (if any)
  58993. */
  58994. get connectInputBlock(): Nullable<InputBlock>;
  58995. /** Get the other side of the connection (if any) */
  58996. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58997. /** Get the block that owns this connection point */
  58998. get ownerBlock(): NodeMaterialBlock;
  58999. /** Get the block connected on the other side of this connection (if any) */
  59000. get sourceBlock(): Nullable<NodeMaterialBlock>;
  59001. /** Get the block connected on the endpoints of this connection (if any) */
  59002. get connectedBlocks(): Array<NodeMaterialBlock>;
  59003. /** Gets the list of connected endpoints */
  59004. get endpoints(): NodeMaterialConnectionPoint[];
  59005. /** Gets a boolean indicating if that output point is connected to at least one input */
  59006. get hasEndpoints(): boolean;
  59007. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  59008. get isConnectedInVertexShader(): boolean;
  59009. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  59010. get isConnectedInFragmentShader(): boolean;
  59011. /**
  59012. * Creates a new connection point
  59013. * @param name defines the connection point name
  59014. * @param ownerBlock defines the block hosting this connection point
  59015. * @param direction defines the direction of the connection point
  59016. */
  59017. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  59018. /**
  59019. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  59020. * @returns the class name
  59021. */
  59022. getClassName(): string;
  59023. /**
  59024. * Gets a boolean indicating if the current point can be connected to another point
  59025. * @param connectionPoint defines the other connection point
  59026. * @returns a boolean
  59027. */
  59028. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  59029. /**
  59030. * Gets a number indicating if the current point can be connected to another point
  59031. * @param connectionPoint defines the other connection point
  59032. * @returns a number defining the compatibility state
  59033. */
  59034. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  59035. /**
  59036. * Connect this point to another connection point
  59037. * @param connectionPoint defines the other connection point
  59038. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  59039. * @returns the current connection point
  59040. */
  59041. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  59042. /**
  59043. * Disconnect this point from one of his endpoint
  59044. * @param endpoint defines the other connection point
  59045. * @returns the current connection point
  59046. */
  59047. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  59048. /**
  59049. * Serializes this point in a JSON representation
  59050. * @returns the serialized point object
  59051. */
  59052. serialize(): any;
  59053. /**
  59054. * Release resources
  59055. */
  59056. dispose(): void;
  59057. }
  59058. }
  59059. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  59060. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59061. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59062. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59063. import { Mesh } from "babylonjs/Meshes/mesh";
  59064. import { Effect } from "babylonjs/Materials/effect";
  59065. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59066. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59067. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59068. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59069. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  59070. /**
  59071. * Block used to add support for vertex skinning (bones)
  59072. */
  59073. export class BonesBlock extends NodeMaterialBlock {
  59074. /**
  59075. * Creates a new BonesBlock
  59076. * @param name defines the block name
  59077. */
  59078. constructor(name: string);
  59079. /**
  59080. * Initialize the block and prepare the context for build
  59081. * @param state defines the state that will be used for the build
  59082. */
  59083. initialize(state: NodeMaterialBuildState): void;
  59084. /**
  59085. * Gets the current class name
  59086. * @returns the class name
  59087. */
  59088. getClassName(): string;
  59089. /**
  59090. * Gets the matrix indices input component
  59091. */
  59092. get matricesIndices(): NodeMaterialConnectionPoint;
  59093. /**
  59094. * Gets the matrix weights input component
  59095. */
  59096. get matricesWeights(): NodeMaterialConnectionPoint;
  59097. /**
  59098. * Gets the extra matrix indices input component
  59099. */
  59100. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  59101. /**
  59102. * Gets the extra matrix weights input component
  59103. */
  59104. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  59105. /**
  59106. * Gets the world input component
  59107. */
  59108. get world(): NodeMaterialConnectionPoint;
  59109. /**
  59110. * Gets the output component
  59111. */
  59112. get output(): NodeMaterialConnectionPoint;
  59113. autoConfigure(material: NodeMaterial): void;
  59114. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  59115. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59116. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59117. protected _buildBlock(state: NodeMaterialBuildState): this;
  59118. }
  59119. }
  59120. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  59121. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59122. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59123. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59124. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59125. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59126. /**
  59127. * Block used to add support for instances
  59128. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  59129. */
  59130. export class InstancesBlock extends NodeMaterialBlock {
  59131. /**
  59132. * Creates a new InstancesBlock
  59133. * @param name defines the block name
  59134. */
  59135. constructor(name: string);
  59136. /**
  59137. * Gets the current class name
  59138. * @returns the class name
  59139. */
  59140. getClassName(): string;
  59141. /**
  59142. * Gets the first world row input component
  59143. */
  59144. get world0(): NodeMaterialConnectionPoint;
  59145. /**
  59146. * Gets the second world row input component
  59147. */
  59148. get world1(): NodeMaterialConnectionPoint;
  59149. /**
  59150. * Gets the third world row input component
  59151. */
  59152. get world2(): NodeMaterialConnectionPoint;
  59153. /**
  59154. * Gets the forth world row input component
  59155. */
  59156. get world3(): NodeMaterialConnectionPoint;
  59157. /**
  59158. * Gets the world input component
  59159. */
  59160. get world(): NodeMaterialConnectionPoint;
  59161. /**
  59162. * Gets the output component
  59163. */
  59164. get output(): NodeMaterialConnectionPoint;
  59165. autoConfigure(material: NodeMaterial): void;
  59166. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59167. protected _buildBlock(state: NodeMaterialBuildState): this;
  59168. }
  59169. }
  59170. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  59171. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59172. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59173. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59175. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59176. import { Effect } from "babylonjs/Materials/effect";
  59177. import { Mesh } from "babylonjs/Meshes/mesh";
  59178. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59179. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59180. /**
  59181. * Block used to add morph targets support to vertex shader
  59182. */
  59183. export class MorphTargetsBlock extends NodeMaterialBlock {
  59184. private _repeatableContentAnchor;
  59185. private _repeatebleContentGenerated;
  59186. /**
  59187. * Create a new MorphTargetsBlock
  59188. * @param name defines the block name
  59189. */
  59190. constructor(name: string);
  59191. /**
  59192. * Gets the current class name
  59193. * @returns the class name
  59194. */
  59195. getClassName(): string;
  59196. /**
  59197. * Gets the position input component
  59198. */
  59199. get position(): NodeMaterialConnectionPoint;
  59200. /**
  59201. * Gets the normal input component
  59202. */
  59203. get normal(): NodeMaterialConnectionPoint;
  59204. /**
  59205. * Gets the tangent input component
  59206. */
  59207. get tangent(): NodeMaterialConnectionPoint;
  59208. /**
  59209. * Gets the tangent input component
  59210. */
  59211. get uv(): NodeMaterialConnectionPoint;
  59212. /**
  59213. * Gets the position output component
  59214. */
  59215. get positionOutput(): NodeMaterialConnectionPoint;
  59216. /**
  59217. * Gets the normal output component
  59218. */
  59219. get normalOutput(): NodeMaterialConnectionPoint;
  59220. /**
  59221. * Gets the tangent output component
  59222. */
  59223. get tangentOutput(): NodeMaterialConnectionPoint;
  59224. /**
  59225. * Gets the tangent output component
  59226. */
  59227. get uvOutput(): NodeMaterialConnectionPoint;
  59228. initialize(state: NodeMaterialBuildState): void;
  59229. autoConfigure(material: NodeMaterial): void;
  59230. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59231. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59232. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  59233. protected _buildBlock(state: NodeMaterialBuildState): this;
  59234. }
  59235. }
  59236. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  59237. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59238. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59239. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59240. import { Nullable } from "babylonjs/types";
  59241. import { Scene } from "babylonjs/scene";
  59242. import { Effect } from "babylonjs/Materials/effect";
  59243. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59244. import { Mesh } from "babylonjs/Meshes/mesh";
  59245. import { Light } from "babylonjs/Lights/light";
  59246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59247. /**
  59248. * Block used to get data information from a light
  59249. */
  59250. export class LightInformationBlock extends NodeMaterialBlock {
  59251. private _lightDataUniformName;
  59252. private _lightColorUniformName;
  59253. private _lightTypeDefineName;
  59254. /**
  59255. * Gets or sets the light associated with this block
  59256. */
  59257. light: Nullable<Light>;
  59258. /**
  59259. * Creates a new LightInformationBlock
  59260. * @param name defines the block name
  59261. */
  59262. constructor(name: string);
  59263. /**
  59264. * Gets the current class name
  59265. * @returns the class name
  59266. */
  59267. getClassName(): string;
  59268. /**
  59269. * Gets the world position input component
  59270. */
  59271. get worldPosition(): NodeMaterialConnectionPoint;
  59272. /**
  59273. * Gets the direction output component
  59274. */
  59275. get direction(): NodeMaterialConnectionPoint;
  59276. /**
  59277. * Gets the direction output component
  59278. */
  59279. get color(): NodeMaterialConnectionPoint;
  59280. /**
  59281. * Gets the direction output component
  59282. */
  59283. get intensity(): NodeMaterialConnectionPoint;
  59284. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59285. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59286. protected _buildBlock(state: NodeMaterialBuildState): this;
  59287. serialize(): any;
  59288. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59289. }
  59290. }
  59291. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  59292. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  59293. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  59294. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  59295. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  59296. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  59297. }
  59298. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  59299. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59300. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59301. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59302. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59303. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59304. import { Effect } from "babylonjs/Materials/effect";
  59305. import { Mesh } from "babylonjs/Meshes/mesh";
  59306. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59307. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59308. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59309. /**
  59310. * Block used to add image processing support to fragment shader
  59311. */
  59312. export class ImageProcessingBlock extends NodeMaterialBlock {
  59313. /**
  59314. * Create a new ImageProcessingBlock
  59315. * @param name defines the block name
  59316. */
  59317. constructor(name: string);
  59318. /**
  59319. * Gets the current class name
  59320. * @returns the class name
  59321. */
  59322. getClassName(): string;
  59323. /**
  59324. * Gets the color input component
  59325. */
  59326. get color(): NodeMaterialConnectionPoint;
  59327. /**
  59328. * Gets the output component
  59329. */
  59330. get output(): NodeMaterialConnectionPoint;
  59331. /**
  59332. * Initialize the block and prepare the context for build
  59333. * @param state defines the state that will be used for the build
  59334. */
  59335. initialize(state: NodeMaterialBuildState): void;
  59336. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  59337. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59338. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59339. protected _buildBlock(state: NodeMaterialBuildState): this;
  59340. }
  59341. }
  59342. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  59343. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59344. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59345. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59346. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59347. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59348. import { Effect } from "babylonjs/Materials/effect";
  59349. import { Mesh } from "babylonjs/Meshes/mesh";
  59350. import { Scene } from "babylonjs/scene";
  59351. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  59352. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  59353. /**
  59354. * Block used to pertub normals based on a normal map
  59355. */
  59356. export class PerturbNormalBlock extends NodeMaterialBlock {
  59357. private _tangentSpaceParameterName;
  59358. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59359. invertX: boolean;
  59360. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  59361. invertY: boolean;
  59362. /**
  59363. * Create a new PerturbNormalBlock
  59364. * @param name defines the block name
  59365. */
  59366. constructor(name: string);
  59367. /**
  59368. * Gets the current class name
  59369. * @returns the class name
  59370. */
  59371. getClassName(): string;
  59372. /**
  59373. * Gets the world position input component
  59374. */
  59375. get worldPosition(): NodeMaterialConnectionPoint;
  59376. /**
  59377. * Gets the world normal input component
  59378. */
  59379. get worldNormal(): NodeMaterialConnectionPoint;
  59380. /**
  59381. * Gets the uv input component
  59382. */
  59383. get uv(): NodeMaterialConnectionPoint;
  59384. /**
  59385. * Gets the normal map color input component
  59386. */
  59387. get normalMapColor(): NodeMaterialConnectionPoint;
  59388. /**
  59389. * Gets the strength input component
  59390. */
  59391. get strength(): NodeMaterialConnectionPoint;
  59392. /**
  59393. * Gets the output component
  59394. */
  59395. get output(): NodeMaterialConnectionPoint;
  59396. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59397. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59398. autoConfigure(material: NodeMaterial): void;
  59399. protected _buildBlock(state: NodeMaterialBuildState): this;
  59400. protected _dumpPropertiesCode(): string;
  59401. serialize(): any;
  59402. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59403. }
  59404. }
  59405. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  59406. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59407. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59408. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59409. /**
  59410. * Block used to discard a pixel if a value is smaller than a cutoff
  59411. */
  59412. export class DiscardBlock extends NodeMaterialBlock {
  59413. /**
  59414. * Create a new DiscardBlock
  59415. * @param name defines the block name
  59416. */
  59417. constructor(name: string);
  59418. /**
  59419. * Gets the current class name
  59420. * @returns the class name
  59421. */
  59422. getClassName(): string;
  59423. /**
  59424. * Gets the color input component
  59425. */
  59426. get value(): NodeMaterialConnectionPoint;
  59427. /**
  59428. * Gets the cutoff input component
  59429. */
  59430. get cutoff(): NodeMaterialConnectionPoint;
  59431. protected _buildBlock(state: NodeMaterialBuildState): this;
  59432. }
  59433. }
  59434. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  59435. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59436. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59437. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59438. /**
  59439. * Block used to test if the fragment shader is front facing
  59440. */
  59441. export class FrontFacingBlock extends NodeMaterialBlock {
  59442. /**
  59443. * Creates a new FrontFacingBlock
  59444. * @param name defines the block name
  59445. */
  59446. constructor(name: string);
  59447. /**
  59448. * Gets the current class name
  59449. * @returns the class name
  59450. */
  59451. getClassName(): string;
  59452. /**
  59453. * Gets the output component
  59454. */
  59455. get output(): NodeMaterialConnectionPoint;
  59456. protected _buildBlock(state: NodeMaterialBuildState): this;
  59457. }
  59458. }
  59459. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  59460. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59461. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59462. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59463. /**
  59464. * Block used to get the derivative value on x and y of a given input
  59465. */
  59466. export class DerivativeBlock extends NodeMaterialBlock {
  59467. /**
  59468. * Create a new DerivativeBlock
  59469. * @param name defines the block name
  59470. */
  59471. constructor(name: string);
  59472. /**
  59473. * Gets the current class name
  59474. * @returns the class name
  59475. */
  59476. getClassName(): string;
  59477. /**
  59478. * Gets the input component
  59479. */
  59480. get input(): NodeMaterialConnectionPoint;
  59481. /**
  59482. * Gets the derivative output on x
  59483. */
  59484. get dx(): NodeMaterialConnectionPoint;
  59485. /**
  59486. * Gets the derivative output on y
  59487. */
  59488. get dy(): NodeMaterialConnectionPoint;
  59489. protected _buildBlock(state: NodeMaterialBuildState): this;
  59490. }
  59491. }
  59492. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  59493. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  59494. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  59495. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  59496. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  59497. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  59498. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  59499. }
  59500. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  59501. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59502. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59503. import { Mesh } from "babylonjs/Meshes/mesh";
  59504. import { Effect } from "babylonjs/Materials/effect";
  59505. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59507. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59508. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  59509. /**
  59510. * Block used to add support for scene fog
  59511. */
  59512. export class FogBlock extends NodeMaterialBlock {
  59513. private _fogDistanceName;
  59514. private _fogParameters;
  59515. /**
  59516. * Create a new FogBlock
  59517. * @param name defines the block name
  59518. */
  59519. constructor(name: string);
  59520. /**
  59521. * Gets the current class name
  59522. * @returns the class name
  59523. */
  59524. getClassName(): string;
  59525. /**
  59526. * Gets the world position input component
  59527. */
  59528. get worldPosition(): NodeMaterialConnectionPoint;
  59529. /**
  59530. * Gets the view input component
  59531. */
  59532. get view(): NodeMaterialConnectionPoint;
  59533. /**
  59534. * Gets the color input component
  59535. */
  59536. get input(): NodeMaterialConnectionPoint;
  59537. /**
  59538. * Gets the fog color input component
  59539. */
  59540. get fogColor(): NodeMaterialConnectionPoint;
  59541. /**
  59542. * Gets the output component
  59543. */
  59544. get output(): NodeMaterialConnectionPoint;
  59545. autoConfigure(material: NodeMaterial): void;
  59546. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59547. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59548. protected _buildBlock(state: NodeMaterialBuildState): this;
  59549. }
  59550. }
  59551. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  59552. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59553. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59554. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59555. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59556. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59557. import { Effect } from "babylonjs/Materials/effect";
  59558. import { Mesh } from "babylonjs/Meshes/mesh";
  59559. import { Light } from "babylonjs/Lights/light";
  59560. import { Nullable } from "babylonjs/types";
  59561. import { Scene } from "babylonjs/scene";
  59562. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59563. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59564. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  59565. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59566. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  59567. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  59568. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  59569. /**
  59570. * Block used to add light in the fragment shader
  59571. */
  59572. export class LightBlock extends NodeMaterialBlock {
  59573. private _lightId;
  59574. /**
  59575. * Gets or sets the light associated with this block
  59576. */
  59577. light: Nullable<Light>;
  59578. /**
  59579. * Create a new LightBlock
  59580. * @param name defines the block name
  59581. */
  59582. constructor(name: string);
  59583. /**
  59584. * Gets the current class name
  59585. * @returns the class name
  59586. */
  59587. getClassName(): string;
  59588. /**
  59589. * Gets the world position input component
  59590. */
  59591. get worldPosition(): NodeMaterialConnectionPoint;
  59592. /**
  59593. * Gets the world normal input component
  59594. */
  59595. get worldNormal(): NodeMaterialConnectionPoint;
  59596. /**
  59597. * Gets the camera (or eye) position component
  59598. */
  59599. get cameraPosition(): NodeMaterialConnectionPoint;
  59600. /**
  59601. * Gets the glossiness component
  59602. */
  59603. get glossiness(): NodeMaterialConnectionPoint;
  59604. /**
  59605. * Gets the glossinness power component
  59606. */
  59607. get glossPower(): NodeMaterialConnectionPoint;
  59608. /**
  59609. * Gets the diffuse color component
  59610. */
  59611. get diffuseColor(): NodeMaterialConnectionPoint;
  59612. /**
  59613. * Gets the specular color component
  59614. */
  59615. get specularColor(): NodeMaterialConnectionPoint;
  59616. /**
  59617. * Gets the diffuse output component
  59618. */
  59619. get diffuseOutput(): NodeMaterialConnectionPoint;
  59620. /**
  59621. * Gets the specular output component
  59622. */
  59623. get specularOutput(): NodeMaterialConnectionPoint;
  59624. /**
  59625. * Gets the shadow output component
  59626. */
  59627. get shadow(): NodeMaterialConnectionPoint;
  59628. autoConfigure(material: NodeMaterial): void;
  59629. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59630. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59631. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59632. private _injectVertexCode;
  59633. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59634. serialize(): any;
  59635. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59636. }
  59637. }
  59638. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  59639. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  59640. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  59641. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59642. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59643. }
  59644. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  59645. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59646. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  59647. }
  59648. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  59649. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59650. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59651. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59652. /**
  59653. * Block used to multiply 2 values
  59654. */
  59655. export class MultiplyBlock extends NodeMaterialBlock {
  59656. /**
  59657. * Creates a new MultiplyBlock
  59658. * @param name defines the block name
  59659. */
  59660. constructor(name: string);
  59661. /**
  59662. * Gets the current class name
  59663. * @returns the class name
  59664. */
  59665. getClassName(): string;
  59666. /**
  59667. * Gets the left operand input component
  59668. */
  59669. get left(): NodeMaterialConnectionPoint;
  59670. /**
  59671. * Gets the right operand input component
  59672. */
  59673. get right(): NodeMaterialConnectionPoint;
  59674. /**
  59675. * Gets the output component
  59676. */
  59677. get output(): NodeMaterialConnectionPoint;
  59678. protected _buildBlock(state: NodeMaterialBuildState): this;
  59679. }
  59680. }
  59681. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  59682. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59683. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59684. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59685. /**
  59686. * Block used to add 2 vectors
  59687. */
  59688. export class AddBlock extends NodeMaterialBlock {
  59689. /**
  59690. * Creates a new AddBlock
  59691. * @param name defines the block name
  59692. */
  59693. constructor(name: string);
  59694. /**
  59695. * Gets the current class name
  59696. * @returns the class name
  59697. */
  59698. getClassName(): string;
  59699. /**
  59700. * Gets the left operand input component
  59701. */
  59702. get left(): NodeMaterialConnectionPoint;
  59703. /**
  59704. * Gets the right operand input component
  59705. */
  59706. get right(): NodeMaterialConnectionPoint;
  59707. /**
  59708. * Gets the output component
  59709. */
  59710. get output(): NodeMaterialConnectionPoint;
  59711. protected _buildBlock(state: NodeMaterialBuildState): this;
  59712. }
  59713. }
  59714. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  59715. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59716. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59717. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59718. /**
  59719. * Block used to scale a vector by a float
  59720. */
  59721. export class ScaleBlock extends NodeMaterialBlock {
  59722. /**
  59723. * Creates a new ScaleBlock
  59724. * @param name defines the block name
  59725. */
  59726. constructor(name: string);
  59727. /**
  59728. * Gets the current class name
  59729. * @returns the class name
  59730. */
  59731. getClassName(): string;
  59732. /**
  59733. * Gets the input component
  59734. */
  59735. get input(): NodeMaterialConnectionPoint;
  59736. /**
  59737. * Gets the factor input component
  59738. */
  59739. get factor(): NodeMaterialConnectionPoint;
  59740. /**
  59741. * Gets the output component
  59742. */
  59743. get output(): NodeMaterialConnectionPoint;
  59744. protected _buildBlock(state: NodeMaterialBuildState): this;
  59745. }
  59746. }
  59747. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  59748. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59749. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59750. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59751. import { Scene } from "babylonjs/scene";
  59752. /**
  59753. * Block used to clamp a float
  59754. */
  59755. export class ClampBlock extends NodeMaterialBlock {
  59756. /** Gets or sets the minimum range */
  59757. minimum: number;
  59758. /** Gets or sets the maximum range */
  59759. maximum: number;
  59760. /**
  59761. * Creates a new ClampBlock
  59762. * @param name defines the block name
  59763. */
  59764. constructor(name: string);
  59765. /**
  59766. * Gets the current class name
  59767. * @returns the class name
  59768. */
  59769. getClassName(): string;
  59770. /**
  59771. * Gets the value input component
  59772. */
  59773. get value(): NodeMaterialConnectionPoint;
  59774. /**
  59775. * Gets the output component
  59776. */
  59777. get output(): NodeMaterialConnectionPoint;
  59778. protected _buildBlock(state: NodeMaterialBuildState): this;
  59779. protected _dumpPropertiesCode(): string;
  59780. serialize(): any;
  59781. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59782. }
  59783. }
  59784. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  59785. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59786. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59787. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59788. /**
  59789. * Block used to apply a cross product between 2 vectors
  59790. */
  59791. export class CrossBlock extends NodeMaterialBlock {
  59792. /**
  59793. * Creates a new CrossBlock
  59794. * @param name defines the block name
  59795. */
  59796. constructor(name: string);
  59797. /**
  59798. * Gets the current class name
  59799. * @returns the class name
  59800. */
  59801. getClassName(): string;
  59802. /**
  59803. * Gets the left operand input component
  59804. */
  59805. get left(): NodeMaterialConnectionPoint;
  59806. /**
  59807. * Gets the right operand input component
  59808. */
  59809. get right(): NodeMaterialConnectionPoint;
  59810. /**
  59811. * Gets the output component
  59812. */
  59813. get output(): NodeMaterialConnectionPoint;
  59814. protected _buildBlock(state: NodeMaterialBuildState): this;
  59815. }
  59816. }
  59817. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  59818. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59819. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59820. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59821. /**
  59822. * Block used to apply a dot product between 2 vectors
  59823. */
  59824. export class DotBlock extends NodeMaterialBlock {
  59825. /**
  59826. * Creates a new DotBlock
  59827. * @param name defines the block name
  59828. */
  59829. constructor(name: string);
  59830. /**
  59831. * Gets the current class name
  59832. * @returns the class name
  59833. */
  59834. getClassName(): string;
  59835. /**
  59836. * Gets the left operand input component
  59837. */
  59838. get left(): NodeMaterialConnectionPoint;
  59839. /**
  59840. * Gets the right operand input component
  59841. */
  59842. get right(): NodeMaterialConnectionPoint;
  59843. /**
  59844. * Gets the output component
  59845. */
  59846. get output(): NodeMaterialConnectionPoint;
  59847. protected _buildBlock(state: NodeMaterialBuildState): this;
  59848. }
  59849. }
  59850. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  59851. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59852. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59853. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59854. import { Vector2 } from "babylonjs/Maths/math.vector";
  59855. import { Scene } from "babylonjs/scene";
  59856. /**
  59857. * Block used to remap a float from a range to a new one
  59858. */
  59859. export class RemapBlock extends NodeMaterialBlock {
  59860. /**
  59861. * Gets or sets the source range
  59862. */
  59863. sourceRange: Vector2;
  59864. /**
  59865. * Gets or sets the target range
  59866. */
  59867. targetRange: Vector2;
  59868. /**
  59869. * Creates a new RemapBlock
  59870. * @param name defines the block name
  59871. */
  59872. constructor(name: string);
  59873. /**
  59874. * Gets the current class name
  59875. * @returns the class name
  59876. */
  59877. getClassName(): string;
  59878. /**
  59879. * Gets the input component
  59880. */
  59881. get input(): NodeMaterialConnectionPoint;
  59882. /**
  59883. * Gets the source min input component
  59884. */
  59885. get sourceMin(): NodeMaterialConnectionPoint;
  59886. /**
  59887. * Gets the source max input component
  59888. */
  59889. get sourceMax(): NodeMaterialConnectionPoint;
  59890. /**
  59891. * Gets the target min input component
  59892. */
  59893. get targetMin(): NodeMaterialConnectionPoint;
  59894. /**
  59895. * Gets the target max input component
  59896. */
  59897. get targetMax(): NodeMaterialConnectionPoint;
  59898. /**
  59899. * Gets the output component
  59900. */
  59901. get output(): NodeMaterialConnectionPoint;
  59902. protected _buildBlock(state: NodeMaterialBuildState): this;
  59903. protected _dumpPropertiesCode(): string;
  59904. serialize(): any;
  59905. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59906. }
  59907. }
  59908. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  59909. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59910. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59911. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59912. /**
  59913. * Block used to normalize a vector
  59914. */
  59915. export class NormalizeBlock extends NodeMaterialBlock {
  59916. /**
  59917. * Creates a new NormalizeBlock
  59918. * @param name defines the block name
  59919. */
  59920. constructor(name: string);
  59921. /**
  59922. * Gets the current class name
  59923. * @returns the class name
  59924. */
  59925. getClassName(): string;
  59926. /**
  59927. * Gets the input component
  59928. */
  59929. get input(): NodeMaterialConnectionPoint;
  59930. /**
  59931. * Gets the output component
  59932. */
  59933. get output(): NodeMaterialConnectionPoint;
  59934. protected _buildBlock(state: NodeMaterialBuildState): this;
  59935. }
  59936. }
  59937. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  59938. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59939. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59940. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59941. import { Scene } from "babylonjs/scene";
  59942. /**
  59943. * Operations supported by the Trigonometry block
  59944. */
  59945. export enum TrigonometryBlockOperations {
  59946. /** Cos */
  59947. Cos = 0,
  59948. /** Sin */
  59949. Sin = 1,
  59950. /** Abs */
  59951. Abs = 2,
  59952. /** Exp */
  59953. Exp = 3,
  59954. /** Exp2 */
  59955. Exp2 = 4,
  59956. /** Round */
  59957. Round = 5,
  59958. /** Floor */
  59959. Floor = 6,
  59960. /** Ceiling */
  59961. Ceiling = 7,
  59962. /** Square root */
  59963. Sqrt = 8,
  59964. /** Log */
  59965. Log = 9,
  59966. /** Tangent */
  59967. Tan = 10,
  59968. /** Arc tangent */
  59969. ArcTan = 11,
  59970. /** Arc cosinus */
  59971. ArcCos = 12,
  59972. /** Arc sinus */
  59973. ArcSin = 13,
  59974. /** Fraction */
  59975. Fract = 14,
  59976. /** Sign */
  59977. Sign = 15,
  59978. /** To radians (from degrees) */
  59979. Radians = 16,
  59980. /** To degrees (from radians) */
  59981. Degrees = 17
  59982. }
  59983. /**
  59984. * Block used to apply trigonometry operation to floats
  59985. */
  59986. export class TrigonometryBlock extends NodeMaterialBlock {
  59987. /**
  59988. * Gets or sets the operation applied by the block
  59989. */
  59990. operation: TrigonometryBlockOperations;
  59991. /**
  59992. * Creates a new TrigonometryBlock
  59993. * @param name defines the block name
  59994. */
  59995. constructor(name: string);
  59996. /**
  59997. * Gets the current class name
  59998. * @returns the class name
  59999. */
  60000. getClassName(): string;
  60001. /**
  60002. * Gets the input component
  60003. */
  60004. get input(): NodeMaterialConnectionPoint;
  60005. /**
  60006. * Gets the output component
  60007. */
  60008. get output(): NodeMaterialConnectionPoint;
  60009. protected _buildBlock(state: NodeMaterialBuildState): this;
  60010. serialize(): any;
  60011. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60012. protected _dumpPropertiesCode(): string;
  60013. }
  60014. }
  60015. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  60016. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60017. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60018. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60019. /**
  60020. * Block used to create a Color3/4 out of individual inputs (one for each component)
  60021. */
  60022. export class ColorMergerBlock extends NodeMaterialBlock {
  60023. /**
  60024. * Create a new ColorMergerBlock
  60025. * @param name defines the block name
  60026. */
  60027. constructor(name: string);
  60028. /**
  60029. * Gets the current class name
  60030. * @returns the class name
  60031. */
  60032. getClassName(): string;
  60033. /**
  60034. * Gets the rgb component (input)
  60035. */
  60036. get rgbIn(): NodeMaterialConnectionPoint;
  60037. /**
  60038. * Gets the r component (input)
  60039. */
  60040. get r(): NodeMaterialConnectionPoint;
  60041. /**
  60042. * Gets the g component (input)
  60043. */
  60044. get g(): NodeMaterialConnectionPoint;
  60045. /**
  60046. * Gets the b component (input)
  60047. */
  60048. get b(): NodeMaterialConnectionPoint;
  60049. /**
  60050. * Gets the a component (input)
  60051. */
  60052. get a(): NodeMaterialConnectionPoint;
  60053. /**
  60054. * Gets the rgba component (output)
  60055. */
  60056. get rgba(): NodeMaterialConnectionPoint;
  60057. /**
  60058. * Gets the rgb component (output)
  60059. */
  60060. get rgbOut(): NodeMaterialConnectionPoint;
  60061. /**
  60062. * Gets the rgb component (output)
  60063. * @deprecated Please use rgbOut instead.
  60064. */
  60065. get rgb(): NodeMaterialConnectionPoint;
  60066. protected _buildBlock(state: NodeMaterialBuildState): this;
  60067. }
  60068. }
  60069. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  60070. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60071. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60072. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60073. /**
  60074. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  60075. */
  60076. export class VectorMergerBlock extends NodeMaterialBlock {
  60077. /**
  60078. * Create a new VectorMergerBlock
  60079. * @param name defines the block name
  60080. */
  60081. constructor(name: string);
  60082. /**
  60083. * Gets the current class name
  60084. * @returns the class name
  60085. */
  60086. getClassName(): string;
  60087. /**
  60088. * Gets the xyz component (input)
  60089. */
  60090. get xyzIn(): NodeMaterialConnectionPoint;
  60091. /**
  60092. * Gets the xy component (input)
  60093. */
  60094. get xyIn(): NodeMaterialConnectionPoint;
  60095. /**
  60096. * Gets the x component (input)
  60097. */
  60098. get x(): NodeMaterialConnectionPoint;
  60099. /**
  60100. * Gets the y component (input)
  60101. */
  60102. get y(): NodeMaterialConnectionPoint;
  60103. /**
  60104. * Gets the z component (input)
  60105. */
  60106. get z(): NodeMaterialConnectionPoint;
  60107. /**
  60108. * Gets the w component (input)
  60109. */
  60110. get w(): NodeMaterialConnectionPoint;
  60111. /**
  60112. * Gets the xyzw component (output)
  60113. */
  60114. get xyzw(): NodeMaterialConnectionPoint;
  60115. /**
  60116. * Gets the xyz component (output)
  60117. */
  60118. get xyzOut(): NodeMaterialConnectionPoint;
  60119. /**
  60120. * Gets the xy component (output)
  60121. */
  60122. get xyOut(): NodeMaterialConnectionPoint;
  60123. /**
  60124. * Gets the xy component (output)
  60125. * @deprecated Please use xyOut instead.
  60126. */
  60127. get xy(): NodeMaterialConnectionPoint;
  60128. /**
  60129. * Gets the xyz component (output)
  60130. * @deprecated Please use xyzOut instead.
  60131. */
  60132. get xyz(): NodeMaterialConnectionPoint;
  60133. protected _buildBlock(state: NodeMaterialBuildState): this;
  60134. }
  60135. }
  60136. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  60137. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60138. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60139. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60140. /**
  60141. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  60142. */
  60143. export class ColorSplitterBlock extends NodeMaterialBlock {
  60144. /**
  60145. * Create a new ColorSplitterBlock
  60146. * @param name defines the block name
  60147. */
  60148. constructor(name: string);
  60149. /**
  60150. * Gets the current class name
  60151. * @returns the class name
  60152. */
  60153. getClassName(): string;
  60154. /**
  60155. * Gets the rgba component (input)
  60156. */
  60157. get rgba(): NodeMaterialConnectionPoint;
  60158. /**
  60159. * Gets the rgb component (input)
  60160. */
  60161. get rgbIn(): NodeMaterialConnectionPoint;
  60162. /**
  60163. * Gets the rgb component (output)
  60164. */
  60165. get rgbOut(): NodeMaterialConnectionPoint;
  60166. /**
  60167. * Gets the r component (output)
  60168. */
  60169. get r(): NodeMaterialConnectionPoint;
  60170. /**
  60171. * Gets the g component (output)
  60172. */
  60173. get g(): NodeMaterialConnectionPoint;
  60174. /**
  60175. * Gets the b component (output)
  60176. */
  60177. get b(): NodeMaterialConnectionPoint;
  60178. /**
  60179. * Gets the a component (output)
  60180. */
  60181. get a(): NodeMaterialConnectionPoint;
  60182. protected _inputRename(name: string): string;
  60183. protected _outputRename(name: string): string;
  60184. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60185. }
  60186. }
  60187. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  60188. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60189. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60190. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60191. /**
  60192. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  60193. */
  60194. export class VectorSplitterBlock extends NodeMaterialBlock {
  60195. /**
  60196. * Create a new VectorSplitterBlock
  60197. * @param name defines the block name
  60198. */
  60199. constructor(name: string);
  60200. /**
  60201. * Gets the current class name
  60202. * @returns the class name
  60203. */
  60204. getClassName(): string;
  60205. /**
  60206. * Gets the xyzw component (input)
  60207. */
  60208. get xyzw(): NodeMaterialConnectionPoint;
  60209. /**
  60210. * Gets the xyz component (input)
  60211. */
  60212. get xyzIn(): NodeMaterialConnectionPoint;
  60213. /**
  60214. * Gets the xy component (input)
  60215. */
  60216. get xyIn(): NodeMaterialConnectionPoint;
  60217. /**
  60218. * Gets the xyz component (output)
  60219. */
  60220. get xyzOut(): NodeMaterialConnectionPoint;
  60221. /**
  60222. * Gets the xy component (output)
  60223. */
  60224. get xyOut(): NodeMaterialConnectionPoint;
  60225. /**
  60226. * Gets the x component (output)
  60227. */
  60228. get x(): NodeMaterialConnectionPoint;
  60229. /**
  60230. * Gets the y component (output)
  60231. */
  60232. get y(): NodeMaterialConnectionPoint;
  60233. /**
  60234. * Gets the z component (output)
  60235. */
  60236. get z(): NodeMaterialConnectionPoint;
  60237. /**
  60238. * Gets the w component (output)
  60239. */
  60240. get w(): NodeMaterialConnectionPoint;
  60241. protected _inputRename(name: string): string;
  60242. protected _outputRename(name: string): string;
  60243. protected _buildBlock(state: NodeMaterialBuildState): this;
  60244. }
  60245. }
  60246. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  60247. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60248. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60249. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60250. /**
  60251. * Block used to lerp between 2 values
  60252. */
  60253. export class LerpBlock extends NodeMaterialBlock {
  60254. /**
  60255. * Creates a new LerpBlock
  60256. * @param name defines the block name
  60257. */
  60258. constructor(name: string);
  60259. /**
  60260. * Gets the current class name
  60261. * @returns the class name
  60262. */
  60263. getClassName(): string;
  60264. /**
  60265. * Gets the left operand input component
  60266. */
  60267. get left(): NodeMaterialConnectionPoint;
  60268. /**
  60269. * Gets the right operand input component
  60270. */
  60271. get right(): NodeMaterialConnectionPoint;
  60272. /**
  60273. * Gets the gradient operand input component
  60274. */
  60275. get gradient(): NodeMaterialConnectionPoint;
  60276. /**
  60277. * Gets the output component
  60278. */
  60279. get output(): NodeMaterialConnectionPoint;
  60280. protected _buildBlock(state: NodeMaterialBuildState): this;
  60281. }
  60282. }
  60283. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  60284. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60285. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60286. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60287. /**
  60288. * Block used to divide 2 vectors
  60289. */
  60290. export class DivideBlock extends NodeMaterialBlock {
  60291. /**
  60292. * Creates a new DivideBlock
  60293. * @param name defines the block name
  60294. */
  60295. constructor(name: string);
  60296. /**
  60297. * Gets the current class name
  60298. * @returns the class name
  60299. */
  60300. getClassName(): string;
  60301. /**
  60302. * Gets the left operand input component
  60303. */
  60304. get left(): NodeMaterialConnectionPoint;
  60305. /**
  60306. * Gets the right operand input component
  60307. */
  60308. get right(): NodeMaterialConnectionPoint;
  60309. /**
  60310. * Gets the output component
  60311. */
  60312. get output(): NodeMaterialConnectionPoint;
  60313. protected _buildBlock(state: NodeMaterialBuildState): this;
  60314. }
  60315. }
  60316. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  60317. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60318. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60319. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60320. /**
  60321. * Block used to subtract 2 vectors
  60322. */
  60323. export class SubtractBlock extends NodeMaterialBlock {
  60324. /**
  60325. * Creates a new SubtractBlock
  60326. * @param name defines the block name
  60327. */
  60328. constructor(name: string);
  60329. /**
  60330. * Gets the current class name
  60331. * @returns the class name
  60332. */
  60333. getClassName(): string;
  60334. /**
  60335. * Gets the left operand input component
  60336. */
  60337. get left(): NodeMaterialConnectionPoint;
  60338. /**
  60339. * Gets the right operand input component
  60340. */
  60341. get right(): NodeMaterialConnectionPoint;
  60342. /**
  60343. * Gets the output component
  60344. */
  60345. get output(): NodeMaterialConnectionPoint;
  60346. protected _buildBlock(state: NodeMaterialBuildState): this;
  60347. }
  60348. }
  60349. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  60350. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60351. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60352. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60353. /**
  60354. * Block used to step a value
  60355. */
  60356. export class StepBlock extends NodeMaterialBlock {
  60357. /**
  60358. * Creates a new StepBlock
  60359. * @param name defines the block name
  60360. */
  60361. constructor(name: string);
  60362. /**
  60363. * Gets the current class name
  60364. * @returns the class name
  60365. */
  60366. getClassName(): string;
  60367. /**
  60368. * Gets the value operand input component
  60369. */
  60370. get value(): NodeMaterialConnectionPoint;
  60371. /**
  60372. * Gets the edge operand input component
  60373. */
  60374. get edge(): NodeMaterialConnectionPoint;
  60375. /**
  60376. * Gets the output component
  60377. */
  60378. get output(): NodeMaterialConnectionPoint;
  60379. protected _buildBlock(state: NodeMaterialBuildState): this;
  60380. }
  60381. }
  60382. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  60383. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60384. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60385. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60386. /**
  60387. * Block used to get the opposite (1 - x) of a value
  60388. */
  60389. export class OneMinusBlock extends NodeMaterialBlock {
  60390. /**
  60391. * Creates a new OneMinusBlock
  60392. * @param name defines the block name
  60393. */
  60394. constructor(name: string);
  60395. /**
  60396. * Gets the current class name
  60397. * @returns the class name
  60398. */
  60399. getClassName(): string;
  60400. /**
  60401. * Gets the input component
  60402. */
  60403. get input(): NodeMaterialConnectionPoint;
  60404. /**
  60405. * Gets the output component
  60406. */
  60407. get output(): NodeMaterialConnectionPoint;
  60408. protected _buildBlock(state: NodeMaterialBuildState): this;
  60409. }
  60410. }
  60411. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  60412. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60413. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60414. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60415. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  60416. /**
  60417. * Block used to get the view direction
  60418. */
  60419. export class ViewDirectionBlock extends NodeMaterialBlock {
  60420. /**
  60421. * Creates a new ViewDirectionBlock
  60422. * @param name defines the block name
  60423. */
  60424. constructor(name: string);
  60425. /**
  60426. * Gets the current class name
  60427. * @returns the class name
  60428. */
  60429. getClassName(): string;
  60430. /**
  60431. * Gets the world position component
  60432. */
  60433. get worldPosition(): NodeMaterialConnectionPoint;
  60434. /**
  60435. * Gets the camera position component
  60436. */
  60437. get cameraPosition(): NodeMaterialConnectionPoint;
  60438. /**
  60439. * Gets the output component
  60440. */
  60441. get output(): NodeMaterialConnectionPoint;
  60442. autoConfigure(material: NodeMaterial): void;
  60443. protected _buildBlock(state: NodeMaterialBuildState): this;
  60444. }
  60445. }
  60446. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  60447. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60448. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60449. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60450. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  60451. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  60452. /**
  60453. * Block used to compute fresnel value
  60454. */
  60455. export class FresnelBlock extends NodeMaterialBlock {
  60456. /**
  60457. * Create a new FresnelBlock
  60458. * @param name defines the block name
  60459. */
  60460. constructor(name: string);
  60461. /**
  60462. * Gets the current class name
  60463. * @returns the class name
  60464. */
  60465. getClassName(): string;
  60466. /**
  60467. * Gets the world normal input component
  60468. */
  60469. get worldNormal(): NodeMaterialConnectionPoint;
  60470. /**
  60471. * Gets the view direction input component
  60472. */
  60473. get viewDirection(): NodeMaterialConnectionPoint;
  60474. /**
  60475. * Gets the bias input component
  60476. */
  60477. get bias(): NodeMaterialConnectionPoint;
  60478. /**
  60479. * Gets the camera (or eye) position component
  60480. */
  60481. get power(): NodeMaterialConnectionPoint;
  60482. /**
  60483. * Gets the fresnel output component
  60484. */
  60485. get fresnel(): NodeMaterialConnectionPoint;
  60486. autoConfigure(material: NodeMaterial): void;
  60487. protected _buildBlock(state: NodeMaterialBuildState): this;
  60488. }
  60489. }
  60490. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  60491. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60492. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60493. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60494. /**
  60495. * Block used to get the max of 2 values
  60496. */
  60497. export class MaxBlock extends NodeMaterialBlock {
  60498. /**
  60499. * Creates a new MaxBlock
  60500. * @param name defines the block name
  60501. */
  60502. constructor(name: string);
  60503. /**
  60504. * Gets the current class name
  60505. * @returns the class name
  60506. */
  60507. getClassName(): string;
  60508. /**
  60509. * Gets the left operand input component
  60510. */
  60511. get left(): NodeMaterialConnectionPoint;
  60512. /**
  60513. * Gets the right operand input component
  60514. */
  60515. get right(): NodeMaterialConnectionPoint;
  60516. /**
  60517. * Gets the output component
  60518. */
  60519. get output(): NodeMaterialConnectionPoint;
  60520. protected _buildBlock(state: NodeMaterialBuildState): this;
  60521. }
  60522. }
  60523. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  60524. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60525. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60526. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60527. /**
  60528. * Block used to get the min of 2 values
  60529. */
  60530. export class MinBlock extends NodeMaterialBlock {
  60531. /**
  60532. * Creates a new MinBlock
  60533. * @param name defines the block name
  60534. */
  60535. constructor(name: string);
  60536. /**
  60537. * Gets the current class name
  60538. * @returns the class name
  60539. */
  60540. getClassName(): string;
  60541. /**
  60542. * Gets the left operand input component
  60543. */
  60544. get left(): NodeMaterialConnectionPoint;
  60545. /**
  60546. * Gets the right operand input component
  60547. */
  60548. get right(): NodeMaterialConnectionPoint;
  60549. /**
  60550. * Gets the output component
  60551. */
  60552. get output(): NodeMaterialConnectionPoint;
  60553. protected _buildBlock(state: NodeMaterialBuildState): this;
  60554. }
  60555. }
  60556. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  60557. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60558. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60559. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60560. /**
  60561. * Block used to get the distance between 2 values
  60562. */
  60563. export class DistanceBlock extends NodeMaterialBlock {
  60564. /**
  60565. * Creates a new DistanceBlock
  60566. * @param name defines the block name
  60567. */
  60568. constructor(name: string);
  60569. /**
  60570. * Gets the current class name
  60571. * @returns the class name
  60572. */
  60573. getClassName(): string;
  60574. /**
  60575. * Gets the left operand input component
  60576. */
  60577. get left(): NodeMaterialConnectionPoint;
  60578. /**
  60579. * Gets the right operand input component
  60580. */
  60581. get right(): NodeMaterialConnectionPoint;
  60582. /**
  60583. * Gets the output component
  60584. */
  60585. get output(): NodeMaterialConnectionPoint;
  60586. protected _buildBlock(state: NodeMaterialBuildState): this;
  60587. }
  60588. }
  60589. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  60590. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60591. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60592. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60593. /**
  60594. * Block used to get the length of a vector
  60595. */
  60596. export class LengthBlock extends NodeMaterialBlock {
  60597. /**
  60598. * Creates a new LengthBlock
  60599. * @param name defines the block name
  60600. */
  60601. constructor(name: string);
  60602. /**
  60603. * Gets the current class name
  60604. * @returns the class name
  60605. */
  60606. getClassName(): string;
  60607. /**
  60608. * Gets the value input component
  60609. */
  60610. get value(): NodeMaterialConnectionPoint;
  60611. /**
  60612. * Gets the output component
  60613. */
  60614. get output(): NodeMaterialConnectionPoint;
  60615. protected _buildBlock(state: NodeMaterialBuildState): this;
  60616. }
  60617. }
  60618. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  60619. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60620. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60621. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60622. /**
  60623. * Block used to get negative version of a value (i.e. x * -1)
  60624. */
  60625. export class NegateBlock extends NodeMaterialBlock {
  60626. /**
  60627. * Creates a new NegateBlock
  60628. * @param name defines the block name
  60629. */
  60630. constructor(name: string);
  60631. /**
  60632. * Gets the current class name
  60633. * @returns the class name
  60634. */
  60635. getClassName(): string;
  60636. /**
  60637. * Gets the value input component
  60638. */
  60639. get value(): NodeMaterialConnectionPoint;
  60640. /**
  60641. * Gets the output component
  60642. */
  60643. get output(): NodeMaterialConnectionPoint;
  60644. protected _buildBlock(state: NodeMaterialBuildState): this;
  60645. }
  60646. }
  60647. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  60648. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60649. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60650. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60651. /**
  60652. * Block used to get the value of the first parameter raised to the power of the second
  60653. */
  60654. export class PowBlock extends NodeMaterialBlock {
  60655. /**
  60656. * Creates a new PowBlock
  60657. * @param name defines the block name
  60658. */
  60659. constructor(name: string);
  60660. /**
  60661. * Gets the current class name
  60662. * @returns the class name
  60663. */
  60664. getClassName(): string;
  60665. /**
  60666. * Gets the value operand input component
  60667. */
  60668. get value(): NodeMaterialConnectionPoint;
  60669. /**
  60670. * Gets the power operand input component
  60671. */
  60672. get power(): NodeMaterialConnectionPoint;
  60673. /**
  60674. * Gets the output component
  60675. */
  60676. get output(): NodeMaterialConnectionPoint;
  60677. protected _buildBlock(state: NodeMaterialBuildState): this;
  60678. }
  60679. }
  60680. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  60681. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60682. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60683. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60684. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60685. /**
  60686. * Block used to get a random number
  60687. */
  60688. export class RandomNumberBlock extends NodeMaterialBlock {
  60689. /**
  60690. * Creates a new RandomNumberBlock
  60691. * @param name defines the block name
  60692. */
  60693. constructor(name: string);
  60694. /**
  60695. * Gets the current class name
  60696. * @returns the class name
  60697. */
  60698. getClassName(): string;
  60699. /**
  60700. * Gets the seed input component
  60701. */
  60702. get seed(): NodeMaterialConnectionPoint;
  60703. /**
  60704. * Gets the output component
  60705. */
  60706. get output(): NodeMaterialConnectionPoint;
  60707. protected _buildBlock(state: NodeMaterialBuildState): this;
  60708. }
  60709. }
  60710. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  60711. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60712. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60713. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60714. /**
  60715. * Block used to compute arc tangent of 2 values
  60716. */
  60717. export class ArcTan2Block extends NodeMaterialBlock {
  60718. /**
  60719. * Creates a new ArcTan2Block
  60720. * @param name defines the block name
  60721. */
  60722. constructor(name: string);
  60723. /**
  60724. * Gets the current class name
  60725. * @returns the class name
  60726. */
  60727. getClassName(): string;
  60728. /**
  60729. * Gets the x operand input component
  60730. */
  60731. get x(): NodeMaterialConnectionPoint;
  60732. /**
  60733. * Gets the y operand input component
  60734. */
  60735. get y(): NodeMaterialConnectionPoint;
  60736. /**
  60737. * Gets the output component
  60738. */
  60739. get output(): NodeMaterialConnectionPoint;
  60740. protected _buildBlock(state: NodeMaterialBuildState): this;
  60741. }
  60742. }
  60743. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  60744. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60745. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60746. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60747. /**
  60748. * Block used to smooth step a value
  60749. */
  60750. export class SmoothStepBlock extends NodeMaterialBlock {
  60751. /**
  60752. * Creates a new SmoothStepBlock
  60753. * @param name defines the block name
  60754. */
  60755. constructor(name: string);
  60756. /**
  60757. * Gets the current class name
  60758. * @returns the class name
  60759. */
  60760. getClassName(): string;
  60761. /**
  60762. * Gets the value operand input component
  60763. */
  60764. get value(): NodeMaterialConnectionPoint;
  60765. /**
  60766. * Gets the first edge operand input component
  60767. */
  60768. get edge0(): NodeMaterialConnectionPoint;
  60769. /**
  60770. * Gets the second edge operand input component
  60771. */
  60772. get edge1(): NodeMaterialConnectionPoint;
  60773. /**
  60774. * Gets the output component
  60775. */
  60776. get output(): NodeMaterialConnectionPoint;
  60777. protected _buildBlock(state: NodeMaterialBuildState): this;
  60778. }
  60779. }
  60780. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  60781. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60782. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60783. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60784. /**
  60785. * Block used to get the reciprocal (1 / x) of a value
  60786. */
  60787. export class ReciprocalBlock extends NodeMaterialBlock {
  60788. /**
  60789. * Creates a new ReciprocalBlock
  60790. * @param name defines the block name
  60791. */
  60792. constructor(name: string);
  60793. /**
  60794. * Gets the current class name
  60795. * @returns the class name
  60796. */
  60797. getClassName(): string;
  60798. /**
  60799. * Gets the input component
  60800. */
  60801. get input(): NodeMaterialConnectionPoint;
  60802. /**
  60803. * Gets the output component
  60804. */
  60805. get output(): NodeMaterialConnectionPoint;
  60806. protected _buildBlock(state: NodeMaterialBuildState): this;
  60807. }
  60808. }
  60809. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  60810. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60811. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60812. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60813. /**
  60814. * Block used to replace a color by another one
  60815. */
  60816. export class ReplaceColorBlock extends NodeMaterialBlock {
  60817. /**
  60818. * Creates a new ReplaceColorBlock
  60819. * @param name defines the block name
  60820. */
  60821. constructor(name: string);
  60822. /**
  60823. * Gets the current class name
  60824. * @returns the class name
  60825. */
  60826. getClassName(): string;
  60827. /**
  60828. * Gets the value input component
  60829. */
  60830. get value(): NodeMaterialConnectionPoint;
  60831. /**
  60832. * Gets the reference input component
  60833. */
  60834. get reference(): NodeMaterialConnectionPoint;
  60835. /**
  60836. * Gets the distance input component
  60837. */
  60838. get distance(): NodeMaterialConnectionPoint;
  60839. /**
  60840. * Gets the replacement input component
  60841. */
  60842. get replacement(): NodeMaterialConnectionPoint;
  60843. /**
  60844. * Gets the output component
  60845. */
  60846. get output(): NodeMaterialConnectionPoint;
  60847. protected _buildBlock(state: NodeMaterialBuildState): this;
  60848. }
  60849. }
  60850. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  60851. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60852. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60853. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60854. /**
  60855. * Block used to posterize a value
  60856. * @see https://en.wikipedia.org/wiki/Posterization
  60857. */
  60858. export class PosterizeBlock extends NodeMaterialBlock {
  60859. /**
  60860. * Creates a new PosterizeBlock
  60861. * @param name defines the block name
  60862. */
  60863. constructor(name: string);
  60864. /**
  60865. * Gets the current class name
  60866. * @returns the class name
  60867. */
  60868. getClassName(): string;
  60869. /**
  60870. * Gets the value input component
  60871. */
  60872. get value(): NodeMaterialConnectionPoint;
  60873. /**
  60874. * Gets the steps input component
  60875. */
  60876. get steps(): NodeMaterialConnectionPoint;
  60877. /**
  60878. * Gets the output component
  60879. */
  60880. get output(): NodeMaterialConnectionPoint;
  60881. protected _buildBlock(state: NodeMaterialBuildState): this;
  60882. }
  60883. }
  60884. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  60885. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60886. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60887. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60888. import { Scene } from "babylonjs/scene";
  60889. /**
  60890. * Operations supported by the Wave block
  60891. */
  60892. export enum WaveBlockKind {
  60893. /** SawTooth */
  60894. SawTooth = 0,
  60895. /** Square */
  60896. Square = 1,
  60897. /** Triangle */
  60898. Triangle = 2
  60899. }
  60900. /**
  60901. * Block used to apply wave operation to floats
  60902. */
  60903. export class WaveBlock extends NodeMaterialBlock {
  60904. /**
  60905. * Gets or sets the kibnd of wave to be applied by the block
  60906. */
  60907. kind: WaveBlockKind;
  60908. /**
  60909. * Creates a new WaveBlock
  60910. * @param name defines the block name
  60911. */
  60912. constructor(name: string);
  60913. /**
  60914. * Gets the current class name
  60915. * @returns the class name
  60916. */
  60917. getClassName(): string;
  60918. /**
  60919. * Gets the input component
  60920. */
  60921. get input(): NodeMaterialConnectionPoint;
  60922. /**
  60923. * Gets the output component
  60924. */
  60925. get output(): NodeMaterialConnectionPoint;
  60926. protected _buildBlock(state: NodeMaterialBuildState): this;
  60927. serialize(): any;
  60928. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60929. }
  60930. }
  60931. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  60932. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60933. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60934. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60935. import { Color3 } from "babylonjs/Maths/math.color";
  60936. import { Scene } from "babylonjs/scene";
  60937. /**
  60938. * Class used to store a color step for the GradientBlock
  60939. */
  60940. export class GradientBlockColorStep {
  60941. /**
  60942. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60943. */
  60944. step: number;
  60945. /**
  60946. * Gets or sets the color associated with this step
  60947. */
  60948. color: Color3;
  60949. /**
  60950. * Creates a new GradientBlockColorStep
  60951. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  60952. * @param color defines the color associated with this step
  60953. */
  60954. constructor(
  60955. /**
  60956. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60957. */
  60958. step: number,
  60959. /**
  60960. * Gets or sets the color associated with this step
  60961. */
  60962. color: Color3);
  60963. }
  60964. /**
  60965. * Block used to return a color from a gradient based on an input value between 0 and 1
  60966. */
  60967. export class GradientBlock extends NodeMaterialBlock {
  60968. /**
  60969. * Gets or sets the list of color steps
  60970. */
  60971. colorSteps: GradientBlockColorStep[];
  60972. /**
  60973. * Creates a new GradientBlock
  60974. * @param name defines the block name
  60975. */
  60976. constructor(name: string);
  60977. /**
  60978. * Gets the current class name
  60979. * @returns the class name
  60980. */
  60981. getClassName(): string;
  60982. /**
  60983. * Gets the gradient input component
  60984. */
  60985. get gradient(): NodeMaterialConnectionPoint;
  60986. /**
  60987. * Gets the output component
  60988. */
  60989. get output(): NodeMaterialConnectionPoint;
  60990. private _writeColorConstant;
  60991. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60992. serialize(): any;
  60993. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60994. protected _dumpPropertiesCode(): string;
  60995. }
  60996. }
  60997. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  60998. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60999. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61000. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61001. /**
  61002. * Block used to normalize lerp between 2 values
  61003. */
  61004. export class NLerpBlock extends NodeMaterialBlock {
  61005. /**
  61006. * Creates a new NLerpBlock
  61007. * @param name defines the block name
  61008. */
  61009. constructor(name: string);
  61010. /**
  61011. * Gets the current class name
  61012. * @returns the class name
  61013. */
  61014. getClassName(): string;
  61015. /**
  61016. * Gets the left operand input component
  61017. */
  61018. get left(): NodeMaterialConnectionPoint;
  61019. /**
  61020. * Gets the right operand input component
  61021. */
  61022. get right(): NodeMaterialConnectionPoint;
  61023. /**
  61024. * Gets the gradient operand input component
  61025. */
  61026. get gradient(): NodeMaterialConnectionPoint;
  61027. /**
  61028. * Gets the output component
  61029. */
  61030. get output(): NodeMaterialConnectionPoint;
  61031. protected _buildBlock(state: NodeMaterialBuildState): this;
  61032. }
  61033. }
  61034. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  61035. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61036. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61037. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61038. import { Scene } from "babylonjs/scene";
  61039. /**
  61040. * block used to Generate a Worley Noise 3D Noise Pattern
  61041. */
  61042. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  61043. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61044. manhattanDistance: boolean;
  61045. /**
  61046. * Creates a new WorleyNoise3DBlock
  61047. * @param name defines the block name
  61048. */
  61049. constructor(name: string);
  61050. /**
  61051. * Gets the current class name
  61052. * @returns the class name
  61053. */
  61054. getClassName(): string;
  61055. /**
  61056. * Gets the seed input component
  61057. */
  61058. get seed(): NodeMaterialConnectionPoint;
  61059. /**
  61060. * Gets the jitter input component
  61061. */
  61062. get jitter(): NodeMaterialConnectionPoint;
  61063. /**
  61064. * Gets the output component
  61065. */
  61066. get output(): NodeMaterialConnectionPoint;
  61067. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61068. /**
  61069. * Exposes the properties to the UI?
  61070. */
  61071. protected _dumpPropertiesCode(): string;
  61072. /**
  61073. * Exposes the properties to the Seralize?
  61074. */
  61075. serialize(): any;
  61076. /**
  61077. * Exposes the properties to the deseralize?
  61078. */
  61079. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61080. }
  61081. }
  61082. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  61083. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61084. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61085. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61086. /**
  61087. * block used to Generate a Simplex Perlin 3d Noise Pattern
  61088. */
  61089. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  61090. /**
  61091. * Creates a new SimplexPerlin3DBlock
  61092. * @param name defines the block name
  61093. */
  61094. constructor(name: string);
  61095. /**
  61096. * Gets the current class name
  61097. * @returns the class name
  61098. */
  61099. getClassName(): string;
  61100. /**
  61101. * Gets the seed operand input component
  61102. */
  61103. get seed(): NodeMaterialConnectionPoint;
  61104. /**
  61105. * Gets the output component
  61106. */
  61107. get output(): NodeMaterialConnectionPoint;
  61108. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61109. }
  61110. }
  61111. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  61112. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61113. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61114. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61115. /**
  61116. * Block used to blend normals
  61117. */
  61118. export class NormalBlendBlock extends NodeMaterialBlock {
  61119. /**
  61120. * Creates a new NormalBlendBlock
  61121. * @param name defines the block name
  61122. */
  61123. constructor(name: string);
  61124. /**
  61125. * Gets the current class name
  61126. * @returns the class name
  61127. */
  61128. getClassName(): string;
  61129. /**
  61130. * Gets the first input component
  61131. */
  61132. get normalMap0(): NodeMaterialConnectionPoint;
  61133. /**
  61134. * Gets the second input component
  61135. */
  61136. get normalMap1(): NodeMaterialConnectionPoint;
  61137. /**
  61138. * Gets the output component
  61139. */
  61140. get output(): NodeMaterialConnectionPoint;
  61141. protected _buildBlock(state: NodeMaterialBuildState): this;
  61142. }
  61143. }
  61144. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  61145. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61146. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61147. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61148. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  61149. /**
  61150. * Block used to rotate a 2d vector by a given angle
  61151. */
  61152. export class Rotate2dBlock extends NodeMaterialBlock {
  61153. /**
  61154. * Creates a new Rotate2dBlock
  61155. * @param name defines the block name
  61156. */
  61157. constructor(name: string);
  61158. /**
  61159. * Gets the current class name
  61160. * @returns the class name
  61161. */
  61162. getClassName(): string;
  61163. /**
  61164. * Gets the input vector
  61165. */
  61166. get input(): NodeMaterialConnectionPoint;
  61167. /**
  61168. * Gets the input angle
  61169. */
  61170. get angle(): NodeMaterialConnectionPoint;
  61171. /**
  61172. * Gets the output component
  61173. */
  61174. get output(): NodeMaterialConnectionPoint;
  61175. autoConfigure(material: NodeMaterial): void;
  61176. protected _buildBlock(state: NodeMaterialBuildState): this;
  61177. }
  61178. }
  61179. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  61180. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61181. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61182. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61183. /**
  61184. * Block used to get the reflected vector from a direction and a normal
  61185. */
  61186. export class ReflectBlock extends NodeMaterialBlock {
  61187. /**
  61188. * Creates a new ReflectBlock
  61189. * @param name defines the block name
  61190. */
  61191. constructor(name: string);
  61192. /**
  61193. * Gets the current class name
  61194. * @returns the class name
  61195. */
  61196. getClassName(): string;
  61197. /**
  61198. * Gets the incident component
  61199. */
  61200. get incident(): NodeMaterialConnectionPoint;
  61201. /**
  61202. * Gets the normal component
  61203. */
  61204. get normal(): NodeMaterialConnectionPoint;
  61205. /**
  61206. * Gets the output component
  61207. */
  61208. get output(): NodeMaterialConnectionPoint;
  61209. protected _buildBlock(state: NodeMaterialBuildState): this;
  61210. }
  61211. }
  61212. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  61213. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61214. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61215. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61216. /**
  61217. * Block used to get the refracted vector from a direction and a normal
  61218. */
  61219. export class RefractBlock extends NodeMaterialBlock {
  61220. /**
  61221. * Creates a new RefractBlock
  61222. * @param name defines the block name
  61223. */
  61224. constructor(name: string);
  61225. /**
  61226. * Gets the current class name
  61227. * @returns the class name
  61228. */
  61229. getClassName(): string;
  61230. /**
  61231. * Gets the incident component
  61232. */
  61233. get incident(): NodeMaterialConnectionPoint;
  61234. /**
  61235. * Gets the normal component
  61236. */
  61237. get normal(): NodeMaterialConnectionPoint;
  61238. /**
  61239. * Gets the index of refraction component
  61240. */
  61241. get ior(): NodeMaterialConnectionPoint;
  61242. /**
  61243. * Gets the output component
  61244. */
  61245. get output(): NodeMaterialConnectionPoint;
  61246. protected _buildBlock(state: NodeMaterialBuildState): this;
  61247. }
  61248. }
  61249. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  61250. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61251. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61252. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61253. /**
  61254. * Block used to desaturate a color
  61255. */
  61256. export class DesaturateBlock extends NodeMaterialBlock {
  61257. /**
  61258. * Creates a new DesaturateBlock
  61259. * @param name defines the block name
  61260. */
  61261. constructor(name: string);
  61262. /**
  61263. * Gets the current class name
  61264. * @returns the class name
  61265. */
  61266. getClassName(): string;
  61267. /**
  61268. * Gets the color operand input component
  61269. */
  61270. get color(): NodeMaterialConnectionPoint;
  61271. /**
  61272. * Gets the level operand input component
  61273. */
  61274. get level(): NodeMaterialConnectionPoint;
  61275. /**
  61276. * Gets the output component
  61277. */
  61278. get output(): NodeMaterialConnectionPoint;
  61279. protected _buildBlock(state: NodeMaterialBuildState): this;
  61280. }
  61281. }
  61282. declare module "babylonjs/Materials/Node/Blocks/index" {
  61283. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  61284. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  61285. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  61286. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  61287. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  61288. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  61289. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  61290. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  61291. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  61292. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  61293. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  61294. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  61295. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  61296. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  61297. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  61298. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  61299. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  61300. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  61301. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  61302. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  61303. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  61304. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  61305. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  61306. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  61307. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  61308. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  61309. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  61310. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  61311. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  61312. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  61313. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  61314. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  61315. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  61316. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  61317. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  61318. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  61319. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  61320. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  61321. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  61322. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  61323. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  61324. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  61325. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  61326. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  61327. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  61328. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  61329. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  61330. }
  61331. declare module "babylonjs/Materials/Node/Optimizers/index" {
  61332. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  61333. }
  61334. declare module "babylonjs/Materials/Node/index" {
  61335. export * from "babylonjs/Materials/Node/Enums/index";
  61336. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61337. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  61338. export * from "babylonjs/Materials/Node/nodeMaterial";
  61339. export * from "babylonjs/Materials/Node/Blocks/index";
  61340. export * from "babylonjs/Materials/Node/Optimizers/index";
  61341. }
  61342. declare module "babylonjs/Materials/effectRenderer" {
  61343. import { Nullable } from "babylonjs/types";
  61344. import { Texture } from "babylonjs/Materials/Textures/texture";
  61345. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61346. import { Viewport } from "babylonjs/Maths/math.viewport";
  61347. import { Observable } from "babylonjs/Misc/observable";
  61348. import { Effect } from "babylonjs/Materials/effect";
  61349. import "babylonjs/Engines/Extensions/engine.renderTarget";
  61350. import "babylonjs/Shaders/postprocess.vertex";
  61351. /**
  61352. * Effect Render Options
  61353. */
  61354. export interface IEffectRendererOptions {
  61355. /**
  61356. * Defines the vertices positions.
  61357. */
  61358. positions?: number[];
  61359. /**
  61360. * Defines the indices.
  61361. */
  61362. indices?: number[];
  61363. }
  61364. /**
  61365. * Helper class to render one or more effects
  61366. */
  61367. export class EffectRenderer {
  61368. private engine;
  61369. private static _DefaultOptions;
  61370. private _vertexBuffers;
  61371. private _indexBuffer;
  61372. private _ringBufferIndex;
  61373. private _ringScreenBuffer;
  61374. private _fullscreenViewport;
  61375. private _getNextFrameBuffer;
  61376. /**
  61377. * Creates an effect renderer
  61378. * @param engine the engine to use for rendering
  61379. * @param options defines the options of the effect renderer
  61380. */
  61381. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61382. /**
  61383. * Sets the current viewport in normalized coordinates 0-1
  61384. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61385. */
  61386. setViewport(viewport?: Viewport): void;
  61387. /**
  61388. * Binds the embedded attributes buffer to the effect.
  61389. * @param effect Defines the effect to bind the attributes for
  61390. */
  61391. bindBuffers(effect: Effect): void;
  61392. /**
  61393. * Sets the current effect wrapper to use during draw.
  61394. * The effect needs to be ready before calling this api.
  61395. * This also sets the default full screen position attribute.
  61396. * @param effectWrapper Defines the effect to draw with
  61397. */
  61398. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61399. /**
  61400. * Draws a full screen quad.
  61401. */
  61402. draw(): void;
  61403. /**
  61404. * renders one or more effects to a specified texture
  61405. * @param effectWrappers list of effects to renderer
  61406. * @param outputTexture texture to draw to, if null it will render to the screen
  61407. */
  61408. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  61409. /**
  61410. * Disposes of the effect renderer
  61411. */
  61412. dispose(): void;
  61413. }
  61414. /**
  61415. * Options to create an EffectWrapper
  61416. */
  61417. interface EffectWrapperCreationOptions {
  61418. /**
  61419. * Engine to use to create the effect
  61420. */
  61421. engine: ThinEngine;
  61422. /**
  61423. * Fragment shader for the effect
  61424. */
  61425. fragmentShader: string;
  61426. /**
  61427. * Vertex shader for the effect
  61428. */
  61429. vertexShader?: string;
  61430. /**
  61431. * Attributes to use in the shader
  61432. */
  61433. attributeNames?: Array<string>;
  61434. /**
  61435. * Uniforms to use in the shader
  61436. */
  61437. uniformNames?: Array<string>;
  61438. /**
  61439. * Texture sampler names to use in the shader
  61440. */
  61441. samplerNames?: Array<string>;
  61442. /**
  61443. * The friendly name of the effect displayed in Spector.
  61444. */
  61445. name?: string;
  61446. }
  61447. /**
  61448. * Wraps an effect to be used for rendering
  61449. */
  61450. export class EffectWrapper {
  61451. /**
  61452. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61453. */
  61454. onApplyObservable: Observable<{}>;
  61455. /**
  61456. * The underlying effect
  61457. */
  61458. effect: Effect;
  61459. /**
  61460. * Creates an effect to be renderer
  61461. * @param creationOptions options to create the effect
  61462. */
  61463. constructor(creationOptions: EffectWrapperCreationOptions);
  61464. /**
  61465. * Disposes of the effect wrapper
  61466. */
  61467. dispose(): void;
  61468. }
  61469. }
  61470. declare module "babylonjs/Materials/index" {
  61471. export * from "babylonjs/Materials/Background/index";
  61472. export * from "babylonjs/Materials/colorCurves";
  61473. export * from "babylonjs/Materials/iEffectFallbacks";
  61474. export * from "babylonjs/Materials/effectFallbacks";
  61475. export * from "babylonjs/Materials/effect";
  61476. export * from "babylonjs/Materials/fresnelParameters";
  61477. export * from "babylonjs/Materials/imageProcessingConfiguration";
  61478. export * from "babylonjs/Materials/material";
  61479. export * from "babylonjs/Materials/materialDefines";
  61480. export * from "babylonjs/Materials/materialHelper";
  61481. export * from "babylonjs/Materials/multiMaterial";
  61482. export * from "babylonjs/Materials/PBR/index";
  61483. export * from "babylonjs/Materials/pushMaterial";
  61484. export * from "babylonjs/Materials/shaderMaterial";
  61485. export * from "babylonjs/Materials/standardMaterial";
  61486. export * from "babylonjs/Materials/Textures/index";
  61487. export * from "babylonjs/Materials/uniformBuffer";
  61488. export * from "babylonjs/Materials/materialFlags";
  61489. export * from "babylonjs/Materials/Node/index";
  61490. export * from "babylonjs/Materials/effectRenderer";
  61491. }
  61492. declare module "babylonjs/Maths/index" {
  61493. export * from "babylonjs/Maths/math.scalar";
  61494. export * from "babylonjs/Maths/math";
  61495. export * from "babylonjs/Maths/sphericalPolynomial";
  61496. }
  61497. declare module "babylonjs/Misc/workerPool" {
  61498. import { IDisposable } from "babylonjs/scene";
  61499. /**
  61500. * Helper class to push actions to a pool of workers.
  61501. */
  61502. export class WorkerPool implements IDisposable {
  61503. private _workerInfos;
  61504. private _pendingActions;
  61505. /**
  61506. * Constructor
  61507. * @param workers Array of workers to use for actions
  61508. */
  61509. constructor(workers: Array<Worker>);
  61510. /**
  61511. * Terminates all workers and clears any pending actions.
  61512. */
  61513. dispose(): void;
  61514. /**
  61515. * Pushes an action to the worker pool. If all the workers are active, the action will be
  61516. * pended until a worker has completed its action.
  61517. * @param action The action to perform. Call onComplete when the action is complete.
  61518. */
  61519. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61520. private _execute;
  61521. }
  61522. }
  61523. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  61524. import { IDisposable } from "babylonjs/scene";
  61525. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  61526. /**
  61527. * Configuration for Draco compression
  61528. */
  61529. export interface IDracoCompressionConfiguration {
  61530. /**
  61531. * Configuration for the decoder.
  61532. */
  61533. decoder: {
  61534. /**
  61535. * The url to the WebAssembly module.
  61536. */
  61537. wasmUrl?: string;
  61538. /**
  61539. * The url to the WebAssembly binary.
  61540. */
  61541. wasmBinaryUrl?: string;
  61542. /**
  61543. * The url to the fallback JavaScript module.
  61544. */
  61545. fallbackUrl?: string;
  61546. };
  61547. }
  61548. /**
  61549. * Draco compression (https://google.github.io/draco/)
  61550. *
  61551. * This class wraps the Draco module.
  61552. *
  61553. * **Encoder**
  61554. *
  61555. * The encoder is not currently implemented.
  61556. *
  61557. * **Decoder**
  61558. *
  61559. * 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.
  61560. *
  61561. * To update the configuration, use the following code:
  61562. * ```javascript
  61563. * DracoCompression.Configuration = {
  61564. * decoder: {
  61565. * wasmUrl: "<url to the WebAssembly library>",
  61566. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  61567. * fallbackUrl: "<url to the fallback JavaScript library>",
  61568. * }
  61569. * };
  61570. * ```
  61571. *
  61572. * 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.
  61573. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  61574. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  61575. *
  61576. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  61577. * ```javascript
  61578. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  61579. * ```
  61580. *
  61581. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  61582. */
  61583. export class DracoCompression implements IDisposable {
  61584. private _workerPoolPromise?;
  61585. private _decoderModulePromise?;
  61586. /**
  61587. * The configuration. Defaults to the following urls:
  61588. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  61589. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  61590. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  61591. */
  61592. static Configuration: IDracoCompressionConfiguration;
  61593. /**
  61594. * Returns true if the decoder configuration is available.
  61595. */
  61596. static get DecoderAvailable(): boolean;
  61597. /**
  61598. * Default number of workers to create when creating the draco compression object.
  61599. */
  61600. static DefaultNumWorkers: number;
  61601. private static GetDefaultNumWorkers;
  61602. private static _Default;
  61603. /**
  61604. * Default instance for the draco compression object.
  61605. */
  61606. static get Default(): DracoCompression;
  61607. /**
  61608. * Constructor
  61609. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61610. */
  61611. constructor(numWorkers?: number);
  61612. /**
  61613. * Stop all async operations and release resources.
  61614. */
  61615. dispose(): void;
  61616. /**
  61617. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  61618. * @returns a promise that resolves when ready
  61619. */
  61620. whenReadyAsync(): Promise<void>;
  61621. /**
  61622. * Decode Draco compressed mesh data to vertex data.
  61623. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  61624. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  61625. * @returns A promise that resolves with the decoded vertex data
  61626. */
  61627. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  61628. [kind: string]: number;
  61629. }): Promise<VertexData>;
  61630. }
  61631. }
  61632. declare module "babylonjs/Meshes/Compression/index" {
  61633. export * from "babylonjs/Meshes/Compression/dracoCompression";
  61634. }
  61635. declare module "babylonjs/Meshes/csg" {
  61636. import { Nullable } from "babylonjs/types";
  61637. import { Scene } from "babylonjs/scene";
  61638. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61639. import { Mesh } from "babylonjs/Meshes/mesh";
  61640. import { Material } from "babylonjs/Materials/material";
  61641. /**
  61642. * Class for building Constructive Solid Geometry
  61643. */
  61644. export class CSG {
  61645. private polygons;
  61646. /**
  61647. * The world matrix
  61648. */
  61649. matrix: Matrix;
  61650. /**
  61651. * Stores the position
  61652. */
  61653. position: Vector3;
  61654. /**
  61655. * Stores the rotation
  61656. */
  61657. rotation: Vector3;
  61658. /**
  61659. * Stores the rotation quaternion
  61660. */
  61661. rotationQuaternion: Nullable<Quaternion>;
  61662. /**
  61663. * Stores the scaling vector
  61664. */
  61665. scaling: Vector3;
  61666. /**
  61667. * Convert the Mesh to CSG
  61668. * @param mesh The Mesh to convert to CSG
  61669. * @returns A new CSG from the Mesh
  61670. */
  61671. static FromMesh(mesh: Mesh): CSG;
  61672. /**
  61673. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  61674. * @param polygons Polygons used to construct a CSG solid
  61675. */
  61676. private static FromPolygons;
  61677. /**
  61678. * Clones, or makes a deep copy, of the CSG
  61679. * @returns A new CSG
  61680. */
  61681. clone(): CSG;
  61682. /**
  61683. * Unions this CSG with another CSG
  61684. * @param csg The CSG to union against this CSG
  61685. * @returns The unioned CSG
  61686. */
  61687. union(csg: CSG): CSG;
  61688. /**
  61689. * Unions this CSG with another CSG in place
  61690. * @param csg The CSG to union against this CSG
  61691. */
  61692. unionInPlace(csg: CSG): void;
  61693. /**
  61694. * Subtracts this CSG with another CSG
  61695. * @param csg The CSG to subtract against this CSG
  61696. * @returns A new CSG
  61697. */
  61698. subtract(csg: CSG): CSG;
  61699. /**
  61700. * Subtracts this CSG with another CSG in place
  61701. * @param csg The CSG to subtact against this CSG
  61702. */
  61703. subtractInPlace(csg: CSG): void;
  61704. /**
  61705. * Intersect this CSG with another CSG
  61706. * @param csg The CSG to intersect against this CSG
  61707. * @returns A new CSG
  61708. */
  61709. intersect(csg: CSG): CSG;
  61710. /**
  61711. * Intersects this CSG with another CSG in place
  61712. * @param csg The CSG to intersect against this CSG
  61713. */
  61714. intersectInPlace(csg: CSG): void;
  61715. /**
  61716. * Return a new CSG solid with solid and empty space switched. This solid is
  61717. * not modified.
  61718. * @returns A new CSG solid with solid and empty space switched
  61719. */
  61720. inverse(): CSG;
  61721. /**
  61722. * Inverses the CSG in place
  61723. */
  61724. inverseInPlace(): void;
  61725. /**
  61726. * This is used to keep meshes transformations so they can be restored
  61727. * when we build back a Babylon Mesh
  61728. * NB : All CSG operations are performed in world coordinates
  61729. * @param csg The CSG to copy the transform attributes from
  61730. * @returns This CSG
  61731. */
  61732. copyTransformAttributes(csg: CSG): CSG;
  61733. /**
  61734. * Build Raw mesh from CSG
  61735. * Coordinates here are in world space
  61736. * @param name The name of the mesh geometry
  61737. * @param scene The Scene
  61738. * @param keepSubMeshes Specifies if the submeshes should be kept
  61739. * @returns A new Mesh
  61740. */
  61741. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61742. /**
  61743. * Build Mesh from CSG taking material and transforms into account
  61744. * @param name The name of the Mesh
  61745. * @param material The material of the Mesh
  61746. * @param scene The Scene
  61747. * @param keepSubMeshes Specifies if submeshes should be kept
  61748. * @returns The new Mesh
  61749. */
  61750. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61751. }
  61752. }
  61753. declare module "babylonjs/Meshes/trailMesh" {
  61754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61755. import { Mesh } from "babylonjs/Meshes/mesh";
  61756. import { Scene } from "babylonjs/scene";
  61757. /**
  61758. * Class used to create a trail following a mesh
  61759. */
  61760. export class TrailMesh extends Mesh {
  61761. private _generator;
  61762. private _autoStart;
  61763. private _running;
  61764. private _diameter;
  61765. private _length;
  61766. private _sectionPolygonPointsCount;
  61767. private _sectionVectors;
  61768. private _sectionNormalVectors;
  61769. private _beforeRenderObserver;
  61770. /**
  61771. * @constructor
  61772. * @param name The value used by scene.getMeshByName() to do a lookup.
  61773. * @param generator The mesh to generate a trail.
  61774. * @param scene The scene to add this mesh to.
  61775. * @param diameter Diameter of trailing mesh. Default is 1.
  61776. * @param length Length of trailing mesh. Default is 60.
  61777. * @param autoStart Automatically start trailing mesh. Default true.
  61778. */
  61779. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  61780. /**
  61781. * "TrailMesh"
  61782. * @returns "TrailMesh"
  61783. */
  61784. getClassName(): string;
  61785. private _createMesh;
  61786. /**
  61787. * Start trailing mesh.
  61788. */
  61789. start(): void;
  61790. /**
  61791. * Stop trailing mesh.
  61792. */
  61793. stop(): void;
  61794. /**
  61795. * Update trailing mesh geometry.
  61796. */
  61797. update(): void;
  61798. /**
  61799. * Returns a new TrailMesh object.
  61800. * @param name is a string, the name given to the new mesh
  61801. * @param newGenerator use new generator object for cloned trail mesh
  61802. * @returns a new mesh
  61803. */
  61804. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  61805. /**
  61806. * Serializes this trail mesh
  61807. * @param serializationObject object to write serialization to
  61808. */
  61809. serialize(serializationObject: any): void;
  61810. /**
  61811. * Parses a serialized trail mesh
  61812. * @param parsedMesh the serialized mesh
  61813. * @param scene the scene to create the trail mesh in
  61814. * @returns the created trail mesh
  61815. */
  61816. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  61817. }
  61818. }
  61819. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  61820. import { Nullable } from "babylonjs/types";
  61821. import { Scene } from "babylonjs/scene";
  61822. import { Vector4 } from "babylonjs/Maths/math.vector";
  61823. import { Color4 } from "babylonjs/Maths/math.color";
  61824. import { Mesh } from "babylonjs/Meshes/mesh";
  61825. /**
  61826. * Class containing static functions to help procedurally build meshes
  61827. */
  61828. export class TiledBoxBuilder {
  61829. /**
  61830. * Creates a box mesh
  61831. * 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)
  61832. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61833. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61834. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61835. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61836. * @param name defines the name of the mesh
  61837. * @param options defines the options used to create the mesh
  61838. * @param scene defines the hosting scene
  61839. * @returns the box mesh
  61840. */
  61841. static CreateTiledBox(name: string, options: {
  61842. pattern?: number;
  61843. width?: number;
  61844. height?: number;
  61845. depth?: number;
  61846. tileSize?: number;
  61847. tileWidth?: number;
  61848. tileHeight?: number;
  61849. alignHorizontal?: number;
  61850. alignVertical?: number;
  61851. faceUV?: Vector4[];
  61852. faceColors?: Color4[];
  61853. sideOrientation?: number;
  61854. updatable?: boolean;
  61855. }, scene?: Nullable<Scene>): Mesh;
  61856. }
  61857. }
  61858. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  61859. import { Vector4 } from "babylonjs/Maths/math.vector";
  61860. import { Mesh } from "babylonjs/Meshes/mesh";
  61861. /**
  61862. * Class containing static functions to help procedurally build meshes
  61863. */
  61864. export class TorusKnotBuilder {
  61865. /**
  61866. * Creates a torus knot mesh
  61867. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61868. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61869. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61870. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61871. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61872. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61874. * @param name defines the name of the mesh
  61875. * @param options defines the options used to create the mesh
  61876. * @param scene defines the hosting scene
  61877. * @returns the torus knot mesh
  61878. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61879. */
  61880. static CreateTorusKnot(name: string, options: {
  61881. radius?: number;
  61882. tube?: number;
  61883. radialSegments?: number;
  61884. tubularSegments?: number;
  61885. p?: number;
  61886. q?: number;
  61887. updatable?: boolean;
  61888. sideOrientation?: number;
  61889. frontUVs?: Vector4;
  61890. backUVs?: Vector4;
  61891. }, scene: any): Mesh;
  61892. }
  61893. }
  61894. declare module "babylonjs/Meshes/polygonMesh" {
  61895. import { Scene } from "babylonjs/scene";
  61896. import { Vector2 } from "babylonjs/Maths/math.vector";
  61897. import { Mesh } from "babylonjs/Meshes/mesh";
  61898. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  61899. import { Path2 } from "babylonjs/Maths/math.path";
  61900. /**
  61901. * Polygon
  61902. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  61903. */
  61904. export class Polygon {
  61905. /**
  61906. * Creates a rectangle
  61907. * @param xmin bottom X coord
  61908. * @param ymin bottom Y coord
  61909. * @param xmax top X coord
  61910. * @param ymax top Y coord
  61911. * @returns points that make the resulting rectation
  61912. */
  61913. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  61914. /**
  61915. * Creates a circle
  61916. * @param radius radius of circle
  61917. * @param cx scale in x
  61918. * @param cy scale in y
  61919. * @param numberOfSides number of sides that make up the circle
  61920. * @returns points that make the resulting circle
  61921. */
  61922. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  61923. /**
  61924. * Creates a polygon from input string
  61925. * @param input Input polygon data
  61926. * @returns the parsed points
  61927. */
  61928. static Parse(input: string): Vector2[];
  61929. /**
  61930. * Starts building a polygon from x and y coordinates
  61931. * @param x x coordinate
  61932. * @param y y coordinate
  61933. * @returns the started path2
  61934. */
  61935. static StartingAt(x: number, y: number): Path2;
  61936. }
  61937. /**
  61938. * Builds a polygon
  61939. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  61940. */
  61941. export class PolygonMeshBuilder {
  61942. private _points;
  61943. private _outlinepoints;
  61944. private _holes;
  61945. private _name;
  61946. private _scene;
  61947. private _epoints;
  61948. private _eholes;
  61949. private _addToepoint;
  61950. /**
  61951. * Babylon reference to the earcut plugin.
  61952. */
  61953. bjsEarcut: any;
  61954. /**
  61955. * Creates a PolygonMeshBuilder
  61956. * @param name name of the builder
  61957. * @param contours Path of the polygon
  61958. * @param scene scene to add to when creating the mesh
  61959. * @param earcutInjection can be used to inject your own earcut reference
  61960. */
  61961. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  61962. /**
  61963. * Adds a whole within the polygon
  61964. * @param hole Array of points defining the hole
  61965. * @returns this
  61966. */
  61967. addHole(hole: Vector2[]): PolygonMeshBuilder;
  61968. /**
  61969. * Creates the polygon
  61970. * @param updatable If the mesh should be updatable
  61971. * @param depth The depth of the mesh created
  61972. * @returns the created mesh
  61973. */
  61974. build(updatable?: boolean, depth?: number): Mesh;
  61975. /**
  61976. * Creates the polygon
  61977. * @param depth The depth of the mesh created
  61978. * @returns the created VertexData
  61979. */
  61980. buildVertexData(depth?: number): VertexData;
  61981. /**
  61982. * Adds a side to the polygon
  61983. * @param positions points that make the polygon
  61984. * @param normals normals of the polygon
  61985. * @param uvs uvs of the polygon
  61986. * @param indices indices of the polygon
  61987. * @param bounds bounds of the polygon
  61988. * @param points points of the polygon
  61989. * @param depth depth of the polygon
  61990. * @param flip flip of the polygon
  61991. */
  61992. private addSide;
  61993. }
  61994. }
  61995. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  61996. import { Scene } from "babylonjs/scene";
  61997. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  61998. import { Color4 } from "babylonjs/Maths/math.color";
  61999. import { Mesh } from "babylonjs/Meshes/mesh";
  62000. import { Nullable } from "babylonjs/types";
  62001. /**
  62002. * Class containing static functions to help procedurally build meshes
  62003. */
  62004. export class PolygonBuilder {
  62005. /**
  62006. * Creates a polygon mesh
  62007. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62008. * * 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
  62009. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62011. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  62012. * * Remember you can only change the shape positions, not their number when updating a polygon
  62013. * @param name defines the name of the mesh
  62014. * @param options defines the options used to create the mesh
  62015. * @param scene defines the hosting scene
  62016. * @param earcutInjection can be used to inject your own earcut reference
  62017. * @returns the polygon mesh
  62018. */
  62019. static CreatePolygon(name: string, options: {
  62020. shape: Vector3[];
  62021. holes?: Vector3[][];
  62022. depth?: number;
  62023. faceUV?: Vector4[];
  62024. faceColors?: Color4[];
  62025. updatable?: boolean;
  62026. sideOrientation?: number;
  62027. frontUVs?: Vector4;
  62028. backUVs?: Vector4;
  62029. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62030. /**
  62031. * Creates an extruded polygon mesh, with depth in the Y direction.
  62032. * * 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)
  62033. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62034. * @param name defines the name of the mesh
  62035. * @param options defines the options used to create the mesh
  62036. * @param scene defines the hosting scene
  62037. * @param earcutInjection can be used to inject your own earcut reference
  62038. * @returns the polygon mesh
  62039. */
  62040. static ExtrudePolygon(name: string, options: {
  62041. shape: Vector3[];
  62042. holes?: Vector3[][];
  62043. depth?: number;
  62044. faceUV?: Vector4[];
  62045. faceColors?: Color4[];
  62046. updatable?: boolean;
  62047. sideOrientation?: number;
  62048. frontUVs?: Vector4;
  62049. backUVs?: Vector4;
  62050. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62051. }
  62052. }
  62053. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  62054. import { Scene } from "babylonjs/scene";
  62055. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62056. import { Mesh } from "babylonjs/Meshes/mesh";
  62057. import { Nullable } from "babylonjs/types";
  62058. /**
  62059. * Class containing static functions to help procedurally build meshes
  62060. */
  62061. export class LatheBuilder {
  62062. /**
  62063. * Creates lathe mesh.
  62064. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  62065. * * 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
  62066. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  62067. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  62068. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  62069. * * 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
  62070. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  62071. * * 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
  62072. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62073. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62074. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62076. * @param name defines the name of the mesh
  62077. * @param options defines the options used to create the mesh
  62078. * @param scene defines the hosting scene
  62079. * @returns the lathe mesh
  62080. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  62081. */
  62082. static CreateLathe(name: string, options: {
  62083. shape: Vector3[];
  62084. radius?: number;
  62085. tessellation?: number;
  62086. clip?: number;
  62087. arc?: number;
  62088. closed?: boolean;
  62089. updatable?: boolean;
  62090. sideOrientation?: number;
  62091. frontUVs?: Vector4;
  62092. backUVs?: Vector4;
  62093. cap?: number;
  62094. invertUV?: boolean;
  62095. }, scene?: Nullable<Scene>): Mesh;
  62096. }
  62097. }
  62098. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  62099. import { Nullable } from "babylonjs/types";
  62100. import { Scene } from "babylonjs/scene";
  62101. import { Vector4 } from "babylonjs/Maths/math.vector";
  62102. import { Mesh } from "babylonjs/Meshes/mesh";
  62103. /**
  62104. * Class containing static functions to help procedurally build meshes
  62105. */
  62106. export class TiledPlaneBuilder {
  62107. /**
  62108. * Creates a tiled plane mesh
  62109. * * The parameter `pattern` will, depending on value, do nothing or
  62110. * * * flip (reflect about central vertical) alternate tiles across and up
  62111. * * * flip every tile on alternate rows
  62112. * * * rotate (180 degs) alternate tiles across and up
  62113. * * * rotate every tile on alternate rows
  62114. * * * flip and rotate alternate tiles across and up
  62115. * * * flip and rotate every tile on alternate rows
  62116. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  62117. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  62118. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62119. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62120. * * 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)
  62121. * * 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)
  62122. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  62123. * @param name defines the name of the mesh
  62124. * @param options defines the options used to create the mesh
  62125. * @param scene defines the hosting scene
  62126. * @returns the box mesh
  62127. */
  62128. static CreateTiledPlane(name: string, options: {
  62129. pattern?: number;
  62130. tileSize?: number;
  62131. tileWidth?: number;
  62132. tileHeight?: number;
  62133. size?: number;
  62134. width?: number;
  62135. height?: number;
  62136. alignHorizontal?: number;
  62137. alignVertical?: number;
  62138. sideOrientation?: number;
  62139. frontUVs?: Vector4;
  62140. backUVs?: Vector4;
  62141. updatable?: boolean;
  62142. }, scene?: Nullable<Scene>): Mesh;
  62143. }
  62144. }
  62145. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  62146. import { Nullable } from "babylonjs/types";
  62147. import { Scene } from "babylonjs/scene";
  62148. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62149. import { Mesh } from "babylonjs/Meshes/mesh";
  62150. /**
  62151. * Class containing static functions to help procedurally build meshes
  62152. */
  62153. export class TubeBuilder {
  62154. /**
  62155. * Creates a tube mesh.
  62156. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62157. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62158. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62159. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62160. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62161. * * 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)
  62162. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62163. * * 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
  62164. * * 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
  62165. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62166. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62167. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62169. * @param name defines the name of the mesh
  62170. * @param options defines the options used to create the mesh
  62171. * @param scene defines the hosting scene
  62172. * @returns the tube mesh
  62173. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62174. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62175. */
  62176. static CreateTube(name: string, options: {
  62177. path: Vector3[];
  62178. radius?: number;
  62179. tessellation?: number;
  62180. radiusFunction?: {
  62181. (i: number, distance: number): number;
  62182. };
  62183. cap?: number;
  62184. arc?: number;
  62185. updatable?: boolean;
  62186. sideOrientation?: number;
  62187. frontUVs?: Vector4;
  62188. backUVs?: Vector4;
  62189. instance?: Mesh;
  62190. invertUV?: boolean;
  62191. }, scene?: Nullable<Scene>): Mesh;
  62192. }
  62193. }
  62194. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  62195. import { Scene } from "babylonjs/scene";
  62196. import { Vector4 } from "babylonjs/Maths/math.vector";
  62197. import { Mesh } from "babylonjs/Meshes/mesh";
  62198. import { Nullable } from "babylonjs/types";
  62199. /**
  62200. * Class containing static functions to help procedurally build meshes
  62201. */
  62202. export class IcoSphereBuilder {
  62203. /**
  62204. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  62205. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  62206. * * 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`)
  62207. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  62208. * * 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
  62209. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62210. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62211. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62212. * @param name defines the name of the mesh
  62213. * @param options defines the options used to create the mesh
  62214. * @param scene defines the hosting scene
  62215. * @returns the icosahedron mesh
  62216. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  62217. */
  62218. static CreateIcoSphere(name: string, options: {
  62219. radius?: number;
  62220. radiusX?: number;
  62221. radiusY?: number;
  62222. radiusZ?: number;
  62223. flat?: boolean;
  62224. subdivisions?: number;
  62225. sideOrientation?: number;
  62226. frontUVs?: Vector4;
  62227. backUVs?: Vector4;
  62228. updatable?: boolean;
  62229. }, scene?: Nullable<Scene>): Mesh;
  62230. }
  62231. }
  62232. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  62233. import { Vector3 } from "babylonjs/Maths/math.vector";
  62234. import { Mesh } from "babylonjs/Meshes/mesh";
  62235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62236. /**
  62237. * Class containing static functions to help procedurally build meshes
  62238. */
  62239. export class DecalBuilder {
  62240. /**
  62241. * Creates a decal mesh.
  62242. * 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
  62243. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62244. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62245. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62246. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62247. * @param name defines the name of the mesh
  62248. * @param sourceMesh defines the mesh where the decal must be applied
  62249. * @param options defines the options used to create the mesh
  62250. * @param scene defines the hosting scene
  62251. * @returns the decal mesh
  62252. * @see https://doc.babylonjs.com/how_to/decals
  62253. */
  62254. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62255. position?: Vector3;
  62256. normal?: Vector3;
  62257. size?: Vector3;
  62258. angle?: number;
  62259. }): Mesh;
  62260. }
  62261. }
  62262. declare module "babylonjs/Meshes/meshBuilder" {
  62263. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  62264. import { Nullable } from "babylonjs/types";
  62265. import { Scene } from "babylonjs/scene";
  62266. import { Mesh } from "babylonjs/Meshes/mesh";
  62267. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  62268. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  62269. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62270. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  62271. import { Plane } from "babylonjs/Maths/math.plane";
  62272. /**
  62273. * Class containing static functions to help procedurally build meshes
  62274. */
  62275. export class MeshBuilder {
  62276. /**
  62277. * Creates a box mesh
  62278. * * The parameter `size` sets the size (float) of each box side (default 1)
  62279. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  62280. * * 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)
  62281. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62282. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62283. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62285. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  62286. * @param name defines the name of the mesh
  62287. * @param options defines the options used to create the mesh
  62288. * @param scene defines the hosting scene
  62289. * @returns the box mesh
  62290. */
  62291. static CreateBox(name: string, options: {
  62292. size?: number;
  62293. width?: number;
  62294. height?: number;
  62295. depth?: number;
  62296. faceUV?: Vector4[];
  62297. faceColors?: Color4[];
  62298. sideOrientation?: number;
  62299. frontUVs?: Vector4;
  62300. backUVs?: Vector4;
  62301. updatable?: boolean;
  62302. }, scene?: Nullable<Scene>): Mesh;
  62303. /**
  62304. * Creates a tiled box mesh
  62305. * * faceTiles sets the pattern, tile size and number of tiles for a face
  62306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62307. * @param name defines the name of the mesh
  62308. * @param options defines the options used to create the mesh
  62309. * @param scene defines the hosting scene
  62310. * @returns the tiled box mesh
  62311. */
  62312. static CreateTiledBox(name: string, options: {
  62313. pattern?: number;
  62314. size?: number;
  62315. width?: number;
  62316. height?: number;
  62317. depth: number;
  62318. tileSize?: number;
  62319. tileWidth?: number;
  62320. tileHeight?: number;
  62321. faceUV?: Vector4[];
  62322. faceColors?: Color4[];
  62323. alignHorizontal?: number;
  62324. alignVertical?: number;
  62325. sideOrientation?: number;
  62326. updatable?: boolean;
  62327. }, scene?: Nullable<Scene>): Mesh;
  62328. /**
  62329. * Creates a sphere mesh
  62330. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  62331. * * 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`)
  62332. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  62333. * * 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
  62334. * * 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)
  62335. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62336. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62338. * @param name defines the name of the mesh
  62339. * @param options defines the options used to create the mesh
  62340. * @param scene defines the hosting scene
  62341. * @returns the sphere mesh
  62342. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  62343. */
  62344. static CreateSphere(name: string, options: {
  62345. segments?: number;
  62346. diameter?: number;
  62347. diameterX?: number;
  62348. diameterY?: number;
  62349. diameterZ?: number;
  62350. arc?: number;
  62351. slice?: number;
  62352. sideOrientation?: number;
  62353. frontUVs?: Vector4;
  62354. backUVs?: Vector4;
  62355. updatable?: boolean;
  62356. }, scene?: Nullable<Scene>): Mesh;
  62357. /**
  62358. * Creates a plane polygonal mesh. By default, this is a disc
  62359. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  62360. * * 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
  62361. * * 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
  62362. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62363. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62365. * @param name defines the name of the mesh
  62366. * @param options defines the options used to create the mesh
  62367. * @param scene defines the hosting scene
  62368. * @returns the plane polygonal mesh
  62369. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  62370. */
  62371. static CreateDisc(name: string, options: {
  62372. radius?: number;
  62373. tessellation?: number;
  62374. arc?: number;
  62375. updatable?: boolean;
  62376. sideOrientation?: number;
  62377. frontUVs?: Vector4;
  62378. backUVs?: Vector4;
  62379. }, scene?: Nullable<Scene>): Mesh;
  62380. /**
  62381. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  62382. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  62383. * * 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`)
  62384. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  62385. * * 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
  62386. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62387. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62389. * @param name defines the name of the mesh
  62390. * @param options defines the options used to create the mesh
  62391. * @param scene defines the hosting scene
  62392. * @returns the icosahedron mesh
  62393. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  62394. */
  62395. static CreateIcoSphere(name: string, options: {
  62396. radius?: number;
  62397. radiusX?: number;
  62398. radiusY?: number;
  62399. radiusZ?: number;
  62400. flat?: boolean;
  62401. subdivisions?: number;
  62402. sideOrientation?: number;
  62403. frontUVs?: Vector4;
  62404. backUVs?: Vector4;
  62405. updatable?: boolean;
  62406. }, scene?: Nullable<Scene>): Mesh;
  62407. /**
  62408. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62409. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  62410. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  62411. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  62412. * * 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
  62413. * * 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
  62414. * * 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
  62415. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62416. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62417. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62418. * * 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
  62419. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  62420. * * 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
  62421. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  62422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62423. * @param name defines the name of the mesh
  62424. * @param options defines the options used to create the mesh
  62425. * @param scene defines the hosting scene
  62426. * @returns the ribbon mesh
  62427. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  62428. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62429. */
  62430. static CreateRibbon(name: string, options: {
  62431. pathArray: Vector3[][];
  62432. closeArray?: boolean;
  62433. closePath?: boolean;
  62434. offset?: number;
  62435. updatable?: boolean;
  62436. sideOrientation?: number;
  62437. frontUVs?: Vector4;
  62438. backUVs?: Vector4;
  62439. instance?: Mesh;
  62440. invertUV?: boolean;
  62441. uvs?: Vector2[];
  62442. colors?: Color4[];
  62443. }, scene?: Nullable<Scene>): Mesh;
  62444. /**
  62445. * Creates a cylinder or a cone mesh
  62446. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  62447. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  62448. * * 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.
  62449. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  62450. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  62451. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  62452. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  62453. * * 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).
  62454. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  62455. * * 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).
  62456. * * 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
  62457. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  62458. * * 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
  62459. * * 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.
  62460. * * If `enclose` is false, a ring surface is one element.
  62461. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  62462. * * 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
  62463. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62464. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62466. * @param name defines the name of the mesh
  62467. * @param options defines the options used to create the mesh
  62468. * @param scene defines the hosting scene
  62469. * @returns the cylinder mesh
  62470. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  62471. */
  62472. static CreateCylinder(name: string, options: {
  62473. height?: number;
  62474. diameterTop?: number;
  62475. diameterBottom?: number;
  62476. diameter?: number;
  62477. tessellation?: number;
  62478. subdivisions?: number;
  62479. arc?: number;
  62480. faceColors?: Color4[];
  62481. faceUV?: Vector4[];
  62482. updatable?: boolean;
  62483. hasRings?: boolean;
  62484. enclose?: boolean;
  62485. cap?: number;
  62486. sideOrientation?: number;
  62487. frontUVs?: Vector4;
  62488. backUVs?: Vector4;
  62489. }, scene?: Nullable<Scene>): Mesh;
  62490. /**
  62491. * Creates a torus mesh
  62492. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  62493. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  62494. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  62495. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62496. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62498. * @param name defines the name of the mesh
  62499. * @param options defines the options used to create the mesh
  62500. * @param scene defines the hosting scene
  62501. * @returns the torus mesh
  62502. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  62503. */
  62504. static CreateTorus(name: string, options: {
  62505. diameter?: number;
  62506. thickness?: number;
  62507. tessellation?: number;
  62508. updatable?: boolean;
  62509. sideOrientation?: number;
  62510. frontUVs?: Vector4;
  62511. backUVs?: Vector4;
  62512. }, scene?: Nullable<Scene>): Mesh;
  62513. /**
  62514. * Creates a torus knot mesh
  62515. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  62516. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  62517. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  62518. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  62519. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62520. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62522. * @param name defines the name of the mesh
  62523. * @param options defines the options used to create the mesh
  62524. * @param scene defines the hosting scene
  62525. * @returns the torus knot mesh
  62526. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  62527. */
  62528. static CreateTorusKnot(name: string, options: {
  62529. radius?: number;
  62530. tube?: number;
  62531. radialSegments?: number;
  62532. tubularSegments?: number;
  62533. p?: number;
  62534. q?: number;
  62535. updatable?: boolean;
  62536. sideOrientation?: number;
  62537. frontUVs?: Vector4;
  62538. backUVs?: Vector4;
  62539. }, scene?: Nullable<Scene>): Mesh;
  62540. /**
  62541. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  62542. * * 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
  62543. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  62544. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  62545. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  62546. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  62547. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  62548. * * 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
  62549. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  62550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62551. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  62552. * @param name defines the name of the new line system
  62553. * @param options defines the options used to create the line system
  62554. * @param scene defines the hosting scene
  62555. * @returns a new line system mesh
  62556. */
  62557. static CreateLineSystem(name: string, options: {
  62558. lines: Vector3[][];
  62559. updatable?: boolean;
  62560. instance?: Nullable<LinesMesh>;
  62561. colors?: Nullable<Color4[][]>;
  62562. useVertexAlpha?: boolean;
  62563. }, scene: Nullable<Scene>): LinesMesh;
  62564. /**
  62565. * Creates a line mesh
  62566. * 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
  62567. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  62568. * * The parameter `points` is an array successive Vector3
  62569. * * 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
  62570. * * The optional parameter `colors` is an array of successive Color4, one per line point
  62571. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  62572. * * When updating an instance, remember that only point positions can change, not the number of points
  62573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62574. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  62575. * @param name defines the name of the new line system
  62576. * @param options defines the options used to create the line system
  62577. * @param scene defines the hosting scene
  62578. * @returns a new line mesh
  62579. */
  62580. static CreateLines(name: string, options: {
  62581. points: Vector3[];
  62582. updatable?: boolean;
  62583. instance?: Nullable<LinesMesh>;
  62584. colors?: Color4[];
  62585. useVertexAlpha?: boolean;
  62586. }, scene?: Nullable<Scene>): LinesMesh;
  62587. /**
  62588. * Creates a dashed line mesh
  62589. * * 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
  62590. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  62591. * * The parameter `points` is an array successive Vector3
  62592. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  62593. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  62594. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  62595. * * 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
  62596. * * When updating an instance, remember that only point positions can change, not the number of points
  62597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62598. * @param name defines the name of the mesh
  62599. * @param options defines the options used to create the mesh
  62600. * @param scene defines the hosting scene
  62601. * @returns the dashed line mesh
  62602. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  62603. */
  62604. static CreateDashedLines(name: string, options: {
  62605. points: Vector3[];
  62606. dashSize?: number;
  62607. gapSize?: number;
  62608. dashNb?: number;
  62609. updatable?: boolean;
  62610. instance?: LinesMesh;
  62611. }, scene?: Nullable<Scene>): LinesMesh;
  62612. /**
  62613. * 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.
  62614. * * 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.
  62615. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62616. * * 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.
  62617. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  62618. * * 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
  62619. * * 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
  62620. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  62621. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62622. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62623. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  62624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62625. * @param name defines the name of the mesh
  62626. * @param options defines the options used to create the mesh
  62627. * @param scene defines the hosting scene
  62628. * @returns the extruded shape mesh
  62629. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62630. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62631. */
  62632. static ExtrudeShape(name: string, options: {
  62633. shape: Vector3[];
  62634. path: Vector3[];
  62635. scale?: number;
  62636. rotation?: number;
  62637. cap?: number;
  62638. updatable?: boolean;
  62639. sideOrientation?: number;
  62640. frontUVs?: Vector4;
  62641. backUVs?: Vector4;
  62642. instance?: Mesh;
  62643. invertUV?: boolean;
  62644. }, scene?: Nullable<Scene>): Mesh;
  62645. /**
  62646. * Creates an custom extruded shape mesh.
  62647. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  62648. * * 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.
  62649. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62650. * * 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
  62651. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  62652. * * 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
  62653. * * It must returns a float value that will be the scale value applied to the shape on each path point
  62654. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  62655. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  62656. * * 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
  62657. * * 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
  62658. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  62659. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62660. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62661. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62663. * @param name defines the name of the mesh
  62664. * @param options defines the options used to create the mesh
  62665. * @param scene defines the hosting scene
  62666. * @returns the custom extruded shape mesh
  62667. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  62668. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62669. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62670. */
  62671. static ExtrudeShapeCustom(name: string, options: {
  62672. shape: Vector3[];
  62673. path: Vector3[];
  62674. scaleFunction?: any;
  62675. rotationFunction?: any;
  62676. ribbonCloseArray?: boolean;
  62677. ribbonClosePath?: boolean;
  62678. cap?: number;
  62679. updatable?: boolean;
  62680. sideOrientation?: number;
  62681. frontUVs?: Vector4;
  62682. backUVs?: Vector4;
  62683. instance?: Mesh;
  62684. invertUV?: boolean;
  62685. }, scene?: Nullable<Scene>): Mesh;
  62686. /**
  62687. * Creates lathe mesh.
  62688. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  62689. * * 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
  62690. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  62691. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  62692. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  62693. * * 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
  62694. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  62695. * * 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
  62696. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62697. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62698. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62700. * @param name defines the name of the mesh
  62701. * @param options defines the options used to create the mesh
  62702. * @param scene defines the hosting scene
  62703. * @returns the lathe mesh
  62704. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  62705. */
  62706. static CreateLathe(name: string, options: {
  62707. shape: Vector3[];
  62708. radius?: number;
  62709. tessellation?: number;
  62710. clip?: number;
  62711. arc?: number;
  62712. closed?: boolean;
  62713. updatable?: boolean;
  62714. sideOrientation?: number;
  62715. frontUVs?: Vector4;
  62716. backUVs?: Vector4;
  62717. cap?: number;
  62718. invertUV?: boolean;
  62719. }, scene?: Nullable<Scene>): Mesh;
  62720. /**
  62721. * Creates a tiled plane mesh
  62722. * * You can set a limited pattern arrangement with the tiles
  62723. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62724. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62726. * @param name defines the name of the mesh
  62727. * @param options defines the options used to create the mesh
  62728. * @param scene defines the hosting scene
  62729. * @returns the plane mesh
  62730. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62731. */
  62732. static CreateTiledPlane(name: string, options: {
  62733. pattern?: number;
  62734. tileSize?: number;
  62735. tileWidth?: number;
  62736. tileHeight?: number;
  62737. size?: number;
  62738. width?: number;
  62739. height?: number;
  62740. alignHorizontal?: number;
  62741. alignVertical?: number;
  62742. sideOrientation?: number;
  62743. frontUVs?: Vector4;
  62744. backUVs?: Vector4;
  62745. updatable?: boolean;
  62746. }, scene?: Nullable<Scene>): Mesh;
  62747. /**
  62748. * Creates a plane mesh
  62749. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  62750. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  62751. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  62752. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62753. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62755. * @param name defines the name of the mesh
  62756. * @param options defines the options used to create the mesh
  62757. * @param scene defines the hosting scene
  62758. * @returns the plane mesh
  62759. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62760. */
  62761. static CreatePlane(name: string, options: {
  62762. size?: number;
  62763. width?: number;
  62764. height?: number;
  62765. sideOrientation?: number;
  62766. frontUVs?: Vector4;
  62767. backUVs?: Vector4;
  62768. updatable?: boolean;
  62769. sourcePlane?: Plane;
  62770. }, scene?: Nullable<Scene>): Mesh;
  62771. /**
  62772. * Creates a ground mesh
  62773. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  62774. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  62775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62776. * @param name defines the name of the mesh
  62777. * @param options defines the options used to create the mesh
  62778. * @param scene defines the hosting scene
  62779. * @returns the ground mesh
  62780. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  62781. */
  62782. static CreateGround(name: string, options: {
  62783. width?: number;
  62784. height?: number;
  62785. subdivisions?: number;
  62786. subdivisionsX?: number;
  62787. subdivisionsY?: number;
  62788. updatable?: boolean;
  62789. }, scene?: Nullable<Scene>): Mesh;
  62790. /**
  62791. * Creates a tiled ground mesh
  62792. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  62793. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  62794. * * 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
  62795. * * 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
  62796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62797. * @param name defines the name of the mesh
  62798. * @param options defines the options used to create the mesh
  62799. * @param scene defines the hosting scene
  62800. * @returns the tiled ground mesh
  62801. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  62802. */
  62803. static CreateTiledGround(name: string, options: {
  62804. xmin: number;
  62805. zmin: number;
  62806. xmax: number;
  62807. zmax: number;
  62808. subdivisions?: {
  62809. w: number;
  62810. h: number;
  62811. };
  62812. precision?: {
  62813. w: number;
  62814. h: number;
  62815. };
  62816. updatable?: boolean;
  62817. }, scene?: Nullable<Scene>): Mesh;
  62818. /**
  62819. * Creates a ground mesh from a height map
  62820. * * The parameter `url` sets the URL of the height map image resource.
  62821. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  62822. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  62823. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  62824. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  62825. * * 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.
  62826. * * 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).
  62827. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  62828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62829. * @param name defines the name of the mesh
  62830. * @param url defines the url to the height map
  62831. * @param options defines the options used to create the mesh
  62832. * @param scene defines the hosting scene
  62833. * @returns the ground mesh
  62834. * @see https://doc.babylonjs.com/babylon101/height_map
  62835. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  62836. */
  62837. static CreateGroundFromHeightMap(name: string, url: string, options: {
  62838. width?: number;
  62839. height?: number;
  62840. subdivisions?: number;
  62841. minHeight?: number;
  62842. maxHeight?: number;
  62843. colorFilter?: Color3;
  62844. alphaFilter?: number;
  62845. updatable?: boolean;
  62846. onReady?: (mesh: GroundMesh) => void;
  62847. }, scene?: Nullable<Scene>): GroundMesh;
  62848. /**
  62849. * Creates a polygon mesh
  62850. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62851. * * 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
  62852. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62854. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  62855. * * Remember you can only change the shape positions, not their number when updating a polygon
  62856. * @param name defines the name of the mesh
  62857. * @param options defines the options used to create the mesh
  62858. * @param scene defines the hosting scene
  62859. * @param earcutInjection can be used to inject your own earcut reference
  62860. * @returns the polygon mesh
  62861. */
  62862. static CreatePolygon(name: string, options: {
  62863. shape: Vector3[];
  62864. holes?: Vector3[][];
  62865. depth?: number;
  62866. faceUV?: Vector4[];
  62867. faceColors?: Color4[];
  62868. updatable?: boolean;
  62869. sideOrientation?: number;
  62870. frontUVs?: Vector4;
  62871. backUVs?: Vector4;
  62872. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62873. /**
  62874. * Creates an extruded polygon mesh, with depth in the Y direction.
  62875. * * 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)
  62876. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62877. * @param name defines the name of the mesh
  62878. * @param options defines the options used to create the mesh
  62879. * @param scene defines the hosting scene
  62880. * @param earcutInjection can be used to inject your own earcut reference
  62881. * @returns the polygon mesh
  62882. */
  62883. static ExtrudePolygon(name: string, options: {
  62884. shape: Vector3[];
  62885. holes?: Vector3[][];
  62886. depth?: number;
  62887. faceUV?: Vector4[];
  62888. faceColors?: Color4[];
  62889. updatable?: boolean;
  62890. sideOrientation?: number;
  62891. frontUVs?: Vector4;
  62892. backUVs?: Vector4;
  62893. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62894. /**
  62895. * Creates a tube mesh.
  62896. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62897. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62898. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62899. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62900. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62901. * * 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)
  62902. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62903. * * 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
  62904. * * 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
  62905. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62906. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62907. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62909. * @param name defines the name of the mesh
  62910. * @param options defines the options used to create the mesh
  62911. * @param scene defines the hosting scene
  62912. * @returns the tube mesh
  62913. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62914. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62915. */
  62916. static CreateTube(name: string, options: {
  62917. path: Vector3[];
  62918. radius?: number;
  62919. tessellation?: number;
  62920. radiusFunction?: {
  62921. (i: number, distance: number): number;
  62922. };
  62923. cap?: number;
  62924. arc?: number;
  62925. updatable?: boolean;
  62926. sideOrientation?: number;
  62927. frontUVs?: Vector4;
  62928. backUVs?: Vector4;
  62929. instance?: Mesh;
  62930. invertUV?: boolean;
  62931. }, scene?: Nullable<Scene>): Mesh;
  62932. /**
  62933. * Creates a polyhedron mesh
  62934. * * 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
  62935. * * The parameter `size` (positive float, default 1) sets the polygon size
  62936. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  62937. * * 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`
  62938. * * 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
  62939. * * 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)`)
  62940. * * 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
  62941. * * 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
  62942. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62943. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62945. * @param name defines the name of the mesh
  62946. * @param options defines the options used to create the mesh
  62947. * @param scene defines the hosting scene
  62948. * @returns the polyhedron mesh
  62949. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  62950. */
  62951. static CreatePolyhedron(name: string, options: {
  62952. type?: number;
  62953. size?: number;
  62954. sizeX?: number;
  62955. sizeY?: number;
  62956. sizeZ?: number;
  62957. custom?: any;
  62958. faceUV?: Vector4[];
  62959. faceColors?: Color4[];
  62960. flat?: boolean;
  62961. updatable?: boolean;
  62962. sideOrientation?: number;
  62963. frontUVs?: Vector4;
  62964. backUVs?: Vector4;
  62965. }, scene?: Nullable<Scene>): Mesh;
  62966. /**
  62967. * Creates a decal mesh.
  62968. * 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
  62969. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62970. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62971. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62972. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62973. * @param name defines the name of the mesh
  62974. * @param sourceMesh defines the mesh where the decal must be applied
  62975. * @param options defines the options used to create the mesh
  62976. * @param scene defines the hosting scene
  62977. * @returns the decal mesh
  62978. * @see https://doc.babylonjs.com/how_to/decals
  62979. */
  62980. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62981. position?: Vector3;
  62982. normal?: Vector3;
  62983. size?: Vector3;
  62984. angle?: number;
  62985. }): Mesh;
  62986. }
  62987. }
  62988. declare module "babylonjs/Meshes/meshSimplification" {
  62989. import { Mesh } from "babylonjs/Meshes/mesh";
  62990. /**
  62991. * A simplifier interface for future simplification implementations
  62992. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62993. */
  62994. export interface ISimplifier {
  62995. /**
  62996. * Simplification of a given mesh according to the given settings.
  62997. * Since this requires computation, it is assumed that the function runs async.
  62998. * @param settings The settings of the simplification, including quality and distance
  62999. * @param successCallback A callback that will be called after the mesh was simplified.
  63000. * @param errorCallback in case of an error, this callback will be called. optional.
  63001. */
  63002. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  63003. }
  63004. /**
  63005. * Expected simplification settings.
  63006. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  63007. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63008. */
  63009. export interface ISimplificationSettings {
  63010. /**
  63011. * Gets or sets the expected quality
  63012. */
  63013. quality: number;
  63014. /**
  63015. * Gets or sets the distance when this optimized version should be used
  63016. */
  63017. distance: number;
  63018. /**
  63019. * Gets an already optimized mesh
  63020. */
  63021. optimizeMesh?: boolean;
  63022. }
  63023. /**
  63024. * Class used to specify simplification options
  63025. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63026. */
  63027. export class SimplificationSettings implements ISimplificationSettings {
  63028. /** expected quality */
  63029. quality: number;
  63030. /** distance when this optimized version should be used */
  63031. distance: number;
  63032. /** already optimized mesh */
  63033. optimizeMesh?: boolean | undefined;
  63034. /**
  63035. * Creates a SimplificationSettings
  63036. * @param quality expected quality
  63037. * @param distance distance when this optimized version should be used
  63038. * @param optimizeMesh already optimized mesh
  63039. */
  63040. constructor(
  63041. /** expected quality */
  63042. quality: number,
  63043. /** distance when this optimized version should be used */
  63044. distance: number,
  63045. /** already optimized mesh */
  63046. optimizeMesh?: boolean | undefined);
  63047. }
  63048. /**
  63049. * Interface used to define a simplification task
  63050. */
  63051. export interface ISimplificationTask {
  63052. /**
  63053. * Array of settings
  63054. */
  63055. settings: Array<ISimplificationSettings>;
  63056. /**
  63057. * Simplification type
  63058. */
  63059. simplificationType: SimplificationType;
  63060. /**
  63061. * Mesh to simplify
  63062. */
  63063. mesh: Mesh;
  63064. /**
  63065. * Callback called on success
  63066. */
  63067. successCallback?: () => void;
  63068. /**
  63069. * Defines if parallel processing can be used
  63070. */
  63071. parallelProcessing: boolean;
  63072. }
  63073. /**
  63074. * Queue used to order the simplification tasks
  63075. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63076. */
  63077. export class SimplificationQueue {
  63078. private _simplificationArray;
  63079. /**
  63080. * Gets a boolean indicating that the process is still running
  63081. */
  63082. running: boolean;
  63083. /**
  63084. * Creates a new queue
  63085. */
  63086. constructor();
  63087. /**
  63088. * Adds a new simplification task
  63089. * @param task defines a task to add
  63090. */
  63091. addTask(task: ISimplificationTask): void;
  63092. /**
  63093. * Execute next task
  63094. */
  63095. executeNext(): void;
  63096. /**
  63097. * Execute a simplification task
  63098. * @param task defines the task to run
  63099. */
  63100. runSimplification(task: ISimplificationTask): void;
  63101. private getSimplifier;
  63102. }
  63103. /**
  63104. * The implemented types of simplification
  63105. * At the moment only Quadratic Error Decimation is implemented
  63106. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63107. */
  63108. export enum SimplificationType {
  63109. /** Quadratic error decimation */
  63110. QUADRATIC = 0
  63111. }
  63112. }
  63113. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  63114. import { Scene } from "babylonjs/scene";
  63115. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  63116. import { ISceneComponent } from "babylonjs/sceneComponent";
  63117. module "babylonjs/scene" {
  63118. interface Scene {
  63119. /** @hidden (Backing field) */
  63120. _simplificationQueue: SimplificationQueue;
  63121. /**
  63122. * Gets or sets the simplification queue attached to the scene
  63123. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63124. */
  63125. simplificationQueue: SimplificationQueue;
  63126. }
  63127. }
  63128. module "babylonjs/Meshes/mesh" {
  63129. interface Mesh {
  63130. /**
  63131. * Simplify the mesh according to the given array of settings.
  63132. * Function will return immediately and will simplify async
  63133. * @param settings a collection of simplification settings
  63134. * @param parallelProcessing should all levels calculate parallel or one after the other
  63135. * @param simplificationType the type of simplification to run
  63136. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  63137. * @returns the current mesh
  63138. */
  63139. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  63140. }
  63141. }
  63142. /**
  63143. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  63144. * created in a scene
  63145. */
  63146. export class SimplicationQueueSceneComponent implements ISceneComponent {
  63147. /**
  63148. * The component name helpfull to identify the component in the list of scene components.
  63149. */
  63150. readonly name: string;
  63151. /**
  63152. * The scene the component belongs to.
  63153. */
  63154. scene: Scene;
  63155. /**
  63156. * Creates a new instance of the component for the given scene
  63157. * @param scene Defines the scene to register the component in
  63158. */
  63159. constructor(scene: Scene);
  63160. /**
  63161. * Registers the component in a given scene
  63162. */
  63163. register(): void;
  63164. /**
  63165. * Rebuilds the elements related to this component in case of
  63166. * context lost for instance.
  63167. */
  63168. rebuild(): void;
  63169. /**
  63170. * Disposes the component and the associated ressources
  63171. */
  63172. dispose(): void;
  63173. private _beforeCameraUpdate;
  63174. }
  63175. }
  63176. declare module "babylonjs/Meshes/Builders/index" {
  63177. export * from "babylonjs/Meshes/Builders/boxBuilder";
  63178. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  63179. export * from "babylonjs/Meshes/Builders/discBuilder";
  63180. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  63181. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  63182. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  63183. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  63184. export * from "babylonjs/Meshes/Builders/torusBuilder";
  63185. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  63186. export * from "babylonjs/Meshes/Builders/linesBuilder";
  63187. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  63188. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  63189. export * from "babylonjs/Meshes/Builders/latheBuilder";
  63190. export * from "babylonjs/Meshes/Builders/planeBuilder";
  63191. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  63192. export * from "babylonjs/Meshes/Builders/groundBuilder";
  63193. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  63194. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  63195. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  63196. export * from "babylonjs/Meshes/Builders/decalBuilder";
  63197. }
  63198. declare module "babylonjs/Meshes/index" {
  63199. export * from "babylonjs/Meshes/abstractMesh";
  63200. export * from "babylonjs/Meshes/buffer";
  63201. export * from "babylonjs/Meshes/Compression/index";
  63202. export * from "babylonjs/Meshes/csg";
  63203. export * from "babylonjs/Meshes/geometry";
  63204. export * from "babylonjs/Meshes/groundMesh";
  63205. export * from "babylonjs/Meshes/trailMesh";
  63206. export * from "babylonjs/Meshes/instancedMesh";
  63207. export * from "babylonjs/Meshes/linesMesh";
  63208. export * from "babylonjs/Meshes/mesh";
  63209. export * from "babylonjs/Meshes/mesh.vertexData";
  63210. export * from "babylonjs/Meshes/meshBuilder";
  63211. export * from "babylonjs/Meshes/meshSimplification";
  63212. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  63213. export * from "babylonjs/Meshes/polygonMesh";
  63214. export * from "babylonjs/Meshes/subMesh";
  63215. export * from "babylonjs/Meshes/meshLODLevel";
  63216. export * from "babylonjs/Meshes/transformNode";
  63217. export * from "babylonjs/Meshes/Builders/index";
  63218. export * from "babylonjs/Meshes/dataBuffer";
  63219. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  63220. }
  63221. declare module "babylonjs/Morph/index" {
  63222. export * from "babylonjs/Morph/morphTarget";
  63223. export * from "babylonjs/Morph/morphTargetManager";
  63224. }
  63225. declare module "babylonjs/Navigation/INavigationEngine" {
  63226. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63227. import { Vector3 } from "babylonjs/Maths/math";
  63228. import { Mesh } from "babylonjs/Meshes/mesh";
  63229. import { Scene } from "babylonjs/scene";
  63230. /**
  63231. * Navigation plugin interface to add navigation constrained by a navigation mesh
  63232. */
  63233. export interface INavigationEnginePlugin {
  63234. /**
  63235. * plugin name
  63236. */
  63237. name: string;
  63238. /**
  63239. * Creates a navigation mesh
  63240. * @param meshes array of all the geometry used to compute the navigatio mesh
  63241. * @param parameters bunch of parameters used to filter geometry
  63242. */
  63243. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  63244. /**
  63245. * Create a navigation mesh debug mesh
  63246. * @param scene is where the mesh will be added
  63247. * @returns debug display mesh
  63248. */
  63249. createDebugNavMesh(scene: Scene): Mesh;
  63250. /**
  63251. * Get a navigation mesh constrained position, closest to the parameter position
  63252. * @param position world position
  63253. * @returns the closest point to position constrained by the navigation mesh
  63254. */
  63255. getClosestPoint(position: Vector3): Vector3;
  63256. /**
  63257. * Get a navigation mesh constrained position, within a particular radius
  63258. * @param position world position
  63259. * @param maxRadius the maximum distance to the constrained world position
  63260. * @returns the closest point to position constrained by the navigation mesh
  63261. */
  63262. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  63263. /**
  63264. * Compute the final position from a segment made of destination-position
  63265. * @param position world position
  63266. * @param destination world position
  63267. * @returns the resulting point along the navmesh
  63268. */
  63269. moveAlong(position: Vector3, destination: Vector3): Vector3;
  63270. /**
  63271. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  63272. * @param start world position
  63273. * @param end world position
  63274. * @returns array containing world position composing the path
  63275. */
  63276. computePath(start: Vector3, end: Vector3): Vector3[];
  63277. /**
  63278. * If this plugin is supported
  63279. * @returns true if plugin is supported
  63280. */
  63281. isSupported(): boolean;
  63282. /**
  63283. * Create a new Crowd so you can add agents
  63284. * @param maxAgents the maximum agent count in the crowd
  63285. * @param maxAgentRadius the maximum radius an agent can have
  63286. * @param scene to attach the crowd to
  63287. * @returns the crowd you can add agents to
  63288. */
  63289. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  63290. /**
  63291. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63292. * The queries will try to find a solution within those bounds
  63293. * default is (1,1,1)
  63294. * @param extent x,y,z value that define the extent around the queries point of reference
  63295. */
  63296. setDefaultQueryExtent(extent: Vector3): void;
  63297. /**
  63298. * Get the Bounding box extent specified by setDefaultQueryExtent
  63299. * @returns the box extent values
  63300. */
  63301. getDefaultQueryExtent(): Vector3;
  63302. /**
  63303. * Release all resources
  63304. */
  63305. dispose(): void;
  63306. }
  63307. /**
  63308. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  63309. */
  63310. export interface ICrowd {
  63311. /**
  63312. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  63313. * You can attach anything to that node. The node position is updated in the scene update tick.
  63314. * @param pos world position that will be constrained by the navigation mesh
  63315. * @param parameters agent parameters
  63316. * @param transform hooked to the agent that will be update by the scene
  63317. * @returns agent index
  63318. */
  63319. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  63320. /**
  63321. * Returns the agent position in world space
  63322. * @param index agent index returned by addAgent
  63323. * @returns world space position
  63324. */
  63325. getAgentPosition(index: number): Vector3;
  63326. /**
  63327. * Gets the agent velocity in world space
  63328. * @param index agent index returned by addAgent
  63329. * @returns world space velocity
  63330. */
  63331. getAgentVelocity(index: number): Vector3;
  63332. /**
  63333. * remove a particular agent previously created
  63334. * @param index agent index returned by addAgent
  63335. */
  63336. removeAgent(index: number): void;
  63337. /**
  63338. * get the list of all agents attached to this crowd
  63339. * @returns list of agent indices
  63340. */
  63341. getAgents(): number[];
  63342. /**
  63343. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  63344. * @param deltaTime in seconds
  63345. */
  63346. update(deltaTime: number): void;
  63347. /**
  63348. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  63349. * @param index agent index returned by addAgent
  63350. * @param destination targeted world position
  63351. */
  63352. agentGoto(index: number, destination: Vector3): void;
  63353. /**
  63354. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63355. * The queries will try to find a solution within those bounds
  63356. * default is (1,1,1)
  63357. * @param extent x,y,z value that define the extent around the queries point of reference
  63358. */
  63359. setDefaultQueryExtent(extent: Vector3): void;
  63360. /**
  63361. * Get the Bounding box extent specified by setDefaultQueryExtent
  63362. * @returns the box extent values
  63363. */
  63364. getDefaultQueryExtent(): Vector3;
  63365. /**
  63366. * Release all resources
  63367. */
  63368. dispose(): void;
  63369. }
  63370. /**
  63371. * Configures an agent
  63372. */
  63373. export interface IAgentParameters {
  63374. /**
  63375. * Agent radius. [Limit: >= 0]
  63376. */
  63377. radius: number;
  63378. /**
  63379. * Agent height. [Limit: > 0]
  63380. */
  63381. height: number;
  63382. /**
  63383. * Maximum allowed acceleration. [Limit: >= 0]
  63384. */
  63385. maxAcceleration: number;
  63386. /**
  63387. * Maximum allowed speed. [Limit: >= 0]
  63388. */
  63389. maxSpeed: number;
  63390. /**
  63391. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  63392. */
  63393. collisionQueryRange: number;
  63394. /**
  63395. * The path visibility optimization range. [Limit: > 0]
  63396. */
  63397. pathOptimizationRange: number;
  63398. /**
  63399. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  63400. */
  63401. separationWeight: number;
  63402. }
  63403. /**
  63404. * Configures the navigation mesh creation
  63405. */
  63406. export interface INavMeshParameters {
  63407. /**
  63408. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  63409. */
  63410. cs: number;
  63411. /**
  63412. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  63413. */
  63414. ch: number;
  63415. /**
  63416. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  63417. */
  63418. walkableSlopeAngle: number;
  63419. /**
  63420. * Minimum floor to 'ceiling' height that will still allow the floor area to
  63421. * be considered walkable. [Limit: >= 3] [Units: vx]
  63422. */
  63423. walkableHeight: number;
  63424. /**
  63425. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  63426. */
  63427. walkableClimb: number;
  63428. /**
  63429. * The distance to erode/shrink the walkable area of the heightfield away from
  63430. * obstructions. [Limit: >=0] [Units: vx]
  63431. */
  63432. walkableRadius: number;
  63433. /**
  63434. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  63435. */
  63436. maxEdgeLen: number;
  63437. /**
  63438. * The maximum distance a simplfied contour's border edges should deviate
  63439. * the original raw contour. [Limit: >=0] [Units: vx]
  63440. */
  63441. maxSimplificationError: number;
  63442. /**
  63443. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  63444. */
  63445. minRegionArea: number;
  63446. /**
  63447. * Any regions with a span count smaller than this value will, if possible,
  63448. * be merged with larger regions. [Limit: >=0] [Units: vx]
  63449. */
  63450. mergeRegionArea: number;
  63451. /**
  63452. * The maximum number of vertices allowed for polygons generated during the
  63453. * contour to polygon conversion process. [Limit: >= 3]
  63454. */
  63455. maxVertsPerPoly: number;
  63456. /**
  63457. * Sets the sampling distance to use when generating the detail mesh.
  63458. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  63459. */
  63460. detailSampleDist: number;
  63461. /**
  63462. * The maximum distance the detail mesh surface should deviate from heightfield
  63463. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  63464. */
  63465. detailSampleMaxError: number;
  63466. }
  63467. }
  63468. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  63469. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  63470. import { Mesh } from "babylonjs/Meshes/mesh";
  63471. import { Scene } from "babylonjs/scene";
  63472. import { Vector3 } from "babylonjs/Maths/math";
  63473. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63474. /**
  63475. * RecastJS navigation plugin
  63476. */
  63477. export class RecastJSPlugin implements INavigationEnginePlugin {
  63478. /**
  63479. * Reference to the Recast library
  63480. */
  63481. bjsRECAST: any;
  63482. /**
  63483. * plugin name
  63484. */
  63485. name: string;
  63486. /**
  63487. * the first navmesh created. We might extend this to support multiple navmeshes
  63488. */
  63489. navMesh: any;
  63490. /**
  63491. * Initializes the recastJS plugin
  63492. * @param recastInjection can be used to inject your own recast reference
  63493. */
  63494. constructor(recastInjection?: any);
  63495. /**
  63496. * Creates a navigation mesh
  63497. * @param meshes array of all the geometry used to compute the navigatio mesh
  63498. * @param parameters bunch of parameters used to filter geometry
  63499. */
  63500. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  63501. /**
  63502. * Create a navigation mesh debug mesh
  63503. * @param scene is where the mesh will be added
  63504. * @returns debug display mesh
  63505. */
  63506. createDebugNavMesh(scene: Scene): Mesh;
  63507. /**
  63508. * Get a navigation mesh constrained position, closest to the parameter position
  63509. * @param position world position
  63510. * @returns the closest point to position constrained by the navigation mesh
  63511. */
  63512. getClosestPoint(position: Vector3): Vector3;
  63513. /**
  63514. * Get a navigation mesh constrained position, within a particular radius
  63515. * @param position world position
  63516. * @param maxRadius the maximum distance to the constrained world position
  63517. * @returns the closest point to position constrained by the navigation mesh
  63518. */
  63519. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  63520. /**
  63521. * Compute the final position from a segment made of destination-position
  63522. * @param position world position
  63523. * @param destination world position
  63524. * @returns the resulting point along the navmesh
  63525. */
  63526. moveAlong(position: Vector3, destination: Vector3): Vector3;
  63527. /**
  63528. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  63529. * @param start world position
  63530. * @param end world position
  63531. * @returns array containing world position composing the path
  63532. */
  63533. computePath(start: Vector3, end: Vector3): Vector3[];
  63534. /**
  63535. * Create a new Crowd so you can add agents
  63536. * @param maxAgents the maximum agent count in the crowd
  63537. * @param maxAgentRadius the maximum radius an agent can have
  63538. * @param scene to attach the crowd to
  63539. * @returns the crowd you can add agents to
  63540. */
  63541. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  63542. /**
  63543. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63544. * The queries will try to find a solution within those bounds
  63545. * default is (1,1,1)
  63546. * @param extent x,y,z value that define the extent around the queries point of reference
  63547. */
  63548. setDefaultQueryExtent(extent: Vector3): void;
  63549. /**
  63550. * Get the Bounding box extent specified by setDefaultQueryExtent
  63551. * @returns the box extent values
  63552. */
  63553. getDefaultQueryExtent(): Vector3;
  63554. /**
  63555. * Disposes
  63556. */
  63557. dispose(): void;
  63558. /**
  63559. * If this plugin is supported
  63560. * @returns true if plugin is supported
  63561. */
  63562. isSupported(): boolean;
  63563. }
  63564. /**
  63565. * Recast detour crowd implementation
  63566. */
  63567. export class RecastJSCrowd implements ICrowd {
  63568. /**
  63569. * Recast/detour plugin
  63570. */
  63571. bjsRECASTPlugin: RecastJSPlugin;
  63572. /**
  63573. * Link to the detour crowd
  63574. */
  63575. recastCrowd: any;
  63576. /**
  63577. * One transform per agent
  63578. */
  63579. transforms: TransformNode[];
  63580. /**
  63581. * All agents created
  63582. */
  63583. agents: number[];
  63584. /**
  63585. * Link to the scene is kept to unregister the crowd from the scene
  63586. */
  63587. private _scene;
  63588. /**
  63589. * Observer for crowd updates
  63590. */
  63591. private _onBeforeAnimationsObserver;
  63592. /**
  63593. * Constructor
  63594. * @param plugin recastJS plugin
  63595. * @param maxAgents the maximum agent count in the crowd
  63596. * @param maxAgentRadius the maximum radius an agent can have
  63597. * @param scene to attach the crowd to
  63598. * @returns the crowd you can add agents to
  63599. */
  63600. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  63601. /**
  63602. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  63603. * You can attach anything to that node. The node position is updated in the scene update tick.
  63604. * @param pos world position that will be constrained by the navigation mesh
  63605. * @param parameters agent parameters
  63606. * @param transform hooked to the agent that will be update by the scene
  63607. * @returns agent index
  63608. */
  63609. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  63610. /**
  63611. * Returns the agent position in world space
  63612. * @param index agent index returned by addAgent
  63613. * @returns world space position
  63614. */
  63615. getAgentPosition(index: number): Vector3;
  63616. /**
  63617. * Returns the agent velocity in world space
  63618. * @param index agent index returned by addAgent
  63619. * @returns world space velocity
  63620. */
  63621. getAgentVelocity(index: number): Vector3;
  63622. /**
  63623. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  63624. * @param index agent index returned by addAgent
  63625. * @param destination targeted world position
  63626. */
  63627. agentGoto(index: number, destination: Vector3): void;
  63628. /**
  63629. * remove a particular agent previously created
  63630. * @param index agent index returned by addAgent
  63631. */
  63632. removeAgent(index: number): void;
  63633. /**
  63634. * get the list of all agents attached to this crowd
  63635. * @returns list of agent indices
  63636. */
  63637. getAgents(): number[];
  63638. /**
  63639. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  63640. * @param deltaTime in seconds
  63641. */
  63642. update(deltaTime: number): void;
  63643. /**
  63644. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63645. * The queries will try to find a solution within those bounds
  63646. * default is (1,1,1)
  63647. * @param extent x,y,z value that define the extent around the queries point of reference
  63648. */
  63649. setDefaultQueryExtent(extent: Vector3): void;
  63650. /**
  63651. * Get the Bounding box extent specified by setDefaultQueryExtent
  63652. * @returns the box extent values
  63653. */
  63654. getDefaultQueryExtent(): Vector3;
  63655. /**
  63656. * Release all resources
  63657. */
  63658. dispose(): void;
  63659. }
  63660. }
  63661. declare module "babylonjs/Navigation/Plugins/index" {
  63662. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  63663. }
  63664. declare module "babylonjs/Navigation/index" {
  63665. export * from "babylonjs/Navigation/INavigationEngine";
  63666. export * from "babylonjs/Navigation/Plugins/index";
  63667. }
  63668. declare module "babylonjs/Offline/database" {
  63669. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  63670. /**
  63671. * Class used to enable access to IndexedDB
  63672. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63673. */
  63674. export class Database implements IOfflineProvider {
  63675. private _callbackManifestChecked;
  63676. private _currentSceneUrl;
  63677. private _db;
  63678. private _enableSceneOffline;
  63679. private _enableTexturesOffline;
  63680. private _manifestVersionFound;
  63681. private _mustUpdateRessources;
  63682. private _hasReachedQuota;
  63683. private _isSupported;
  63684. private _idbFactory;
  63685. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  63686. private static IsUASupportingBlobStorage;
  63687. /**
  63688. * Gets a boolean indicating if Database storate is enabled (off by default)
  63689. */
  63690. static IDBStorageEnabled: boolean;
  63691. /**
  63692. * Gets a boolean indicating if scene must be saved in the database
  63693. */
  63694. get enableSceneOffline(): boolean;
  63695. /**
  63696. * Gets a boolean indicating if textures must be saved in the database
  63697. */
  63698. get enableTexturesOffline(): boolean;
  63699. /**
  63700. * Creates a new Database
  63701. * @param urlToScene defines the url to load the scene
  63702. * @param callbackManifestChecked defines the callback to use when manifest is checked
  63703. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  63704. */
  63705. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  63706. private static _ParseURL;
  63707. private static _ReturnFullUrlLocation;
  63708. private _checkManifestFile;
  63709. /**
  63710. * Open the database and make it available
  63711. * @param successCallback defines the callback to call on success
  63712. * @param errorCallback defines the callback to call on error
  63713. */
  63714. open(successCallback: () => void, errorCallback: () => void): void;
  63715. /**
  63716. * Loads an image from the database
  63717. * @param url defines the url to load from
  63718. * @param image defines the target DOM image
  63719. */
  63720. loadImage(url: string, image: HTMLImageElement): void;
  63721. private _loadImageFromDBAsync;
  63722. private _saveImageIntoDBAsync;
  63723. private _checkVersionFromDB;
  63724. private _loadVersionFromDBAsync;
  63725. private _saveVersionIntoDBAsync;
  63726. /**
  63727. * Loads a file from database
  63728. * @param url defines the URL to load from
  63729. * @param sceneLoaded defines a callback to call on success
  63730. * @param progressCallBack defines a callback to call when progress changed
  63731. * @param errorCallback defines a callback to call on error
  63732. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63733. */
  63734. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63735. private _loadFileAsync;
  63736. private _saveFileAsync;
  63737. /**
  63738. * Validates if xhr data is correct
  63739. * @param xhr defines the request to validate
  63740. * @param dataType defines the expected data type
  63741. * @returns true if data is correct
  63742. */
  63743. private static _ValidateXHRData;
  63744. }
  63745. }
  63746. declare module "babylonjs/Offline/index" {
  63747. export * from "babylonjs/Offline/database";
  63748. export * from "babylonjs/Offline/IOfflineProvider";
  63749. }
  63750. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  63751. /** @hidden */
  63752. export var gpuUpdateParticlesPixelShader: {
  63753. name: string;
  63754. shader: string;
  63755. };
  63756. }
  63757. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  63758. /** @hidden */
  63759. export var gpuUpdateParticlesVertexShader: {
  63760. name: string;
  63761. shader: string;
  63762. };
  63763. }
  63764. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  63765. /** @hidden */
  63766. export var clipPlaneFragmentDeclaration2: {
  63767. name: string;
  63768. shader: string;
  63769. };
  63770. }
  63771. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  63772. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  63773. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  63774. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63775. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  63776. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  63777. /** @hidden */
  63778. export var gpuRenderParticlesPixelShader: {
  63779. name: string;
  63780. shader: string;
  63781. };
  63782. }
  63783. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  63784. /** @hidden */
  63785. export var clipPlaneVertexDeclaration2: {
  63786. name: string;
  63787. shader: string;
  63788. };
  63789. }
  63790. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  63791. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  63792. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  63793. /** @hidden */
  63794. export var gpuRenderParticlesVertexShader: {
  63795. name: string;
  63796. shader: string;
  63797. };
  63798. }
  63799. declare module "babylonjs/Particles/gpuParticleSystem" {
  63800. import { Nullable } from "babylonjs/types";
  63801. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  63802. import { Observable } from "babylonjs/Misc/observable";
  63803. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  63804. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  63805. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  63806. import { Scene, IDisposable } from "babylonjs/scene";
  63807. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  63808. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63809. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  63810. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  63811. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  63812. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  63813. /**
  63814. * This represents a GPU particle system in Babylon
  63815. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  63816. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  63817. */
  63818. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  63819. /**
  63820. * The layer mask we are rendering the particles through.
  63821. */
  63822. layerMask: number;
  63823. private _capacity;
  63824. private _activeCount;
  63825. private _currentActiveCount;
  63826. private _accumulatedCount;
  63827. private _renderEffect;
  63828. private _updateEffect;
  63829. private _buffer0;
  63830. private _buffer1;
  63831. private _spriteBuffer;
  63832. private _updateVAO;
  63833. private _renderVAO;
  63834. private _targetIndex;
  63835. private _sourceBuffer;
  63836. private _targetBuffer;
  63837. private _engine;
  63838. private _currentRenderId;
  63839. private _started;
  63840. private _stopped;
  63841. private _timeDelta;
  63842. private _randomTexture;
  63843. private _randomTexture2;
  63844. private _attributesStrideSize;
  63845. private _updateEffectOptions;
  63846. private _randomTextureSize;
  63847. private _actualFrame;
  63848. private readonly _rawTextureWidth;
  63849. /**
  63850. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  63851. */
  63852. static get IsSupported(): boolean;
  63853. /**
  63854. * An event triggered when the system is disposed.
  63855. */
  63856. onDisposeObservable: Observable<GPUParticleSystem>;
  63857. /**
  63858. * Gets the maximum number of particles active at the same time.
  63859. * @returns The max number of active particles.
  63860. */
  63861. getCapacity(): number;
  63862. /**
  63863. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  63864. * to override the particles.
  63865. */
  63866. forceDepthWrite: boolean;
  63867. /**
  63868. * Gets or set the number of active particles
  63869. */
  63870. get activeParticleCount(): number;
  63871. set activeParticleCount(value: number);
  63872. private _preWarmDone;
  63873. /**
  63874. * Is this system ready to be used/rendered
  63875. * @return true if the system is ready
  63876. */
  63877. isReady(): boolean;
  63878. /**
  63879. * Gets if the system has been started. (Note: this will still be true after stop is called)
  63880. * @returns True if it has been started, otherwise false.
  63881. */
  63882. isStarted(): boolean;
  63883. /**
  63884. * Starts the particle system and begins to emit
  63885. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  63886. */
  63887. start(delay?: number): void;
  63888. /**
  63889. * Stops the particle system.
  63890. */
  63891. stop(): void;
  63892. /**
  63893. * Remove all active particles
  63894. */
  63895. reset(): void;
  63896. /**
  63897. * Returns the string "GPUParticleSystem"
  63898. * @returns a string containing the class name
  63899. */
  63900. getClassName(): string;
  63901. private _colorGradientsTexture;
  63902. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  63903. /**
  63904. * Adds a new color gradient
  63905. * @param gradient defines the gradient to use (between 0 and 1)
  63906. * @param color1 defines the color to affect to the specified gradient
  63907. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  63908. * @returns the current particle system
  63909. */
  63910. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  63911. /**
  63912. * Remove a specific color gradient
  63913. * @param gradient defines the gradient to remove
  63914. * @returns the current particle system
  63915. */
  63916. removeColorGradient(gradient: number): GPUParticleSystem;
  63917. private _angularSpeedGradientsTexture;
  63918. private _sizeGradientsTexture;
  63919. private _velocityGradientsTexture;
  63920. private _limitVelocityGradientsTexture;
  63921. private _dragGradientsTexture;
  63922. private _addFactorGradient;
  63923. /**
  63924. * Adds a new size gradient
  63925. * @param gradient defines the gradient to use (between 0 and 1)
  63926. * @param factor defines the size factor to affect to the specified gradient
  63927. * @returns the current particle system
  63928. */
  63929. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  63930. /**
  63931. * Remove a specific size gradient
  63932. * @param gradient defines the gradient to remove
  63933. * @returns the current particle system
  63934. */
  63935. removeSizeGradient(gradient: number): GPUParticleSystem;
  63936. /**
  63937. * Adds a new angular speed gradient
  63938. * @param gradient defines the gradient to use (between 0 and 1)
  63939. * @param factor defines the angular speed to affect to the specified gradient
  63940. * @returns the current particle system
  63941. */
  63942. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  63943. /**
  63944. * Remove a specific angular speed gradient
  63945. * @param gradient defines the gradient to remove
  63946. * @returns the current particle system
  63947. */
  63948. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  63949. /**
  63950. * Adds a new velocity gradient
  63951. * @param gradient defines the gradient to use (between 0 and 1)
  63952. * @param factor defines the velocity to affect to the specified gradient
  63953. * @returns the current particle system
  63954. */
  63955. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63956. /**
  63957. * Remove a specific velocity gradient
  63958. * @param gradient defines the gradient to remove
  63959. * @returns the current particle system
  63960. */
  63961. removeVelocityGradient(gradient: number): GPUParticleSystem;
  63962. /**
  63963. * Adds a new limit velocity gradient
  63964. * @param gradient defines the gradient to use (between 0 and 1)
  63965. * @param factor defines the limit velocity value to affect to the specified gradient
  63966. * @returns the current particle system
  63967. */
  63968. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63969. /**
  63970. * Remove a specific limit velocity gradient
  63971. * @param gradient defines the gradient to remove
  63972. * @returns the current particle system
  63973. */
  63974. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  63975. /**
  63976. * Adds a new drag gradient
  63977. * @param gradient defines the gradient to use (between 0 and 1)
  63978. * @param factor defines the drag value to affect to the specified gradient
  63979. * @returns the current particle system
  63980. */
  63981. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  63982. /**
  63983. * Remove a specific drag gradient
  63984. * @param gradient defines the gradient to remove
  63985. * @returns the current particle system
  63986. */
  63987. removeDragGradient(gradient: number): GPUParticleSystem;
  63988. /**
  63989. * Not supported by GPUParticleSystem
  63990. * @param gradient defines the gradient to use (between 0 and 1)
  63991. * @param factor defines the emit rate value to affect to the specified gradient
  63992. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63993. * @returns the current particle system
  63994. */
  63995. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63996. /**
  63997. * Not supported by GPUParticleSystem
  63998. * @param gradient defines the gradient to remove
  63999. * @returns the current particle system
  64000. */
  64001. removeEmitRateGradient(gradient: number): IParticleSystem;
  64002. /**
  64003. * Not supported by GPUParticleSystem
  64004. * @param gradient defines the gradient to use (between 0 and 1)
  64005. * @param factor defines the start size value to affect to the specified gradient
  64006. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64007. * @returns the current particle system
  64008. */
  64009. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64010. /**
  64011. * Not supported by GPUParticleSystem
  64012. * @param gradient defines the gradient to remove
  64013. * @returns the current particle system
  64014. */
  64015. removeStartSizeGradient(gradient: number): IParticleSystem;
  64016. /**
  64017. * Not supported by GPUParticleSystem
  64018. * @param gradient defines the gradient to use (between 0 and 1)
  64019. * @param min defines the color remap minimal range
  64020. * @param max defines the color remap maximal range
  64021. * @returns the current particle system
  64022. */
  64023. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  64024. /**
  64025. * Not supported by GPUParticleSystem
  64026. * @param gradient defines the gradient to remove
  64027. * @returns the current particle system
  64028. */
  64029. removeColorRemapGradient(): IParticleSystem;
  64030. /**
  64031. * Not supported by GPUParticleSystem
  64032. * @param gradient defines the gradient to use (between 0 and 1)
  64033. * @param min defines the alpha remap minimal range
  64034. * @param max defines the alpha remap maximal range
  64035. * @returns the current particle system
  64036. */
  64037. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  64038. /**
  64039. * Not supported by GPUParticleSystem
  64040. * @param gradient defines the gradient to remove
  64041. * @returns the current particle system
  64042. */
  64043. removeAlphaRemapGradient(): IParticleSystem;
  64044. /**
  64045. * Not supported by GPUParticleSystem
  64046. * @param gradient defines the gradient to use (between 0 and 1)
  64047. * @param color defines the color to affect to the specified gradient
  64048. * @returns the current particle system
  64049. */
  64050. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  64051. /**
  64052. * Not supported by GPUParticleSystem
  64053. * @param gradient defines the gradient to remove
  64054. * @returns the current particle system
  64055. */
  64056. removeRampGradient(): IParticleSystem;
  64057. /**
  64058. * Not supported by GPUParticleSystem
  64059. * @returns the list of ramp gradients
  64060. */
  64061. getRampGradients(): Nullable<Array<Color3Gradient>>;
  64062. /**
  64063. * Not supported by GPUParticleSystem
  64064. * Gets or sets a boolean indicating that ramp gradients must be used
  64065. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  64066. */
  64067. get useRampGradients(): boolean;
  64068. set useRampGradients(value: boolean);
  64069. /**
  64070. * Not supported by GPUParticleSystem
  64071. * @param gradient defines the gradient to use (between 0 and 1)
  64072. * @param factor defines the life time factor to affect to the specified gradient
  64073. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64074. * @returns the current particle system
  64075. */
  64076. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64077. /**
  64078. * Not supported by GPUParticleSystem
  64079. * @param gradient defines the gradient to remove
  64080. * @returns the current particle system
  64081. */
  64082. removeLifeTimeGradient(gradient: number): IParticleSystem;
  64083. /**
  64084. * Instantiates a GPU particle system.
  64085. * 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.
  64086. * @param name The name of the particle system
  64087. * @param options The options used to create the system
  64088. * @param scene The scene the particle system belongs to
  64089. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  64090. */
  64091. constructor(name: string, options: Partial<{
  64092. capacity: number;
  64093. randomTextureSize: number;
  64094. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  64095. protected _reset(): void;
  64096. private _createUpdateVAO;
  64097. private _createRenderVAO;
  64098. private _initialize;
  64099. /** @hidden */
  64100. _recreateUpdateEffect(): void;
  64101. /** @hidden */
  64102. _recreateRenderEffect(): void;
  64103. /**
  64104. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  64105. * @param preWarm defines if we are in the pre-warmimg phase
  64106. */
  64107. animate(preWarm?: boolean): void;
  64108. private _createFactorGradientTexture;
  64109. private _createSizeGradientTexture;
  64110. private _createAngularSpeedGradientTexture;
  64111. private _createVelocityGradientTexture;
  64112. private _createLimitVelocityGradientTexture;
  64113. private _createDragGradientTexture;
  64114. private _createColorGradientTexture;
  64115. /**
  64116. * Renders the particle system in its current state
  64117. * @param preWarm defines if the system should only update the particles but not render them
  64118. * @returns the current number of particles
  64119. */
  64120. render(preWarm?: boolean): number;
  64121. /**
  64122. * Rebuilds the particle system
  64123. */
  64124. rebuild(): void;
  64125. private _releaseBuffers;
  64126. private _releaseVAOs;
  64127. /**
  64128. * Disposes the particle system and free the associated resources
  64129. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  64130. */
  64131. dispose(disposeTexture?: boolean): void;
  64132. /**
  64133. * Clones the particle system.
  64134. * @param name The name of the cloned object
  64135. * @param newEmitter The new emitter to use
  64136. * @returns the cloned particle system
  64137. */
  64138. clone(name: string, newEmitter: any): GPUParticleSystem;
  64139. /**
  64140. * Serializes the particle system to a JSON object.
  64141. * @returns the JSON object
  64142. */
  64143. serialize(): any;
  64144. /**
  64145. * Parses a JSON object to create a GPU particle system.
  64146. * @param parsedParticleSystem The JSON object to parse
  64147. * @param scene The scene to create the particle system in
  64148. * @param rootUrl The root url to use to load external dependencies like texture
  64149. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  64150. * @returns the parsed GPU particle system
  64151. */
  64152. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  64153. }
  64154. }
  64155. declare module "babylonjs/Particles/particleSystemSet" {
  64156. import { Nullable } from "babylonjs/types";
  64157. import { Color3 } from "babylonjs/Maths/math.color";
  64158. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64160. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64161. import { Scene, IDisposable } from "babylonjs/scene";
  64162. /**
  64163. * Represents a set of particle systems working together to create a specific effect
  64164. */
  64165. export class ParticleSystemSet implements IDisposable {
  64166. /**
  64167. * Gets or sets base Assets URL
  64168. */
  64169. static BaseAssetsUrl: string;
  64170. private _emitterCreationOptions;
  64171. private _emitterNode;
  64172. /**
  64173. * Gets the particle system list
  64174. */
  64175. systems: IParticleSystem[];
  64176. /**
  64177. * Gets the emitter node used with this set
  64178. */
  64179. get emitterNode(): Nullable<TransformNode>;
  64180. /**
  64181. * Creates a new emitter mesh as a sphere
  64182. * @param options defines the options used to create the sphere
  64183. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  64184. * @param scene defines the hosting scene
  64185. */
  64186. setEmitterAsSphere(options: {
  64187. diameter: number;
  64188. segments: number;
  64189. color: Color3;
  64190. }, renderingGroupId: number, scene: Scene): void;
  64191. /**
  64192. * Starts all particle systems of the set
  64193. * @param emitter defines an optional mesh to use as emitter for the particle systems
  64194. */
  64195. start(emitter?: AbstractMesh): void;
  64196. /**
  64197. * Release all associated resources
  64198. */
  64199. dispose(): void;
  64200. /**
  64201. * Serialize the set into a JSON compatible object
  64202. * @returns a JSON compatible representation of the set
  64203. */
  64204. serialize(): any;
  64205. /**
  64206. * Parse a new ParticleSystemSet from a serialized source
  64207. * @param data defines a JSON compatible representation of the set
  64208. * @param scene defines the hosting scene
  64209. * @param gpu defines if we want GPU particles or CPU particles
  64210. * @returns a new ParticleSystemSet
  64211. */
  64212. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  64213. }
  64214. }
  64215. declare module "babylonjs/Particles/particleHelper" {
  64216. import { Nullable } from "babylonjs/types";
  64217. import { Scene } from "babylonjs/scene";
  64218. import { Vector3 } from "babylonjs/Maths/math.vector";
  64219. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64220. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64221. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  64222. /**
  64223. * This class is made for on one-liner static method to help creating particle system set.
  64224. */
  64225. export class ParticleHelper {
  64226. /**
  64227. * Gets or sets base Assets URL
  64228. */
  64229. static BaseAssetsUrl: string;
  64230. /**
  64231. * Create a default particle system that you can tweak
  64232. * @param emitter defines the emitter to use
  64233. * @param capacity defines the system capacity (default is 500 particles)
  64234. * @param scene defines the hosting scene
  64235. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  64236. * @returns the new Particle system
  64237. */
  64238. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  64239. /**
  64240. * This is the main static method (one-liner) of this helper to create different particle systems
  64241. * @param type This string represents the type to the particle system to create
  64242. * @param scene The scene where the particle system should live
  64243. * @param gpu If the system will use gpu
  64244. * @returns the ParticleSystemSet created
  64245. */
  64246. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  64247. /**
  64248. * Static function used to export a particle system to a ParticleSystemSet variable.
  64249. * Please note that the emitter shape is not exported
  64250. * @param systems defines the particle systems to export
  64251. * @returns the created particle system set
  64252. */
  64253. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  64254. }
  64255. }
  64256. declare module "babylonjs/Particles/particleSystemComponent" {
  64257. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64258. import { Effect } from "babylonjs/Materials/effect";
  64259. import "babylonjs/Shaders/particles.vertex";
  64260. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  64261. module "babylonjs/Engines/engine" {
  64262. interface Engine {
  64263. /**
  64264. * Create an effect to use with particle systems.
  64265. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  64266. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  64267. * @param uniformsNames defines a list of attribute names
  64268. * @param samplers defines an array of string used to represent textures
  64269. * @param defines defines the string containing the defines to use to compile the shaders
  64270. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  64271. * @param onCompiled defines a function to call when the effect creation is successful
  64272. * @param onError defines a function to call when the effect creation has failed
  64273. * @returns the new Effect
  64274. */
  64275. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  64276. }
  64277. }
  64278. module "babylonjs/Meshes/mesh" {
  64279. interface Mesh {
  64280. /**
  64281. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  64282. * @returns an array of IParticleSystem
  64283. */
  64284. getEmittedParticleSystems(): IParticleSystem[];
  64285. /**
  64286. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  64287. * @returns an array of IParticleSystem
  64288. */
  64289. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  64290. }
  64291. }
  64292. /**
  64293. * @hidden
  64294. */
  64295. export var _IDoNeedToBeInTheBuild: number;
  64296. }
  64297. declare module "babylonjs/Particles/pointsCloudSystem" {
  64298. import { Color4 } from "babylonjs/Maths/math";
  64299. import { Mesh } from "babylonjs/Meshes/mesh";
  64300. import { Scene, IDisposable } from "babylonjs/scene";
  64301. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  64302. /** Defines the 4 color options */
  64303. export enum PointColor {
  64304. /** color value */
  64305. Color = 2,
  64306. /** uv value */
  64307. UV = 1,
  64308. /** random value */
  64309. Random = 0,
  64310. /** stated value */
  64311. Stated = 3
  64312. }
  64313. /**
  64314. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  64315. * 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.
  64316. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  64317. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  64318. *
  64319. * Full documentation here : TO BE ENTERED
  64320. */
  64321. export class PointsCloudSystem implements IDisposable {
  64322. /**
  64323. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  64324. * Example : var p = SPS.particles[i];
  64325. */
  64326. particles: CloudPoint[];
  64327. /**
  64328. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  64329. */
  64330. nbParticles: number;
  64331. /**
  64332. * This a counter for your own usage. It's not set by any SPS functions.
  64333. */
  64334. counter: number;
  64335. /**
  64336. * The PCS name. This name is also given to the underlying mesh.
  64337. */
  64338. name: string;
  64339. /**
  64340. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  64341. */
  64342. mesh: Mesh;
  64343. /**
  64344. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  64345. * Please read :
  64346. */
  64347. vars: any;
  64348. /**
  64349. * @hidden
  64350. */
  64351. _size: number;
  64352. private _scene;
  64353. private _promises;
  64354. private _positions;
  64355. private _indices;
  64356. private _normals;
  64357. private _colors;
  64358. private _uvs;
  64359. private _indices32;
  64360. private _positions32;
  64361. private _colors32;
  64362. private _uvs32;
  64363. private _updatable;
  64364. private _isVisibilityBoxLocked;
  64365. private _alwaysVisible;
  64366. private _groups;
  64367. private _groupCounter;
  64368. private _computeParticleColor;
  64369. private _computeParticleTexture;
  64370. private _computeParticleRotation;
  64371. private _computeBoundingBox;
  64372. private _isReady;
  64373. /**
  64374. * Creates a PCS (Points Cloud System) object
  64375. * @param name (String) is the PCS name, this will be the underlying mesh name
  64376. * @param pointSize (number) is the size for each point
  64377. * @param scene (Scene) is the scene in which the PCS is added
  64378. * @param options defines the options of the PCS e.g.
  64379. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  64380. */
  64381. constructor(name: string, pointSize: number, scene: Scene, options?: {
  64382. updatable?: boolean;
  64383. });
  64384. /**
  64385. * Builds the PCS underlying mesh. Returns a standard Mesh.
  64386. * If no points were added to the PCS, the returned mesh is just a single point.
  64387. * @returns a promise for the created mesh
  64388. */
  64389. buildMeshAsync(): Promise<Mesh>;
  64390. /**
  64391. * @hidden
  64392. */
  64393. private _buildMesh;
  64394. private _addParticle;
  64395. private _randomUnitVector;
  64396. private _getColorIndicesForCoord;
  64397. private _setPointsColorOrUV;
  64398. private _colorFromTexture;
  64399. private _calculateDensity;
  64400. /**
  64401. * Adds points to the PCS in random positions within a unit sphere
  64402. * @param nb (positive integer) the number of particles to be created from this model
  64403. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  64404. * @returns the number of groups in the system
  64405. */
  64406. addPoints(nb: number, pointFunction?: any): number;
  64407. /**
  64408. * Adds points to the PCS from the surface of the model shape
  64409. * @param mesh is any Mesh object that will be used as a surface model for the points
  64410. * @param nb (positive integer) the number of particles to be created from this model
  64411. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  64412. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  64413. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  64414. * @returns the number of groups in the system
  64415. */
  64416. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  64417. /**
  64418. * Adds points to the PCS inside the model shape
  64419. * @param mesh is any Mesh object that will be used as a surface model for the points
  64420. * @param nb (positive integer) the number of particles to be created from this model
  64421. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  64422. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  64423. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  64424. * @returns the number of groups in the system
  64425. */
  64426. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  64427. /**
  64428. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  64429. * This method calls `updateParticle()` for each particle of the SPS.
  64430. * For an animated SPS, it is usually called within the render loop.
  64431. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  64432. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  64433. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  64434. * @returns the PCS.
  64435. */
  64436. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  64437. /**
  64438. * Disposes the PCS.
  64439. */
  64440. dispose(): void;
  64441. /**
  64442. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  64443. * doc :
  64444. * @returns the PCS.
  64445. */
  64446. refreshVisibleSize(): PointsCloudSystem;
  64447. /**
  64448. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  64449. * @param size the size (float) of the visibility box
  64450. * note : this doesn't lock the PCS mesh bounding box.
  64451. * doc :
  64452. */
  64453. setVisibilityBox(size: number): void;
  64454. /**
  64455. * Gets whether the PCS is always visible or not
  64456. * doc :
  64457. */
  64458. get isAlwaysVisible(): boolean;
  64459. /**
  64460. * Sets the PCS as always visible or not
  64461. * doc :
  64462. */
  64463. set isAlwaysVisible(val: boolean);
  64464. /**
  64465. * Tells to `setParticles()` to compute the particle rotations or not
  64466. * Default value : false. The PCS is faster when it's set to false
  64467. * Note : particle rotations are only applied to parent particles
  64468. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  64469. */
  64470. set computeParticleRotation(val: boolean);
  64471. /**
  64472. * Tells to `setParticles()` to compute the particle colors or not.
  64473. * Default value : true. The PCS is faster when it's set to false.
  64474. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  64475. */
  64476. set computeParticleColor(val: boolean);
  64477. set computeParticleTexture(val: boolean);
  64478. /**
  64479. * Gets if `setParticles()` computes the particle colors or not.
  64480. * Default value : false. The PCS is faster when it's set to false.
  64481. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  64482. */
  64483. get computeParticleColor(): boolean;
  64484. /**
  64485. * Gets if `setParticles()` computes the particle textures or not.
  64486. * Default value : false. The PCS is faster when it's set to false.
  64487. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  64488. */
  64489. get computeParticleTexture(): boolean;
  64490. /**
  64491. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  64492. */
  64493. set computeBoundingBox(val: boolean);
  64494. /**
  64495. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  64496. */
  64497. get computeBoundingBox(): boolean;
  64498. /**
  64499. * This function does nothing. It may be overwritten to set all the particle first values.
  64500. * The PCS doesn't call this function, you may have to call it by your own.
  64501. * doc :
  64502. */
  64503. initParticles(): void;
  64504. /**
  64505. * This function does nothing. It may be overwritten to recycle a particle
  64506. * The PCS doesn't call this function, you can to call it
  64507. * doc :
  64508. * @param particle The particle to recycle
  64509. * @returns the recycled particle
  64510. */
  64511. recycleParticle(particle: CloudPoint): CloudPoint;
  64512. /**
  64513. * Updates a particle : this function should be overwritten by the user.
  64514. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  64515. * doc :
  64516. * @example : just set a particle position or velocity and recycle conditions
  64517. * @param particle The particle to update
  64518. * @returns the updated particle
  64519. */
  64520. updateParticle(particle: CloudPoint): CloudPoint;
  64521. /**
  64522. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  64523. * This does nothing and may be overwritten by the user.
  64524. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  64525. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  64526. * @param update the boolean update value actually passed to setParticles()
  64527. */
  64528. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  64529. /**
  64530. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  64531. * This will be passed three parameters.
  64532. * This does nothing and may be overwritten by the user.
  64533. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  64534. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  64535. * @param update the boolean update value actually passed to setParticles()
  64536. */
  64537. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  64538. }
  64539. }
  64540. declare module "babylonjs/Particles/cloudPoint" {
  64541. import { Nullable } from "babylonjs/types";
  64542. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  64543. import { Mesh } from "babylonjs/Meshes/mesh";
  64544. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  64545. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  64546. /**
  64547. * Represents one particle of a points cloud system.
  64548. */
  64549. export class CloudPoint {
  64550. /**
  64551. * particle global index
  64552. */
  64553. idx: number;
  64554. /**
  64555. * The color of the particle
  64556. */
  64557. color: Nullable<Color4>;
  64558. /**
  64559. * The world space position of the particle.
  64560. */
  64561. position: Vector3;
  64562. /**
  64563. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  64564. */
  64565. rotation: Vector3;
  64566. /**
  64567. * The world space rotation quaternion of the particle.
  64568. */
  64569. rotationQuaternion: Nullable<Quaternion>;
  64570. /**
  64571. * The uv of the particle.
  64572. */
  64573. uv: Nullable<Vector2>;
  64574. /**
  64575. * The current speed of the particle.
  64576. */
  64577. velocity: Vector3;
  64578. /**
  64579. * The pivot point in the particle local space.
  64580. */
  64581. pivot: Vector3;
  64582. /**
  64583. * Must the particle be translated from its pivot point in its local space ?
  64584. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  64585. * Default : false
  64586. */
  64587. translateFromPivot: boolean;
  64588. /**
  64589. * Index of this particle in the global "positions" array (Internal use)
  64590. * @hidden
  64591. */
  64592. _pos: number;
  64593. /**
  64594. * @hidden Index of this particle in the global "indices" array (Internal use)
  64595. */
  64596. _ind: number;
  64597. /**
  64598. * Group this particle belongs to
  64599. */
  64600. _group: PointsGroup;
  64601. /**
  64602. * Group id of this particle
  64603. */
  64604. groupId: number;
  64605. /**
  64606. * Index of the particle in its group id (Internal use)
  64607. */
  64608. idxInGroup: number;
  64609. /**
  64610. * @hidden Particle BoundingInfo object (Internal use)
  64611. */
  64612. _boundingInfo: BoundingInfo;
  64613. /**
  64614. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  64615. */
  64616. _pcs: PointsCloudSystem;
  64617. /**
  64618. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  64619. */
  64620. _stillInvisible: boolean;
  64621. /**
  64622. * @hidden Last computed particle rotation matrix
  64623. */
  64624. _rotationMatrix: number[];
  64625. /**
  64626. * Parent particle Id, if any.
  64627. * Default null.
  64628. */
  64629. parentId: Nullable<number>;
  64630. /**
  64631. * @hidden Internal global position in the PCS.
  64632. */
  64633. _globalPosition: Vector3;
  64634. /**
  64635. * Creates a Point Cloud object.
  64636. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  64637. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  64638. * @param group (PointsGroup) is the group the particle belongs to
  64639. * @param groupId (integer) is the group identifier in the PCS.
  64640. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  64641. * @param pcs defines the PCS it is associated to
  64642. */
  64643. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  64644. /**
  64645. * get point size
  64646. */
  64647. get size(): Vector3;
  64648. /**
  64649. * Set point size
  64650. */
  64651. set size(scale: Vector3);
  64652. /**
  64653. * Legacy support, changed quaternion to rotationQuaternion
  64654. */
  64655. get quaternion(): Nullable<Quaternion>;
  64656. /**
  64657. * Legacy support, changed quaternion to rotationQuaternion
  64658. */
  64659. set quaternion(q: Nullable<Quaternion>);
  64660. /**
  64661. * Returns a boolean. True if the particle intersects a mesh, else false
  64662. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  64663. * @param target is the object (point or mesh) what the intersection is computed against
  64664. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  64665. * @returns true if it intersects
  64666. */
  64667. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  64668. /**
  64669. * get the rotation matrix of the particle
  64670. * @hidden
  64671. */
  64672. getRotationMatrix(m: Matrix): void;
  64673. }
  64674. /**
  64675. * Represents a group of points in a points cloud system
  64676. * * PCS internal tool, don't use it manually.
  64677. */
  64678. export class PointsGroup {
  64679. /**
  64680. * The group id
  64681. * @hidden
  64682. */
  64683. groupID: number;
  64684. /**
  64685. * image data for group (internal use)
  64686. * @hidden
  64687. */
  64688. _groupImageData: Nullable<ArrayBufferView>;
  64689. /**
  64690. * Image Width (internal use)
  64691. * @hidden
  64692. */
  64693. _groupImgWidth: number;
  64694. /**
  64695. * Image Height (internal use)
  64696. * @hidden
  64697. */
  64698. _groupImgHeight: number;
  64699. /**
  64700. * Custom position function (internal use)
  64701. * @hidden
  64702. */
  64703. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  64704. /**
  64705. * density per facet for surface points
  64706. * @hidden
  64707. */
  64708. _groupDensity: number[];
  64709. /**
  64710. * Only when points are colored by texture carries pointer to texture list array
  64711. * @hidden
  64712. */
  64713. _textureNb: number;
  64714. /**
  64715. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  64716. * PCS internal tool, don't use it manually.
  64717. * @hidden
  64718. */
  64719. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  64720. }
  64721. }
  64722. declare module "babylonjs/Particles/index" {
  64723. export * from "babylonjs/Particles/baseParticleSystem";
  64724. export * from "babylonjs/Particles/EmitterTypes/index";
  64725. export * from "babylonjs/Particles/gpuParticleSystem";
  64726. export * from "babylonjs/Particles/IParticleSystem";
  64727. export * from "babylonjs/Particles/particle";
  64728. export * from "babylonjs/Particles/particleHelper";
  64729. export * from "babylonjs/Particles/particleSystem";
  64730. export * from "babylonjs/Particles/particleSystemComponent";
  64731. export * from "babylonjs/Particles/particleSystemSet";
  64732. export * from "babylonjs/Particles/solidParticle";
  64733. export * from "babylonjs/Particles/solidParticleSystem";
  64734. export * from "babylonjs/Particles/cloudPoint";
  64735. export * from "babylonjs/Particles/pointsCloudSystem";
  64736. export * from "babylonjs/Particles/subEmitter";
  64737. }
  64738. declare module "babylonjs/Physics/physicsEngineComponent" {
  64739. import { Nullable } from "babylonjs/types";
  64740. import { Observable, Observer } from "babylonjs/Misc/observable";
  64741. import { Vector3 } from "babylonjs/Maths/math.vector";
  64742. import { Mesh } from "babylonjs/Meshes/mesh";
  64743. import { ISceneComponent } from "babylonjs/sceneComponent";
  64744. import { Scene } from "babylonjs/scene";
  64745. import { Node } from "babylonjs/node";
  64746. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  64747. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64748. module "babylonjs/scene" {
  64749. interface Scene {
  64750. /** @hidden (Backing field) */
  64751. _physicsEngine: Nullable<IPhysicsEngine>;
  64752. /** @hidden */
  64753. _physicsTimeAccumulator: number;
  64754. /**
  64755. * Gets the current physics engine
  64756. * @returns a IPhysicsEngine or null if none attached
  64757. */
  64758. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  64759. /**
  64760. * Enables physics to the current scene
  64761. * @param gravity defines the scene's gravity for the physics engine
  64762. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  64763. * @return a boolean indicating if the physics engine was initialized
  64764. */
  64765. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  64766. /**
  64767. * Disables and disposes the physics engine associated with the scene
  64768. */
  64769. disablePhysicsEngine(): void;
  64770. /**
  64771. * Gets a boolean indicating if there is an active physics engine
  64772. * @returns a boolean indicating if there is an active physics engine
  64773. */
  64774. isPhysicsEnabled(): boolean;
  64775. /**
  64776. * Deletes a physics compound impostor
  64777. * @param compound defines the compound to delete
  64778. */
  64779. deleteCompoundImpostor(compound: any): void;
  64780. /**
  64781. * An event triggered when physic simulation is about to be run
  64782. */
  64783. onBeforePhysicsObservable: Observable<Scene>;
  64784. /**
  64785. * An event triggered when physic simulation has been done
  64786. */
  64787. onAfterPhysicsObservable: Observable<Scene>;
  64788. }
  64789. }
  64790. module "babylonjs/Meshes/abstractMesh" {
  64791. interface AbstractMesh {
  64792. /** @hidden */
  64793. _physicsImpostor: Nullable<PhysicsImpostor>;
  64794. /**
  64795. * Gets or sets impostor used for physic simulation
  64796. * @see http://doc.babylonjs.com/features/physics_engine
  64797. */
  64798. physicsImpostor: Nullable<PhysicsImpostor>;
  64799. /**
  64800. * Gets the current physics impostor
  64801. * @see http://doc.babylonjs.com/features/physics_engine
  64802. * @returns a physics impostor or null
  64803. */
  64804. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  64805. /** Apply a physic impulse to the mesh
  64806. * @param force defines the force to apply
  64807. * @param contactPoint defines where to apply the force
  64808. * @returns the current mesh
  64809. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  64810. */
  64811. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  64812. /**
  64813. * Creates a physic joint between two meshes
  64814. * @param otherMesh defines the other mesh to use
  64815. * @param pivot1 defines the pivot to use on this mesh
  64816. * @param pivot2 defines the pivot to use on the other mesh
  64817. * @param options defines additional options (can be plugin dependent)
  64818. * @returns the current mesh
  64819. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  64820. */
  64821. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  64822. /** @hidden */
  64823. _disposePhysicsObserver: Nullable<Observer<Node>>;
  64824. }
  64825. }
  64826. /**
  64827. * Defines the physics engine scene component responsible to manage a physics engine
  64828. */
  64829. export class PhysicsEngineSceneComponent implements ISceneComponent {
  64830. /**
  64831. * The component name helpful to identify the component in the list of scene components.
  64832. */
  64833. readonly name: string;
  64834. /**
  64835. * The scene the component belongs to.
  64836. */
  64837. scene: Scene;
  64838. /**
  64839. * Creates a new instance of the component for the given scene
  64840. * @param scene Defines the scene to register the component in
  64841. */
  64842. constructor(scene: Scene);
  64843. /**
  64844. * Registers the component in a given scene
  64845. */
  64846. register(): void;
  64847. /**
  64848. * Rebuilds the elements related to this component in case of
  64849. * context lost for instance.
  64850. */
  64851. rebuild(): void;
  64852. /**
  64853. * Disposes the component and the associated ressources
  64854. */
  64855. dispose(): void;
  64856. }
  64857. }
  64858. declare module "babylonjs/Physics/physicsHelper" {
  64859. import { Nullable } from "babylonjs/types";
  64860. import { Vector3 } from "babylonjs/Maths/math.vector";
  64861. import { Mesh } from "babylonjs/Meshes/mesh";
  64862. import { Scene } from "babylonjs/scene";
  64863. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64864. /**
  64865. * A helper for physics simulations
  64866. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64867. */
  64868. export class PhysicsHelper {
  64869. private _scene;
  64870. private _physicsEngine;
  64871. /**
  64872. * Initializes the Physics helper
  64873. * @param scene Babylon.js scene
  64874. */
  64875. constructor(scene: Scene);
  64876. /**
  64877. * Applies a radial explosion impulse
  64878. * @param origin the origin of the explosion
  64879. * @param radiusOrEventOptions the radius or the options of radial explosion
  64880. * @param strength the explosion strength
  64881. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64882. * @returns A physics radial explosion event, or null
  64883. */
  64884. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64885. /**
  64886. * Applies a radial explosion force
  64887. * @param origin the origin of the explosion
  64888. * @param radiusOrEventOptions the radius or the options of radial explosion
  64889. * @param strength the explosion strength
  64890. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64891. * @returns A physics radial explosion event, or null
  64892. */
  64893. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64894. /**
  64895. * Creates a gravitational field
  64896. * @param origin the origin of the explosion
  64897. * @param radiusOrEventOptions the radius or the options of radial explosion
  64898. * @param strength the explosion strength
  64899. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64900. * @returns A physics gravitational field event, or null
  64901. */
  64902. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  64903. /**
  64904. * Creates a physics updraft event
  64905. * @param origin the origin of the updraft
  64906. * @param radiusOrEventOptions the radius or the options of the updraft
  64907. * @param strength the strength of the updraft
  64908. * @param height the height of the updraft
  64909. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  64910. * @returns A physics updraft event, or null
  64911. */
  64912. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  64913. /**
  64914. * Creates a physics vortex event
  64915. * @param origin the of the vortex
  64916. * @param radiusOrEventOptions the radius or the options of the vortex
  64917. * @param strength the strength of the vortex
  64918. * @param height the height of the vortex
  64919. * @returns a Physics vortex event, or null
  64920. * A physics vortex event or null
  64921. */
  64922. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  64923. }
  64924. /**
  64925. * Represents a physics radial explosion event
  64926. */
  64927. class PhysicsRadialExplosionEvent {
  64928. private _scene;
  64929. private _options;
  64930. private _sphere;
  64931. private _dataFetched;
  64932. /**
  64933. * Initializes a radial explosioin event
  64934. * @param _scene BabylonJS scene
  64935. * @param _options The options for the vortex event
  64936. */
  64937. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  64938. /**
  64939. * Returns the data related to the radial explosion event (sphere).
  64940. * @returns The radial explosion event data
  64941. */
  64942. getData(): PhysicsRadialExplosionEventData;
  64943. /**
  64944. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  64945. * @param impostor A physics imposter
  64946. * @param origin the origin of the explosion
  64947. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  64948. */
  64949. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  64950. /**
  64951. * Triggers affecterd impostors callbacks
  64952. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  64953. */
  64954. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  64955. /**
  64956. * Disposes the sphere.
  64957. * @param force Specifies if the sphere should be disposed by force
  64958. */
  64959. dispose(force?: boolean): void;
  64960. /*** Helpers ***/
  64961. private _prepareSphere;
  64962. private _intersectsWithSphere;
  64963. }
  64964. /**
  64965. * Represents a gravitational field event
  64966. */
  64967. class PhysicsGravitationalFieldEvent {
  64968. private _physicsHelper;
  64969. private _scene;
  64970. private _origin;
  64971. private _options;
  64972. private _tickCallback;
  64973. private _sphere;
  64974. private _dataFetched;
  64975. /**
  64976. * Initializes the physics gravitational field event
  64977. * @param _physicsHelper A physics helper
  64978. * @param _scene BabylonJS scene
  64979. * @param _origin The origin position of the gravitational field event
  64980. * @param _options The options for the vortex event
  64981. */
  64982. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  64983. /**
  64984. * Returns the data related to the gravitational field event (sphere).
  64985. * @returns A gravitational field event
  64986. */
  64987. getData(): PhysicsGravitationalFieldEventData;
  64988. /**
  64989. * Enables the gravitational field.
  64990. */
  64991. enable(): void;
  64992. /**
  64993. * Disables the gravitational field.
  64994. */
  64995. disable(): void;
  64996. /**
  64997. * Disposes the sphere.
  64998. * @param force The force to dispose from the gravitational field event
  64999. */
  65000. dispose(force?: boolean): void;
  65001. private _tick;
  65002. }
  65003. /**
  65004. * Represents a physics updraft event
  65005. */
  65006. class PhysicsUpdraftEvent {
  65007. private _scene;
  65008. private _origin;
  65009. private _options;
  65010. private _physicsEngine;
  65011. private _originTop;
  65012. private _originDirection;
  65013. private _tickCallback;
  65014. private _cylinder;
  65015. private _cylinderPosition;
  65016. private _dataFetched;
  65017. /**
  65018. * Initializes the physics updraft event
  65019. * @param _scene BabylonJS scene
  65020. * @param _origin The origin position of the updraft
  65021. * @param _options The options for the updraft event
  65022. */
  65023. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  65024. /**
  65025. * Returns the data related to the updraft event (cylinder).
  65026. * @returns A physics updraft event
  65027. */
  65028. getData(): PhysicsUpdraftEventData;
  65029. /**
  65030. * Enables the updraft.
  65031. */
  65032. enable(): void;
  65033. /**
  65034. * Disables the updraft.
  65035. */
  65036. disable(): void;
  65037. /**
  65038. * Disposes the cylinder.
  65039. * @param force Specifies if the updraft should be disposed by force
  65040. */
  65041. dispose(force?: boolean): void;
  65042. private getImpostorHitData;
  65043. private _tick;
  65044. /*** Helpers ***/
  65045. private _prepareCylinder;
  65046. private _intersectsWithCylinder;
  65047. }
  65048. /**
  65049. * Represents a physics vortex event
  65050. */
  65051. class PhysicsVortexEvent {
  65052. private _scene;
  65053. private _origin;
  65054. private _options;
  65055. private _physicsEngine;
  65056. private _originTop;
  65057. private _tickCallback;
  65058. private _cylinder;
  65059. private _cylinderPosition;
  65060. private _dataFetched;
  65061. /**
  65062. * Initializes the physics vortex event
  65063. * @param _scene The BabylonJS scene
  65064. * @param _origin The origin position of the vortex
  65065. * @param _options The options for the vortex event
  65066. */
  65067. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  65068. /**
  65069. * Returns the data related to the vortex event (cylinder).
  65070. * @returns The physics vortex event data
  65071. */
  65072. getData(): PhysicsVortexEventData;
  65073. /**
  65074. * Enables the vortex.
  65075. */
  65076. enable(): void;
  65077. /**
  65078. * Disables the cortex.
  65079. */
  65080. disable(): void;
  65081. /**
  65082. * Disposes the sphere.
  65083. * @param force
  65084. */
  65085. dispose(force?: boolean): void;
  65086. private getImpostorHitData;
  65087. private _tick;
  65088. /*** Helpers ***/
  65089. private _prepareCylinder;
  65090. private _intersectsWithCylinder;
  65091. }
  65092. /**
  65093. * Options fot the radial explosion event
  65094. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65095. */
  65096. export class PhysicsRadialExplosionEventOptions {
  65097. /**
  65098. * The radius of the sphere for the radial explosion.
  65099. */
  65100. radius: number;
  65101. /**
  65102. * The strenth of the explosion.
  65103. */
  65104. strength: number;
  65105. /**
  65106. * The strenght of the force in correspondence to the distance of the affected object
  65107. */
  65108. falloff: PhysicsRadialImpulseFalloff;
  65109. /**
  65110. * Sphere options for the radial explosion.
  65111. */
  65112. sphere: {
  65113. segments: number;
  65114. diameter: number;
  65115. };
  65116. /**
  65117. * Sphere options for the radial explosion.
  65118. */
  65119. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  65120. }
  65121. /**
  65122. * Options fot the updraft event
  65123. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65124. */
  65125. export class PhysicsUpdraftEventOptions {
  65126. /**
  65127. * The radius of the cylinder for the vortex
  65128. */
  65129. radius: number;
  65130. /**
  65131. * The strenth of the updraft.
  65132. */
  65133. strength: number;
  65134. /**
  65135. * The height of the cylinder for the updraft.
  65136. */
  65137. height: number;
  65138. /**
  65139. * The mode for the the updraft.
  65140. */
  65141. updraftMode: PhysicsUpdraftMode;
  65142. }
  65143. /**
  65144. * Options fot the vortex event
  65145. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65146. */
  65147. export class PhysicsVortexEventOptions {
  65148. /**
  65149. * The radius of the cylinder for the vortex
  65150. */
  65151. radius: number;
  65152. /**
  65153. * The strenth of the vortex.
  65154. */
  65155. strength: number;
  65156. /**
  65157. * The height of the cylinder for the vortex.
  65158. */
  65159. height: number;
  65160. /**
  65161. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  65162. */
  65163. centripetalForceThreshold: number;
  65164. /**
  65165. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  65166. */
  65167. centripetalForceMultiplier: number;
  65168. /**
  65169. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  65170. */
  65171. centrifugalForceMultiplier: number;
  65172. /**
  65173. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  65174. */
  65175. updraftForceMultiplier: number;
  65176. }
  65177. /**
  65178. * The strenght of the force in correspondence to the distance of the affected object
  65179. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65180. */
  65181. export enum PhysicsRadialImpulseFalloff {
  65182. /** Defines that impulse is constant in strength across it's whole radius */
  65183. Constant = 0,
  65184. /** Defines that impulse gets weaker if it's further from the origin */
  65185. Linear = 1
  65186. }
  65187. /**
  65188. * The strength of the force in correspondence to the distance of the affected object
  65189. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65190. */
  65191. export enum PhysicsUpdraftMode {
  65192. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  65193. Center = 0,
  65194. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  65195. Perpendicular = 1
  65196. }
  65197. /**
  65198. * Interface for a physics hit data
  65199. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65200. */
  65201. export interface PhysicsHitData {
  65202. /**
  65203. * The force applied at the contact point
  65204. */
  65205. force: Vector3;
  65206. /**
  65207. * The contact point
  65208. */
  65209. contactPoint: Vector3;
  65210. /**
  65211. * The distance from the origin to the contact point
  65212. */
  65213. distanceFromOrigin: number;
  65214. }
  65215. /**
  65216. * Interface for radial explosion event data
  65217. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65218. */
  65219. export interface PhysicsRadialExplosionEventData {
  65220. /**
  65221. * A sphere used for the radial explosion event
  65222. */
  65223. sphere: Mesh;
  65224. }
  65225. /**
  65226. * Interface for gravitational field event data
  65227. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65228. */
  65229. export interface PhysicsGravitationalFieldEventData {
  65230. /**
  65231. * A sphere mesh used for the gravitational field event
  65232. */
  65233. sphere: Mesh;
  65234. }
  65235. /**
  65236. * Interface for updraft event data
  65237. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65238. */
  65239. export interface PhysicsUpdraftEventData {
  65240. /**
  65241. * A cylinder used for the updraft event
  65242. */
  65243. cylinder: Mesh;
  65244. }
  65245. /**
  65246. * Interface for vortex event data
  65247. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65248. */
  65249. export interface PhysicsVortexEventData {
  65250. /**
  65251. * A cylinder used for the vortex event
  65252. */
  65253. cylinder: Mesh;
  65254. }
  65255. /**
  65256. * Interface for an affected physics impostor
  65257. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65258. */
  65259. export interface PhysicsAffectedImpostorWithData {
  65260. /**
  65261. * The impostor affected by the effect
  65262. */
  65263. impostor: PhysicsImpostor;
  65264. /**
  65265. * The data about the hit/horce from the explosion
  65266. */
  65267. hitData: PhysicsHitData;
  65268. }
  65269. }
  65270. declare module "babylonjs/Physics/Plugins/index" {
  65271. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  65272. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  65273. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  65274. }
  65275. declare module "babylonjs/Physics/index" {
  65276. export * from "babylonjs/Physics/IPhysicsEngine";
  65277. export * from "babylonjs/Physics/physicsEngine";
  65278. export * from "babylonjs/Physics/physicsEngineComponent";
  65279. export * from "babylonjs/Physics/physicsHelper";
  65280. export * from "babylonjs/Physics/physicsImpostor";
  65281. export * from "babylonjs/Physics/physicsJoint";
  65282. export * from "babylonjs/Physics/Plugins/index";
  65283. }
  65284. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  65285. /** @hidden */
  65286. export var blackAndWhitePixelShader: {
  65287. name: string;
  65288. shader: string;
  65289. };
  65290. }
  65291. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  65292. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65293. import { Camera } from "babylonjs/Cameras/camera";
  65294. import { Engine } from "babylonjs/Engines/engine";
  65295. import "babylonjs/Shaders/blackAndWhite.fragment";
  65296. /**
  65297. * Post process used to render in black and white
  65298. */
  65299. export class BlackAndWhitePostProcess extends PostProcess {
  65300. /**
  65301. * Linear about to convert he result to black and white (default: 1)
  65302. */
  65303. degree: number;
  65304. /**
  65305. * Creates a black and white post process
  65306. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  65307. * @param name The name of the effect.
  65308. * @param options The required width/height ratio to downsize to before computing the render pass.
  65309. * @param camera The camera to apply the render pass to.
  65310. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65311. * @param engine The engine which the post process will be applied. (default: current engine)
  65312. * @param reusable If the post process can be reused on the same frame. (default: false)
  65313. */
  65314. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65315. }
  65316. }
  65317. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  65318. import { Nullable } from "babylonjs/types";
  65319. import { Camera } from "babylonjs/Cameras/camera";
  65320. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65321. import { Engine } from "babylonjs/Engines/engine";
  65322. /**
  65323. * This represents a set of one or more post processes in Babylon.
  65324. * A post process can be used to apply a shader to a texture after it is rendered.
  65325. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65326. */
  65327. export class PostProcessRenderEffect {
  65328. private _postProcesses;
  65329. private _getPostProcesses;
  65330. private _singleInstance;
  65331. private _cameras;
  65332. private _indicesForCamera;
  65333. /**
  65334. * Name of the effect
  65335. * @hidden
  65336. */
  65337. _name: string;
  65338. /**
  65339. * Instantiates a post process render effect.
  65340. * A post process can be used to apply a shader to a texture after it is rendered.
  65341. * @param engine The engine the effect is tied to
  65342. * @param name The name of the effect
  65343. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  65344. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  65345. */
  65346. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  65347. /**
  65348. * Checks if all the post processes in the effect are supported.
  65349. */
  65350. get isSupported(): boolean;
  65351. /**
  65352. * Updates the current state of the effect
  65353. * @hidden
  65354. */
  65355. _update(): void;
  65356. /**
  65357. * Attaches the effect on cameras
  65358. * @param cameras The camera to attach to.
  65359. * @hidden
  65360. */
  65361. _attachCameras(cameras: Camera): void;
  65362. /**
  65363. * Attaches the effect on cameras
  65364. * @param cameras The camera to attach to.
  65365. * @hidden
  65366. */
  65367. _attachCameras(cameras: Camera[]): void;
  65368. /**
  65369. * Detaches the effect on cameras
  65370. * @param cameras The camera to detatch from.
  65371. * @hidden
  65372. */
  65373. _detachCameras(cameras: Camera): void;
  65374. /**
  65375. * Detatches the effect on cameras
  65376. * @param cameras The camera to detatch from.
  65377. * @hidden
  65378. */
  65379. _detachCameras(cameras: Camera[]): void;
  65380. /**
  65381. * Enables the effect on given cameras
  65382. * @param cameras The camera to enable.
  65383. * @hidden
  65384. */
  65385. _enable(cameras: Camera): void;
  65386. /**
  65387. * Enables the effect on given cameras
  65388. * @param cameras The camera to enable.
  65389. * @hidden
  65390. */
  65391. _enable(cameras: Nullable<Camera[]>): void;
  65392. /**
  65393. * Disables the effect on the given cameras
  65394. * @param cameras The camera to disable.
  65395. * @hidden
  65396. */
  65397. _disable(cameras: Camera): void;
  65398. /**
  65399. * Disables the effect on the given cameras
  65400. * @param cameras The camera to disable.
  65401. * @hidden
  65402. */
  65403. _disable(cameras: Nullable<Camera[]>): void;
  65404. /**
  65405. * Gets a list of the post processes contained in the effect.
  65406. * @param camera The camera to get the post processes on.
  65407. * @returns The list of the post processes in the effect.
  65408. */
  65409. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  65410. }
  65411. }
  65412. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  65413. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65414. /** @hidden */
  65415. export var extractHighlightsPixelShader: {
  65416. name: string;
  65417. shader: string;
  65418. };
  65419. }
  65420. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  65421. import { Nullable } from "babylonjs/types";
  65422. import { Camera } from "babylonjs/Cameras/camera";
  65423. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65424. import { Engine } from "babylonjs/Engines/engine";
  65425. import "babylonjs/Shaders/extractHighlights.fragment";
  65426. /**
  65427. * 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.
  65428. */
  65429. export class ExtractHighlightsPostProcess extends PostProcess {
  65430. /**
  65431. * The luminance threshold, pixels below this value will be set to black.
  65432. */
  65433. threshold: number;
  65434. /** @hidden */
  65435. _exposure: number;
  65436. /**
  65437. * Post process which has the input texture to be used when performing highlight extraction
  65438. * @hidden
  65439. */
  65440. _inputPostProcess: Nullable<PostProcess>;
  65441. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65442. }
  65443. }
  65444. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  65445. /** @hidden */
  65446. export var bloomMergePixelShader: {
  65447. name: string;
  65448. shader: string;
  65449. };
  65450. }
  65451. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  65452. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65453. import { Nullable } from "babylonjs/types";
  65454. import { Engine } from "babylonjs/Engines/engine";
  65455. import { Camera } from "babylonjs/Cameras/camera";
  65456. import "babylonjs/Shaders/bloomMerge.fragment";
  65457. /**
  65458. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  65459. */
  65460. export class BloomMergePostProcess extends PostProcess {
  65461. /** Weight of the bloom to be added to the original input. */
  65462. weight: number;
  65463. /**
  65464. * Creates a new instance of @see BloomMergePostProcess
  65465. * @param name The name of the effect.
  65466. * @param originalFromInput Post process which's input will be used for the merge.
  65467. * @param blurred Blurred highlights post process which's output will be used.
  65468. * @param weight Weight of the bloom to be added to the original input.
  65469. * @param options The required width/height ratio to downsize to before computing the render pass.
  65470. * @param camera The camera to apply the render pass to.
  65471. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65472. * @param engine The engine which the post process will be applied. (default: current engine)
  65473. * @param reusable If the post process can be reused on the same frame. (default: false)
  65474. * @param textureType Type of textures used when performing the post process. (default: 0)
  65475. * @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)
  65476. */
  65477. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  65478. /** Weight of the bloom to be added to the original input. */
  65479. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65480. }
  65481. }
  65482. declare module "babylonjs/PostProcesses/bloomEffect" {
  65483. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65484. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65485. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  65486. import { Camera } from "babylonjs/Cameras/camera";
  65487. import { Scene } from "babylonjs/scene";
  65488. /**
  65489. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  65490. */
  65491. export class BloomEffect extends PostProcessRenderEffect {
  65492. private bloomScale;
  65493. /**
  65494. * @hidden Internal
  65495. */
  65496. _effects: Array<PostProcess>;
  65497. /**
  65498. * @hidden Internal
  65499. */
  65500. _downscale: ExtractHighlightsPostProcess;
  65501. private _blurX;
  65502. private _blurY;
  65503. private _merge;
  65504. /**
  65505. * The luminance threshold to find bright areas of the image to bloom.
  65506. */
  65507. get threshold(): number;
  65508. set threshold(value: number);
  65509. /**
  65510. * The strength of the bloom.
  65511. */
  65512. get weight(): number;
  65513. set weight(value: number);
  65514. /**
  65515. * Specifies the size of the bloom blur kernel, relative to the final output size
  65516. */
  65517. get kernel(): number;
  65518. set kernel(value: number);
  65519. /**
  65520. * Creates a new instance of @see BloomEffect
  65521. * @param scene The scene the effect belongs to.
  65522. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  65523. * @param bloomKernel The size of the kernel to be used when applying the blur.
  65524. * @param bloomWeight The the strength of bloom.
  65525. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65526. * @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)
  65527. */
  65528. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  65529. /**
  65530. * Disposes each of the internal effects for a given camera.
  65531. * @param camera The camera to dispose the effect on.
  65532. */
  65533. disposeEffects(camera: Camera): void;
  65534. /**
  65535. * @hidden Internal
  65536. */
  65537. _updateEffects(): void;
  65538. /**
  65539. * Internal
  65540. * @returns if all the contained post processes are ready.
  65541. * @hidden
  65542. */
  65543. _isReady(): boolean;
  65544. }
  65545. }
  65546. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  65547. /** @hidden */
  65548. export var chromaticAberrationPixelShader: {
  65549. name: string;
  65550. shader: string;
  65551. };
  65552. }
  65553. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  65554. import { Vector2 } from "babylonjs/Maths/math.vector";
  65555. import { Nullable } from "babylonjs/types";
  65556. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65557. import { Camera } from "babylonjs/Cameras/camera";
  65558. import { Engine } from "babylonjs/Engines/engine";
  65559. import "babylonjs/Shaders/chromaticAberration.fragment";
  65560. /**
  65561. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  65562. */
  65563. export class ChromaticAberrationPostProcess extends PostProcess {
  65564. /**
  65565. * The amount of seperation of rgb channels (default: 30)
  65566. */
  65567. aberrationAmount: number;
  65568. /**
  65569. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  65570. */
  65571. radialIntensity: number;
  65572. /**
  65573. * 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))
  65574. */
  65575. direction: Vector2;
  65576. /**
  65577. * 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))
  65578. */
  65579. centerPosition: Vector2;
  65580. /**
  65581. * Creates a new instance ChromaticAberrationPostProcess
  65582. * @param name The name of the effect.
  65583. * @param screenWidth The width of the screen to apply the effect on.
  65584. * @param screenHeight The height of the screen to apply the effect on.
  65585. * @param options The required width/height ratio to downsize to before computing the render pass.
  65586. * @param camera The camera to apply the render pass to.
  65587. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65588. * @param engine The engine which the post process will be applied. (default: current engine)
  65589. * @param reusable If the post process can be reused on the same frame. (default: false)
  65590. * @param textureType Type of textures used when performing the post process. (default: 0)
  65591. * @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)
  65592. */
  65593. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65594. }
  65595. }
  65596. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  65597. /** @hidden */
  65598. export var circleOfConfusionPixelShader: {
  65599. name: string;
  65600. shader: string;
  65601. };
  65602. }
  65603. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  65604. import { Nullable } from "babylonjs/types";
  65605. import { Engine } from "babylonjs/Engines/engine";
  65606. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65607. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65608. import { Camera } from "babylonjs/Cameras/camera";
  65609. import "babylonjs/Shaders/circleOfConfusion.fragment";
  65610. /**
  65611. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  65612. */
  65613. export class CircleOfConfusionPostProcess extends PostProcess {
  65614. /**
  65615. * 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.
  65616. */
  65617. lensSize: number;
  65618. /**
  65619. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65620. */
  65621. fStop: number;
  65622. /**
  65623. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65624. */
  65625. focusDistance: number;
  65626. /**
  65627. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  65628. */
  65629. focalLength: number;
  65630. private _depthTexture;
  65631. /**
  65632. * Creates a new instance CircleOfConfusionPostProcess
  65633. * @param name The name of the effect.
  65634. * @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.
  65635. * @param options The required width/height ratio to downsize to before computing the render pass.
  65636. * @param camera The camera to apply the render pass to.
  65637. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65638. * @param engine The engine which the post process will be applied. (default: current engine)
  65639. * @param reusable If the post process can be reused on the same frame. (default: false)
  65640. * @param textureType Type of textures used when performing the post process. (default: 0)
  65641. * @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)
  65642. */
  65643. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65644. /**
  65645. * 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.
  65646. */
  65647. set depthTexture(value: RenderTargetTexture);
  65648. }
  65649. }
  65650. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  65651. /** @hidden */
  65652. export var colorCorrectionPixelShader: {
  65653. name: string;
  65654. shader: string;
  65655. };
  65656. }
  65657. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  65658. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65659. import { Engine } from "babylonjs/Engines/engine";
  65660. import { Camera } from "babylonjs/Cameras/camera";
  65661. import "babylonjs/Shaders/colorCorrection.fragment";
  65662. /**
  65663. *
  65664. * This post-process allows the modification of rendered colors by using
  65665. * a 'look-up table' (LUT). This effect is also called Color Grading.
  65666. *
  65667. * The object needs to be provided an url to a texture containing the color
  65668. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  65669. * Use an image editing software to tweak the LUT to match your needs.
  65670. *
  65671. * For an example of a color LUT, see here:
  65672. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  65673. * For explanations on color grading, see here:
  65674. * @see http://udn.epicgames.com/Three/ColorGrading.html
  65675. *
  65676. */
  65677. export class ColorCorrectionPostProcess extends PostProcess {
  65678. private _colorTableTexture;
  65679. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65680. }
  65681. }
  65682. declare module "babylonjs/Shaders/convolution.fragment" {
  65683. /** @hidden */
  65684. export var convolutionPixelShader: {
  65685. name: string;
  65686. shader: string;
  65687. };
  65688. }
  65689. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  65690. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65691. import { Nullable } from "babylonjs/types";
  65692. import { Camera } from "babylonjs/Cameras/camera";
  65693. import { Engine } from "babylonjs/Engines/engine";
  65694. import "babylonjs/Shaders/convolution.fragment";
  65695. /**
  65696. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  65697. * input texture to perform effects such as edge detection or sharpening
  65698. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65699. */
  65700. export class ConvolutionPostProcess extends PostProcess {
  65701. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65702. kernel: number[];
  65703. /**
  65704. * Creates a new instance ConvolutionPostProcess
  65705. * @param name The name of the effect.
  65706. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  65707. * @param options The required width/height ratio to downsize to before computing the render pass.
  65708. * @param camera The camera to apply the render pass to.
  65709. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65710. * @param engine The engine which the post process will be applied. (default: current engine)
  65711. * @param reusable If the post process can be reused on the same frame. (default: false)
  65712. * @param textureType Type of textures used when performing the post process. (default: 0)
  65713. */
  65714. constructor(name: string,
  65715. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  65716. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65717. /**
  65718. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65719. */
  65720. static EdgeDetect0Kernel: number[];
  65721. /**
  65722. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65723. */
  65724. static EdgeDetect1Kernel: number[];
  65725. /**
  65726. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65727. */
  65728. static EdgeDetect2Kernel: number[];
  65729. /**
  65730. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65731. */
  65732. static SharpenKernel: number[];
  65733. /**
  65734. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65735. */
  65736. static EmbossKernel: number[];
  65737. /**
  65738. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65739. */
  65740. static GaussianKernel: number[];
  65741. }
  65742. }
  65743. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  65744. import { Nullable } from "babylonjs/types";
  65745. import { Vector2 } from "babylonjs/Maths/math.vector";
  65746. import { Camera } from "babylonjs/Cameras/camera";
  65747. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65748. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  65749. import { Engine } from "babylonjs/Engines/engine";
  65750. import { Scene } from "babylonjs/scene";
  65751. /**
  65752. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  65753. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  65754. * based on samples that have a large difference in distance than the center pixel.
  65755. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  65756. */
  65757. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  65758. direction: Vector2;
  65759. /**
  65760. * Creates a new instance CircleOfConfusionPostProcess
  65761. * @param name The name of the effect.
  65762. * @param scene The scene the effect belongs to.
  65763. * @param direction The direction the blur should be applied.
  65764. * @param kernel The size of the kernel used to blur.
  65765. * @param options The required width/height ratio to downsize to before computing the render pass.
  65766. * @param camera The camera to apply the render pass to.
  65767. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  65768. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  65769. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65770. * @param engine The engine which the post process will be applied. (default: current engine)
  65771. * @param reusable If the post process can be reused on the same frame. (default: false)
  65772. * @param textureType Type of textures used when performing the post process. (default: 0)
  65773. * @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)
  65774. */
  65775. 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);
  65776. }
  65777. }
  65778. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  65779. /** @hidden */
  65780. export var depthOfFieldMergePixelShader: {
  65781. name: string;
  65782. shader: string;
  65783. };
  65784. }
  65785. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  65786. import { Nullable } from "babylonjs/types";
  65787. import { Camera } from "babylonjs/Cameras/camera";
  65788. import { Effect } from "babylonjs/Materials/effect";
  65789. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65790. import { Engine } from "babylonjs/Engines/engine";
  65791. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  65792. /**
  65793. * Options to be set when merging outputs from the default pipeline.
  65794. */
  65795. export class DepthOfFieldMergePostProcessOptions {
  65796. /**
  65797. * The original image to merge on top of
  65798. */
  65799. originalFromInput: PostProcess;
  65800. /**
  65801. * Parameters to perform the merge of the depth of field effect
  65802. */
  65803. depthOfField?: {
  65804. circleOfConfusion: PostProcess;
  65805. blurSteps: Array<PostProcess>;
  65806. };
  65807. /**
  65808. * Parameters to perform the merge of bloom effect
  65809. */
  65810. bloom?: {
  65811. blurred: PostProcess;
  65812. weight: number;
  65813. };
  65814. }
  65815. /**
  65816. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  65817. */
  65818. export class DepthOfFieldMergePostProcess extends PostProcess {
  65819. private blurSteps;
  65820. /**
  65821. * Creates a new instance of DepthOfFieldMergePostProcess
  65822. * @param name The name of the effect.
  65823. * @param originalFromInput Post process which's input will be used for the merge.
  65824. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  65825. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  65826. * @param options The required width/height ratio to downsize to before computing the render pass.
  65827. * @param camera The camera to apply the render pass to.
  65828. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65829. * @param engine The engine which the post process will be applied. (default: current engine)
  65830. * @param reusable If the post process can be reused on the same frame. (default: false)
  65831. * @param textureType Type of textures used when performing the post process. (default: 0)
  65832. * @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)
  65833. */
  65834. 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);
  65835. /**
  65836. * Updates the effect with the current post process compile time values and recompiles the shader.
  65837. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  65838. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  65839. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  65840. * @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
  65841. * @param onCompiled Called when the shader has been compiled.
  65842. * @param onError Called if there is an error when compiling a shader.
  65843. */
  65844. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  65845. }
  65846. }
  65847. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  65848. import { Nullable } from "babylonjs/types";
  65849. import { Camera } from "babylonjs/Cameras/camera";
  65850. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65851. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65852. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65853. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  65854. import { Scene } from "babylonjs/scene";
  65855. /**
  65856. * Specifies the level of max blur that should be applied when using the depth of field effect
  65857. */
  65858. export enum DepthOfFieldEffectBlurLevel {
  65859. /**
  65860. * Subtle blur
  65861. */
  65862. Low = 0,
  65863. /**
  65864. * Medium blur
  65865. */
  65866. Medium = 1,
  65867. /**
  65868. * Large blur
  65869. */
  65870. High = 2
  65871. }
  65872. /**
  65873. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  65874. */
  65875. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  65876. private _circleOfConfusion;
  65877. /**
  65878. * @hidden Internal, blurs from high to low
  65879. */
  65880. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  65881. private _depthOfFieldBlurY;
  65882. private _dofMerge;
  65883. /**
  65884. * @hidden Internal post processes in depth of field effect
  65885. */
  65886. _effects: Array<PostProcess>;
  65887. /**
  65888. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  65889. */
  65890. set focalLength(value: number);
  65891. get focalLength(): number;
  65892. /**
  65893. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65894. */
  65895. set fStop(value: number);
  65896. get fStop(): number;
  65897. /**
  65898. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65899. */
  65900. set focusDistance(value: number);
  65901. get focusDistance(): number;
  65902. /**
  65903. * 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.
  65904. */
  65905. set lensSize(value: number);
  65906. get lensSize(): number;
  65907. /**
  65908. * Creates a new instance DepthOfFieldEffect
  65909. * @param scene The scene the effect belongs to.
  65910. * @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.
  65911. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65912. * @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)
  65913. */
  65914. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  65915. /**
  65916. * Get the current class name of the current effet
  65917. * @returns "DepthOfFieldEffect"
  65918. */
  65919. getClassName(): string;
  65920. /**
  65921. * 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.
  65922. */
  65923. set depthTexture(value: RenderTargetTexture);
  65924. /**
  65925. * Disposes each of the internal effects for a given camera.
  65926. * @param camera The camera to dispose the effect on.
  65927. */
  65928. disposeEffects(camera: Camera): void;
  65929. /**
  65930. * @hidden Internal
  65931. */
  65932. _updateEffects(): void;
  65933. /**
  65934. * Internal
  65935. * @returns if all the contained post processes are ready.
  65936. * @hidden
  65937. */
  65938. _isReady(): boolean;
  65939. }
  65940. }
  65941. declare module "babylonjs/Shaders/displayPass.fragment" {
  65942. /** @hidden */
  65943. export var displayPassPixelShader: {
  65944. name: string;
  65945. shader: string;
  65946. };
  65947. }
  65948. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  65949. import { Nullable } from "babylonjs/types";
  65950. import { Camera } from "babylonjs/Cameras/camera";
  65951. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65952. import { Engine } from "babylonjs/Engines/engine";
  65953. import "babylonjs/Shaders/displayPass.fragment";
  65954. /**
  65955. * DisplayPassPostProcess which produces an output the same as it's input
  65956. */
  65957. export class DisplayPassPostProcess extends PostProcess {
  65958. /**
  65959. * Creates the DisplayPassPostProcess
  65960. * @param name The name of the effect.
  65961. * @param options The required width/height ratio to downsize to before computing the render pass.
  65962. * @param camera The camera to apply the render pass to.
  65963. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65964. * @param engine The engine which the post process will be applied. (default: current engine)
  65965. * @param reusable If the post process can be reused on the same frame. (default: false)
  65966. */
  65967. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65968. }
  65969. }
  65970. declare module "babylonjs/Shaders/filter.fragment" {
  65971. /** @hidden */
  65972. export var filterPixelShader: {
  65973. name: string;
  65974. shader: string;
  65975. };
  65976. }
  65977. declare module "babylonjs/PostProcesses/filterPostProcess" {
  65978. import { Nullable } from "babylonjs/types";
  65979. import { Matrix } from "babylonjs/Maths/math.vector";
  65980. import { Camera } from "babylonjs/Cameras/camera";
  65981. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  65982. import { Engine } from "babylonjs/Engines/engine";
  65983. import "babylonjs/Shaders/filter.fragment";
  65984. /**
  65985. * Applies a kernel filter to the image
  65986. */
  65987. export class FilterPostProcess extends PostProcess {
  65988. /** The matrix to be applied to the image */
  65989. kernelMatrix: Matrix;
  65990. /**
  65991. *
  65992. * @param name The name of the effect.
  65993. * @param kernelMatrix The matrix to be applied to the image
  65994. * @param options The required width/height ratio to downsize to before computing the render pass.
  65995. * @param camera The camera to apply the render pass to.
  65996. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65997. * @param engine The engine which the post process will be applied. (default: current engine)
  65998. * @param reusable If the post process can be reused on the same frame. (default: false)
  65999. */
  66000. constructor(name: string,
  66001. /** The matrix to be applied to the image */
  66002. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66003. }
  66004. }
  66005. declare module "babylonjs/Shaders/fxaa.fragment" {
  66006. /** @hidden */
  66007. export var fxaaPixelShader: {
  66008. name: string;
  66009. shader: string;
  66010. };
  66011. }
  66012. declare module "babylonjs/Shaders/fxaa.vertex" {
  66013. /** @hidden */
  66014. export var fxaaVertexShader: {
  66015. name: string;
  66016. shader: string;
  66017. };
  66018. }
  66019. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  66020. import { Nullable } from "babylonjs/types";
  66021. import { Camera } from "babylonjs/Cameras/camera";
  66022. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66023. import { Engine } from "babylonjs/Engines/engine";
  66024. import "babylonjs/Shaders/fxaa.fragment";
  66025. import "babylonjs/Shaders/fxaa.vertex";
  66026. /**
  66027. * Fxaa post process
  66028. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  66029. */
  66030. export class FxaaPostProcess extends PostProcess {
  66031. /** @hidden */
  66032. texelWidth: number;
  66033. /** @hidden */
  66034. texelHeight: number;
  66035. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66036. private _getDefines;
  66037. }
  66038. }
  66039. declare module "babylonjs/Shaders/grain.fragment" {
  66040. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66041. /** @hidden */
  66042. export var grainPixelShader: {
  66043. name: string;
  66044. shader: string;
  66045. };
  66046. }
  66047. declare module "babylonjs/PostProcesses/grainPostProcess" {
  66048. import { Nullable } from "babylonjs/types";
  66049. import { Camera } from "babylonjs/Cameras/camera";
  66050. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66051. import { Engine } from "babylonjs/Engines/engine";
  66052. import "babylonjs/Shaders/grain.fragment";
  66053. /**
  66054. * The GrainPostProcess adds noise to the image at mid luminance levels
  66055. */
  66056. export class GrainPostProcess extends PostProcess {
  66057. /**
  66058. * The intensity of the grain added (default: 30)
  66059. */
  66060. intensity: number;
  66061. /**
  66062. * If the grain should be randomized on every frame
  66063. */
  66064. animated: boolean;
  66065. /**
  66066. * Creates a new instance of @see GrainPostProcess
  66067. * @param name The name of the effect.
  66068. * @param options The required width/height ratio to downsize to before computing the render pass.
  66069. * @param camera The camera to apply the render pass to.
  66070. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66071. * @param engine The engine which the post process will be applied. (default: current engine)
  66072. * @param reusable If the post process can be reused on the same frame. (default: false)
  66073. * @param textureType Type of textures used when performing the post process. (default: 0)
  66074. * @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)
  66075. */
  66076. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66077. }
  66078. }
  66079. declare module "babylonjs/Shaders/highlights.fragment" {
  66080. /** @hidden */
  66081. export var highlightsPixelShader: {
  66082. name: string;
  66083. shader: string;
  66084. };
  66085. }
  66086. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  66087. import { Nullable } from "babylonjs/types";
  66088. import { Camera } from "babylonjs/Cameras/camera";
  66089. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66090. import { Engine } from "babylonjs/Engines/engine";
  66091. import "babylonjs/Shaders/highlights.fragment";
  66092. /**
  66093. * Extracts highlights from the image
  66094. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  66095. */
  66096. export class HighlightsPostProcess extends PostProcess {
  66097. /**
  66098. * Extracts highlights from the image
  66099. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  66100. * @param name The name of the effect.
  66101. * @param options The required width/height ratio to downsize to before computing the render pass.
  66102. * @param camera The camera to apply the render pass to.
  66103. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66104. * @param engine The engine which the post process will be applied. (default: current engine)
  66105. * @param reusable If the post process can be reused on the same frame. (default: false)
  66106. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  66107. */
  66108. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66109. }
  66110. }
  66111. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  66112. /** @hidden */
  66113. export var mrtFragmentDeclaration: {
  66114. name: string;
  66115. shader: string;
  66116. };
  66117. }
  66118. declare module "babylonjs/Shaders/geometry.fragment" {
  66119. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  66120. /** @hidden */
  66121. export var geometryPixelShader: {
  66122. name: string;
  66123. shader: string;
  66124. };
  66125. }
  66126. declare module "babylonjs/Shaders/geometry.vertex" {
  66127. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66128. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66129. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66130. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66131. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66132. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66133. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66134. /** @hidden */
  66135. export var geometryVertexShader: {
  66136. name: string;
  66137. shader: string;
  66138. };
  66139. }
  66140. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  66141. import { Matrix } from "babylonjs/Maths/math.vector";
  66142. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66143. import { Mesh } from "babylonjs/Meshes/mesh";
  66144. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  66145. import { Effect } from "babylonjs/Materials/effect";
  66146. import { Scene } from "babylonjs/scene";
  66147. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66148. import "babylonjs/Shaders/geometry.fragment";
  66149. import "babylonjs/Shaders/geometry.vertex";
  66150. /** @hidden */
  66151. interface ISavedTransformationMatrix {
  66152. world: Matrix;
  66153. viewProjection: Matrix;
  66154. }
  66155. /**
  66156. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  66157. */
  66158. export class GeometryBufferRenderer {
  66159. /**
  66160. * Constant used to retrieve the position texture index in the G-Buffer textures array
  66161. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  66162. */
  66163. static readonly POSITION_TEXTURE_TYPE: number;
  66164. /**
  66165. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  66166. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  66167. */
  66168. static readonly VELOCITY_TEXTURE_TYPE: number;
  66169. /**
  66170. * Dictionary used to store the previous transformation matrices of each rendered mesh
  66171. * in order to compute objects velocities when enableVelocity is set to "true"
  66172. * @hidden
  66173. */
  66174. _previousTransformationMatrices: {
  66175. [index: number]: ISavedTransformationMatrix;
  66176. };
  66177. /**
  66178. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  66179. * in order to compute objects velocities when enableVelocity is set to "true"
  66180. * @hidden
  66181. */
  66182. _previousBonesTransformationMatrices: {
  66183. [index: number]: Float32Array;
  66184. };
  66185. /**
  66186. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  66187. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  66188. */
  66189. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  66190. private _scene;
  66191. private _multiRenderTarget;
  66192. private _ratio;
  66193. private _enablePosition;
  66194. private _enableVelocity;
  66195. private _positionIndex;
  66196. private _velocityIndex;
  66197. protected _effect: Effect;
  66198. protected _cachedDefines: string;
  66199. /**
  66200. * Set the render list (meshes to be rendered) used in the G buffer.
  66201. */
  66202. set renderList(meshes: Mesh[]);
  66203. /**
  66204. * Gets wether or not G buffer are supported by the running hardware.
  66205. * This requires draw buffer supports
  66206. */
  66207. get isSupported(): boolean;
  66208. /**
  66209. * Returns the index of the given texture type in the G-Buffer textures array
  66210. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  66211. * @returns the index of the given texture type in the G-Buffer textures array
  66212. */
  66213. getTextureIndex(textureType: number): number;
  66214. /**
  66215. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  66216. */
  66217. get enablePosition(): boolean;
  66218. /**
  66219. * Sets whether or not objects positions are enabled for the G buffer.
  66220. */
  66221. set enablePosition(enable: boolean);
  66222. /**
  66223. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  66224. */
  66225. get enableVelocity(): boolean;
  66226. /**
  66227. * Sets wether or not objects velocities are enabled for the G buffer.
  66228. */
  66229. set enableVelocity(enable: boolean);
  66230. /**
  66231. * Gets the scene associated with the buffer.
  66232. */
  66233. get scene(): Scene;
  66234. /**
  66235. * Gets the ratio used by the buffer during its creation.
  66236. * How big is the buffer related to the main canvas.
  66237. */
  66238. get ratio(): number;
  66239. /** @hidden */
  66240. static _SceneComponentInitialization: (scene: Scene) => void;
  66241. /**
  66242. * Creates a new G Buffer for the scene
  66243. * @param scene The scene the buffer belongs to
  66244. * @param ratio How big is the buffer related to the main canvas.
  66245. */
  66246. constructor(scene: Scene, ratio?: number);
  66247. /**
  66248. * Checks wether everything is ready to render a submesh to the G buffer.
  66249. * @param subMesh the submesh to check readiness for
  66250. * @param useInstances is the mesh drawn using instance or not
  66251. * @returns true if ready otherwise false
  66252. */
  66253. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66254. /**
  66255. * Gets the current underlying G Buffer.
  66256. * @returns the buffer
  66257. */
  66258. getGBuffer(): MultiRenderTarget;
  66259. /**
  66260. * Gets the number of samples used to render the buffer (anti aliasing).
  66261. */
  66262. get samples(): number;
  66263. /**
  66264. * Sets the number of samples used to render the buffer (anti aliasing).
  66265. */
  66266. set samples(value: number);
  66267. /**
  66268. * Disposes the renderer and frees up associated resources.
  66269. */
  66270. dispose(): void;
  66271. protected _createRenderTargets(): void;
  66272. private _copyBonesTransformationMatrices;
  66273. }
  66274. }
  66275. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  66276. import { Nullable } from "babylonjs/types";
  66277. import { Scene } from "babylonjs/scene";
  66278. import { ISceneComponent } from "babylonjs/sceneComponent";
  66279. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  66280. module "babylonjs/scene" {
  66281. interface Scene {
  66282. /** @hidden (Backing field) */
  66283. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  66284. /**
  66285. * Gets or Sets the current geometry buffer associated to the scene.
  66286. */
  66287. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  66288. /**
  66289. * Enables a GeometryBufferRender and associates it with the scene
  66290. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  66291. * @returns the GeometryBufferRenderer
  66292. */
  66293. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  66294. /**
  66295. * Disables the GeometryBufferRender associated with the scene
  66296. */
  66297. disableGeometryBufferRenderer(): void;
  66298. }
  66299. }
  66300. /**
  66301. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  66302. * in several rendering techniques.
  66303. */
  66304. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  66305. /**
  66306. * The component name helpful to identify the component in the list of scene components.
  66307. */
  66308. readonly name: string;
  66309. /**
  66310. * The scene the component belongs to.
  66311. */
  66312. scene: Scene;
  66313. /**
  66314. * Creates a new instance of the component for the given scene
  66315. * @param scene Defines the scene to register the component in
  66316. */
  66317. constructor(scene: Scene);
  66318. /**
  66319. * Registers the component in a given scene
  66320. */
  66321. register(): void;
  66322. /**
  66323. * Rebuilds the elements related to this component in case of
  66324. * context lost for instance.
  66325. */
  66326. rebuild(): void;
  66327. /**
  66328. * Disposes the component and the associated ressources
  66329. */
  66330. dispose(): void;
  66331. private _gatherRenderTargets;
  66332. }
  66333. }
  66334. declare module "babylonjs/Shaders/motionBlur.fragment" {
  66335. /** @hidden */
  66336. export var motionBlurPixelShader: {
  66337. name: string;
  66338. shader: string;
  66339. };
  66340. }
  66341. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  66342. import { Nullable } from "babylonjs/types";
  66343. import { Camera } from "babylonjs/Cameras/camera";
  66344. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66345. import { Scene } from "babylonjs/scene";
  66346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66347. import "babylonjs/Animations/animatable";
  66348. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  66349. import "babylonjs/Shaders/motionBlur.fragment";
  66350. import { Engine } from "babylonjs/Engines/engine";
  66351. /**
  66352. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  66353. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  66354. * As an example, all you have to do is to create the post-process:
  66355. * var mb = new BABYLON.MotionBlurPostProcess(
  66356. * 'mb', // The name of the effect.
  66357. * scene, // The scene containing the objects to blur according to their velocity.
  66358. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  66359. * camera // The camera to apply the render pass to.
  66360. * );
  66361. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  66362. */
  66363. export class MotionBlurPostProcess extends PostProcess {
  66364. /**
  66365. * Defines how much the image is blurred by the movement. Default value is equal to 1
  66366. */
  66367. motionStrength: number;
  66368. /**
  66369. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  66370. */
  66371. get motionBlurSamples(): number;
  66372. /**
  66373. * Sets the number of iterations to be used for motion blur quality
  66374. */
  66375. set motionBlurSamples(samples: number);
  66376. private _motionBlurSamples;
  66377. private _geometryBufferRenderer;
  66378. /**
  66379. * Creates a new instance MotionBlurPostProcess
  66380. * @param name The name of the effect.
  66381. * @param scene The scene containing the objects to blur according to their velocity.
  66382. * @param options The required width/height ratio to downsize to before computing the render pass.
  66383. * @param camera The camera to apply the render pass to.
  66384. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66385. * @param engine The engine which the post process will be applied. (default: current engine)
  66386. * @param reusable If the post process can be reused on the same frame. (default: false)
  66387. * @param textureType Type of textures used when performing the post process. (default: 0)
  66388. * @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)
  66389. */
  66390. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66391. /**
  66392. * Excludes the given skinned mesh from computing bones velocities.
  66393. * 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.
  66394. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  66395. */
  66396. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  66397. /**
  66398. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  66399. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  66400. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  66401. */
  66402. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  66403. /**
  66404. * Disposes the post process.
  66405. * @param camera The camera to dispose the post process on.
  66406. */
  66407. dispose(camera?: Camera): void;
  66408. }
  66409. }
  66410. declare module "babylonjs/Shaders/refraction.fragment" {
  66411. /** @hidden */
  66412. export var refractionPixelShader: {
  66413. name: string;
  66414. shader: string;
  66415. };
  66416. }
  66417. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  66418. import { Color3 } from "babylonjs/Maths/math.color";
  66419. import { Camera } from "babylonjs/Cameras/camera";
  66420. import { Texture } from "babylonjs/Materials/Textures/texture";
  66421. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66422. import { Engine } from "babylonjs/Engines/engine";
  66423. import "babylonjs/Shaders/refraction.fragment";
  66424. /**
  66425. * Post process which applies a refractin texture
  66426. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  66427. */
  66428. export class RefractionPostProcess extends PostProcess {
  66429. /** the base color of the refraction (used to taint the rendering) */
  66430. color: Color3;
  66431. /** simulated refraction depth */
  66432. depth: number;
  66433. /** the coefficient of the base color (0 to remove base color tainting) */
  66434. colorLevel: number;
  66435. private _refTexture;
  66436. private _ownRefractionTexture;
  66437. /**
  66438. * Gets or sets the refraction texture
  66439. * Please note that you are responsible for disposing the texture if you set it manually
  66440. */
  66441. get refractionTexture(): Texture;
  66442. set refractionTexture(value: Texture);
  66443. /**
  66444. * Initializes the RefractionPostProcess
  66445. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  66446. * @param name The name of the effect.
  66447. * @param refractionTextureUrl Url of the refraction texture to use
  66448. * @param color the base color of the refraction (used to taint the rendering)
  66449. * @param depth simulated refraction depth
  66450. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  66451. * @param camera The camera to apply the render pass to.
  66452. * @param options The required width/height ratio to downsize to before computing the render pass.
  66453. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66454. * @param engine The engine which the post process will be applied. (default: current engine)
  66455. * @param reusable If the post process can be reused on the same frame. (default: false)
  66456. */
  66457. constructor(name: string, refractionTextureUrl: string,
  66458. /** the base color of the refraction (used to taint the rendering) */
  66459. color: Color3,
  66460. /** simulated refraction depth */
  66461. depth: number,
  66462. /** the coefficient of the base color (0 to remove base color tainting) */
  66463. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66464. /**
  66465. * Disposes of the post process
  66466. * @param camera Camera to dispose post process on
  66467. */
  66468. dispose(camera: Camera): void;
  66469. }
  66470. }
  66471. declare module "babylonjs/Shaders/sharpen.fragment" {
  66472. /** @hidden */
  66473. export var sharpenPixelShader: {
  66474. name: string;
  66475. shader: string;
  66476. };
  66477. }
  66478. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  66479. import { Nullable } from "babylonjs/types";
  66480. import { Camera } from "babylonjs/Cameras/camera";
  66481. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66482. import "babylonjs/Shaders/sharpen.fragment";
  66483. import { Engine } from "babylonjs/Engines/engine";
  66484. /**
  66485. * The SharpenPostProcess applies a sharpen kernel to every pixel
  66486. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  66487. */
  66488. export class SharpenPostProcess extends PostProcess {
  66489. /**
  66490. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  66491. */
  66492. colorAmount: number;
  66493. /**
  66494. * How much sharpness should be applied (default: 0.3)
  66495. */
  66496. edgeAmount: number;
  66497. /**
  66498. * Creates a new instance ConvolutionPostProcess
  66499. * @param name The name of the effect.
  66500. * @param options The required width/height ratio to downsize to before computing the render pass.
  66501. * @param camera The camera to apply the render pass to.
  66502. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66503. * @param engine The engine which the post process will be applied. (default: current engine)
  66504. * @param reusable If the post process can be reused on the same frame. (default: false)
  66505. * @param textureType Type of textures used when performing the post process. (default: 0)
  66506. * @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)
  66507. */
  66508. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66509. }
  66510. }
  66511. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  66512. import { Nullable } from "babylonjs/types";
  66513. import { Camera } from "babylonjs/Cameras/camera";
  66514. import { Engine } from "babylonjs/Engines/engine";
  66515. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  66516. import { IInspectable } from "babylonjs/Misc/iInspectable";
  66517. /**
  66518. * PostProcessRenderPipeline
  66519. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66520. */
  66521. export class PostProcessRenderPipeline {
  66522. private engine;
  66523. private _renderEffects;
  66524. private _renderEffectsForIsolatedPass;
  66525. /**
  66526. * List of inspectable custom properties (used by the Inspector)
  66527. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  66528. */
  66529. inspectableCustomProperties: IInspectable[];
  66530. /**
  66531. * @hidden
  66532. */
  66533. protected _cameras: Camera[];
  66534. /** @hidden */
  66535. _name: string;
  66536. /**
  66537. * Gets pipeline name
  66538. */
  66539. get name(): string;
  66540. /** Gets the list of attached cameras */
  66541. get cameras(): Camera[];
  66542. /**
  66543. * Initializes a PostProcessRenderPipeline
  66544. * @param engine engine to add the pipeline to
  66545. * @param name name of the pipeline
  66546. */
  66547. constructor(engine: Engine, name: string);
  66548. /**
  66549. * Gets the class name
  66550. * @returns "PostProcessRenderPipeline"
  66551. */
  66552. getClassName(): string;
  66553. /**
  66554. * If all the render effects in the pipeline are supported
  66555. */
  66556. get isSupported(): boolean;
  66557. /**
  66558. * Adds an effect to the pipeline
  66559. * @param renderEffect the effect to add
  66560. */
  66561. addEffect(renderEffect: PostProcessRenderEffect): void;
  66562. /** @hidden */
  66563. _rebuild(): void;
  66564. /** @hidden */
  66565. _enableEffect(renderEffectName: string, cameras: Camera): void;
  66566. /** @hidden */
  66567. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  66568. /** @hidden */
  66569. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  66570. /** @hidden */
  66571. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  66572. /** @hidden */
  66573. _attachCameras(cameras: Camera, unique: boolean): void;
  66574. /** @hidden */
  66575. _attachCameras(cameras: Camera[], unique: boolean): void;
  66576. /** @hidden */
  66577. _detachCameras(cameras: Camera): void;
  66578. /** @hidden */
  66579. _detachCameras(cameras: Nullable<Camera[]>): void;
  66580. /** @hidden */
  66581. _update(): void;
  66582. /** @hidden */
  66583. _reset(): void;
  66584. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  66585. /**
  66586. * Disposes of the pipeline
  66587. */
  66588. dispose(): void;
  66589. }
  66590. }
  66591. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  66592. import { Camera } from "babylonjs/Cameras/camera";
  66593. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66594. /**
  66595. * PostProcessRenderPipelineManager class
  66596. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66597. */
  66598. export class PostProcessRenderPipelineManager {
  66599. private _renderPipelines;
  66600. /**
  66601. * Initializes a PostProcessRenderPipelineManager
  66602. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66603. */
  66604. constructor();
  66605. /**
  66606. * Gets the list of supported render pipelines
  66607. */
  66608. get supportedPipelines(): PostProcessRenderPipeline[];
  66609. /**
  66610. * Adds a pipeline to the manager
  66611. * @param renderPipeline The pipeline to add
  66612. */
  66613. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  66614. /**
  66615. * Attaches a camera to the pipeline
  66616. * @param renderPipelineName The name of the pipeline to attach to
  66617. * @param cameras the camera to attach
  66618. * @param unique if the camera can be attached multiple times to the pipeline
  66619. */
  66620. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  66621. /**
  66622. * Detaches a camera from the pipeline
  66623. * @param renderPipelineName The name of the pipeline to detach from
  66624. * @param cameras the camera to detach
  66625. */
  66626. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  66627. /**
  66628. * Enables an effect by name on a pipeline
  66629. * @param renderPipelineName the name of the pipeline to enable the effect in
  66630. * @param renderEffectName the name of the effect to enable
  66631. * @param cameras the cameras that the effect should be enabled on
  66632. */
  66633. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  66634. /**
  66635. * Disables an effect by name on a pipeline
  66636. * @param renderPipelineName the name of the pipeline to disable the effect in
  66637. * @param renderEffectName the name of the effect to disable
  66638. * @param cameras the cameras that the effect should be disabled on
  66639. */
  66640. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  66641. /**
  66642. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  66643. */
  66644. update(): void;
  66645. /** @hidden */
  66646. _rebuild(): void;
  66647. /**
  66648. * Disposes of the manager and pipelines
  66649. */
  66650. dispose(): void;
  66651. }
  66652. }
  66653. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  66654. import { ISceneComponent } from "babylonjs/sceneComponent";
  66655. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  66656. import { Scene } from "babylonjs/scene";
  66657. module "babylonjs/scene" {
  66658. interface Scene {
  66659. /** @hidden (Backing field) */
  66660. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  66661. /**
  66662. * Gets the postprocess render pipeline manager
  66663. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66664. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  66665. */
  66666. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  66667. }
  66668. }
  66669. /**
  66670. * Defines the Render Pipeline scene component responsible to rendering pipelines
  66671. */
  66672. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  66673. /**
  66674. * The component name helpfull to identify the component in the list of scene components.
  66675. */
  66676. readonly name: string;
  66677. /**
  66678. * The scene the component belongs to.
  66679. */
  66680. scene: Scene;
  66681. /**
  66682. * Creates a new instance of the component for the given scene
  66683. * @param scene Defines the scene to register the component in
  66684. */
  66685. constructor(scene: Scene);
  66686. /**
  66687. * Registers the component in a given scene
  66688. */
  66689. register(): void;
  66690. /**
  66691. * Rebuilds the elements related to this component in case of
  66692. * context lost for instance.
  66693. */
  66694. rebuild(): void;
  66695. /**
  66696. * Disposes the component and the associated ressources
  66697. */
  66698. dispose(): void;
  66699. private _gatherRenderTargets;
  66700. }
  66701. }
  66702. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  66703. import { Nullable } from "babylonjs/types";
  66704. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  66705. import { Camera } from "babylonjs/Cameras/camera";
  66706. import { IDisposable } from "babylonjs/scene";
  66707. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  66708. import { Scene } from "babylonjs/scene";
  66709. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  66710. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  66711. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  66712. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  66713. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  66714. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66715. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  66716. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66717. import { Animation } from "babylonjs/Animations/animation";
  66718. /**
  66719. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  66720. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  66721. */
  66722. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66723. private _scene;
  66724. private _camerasToBeAttached;
  66725. /**
  66726. * ID of the sharpen post process,
  66727. */
  66728. private readonly SharpenPostProcessId;
  66729. /**
  66730. * @ignore
  66731. * ID of the image processing post process;
  66732. */
  66733. readonly ImageProcessingPostProcessId: string;
  66734. /**
  66735. * @ignore
  66736. * ID of the Fast Approximate Anti-Aliasing post process;
  66737. */
  66738. readonly FxaaPostProcessId: string;
  66739. /**
  66740. * ID of the chromatic aberration post process,
  66741. */
  66742. private readonly ChromaticAberrationPostProcessId;
  66743. /**
  66744. * ID of the grain post process
  66745. */
  66746. private readonly GrainPostProcessId;
  66747. /**
  66748. * Sharpen post process which will apply a sharpen convolution to enhance edges
  66749. */
  66750. sharpen: SharpenPostProcess;
  66751. private _sharpenEffect;
  66752. private bloom;
  66753. /**
  66754. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  66755. */
  66756. depthOfField: DepthOfFieldEffect;
  66757. /**
  66758. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66759. */
  66760. fxaa: FxaaPostProcess;
  66761. /**
  66762. * Image post processing pass used to perform operations such as tone mapping or color grading.
  66763. */
  66764. imageProcessing: ImageProcessingPostProcess;
  66765. /**
  66766. * Chromatic aberration post process which will shift rgb colors in the image
  66767. */
  66768. chromaticAberration: ChromaticAberrationPostProcess;
  66769. private _chromaticAberrationEffect;
  66770. /**
  66771. * Grain post process which add noise to the image
  66772. */
  66773. grain: GrainPostProcess;
  66774. private _grainEffect;
  66775. /**
  66776. * Glow post process which adds a glow to emissive areas of the image
  66777. */
  66778. private _glowLayer;
  66779. /**
  66780. * Animations which can be used to tweak settings over a period of time
  66781. */
  66782. animations: Animation[];
  66783. private _imageProcessingConfigurationObserver;
  66784. private _sharpenEnabled;
  66785. private _bloomEnabled;
  66786. private _depthOfFieldEnabled;
  66787. private _depthOfFieldBlurLevel;
  66788. private _fxaaEnabled;
  66789. private _imageProcessingEnabled;
  66790. private _defaultPipelineTextureType;
  66791. private _bloomScale;
  66792. private _chromaticAberrationEnabled;
  66793. private _grainEnabled;
  66794. private _buildAllowed;
  66795. /**
  66796. * Gets active scene
  66797. */
  66798. get scene(): Scene;
  66799. /**
  66800. * Enable or disable the sharpen process from the pipeline
  66801. */
  66802. set sharpenEnabled(enabled: boolean);
  66803. get sharpenEnabled(): boolean;
  66804. private _resizeObserver;
  66805. private _hardwareScaleLevel;
  66806. private _bloomKernel;
  66807. /**
  66808. * Specifies the size of the bloom blur kernel, relative to the final output size
  66809. */
  66810. get bloomKernel(): number;
  66811. set bloomKernel(value: number);
  66812. /**
  66813. * Specifies the weight of the bloom in the final rendering
  66814. */
  66815. private _bloomWeight;
  66816. /**
  66817. * Specifies the luma threshold for the area that will be blurred by the bloom
  66818. */
  66819. private _bloomThreshold;
  66820. private _hdr;
  66821. /**
  66822. * The strength of the bloom.
  66823. */
  66824. set bloomWeight(value: number);
  66825. get bloomWeight(): number;
  66826. /**
  66827. * The strength of the bloom.
  66828. */
  66829. set bloomThreshold(value: number);
  66830. get bloomThreshold(): number;
  66831. /**
  66832. * The scale of the bloom, lower value will provide better performance.
  66833. */
  66834. set bloomScale(value: number);
  66835. get bloomScale(): number;
  66836. /**
  66837. * Enable or disable the bloom from the pipeline
  66838. */
  66839. set bloomEnabled(enabled: boolean);
  66840. get bloomEnabled(): boolean;
  66841. private _rebuildBloom;
  66842. /**
  66843. * If the depth of field is enabled.
  66844. */
  66845. get depthOfFieldEnabled(): boolean;
  66846. set depthOfFieldEnabled(enabled: boolean);
  66847. /**
  66848. * Blur level of the depth of field effect. (Higher blur will effect performance)
  66849. */
  66850. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  66851. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  66852. /**
  66853. * If the anti aliasing is enabled.
  66854. */
  66855. set fxaaEnabled(enabled: boolean);
  66856. get fxaaEnabled(): boolean;
  66857. private _samples;
  66858. /**
  66859. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66860. */
  66861. set samples(sampleCount: number);
  66862. get samples(): number;
  66863. /**
  66864. * If image processing is enabled.
  66865. */
  66866. set imageProcessingEnabled(enabled: boolean);
  66867. get imageProcessingEnabled(): boolean;
  66868. /**
  66869. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  66870. */
  66871. set glowLayerEnabled(enabled: boolean);
  66872. get glowLayerEnabled(): boolean;
  66873. /**
  66874. * Gets the glow layer (or null if not defined)
  66875. */
  66876. get glowLayer(): Nullable<GlowLayer>;
  66877. /**
  66878. * Enable or disable the chromaticAberration process from the pipeline
  66879. */
  66880. set chromaticAberrationEnabled(enabled: boolean);
  66881. get chromaticAberrationEnabled(): boolean;
  66882. /**
  66883. * Enable or disable the grain process from the pipeline
  66884. */
  66885. set grainEnabled(enabled: boolean);
  66886. get grainEnabled(): boolean;
  66887. /**
  66888. * @constructor
  66889. * @param name - The rendering pipeline name (default: "")
  66890. * @param hdr - If high dynamic range textures should be used (default: true)
  66891. * @param scene - The scene linked to this pipeline (default: the last created scene)
  66892. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  66893. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  66894. */
  66895. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  66896. /**
  66897. * Get the class name
  66898. * @returns "DefaultRenderingPipeline"
  66899. */
  66900. getClassName(): string;
  66901. /**
  66902. * Force the compilation of the entire pipeline.
  66903. */
  66904. prepare(): void;
  66905. private _hasCleared;
  66906. private _prevPostProcess;
  66907. private _prevPrevPostProcess;
  66908. private _setAutoClearAndTextureSharing;
  66909. private _depthOfFieldSceneObserver;
  66910. private _buildPipeline;
  66911. private _disposePostProcesses;
  66912. /**
  66913. * Adds a camera to the pipeline
  66914. * @param camera the camera to be added
  66915. */
  66916. addCamera(camera: Camera): void;
  66917. /**
  66918. * Removes a camera from the pipeline
  66919. * @param camera the camera to remove
  66920. */
  66921. removeCamera(camera: Camera): void;
  66922. /**
  66923. * Dispose of the pipeline and stop all post processes
  66924. */
  66925. dispose(): void;
  66926. /**
  66927. * Serialize the rendering pipeline (Used when exporting)
  66928. * @returns the serialized object
  66929. */
  66930. serialize(): any;
  66931. /**
  66932. * Parse the serialized pipeline
  66933. * @param source Source pipeline.
  66934. * @param scene The scene to load the pipeline to.
  66935. * @param rootUrl The URL of the serialized pipeline.
  66936. * @returns An instantiated pipeline from the serialized object.
  66937. */
  66938. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  66939. }
  66940. }
  66941. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  66942. /** @hidden */
  66943. export var lensHighlightsPixelShader: {
  66944. name: string;
  66945. shader: string;
  66946. };
  66947. }
  66948. declare module "babylonjs/Shaders/depthOfField.fragment" {
  66949. /** @hidden */
  66950. export var depthOfFieldPixelShader: {
  66951. name: string;
  66952. shader: string;
  66953. };
  66954. }
  66955. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  66956. import { Camera } from "babylonjs/Cameras/camera";
  66957. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  66958. import { Scene } from "babylonjs/scene";
  66959. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  66960. import "babylonjs/Shaders/chromaticAberration.fragment";
  66961. import "babylonjs/Shaders/lensHighlights.fragment";
  66962. import "babylonjs/Shaders/depthOfField.fragment";
  66963. /**
  66964. * BABYLON.JS Chromatic Aberration GLSL Shader
  66965. * Author: Olivier Guyot
  66966. * Separates very slightly R, G and B colors on the edges of the screen
  66967. * Inspired by Francois Tarlier & Martins Upitis
  66968. */
  66969. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  66970. /**
  66971. * @ignore
  66972. * The chromatic aberration PostProcess id in the pipeline
  66973. */
  66974. LensChromaticAberrationEffect: string;
  66975. /**
  66976. * @ignore
  66977. * The highlights enhancing PostProcess id in the pipeline
  66978. */
  66979. HighlightsEnhancingEffect: string;
  66980. /**
  66981. * @ignore
  66982. * The depth-of-field PostProcess id in the pipeline
  66983. */
  66984. LensDepthOfFieldEffect: string;
  66985. private _scene;
  66986. private _depthTexture;
  66987. private _grainTexture;
  66988. private _chromaticAberrationPostProcess;
  66989. private _highlightsPostProcess;
  66990. private _depthOfFieldPostProcess;
  66991. private _edgeBlur;
  66992. private _grainAmount;
  66993. private _chromaticAberration;
  66994. private _distortion;
  66995. private _highlightsGain;
  66996. private _highlightsThreshold;
  66997. private _dofDistance;
  66998. private _dofAperture;
  66999. private _dofDarken;
  67000. private _dofPentagon;
  67001. private _blurNoise;
  67002. /**
  67003. * @constructor
  67004. *
  67005. * Effect parameters are as follow:
  67006. * {
  67007. * chromatic_aberration: number; // from 0 to x (1 for realism)
  67008. * edge_blur: number; // from 0 to x (1 for realism)
  67009. * distortion: number; // from 0 to x (1 for realism)
  67010. * grain_amount: number; // from 0 to 1
  67011. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  67012. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  67013. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  67014. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  67015. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  67016. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  67017. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  67018. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  67019. * }
  67020. * Note: if an effect parameter is unset, effect is disabled
  67021. *
  67022. * @param name The rendering pipeline name
  67023. * @param parameters - An object containing all parameters (see above)
  67024. * @param scene The scene linked to this pipeline
  67025. * @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)
  67026. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67027. */
  67028. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  67029. /**
  67030. * Get the class name
  67031. * @returns "LensRenderingPipeline"
  67032. */
  67033. getClassName(): string;
  67034. /**
  67035. * Gets associated scene
  67036. */
  67037. get scene(): Scene;
  67038. /**
  67039. * Gets or sets the edge blur
  67040. */
  67041. get edgeBlur(): number;
  67042. set edgeBlur(value: number);
  67043. /**
  67044. * Gets or sets the grain amount
  67045. */
  67046. get grainAmount(): number;
  67047. set grainAmount(value: number);
  67048. /**
  67049. * Gets or sets the chromatic aberration amount
  67050. */
  67051. get chromaticAberration(): number;
  67052. set chromaticAberration(value: number);
  67053. /**
  67054. * Gets or sets the depth of field aperture
  67055. */
  67056. get dofAperture(): number;
  67057. set dofAperture(value: number);
  67058. /**
  67059. * Gets or sets the edge distortion
  67060. */
  67061. get edgeDistortion(): number;
  67062. set edgeDistortion(value: number);
  67063. /**
  67064. * Gets or sets the depth of field distortion
  67065. */
  67066. get dofDistortion(): number;
  67067. set dofDistortion(value: number);
  67068. /**
  67069. * Gets or sets the darken out of focus amount
  67070. */
  67071. get darkenOutOfFocus(): number;
  67072. set darkenOutOfFocus(value: number);
  67073. /**
  67074. * Gets or sets a boolean indicating if blur noise is enabled
  67075. */
  67076. get blurNoise(): boolean;
  67077. set blurNoise(value: boolean);
  67078. /**
  67079. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  67080. */
  67081. get pentagonBokeh(): boolean;
  67082. set pentagonBokeh(value: boolean);
  67083. /**
  67084. * Gets or sets the highlight grain amount
  67085. */
  67086. get highlightsGain(): number;
  67087. set highlightsGain(value: number);
  67088. /**
  67089. * Gets or sets the highlight threshold
  67090. */
  67091. get highlightsThreshold(): number;
  67092. set highlightsThreshold(value: number);
  67093. /**
  67094. * Sets the amount of blur at the edges
  67095. * @param amount blur amount
  67096. */
  67097. setEdgeBlur(amount: number): void;
  67098. /**
  67099. * Sets edge blur to 0
  67100. */
  67101. disableEdgeBlur(): void;
  67102. /**
  67103. * Sets the amout of grain
  67104. * @param amount Amount of grain
  67105. */
  67106. setGrainAmount(amount: number): void;
  67107. /**
  67108. * Set grain amount to 0
  67109. */
  67110. disableGrain(): void;
  67111. /**
  67112. * Sets the chromatic aberration amount
  67113. * @param amount amount of chromatic aberration
  67114. */
  67115. setChromaticAberration(amount: number): void;
  67116. /**
  67117. * Sets chromatic aberration amount to 0
  67118. */
  67119. disableChromaticAberration(): void;
  67120. /**
  67121. * Sets the EdgeDistortion amount
  67122. * @param amount amount of EdgeDistortion
  67123. */
  67124. setEdgeDistortion(amount: number): void;
  67125. /**
  67126. * Sets edge distortion to 0
  67127. */
  67128. disableEdgeDistortion(): void;
  67129. /**
  67130. * Sets the FocusDistance amount
  67131. * @param amount amount of FocusDistance
  67132. */
  67133. setFocusDistance(amount: number): void;
  67134. /**
  67135. * Disables depth of field
  67136. */
  67137. disableDepthOfField(): void;
  67138. /**
  67139. * Sets the Aperture amount
  67140. * @param amount amount of Aperture
  67141. */
  67142. setAperture(amount: number): void;
  67143. /**
  67144. * Sets the DarkenOutOfFocus amount
  67145. * @param amount amount of DarkenOutOfFocus
  67146. */
  67147. setDarkenOutOfFocus(amount: number): void;
  67148. private _pentagonBokehIsEnabled;
  67149. /**
  67150. * Creates a pentagon bokeh effect
  67151. */
  67152. enablePentagonBokeh(): void;
  67153. /**
  67154. * Disables the pentagon bokeh effect
  67155. */
  67156. disablePentagonBokeh(): void;
  67157. /**
  67158. * Enables noise blur
  67159. */
  67160. enableNoiseBlur(): void;
  67161. /**
  67162. * Disables noise blur
  67163. */
  67164. disableNoiseBlur(): void;
  67165. /**
  67166. * Sets the HighlightsGain amount
  67167. * @param amount amount of HighlightsGain
  67168. */
  67169. setHighlightsGain(amount: number): void;
  67170. /**
  67171. * Sets the HighlightsThreshold amount
  67172. * @param amount amount of HighlightsThreshold
  67173. */
  67174. setHighlightsThreshold(amount: number): void;
  67175. /**
  67176. * Disables highlights
  67177. */
  67178. disableHighlights(): void;
  67179. /**
  67180. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  67181. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  67182. */
  67183. dispose(disableDepthRender?: boolean): void;
  67184. private _createChromaticAberrationPostProcess;
  67185. private _createHighlightsPostProcess;
  67186. private _createDepthOfFieldPostProcess;
  67187. private _createGrainTexture;
  67188. }
  67189. }
  67190. declare module "babylonjs/Shaders/ssao2.fragment" {
  67191. /** @hidden */
  67192. export var ssao2PixelShader: {
  67193. name: string;
  67194. shader: string;
  67195. };
  67196. }
  67197. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  67198. /** @hidden */
  67199. export var ssaoCombinePixelShader: {
  67200. name: string;
  67201. shader: string;
  67202. };
  67203. }
  67204. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  67205. import { Camera } from "babylonjs/Cameras/camera";
  67206. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67207. import { Scene } from "babylonjs/scene";
  67208. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67209. import "babylonjs/Shaders/ssao2.fragment";
  67210. import "babylonjs/Shaders/ssaoCombine.fragment";
  67211. /**
  67212. * Render pipeline to produce ssao effect
  67213. */
  67214. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  67215. /**
  67216. * @ignore
  67217. * The PassPostProcess id in the pipeline that contains the original scene color
  67218. */
  67219. SSAOOriginalSceneColorEffect: string;
  67220. /**
  67221. * @ignore
  67222. * The SSAO PostProcess id in the pipeline
  67223. */
  67224. SSAORenderEffect: string;
  67225. /**
  67226. * @ignore
  67227. * The horizontal blur PostProcess id in the pipeline
  67228. */
  67229. SSAOBlurHRenderEffect: string;
  67230. /**
  67231. * @ignore
  67232. * The vertical blur PostProcess id in the pipeline
  67233. */
  67234. SSAOBlurVRenderEffect: string;
  67235. /**
  67236. * @ignore
  67237. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  67238. */
  67239. SSAOCombineRenderEffect: string;
  67240. /**
  67241. * The output strength of the SSAO post-process. Default value is 1.0.
  67242. */
  67243. totalStrength: number;
  67244. /**
  67245. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  67246. */
  67247. maxZ: number;
  67248. /**
  67249. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  67250. */
  67251. minZAspect: number;
  67252. private _samples;
  67253. /**
  67254. * Number of samples used for the SSAO calculations. Default value is 8
  67255. */
  67256. set samples(n: number);
  67257. get samples(): number;
  67258. private _textureSamples;
  67259. /**
  67260. * Number of samples to use for antialiasing
  67261. */
  67262. set textureSamples(n: number);
  67263. get textureSamples(): number;
  67264. /**
  67265. * Ratio object used for SSAO ratio and blur ratio
  67266. */
  67267. private _ratio;
  67268. /**
  67269. * Dynamically generated sphere sampler.
  67270. */
  67271. private _sampleSphere;
  67272. /**
  67273. * Blur filter offsets
  67274. */
  67275. private _samplerOffsets;
  67276. private _expensiveBlur;
  67277. /**
  67278. * If bilateral blur should be used
  67279. */
  67280. set expensiveBlur(b: boolean);
  67281. get expensiveBlur(): boolean;
  67282. /**
  67283. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  67284. */
  67285. radius: number;
  67286. /**
  67287. * The base color of the SSAO post-process
  67288. * The final result is "base + ssao" between [0, 1]
  67289. */
  67290. base: number;
  67291. /**
  67292. * Support test.
  67293. */
  67294. static get IsSupported(): boolean;
  67295. private _scene;
  67296. private _depthTexture;
  67297. private _normalTexture;
  67298. private _randomTexture;
  67299. private _originalColorPostProcess;
  67300. private _ssaoPostProcess;
  67301. private _blurHPostProcess;
  67302. private _blurVPostProcess;
  67303. private _ssaoCombinePostProcess;
  67304. /**
  67305. * Gets active scene
  67306. */
  67307. get scene(): Scene;
  67308. /**
  67309. * @constructor
  67310. * @param name The rendering pipeline name
  67311. * @param scene The scene linked to this pipeline
  67312. * @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 }
  67313. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67314. */
  67315. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  67316. /**
  67317. * Get the class name
  67318. * @returns "SSAO2RenderingPipeline"
  67319. */
  67320. getClassName(): string;
  67321. /**
  67322. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  67323. */
  67324. dispose(disableGeometryBufferRenderer?: boolean): void;
  67325. private _createBlurPostProcess;
  67326. /** @hidden */
  67327. _rebuild(): void;
  67328. private _bits;
  67329. private _radicalInverse_VdC;
  67330. private _hammersley;
  67331. private _hemisphereSample_uniform;
  67332. private _generateHemisphere;
  67333. private _createSSAOPostProcess;
  67334. private _createSSAOCombinePostProcess;
  67335. private _createRandomTexture;
  67336. /**
  67337. * Serialize the rendering pipeline (Used when exporting)
  67338. * @returns the serialized object
  67339. */
  67340. serialize(): any;
  67341. /**
  67342. * Parse the serialized pipeline
  67343. * @param source Source pipeline.
  67344. * @param scene The scene to load the pipeline to.
  67345. * @param rootUrl The URL of the serialized pipeline.
  67346. * @returns An instantiated pipeline from the serialized object.
  67347. */
  67348. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  67349. }
  67350. }
  67351. declare module "babylonjs/Shaders/ssao.fragment" {
  67352. /** @hidden */
  67353. export var ssaoPixelShader: {
  67354. name: string;
  67355. shader: string;
  67356. };
  67357. }
  67358. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  67359. import { Camera } from "babylonjs/Cameras/camera";
  67360. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67361. import { Scene } from "babylonjs/scene";
  67362. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67363. import "babylonjs/Shaders/ssao.fragment";
  67364. import "babylonjs/Shaders/ssaoCombine.fragment";
  67365. /**
  67366. * Render pipeline to produce ssao effect
  67367. */
  67368. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  67369. /**
  67370. * @ignore
  67371. * The PassPostProcess id in the pipeline that contains the original scene color
  67372. */
  67373. SSAOOriginalSceneColorEffect: string;
  67374. /**
  67375. * @ignore
  67376. * The SSAO PostProcess id in the pipeline
  67377. */
  67378. SSAORenderEffect: string;
  67379. /**
  67380. * @ignore
  67381. * The horizontal blur PostProcess id in the pipeline
  67382. */
  67383. SSAOBlurHRenderEffect: string;
  67384. /**
  67385. * @ignore
  67386. * The vertical blur PostProcess id in the pipeline
  67387. */
  67388. SSAOBlurVRenderEffect: string;
  67389. /**
  67390. * @ignore
  67391. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  67392. */
  67393. SSAOCombineRenderEffect: string;
  67394. /**
  67395. * The output strength of the SSAO post-process. Default value is 1.0.
  67396. */
  67397. totalStrength: number;
  67398. /**
  67399. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  67400. */
  67401. radius: number;
  67402. /**
  67403. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  67404. * Must not be equal to fallOff and superior to fallOff.
  67405. * Default value is 0.0075
  67406. */
  67407. area: number;
  67408. /**
  67409. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  67410. * Must not be equal to area and inferior to area.
  67411. * Default value is 0.000001
  67412. */
  67413. fallOff: number;
  67414. /**
  67415. * The base color of the SSAO post-process
  67416. * The final result is "base + ssao" between [0, 1]
  67417. */
  67418. base: number;
  67419. private _scene;
  67420. private _depthTexture;
  67421. private _randomTexture;
  67422. private _originalColorPostProcess;
  67423. private _ssaoPostProcess;
  67424. private _blurHPostProcess;
  67425. private _blurVPostProcess;
  67426. private _ssaoCombinePostProcess;
  67427. private _firstUpdate;
  67428. /**
  67429. * Gets active scene
  67430. */
  67431. get scene(): Scene;
  67432. /**
  67433. * @constructor
  67434. * @param name - The rendering pipeline name
  67435. * @param scene - The scene linked to this pipeline
  67436. * @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 }
  67437. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  67438. */
  67439. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  67440. /**
  67441. * Get the class name
  67442. * @returns "SSAORenderingPipeline"
  67443. */
  67444. getClassName(): string;
  67445. /**
  67446. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  67447. */
  67448. dispose(disableDepthRender?: boolean): void;
  67449. private _createBlurPostProcess;
  67450. /** @hidden */
  67451. _rebuild(): void;
  67452. private _createSSAOPostProcess;
  67453. private _createSSAOCombinePostProcess;
  67454. private _createRandomTexture;
  67455. }
  67456. }
  67457. declare module "babylonjs/Shaders/standard.fragment" {
  67458. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  67459. /** @hidden */
  67460. export var standardPixelShader: {
  67461. name: string;
  67462. shader: string;
  67463. };
  67464. }
  67465. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  67466. import { Nullable } from "babylonjs/types";
  67467. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  67468. import { Camera } from "babylonjs/Cameras/camera";
  67469. import { Texture } from "babylonjs/Materials/Textures/texture";
  67470. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67471. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67472. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67473. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  67474. import { IDisposable } from "babylonjs/scene";
  67475. import { SpotLight } from "babylonjs/Lights/spotLight";
  67476. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  67477. import { Scene } from "babylonjs/scene";
  67478. import { Animation } from "babylonjs/Animations/animation";
  67479. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67480. import "babylonjs/Shaders/standard.fragment";
  67481. /**
  67482. * Standard rendering pipeline
  67483. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  67484. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  67485. */
  67486. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  67487. /**
  67488. * Public members
  67489. */
  67490. /**
  67491. * Post-process which contains the original scene color before the pipeline applies all the effects
  67492. */
  67493. originalPostProcess: Nullable<PostProcess>;
  67494. /**
  67495. * Post-process used to down scale an image x4
  67496. */
  67497. downSampleX4PostProcess: Nullable<PostProcess>;
  67498. /**
  67499. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  67500. */
  67501. brightPassPostProcess: Nullable<PostProcess>;
  67502. /**
  67503. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  67504. */
  67505. blurHPostProcesses: PostProcess[];
  67506. /**
  67507. * Post-process array storing all the vertical blur post-processes used by the pipeline
  67508. */
  67509. blurVPostProcesses: PostProcess[];
  67510. /**
  67511. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  67512. */
  67513. textureAdderPostProcess: Nullable<PostProcess>;
  67514. /**
  67515. * Post-process used to create volumetric lighting effect
  67516. */
  67517. volumetricLightPostProcess: Nullable<PostProcess>;
  67518. /**
  67519. * Post-process used to smooth the previous volumetric light post-process on the X axis
  67520. */
  67521. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  67522. /**
  67523. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  67524. */
  67525. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  67526. /**
  67527. * Post-process used to merge the volumetric light effect and the real scene color
  67528. */
  67529. volumetricLightMergePostProces: Nullable<PostProcess>;
  67530. /**
  67531. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  67532. */
  67533. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  67534. /**
  67535. * Base post-process used to calculate the average luminance of the final image for HDR
  67536. */
  67537. luminancePostProcess: Nullable<PostProcess>;
  67538. /**
  67539. * Post-processes used to create down sample post-processes in order to get
  67540. * the average luminance of the final image for HDR
  67541. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  67542. */
  67543. luminanceDownSamplePostProcesses: PostProcess[];
  67544. /**
  67545. * Post-process used to create a HDR effect (light adaptation)
  67546. */
  67547. hdrPostProcess: Nullable<PostProcess>;
  67548. /**
  67549. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  67550. */
  67551. textureAdderFinalPostProcess: Nullable<PostProcess>;
  67552. /**
  67553. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  67554. */
  67555. lensFlareFinalPostProcess: Nullable<PostProcess>;
  67556. /**
  67557. * Post-process used to merge the final HDR post-process and the real scene color
  67558. */
  67559. hdrFinalPostProcess: Nullable<PostProcess>;
  67560. /**
  67561. * Post-process used to create a lens flare effect
  67562. */
  67563. lensFlarePostProcess: Nullable<PostProcess>;
  67564. /**
  67565. * Post-process that merges the result of the lens flare post-process and the real scene color
  67566. */
  67567. lensFlareComposePostProcess: Nullable<PostProcess>;
  67568. /**
  67569. * Post-process used to create a motion blur effect
  67570. */
  67571. motionBlurPostProcess: Nullable<PostProcess>;
  67572. /**
  67573. * Post-process used to create a depth of field effect
  67574. */
  67575. depthOfFieldPostProcess: Nullable<PostProcess>;
  67576. /**
  67577. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  67578. */
  67579. fxaaPostProcess: Nullable<FxaaPostProcess>;
  67580. /**
  67581. * Represents the brightness threshold in order to configure the illuminated surfaces
  67582. */
  67583. brightThreshold: number;
  67584. /**
  67585. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  67586. */
  67587. blurWidth: number;
  67588. /**
  67589. * Sets if the blur for highlighted surfaces must be only horizontal
  67590. */
  67591. horizontalBlur: boolean;
  67592. /**
  67593. * Gets the overall exposure used by the pipeline
  67594. */
  67595. get exposure(): number;
  67596. /**
  67597. * Sets the overall exposure used by the pipeline
  67598. */
  67599. set exposure(value: number);
  67600. /**
  67601. * Texture used typically to simulate "dirty" on camera lens
  67602. */
  67603. lensTexture: Nullable<Texture>;
  67604. /**
  67605. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  67606. */
  67607. volumetricLightCoefficient: number;
  67608. /**
  67609. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  67610. */
  67611. volumetricLightPower: number;
  67612. /**
  67613. * Used the set the blur intensity to smooth the volumetric lights
  67614. */
  67615. volumetricLightBlurScale: number;
  67616. /**
  67617. * Light (spot or directional) used to generate the volumetric lights rays
  67618. * The source light must have a shadow generate so the pipeline can get its
  67619. * depth map
  67620. */
  67621. sourceLight: Nullable<SpotLight | DirectionalLight>;
  67622. /**
  67623. * For eye adaptation, represents the minimum luminance the eye can see
  67624. */
  67625. hdrMinimumLuminance: number;
  67626. /**
  67627. * For eye adaptation, represents the decrease luminance speed
  67628. */
  67629. hdrDecreaseRate: number;
  67630. /**
  67631. * For eye adaptation, represents the increase luminance speed
  67632. */
  67633. hdrIncreaseRate: number;
  67634. /**
  67635. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  67636. */
  67637. get hdrAutoExposure(): boolean;
  67638. /**
  67639. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  67640. */
  67641. set hdrAutoExposure(value: boolean);
  67642. /**
  67643. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  67644. */
  67645. lensColorTexture: Nullable<Texture>;
  67646. /**
  67647. * The overall strengh for the lens flare effect
  67648. */
  67649. lensFlareStrength: number;
  67650. /**
  67651. * Dispersion coefficient for lens flare ghosts
  67652. */
  67653. lensFlareGhostDispersal: number;
  67654. /**
  67655. * Main lens flare halo width
  67656. */
  67657. lensFlareHaloWidth: number;
  67658. /**
  67659. * Based on the lens distortion effect, defines how much the lens flare result
  67660. * is distorted
  67661. */
  67662. lensFlareDistortionStrength: number;
  67663. /**
  67664. * Configures the blur intensity used for for lens flare (halo)
  67665. */
  67666. lensFlareBlurWidth: number;
  67667. /**
  67668. * Lens star texture must be used to simulate rays on the flares and is available
  67669. * in the documentation
  67670. */
  67671. lensStarTexture: Nullable<Texture>;
  67672. /**
  67673. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  67674. * flare effect by taking account of the dirt texture
  67675. */
  67676. lensFlareDirtTexture: Nullable<Texture>;
  67677. /**
  67678. * Represents the focal length for the depth of field effect
  67679. */
  67680. depthOfFieldDistance: number;
  67681. /**
  67682. * Represents the blur intensity for the blurred part of the depth of field effect
  67683. */
  67684. depthOfFieldBlurWidth: number;
  67685. /**
  67686. * Gets how much the image is blurred by the movement while using the motion blur post-process
  67687. */
  67688. get motionStrength(): number;
  67689. /**
  67690. * Sets how much the image is blurred by the movement while using the motion blur post-process
  67691. */
  67692. set motionStrength(strength: number);
  67693. /**
  67694. * Gets wether or not the motion blur post-process is object based or screen based.
  67695. */
  67696. get objectBasedMotionBlur(): boolean;
  67697. /**
  67698. * Sets wether or not the motion blur post-process should be object based or screen based
  67699. */
  67700. set objectBasedMotionBlur(value: boolean);
  67701. /**
  67702. * List of animations for the pipeline (IAnimatable implementation)
  67703. */
  67704. animations: Animation[];
  67705. /**
  67706. * Private members
  67707. */
  67708. private _scene;
  67709. private _currentDepthOfFieldSource;
  67710. private _basePostProcess;
  67711. private _fixedExposure;
  67712. private _currentExposure;
  67713. private _hdrAutoExposure;
  67714. private _hdrCurrentLuminance;
  67715. private _motionStrength;
  67716. private _isObjectBasedMotionBlur;
  67717. private _floatTextureType;
  67718. private _camerasToBeAttached;
  67719. private _ratio;
  67720. private _bloomEnabled;
  67721. private _depthOfFieldEnabled;
  67722. private _vlsEnabled;
  67723. private _lensFlareEnabled;
  67724. private _hdrEnabled;
  67725. private _motionBlurEnabled;
  67726. private _fxaaEnabled;
  67727. private _motionBlurSamples;
  67728. private _volumetricLightStepsCount;
  67729. private _samples;
  67730. /**
  67731. * @ignore
  67732. * Specifies if the bloom pipeline is enabled
  67733. */
  67734. get BloomEnabled(): boolean;
  67735. set BloomEnabled(enabled: boolean);
  67736. /**
  67737. * @ignore
  67738. * Specifies if the depth of field pipeline is enabed
  67739. */
  67740. get DepthOfFieldEnabled(): boolean;
  67741. set DepthOfFieldEnabled(enabled: boolean);
  67742. /**
  67743. * @ignore
  67744. * Specifies if the lens flare pipeline is enabed
  67745. */
  67746. get LensFlareEnabled(): boolean;
  67747. set LensFlareEnabled(enabled: boolean);
  67748. /**
  67749. * @ignore
  67750. * Specifies if the HDR pipeline is enabled
  67751. */
  67752. get HDREnabled(): boolean;
  67753. set HDREnabled(enabled: boolean);
  67754. /**
  67755. * @ignore
  67756. * Specifies if the volumetric lights scattering effect is enabled
  67757. */
  67758. get VLSEnabled(): boolean;
  67759. set VLSEnabled(enabled: boolean);
  67760. /**
  67761. * @ignore
  67762. * Specifies if the motion blur effect is enabled
  67763. */
  67764. get MotionBlurEnabled(): boolean;
  67765. set MotionBlurEnabled(enabled: boolean);
  67766. /**
  67767. * Specifies if anti-aliasing is enabled
  67768. */
  67769. get fxaaEnabled(): boolean;
  67770. set fxaaEnabled(enabled: boolean);
  67771. /**
  67772. * Specifies the number of steps used to calculate the volumetric lights
  67773. * Typically in interval [50, 200]
  67774. */
  67775. get volumetricLightStepsCount(): number;
  67776. set volumetricLightStepsCount(count: number);
  67777. /**
  67778. * Specifies the number of samples used for the motion blur effect
  67779. * Typically in interval [16, 64]
  67780. */
  67781. get motionBlurSamples(): number;
  67782. set motionBlurSamples(samples: number);
  67783. /**
  67784. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  67785. */
  67786. get samples(): number;
  67787. set samples(sampleCount: number);
  67788. /**
  67789. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  67790. * @constructor
  67791. * @param name The rendering pipeline name
  67792. * @param scene The scene linked to this pipeline
  67793. * @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)
  67794. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  67795. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67796. */
  67797. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  67798. private _buildPipeline;
  67799. private _createDownSampleX4PostProcess;
  67800. private _createBrightPassPostProcess;
  67801. private _createBlurPostProcesses;
  67802. private _createTextureAdderPostProcess;
  67803. private _createVolumetricLightPostProcess;
  67804. private _createLuminancePostProcesses;
  67805. private _createHdrPostProcess;
  67806. private _createLensFlarePostProcess;
  67807. private _createDepthOfFieldPostProcess;
  67808. private _createMotionBlurPostProcess;
  67809. private _getDepthTexture;
  67810. private _disposePostProcesses;
  67811. /**
  67812. * Dispose of the pipeline and stop all post processes
  67813. */
  67814. dispose(): void;
  67815. /**
  67816. * Serialize the rendering pipeline (Used when exporting)
  67817. * @returns the serialized object
  67818. */
  67819. serialize(): any;
  67820. /**
  67821. * Parse the serialized pipeline
  67822. * @param source Source pipeline.
  67823. * @param scene The scene to load the pipeline to.
  67824. * @param rootUrl The URL of the serialized pipeline.
  67825. * @returns An instantiated pipeline from the serialized object.
  67826. */
  67827. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  67828. /**
  67829. * Luminance steps
  67830. */
  67831. static LuminanceSteps: number;
  67832. }
  67833. }
  67834. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  67835. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  67836. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  67837. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  67838. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  67839. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  67840. }
  67841. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  67842. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  67843. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67844. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67845. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  67846. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67847. }
  67848. declare module "babylonjs/Shaders/tonemap.fragment" {
  67849. /** @hidden */
  67850. export var tonemapPixelShader: {
  67851. name: string;
  67852. shader: string;
  67853. };
  67854. }
  67855. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  67856. import { Camera } from "babylonjs/Cameras/camera";
  67857. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67858. import "babylonjs/Shaders/tonemap.fragment";
  67859. import { Engine } from "babylonjs/Engines/engine";
  67860. /** Defines operator used for tonemapping */
  67861. export enum TonemappingOperator {
  67862. /** Hable */
  67863. Hable = 0,
  67864. /** Reinhard */
  67865. Reinhard = 1,
  67866. /** HejiDawson */
  67867. HejiDawson = 2,
  67868. /** Photographic */
  67869. Photographic = 3
  67870. }
  67871. /**
  67872. * Defines a post process to apply tone mapping
  67873. */
  67874. export class TonemapPostProcess extends PostProcess {
  67875. private _operator;
  67876. /** Defines the required exposure adjustement */
  67877. exposureAdjustment: number;
  67878. /**
  67879. * Creates a new TonemapPostProcess
  67880. * @param name defines the name of the postprocess
  67881. * @param _operator defines the operator to use
  67882. * @param exposureAdjustment defines the required exposure adjustement
  67883. * @param camera defines the camera to use (can be null)
  67884. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  67885. * @param engine defines the hosting engine (can be ignore if camera is set)
  67886. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67887. */
  67888. constructor(name: string, _operator: TonemappingOperator,
  67889. /** Defines the required exposure adjustement */
  67890. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  67891. }
  67892. }
  67893. declare module "babylonjs/Shaders/depth.vertex" {
  67894. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67895. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67896. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67897. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67898. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67899. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67900. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67901. /** @hidden */
  67902. export var depthVertexShader: {
  67903. name: string;
  67904. shader: string;
  67905. };
  67906. }
  67907. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  67908. /** @hidden */
  67909. export var volumetricLightScatteringPixelShader: {
  67910. name: string;
  67911. shader: string;
  67912. };
  67913. }
  67914. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  67915. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67916. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67917. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67918. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67919. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67920. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67921. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67922. /** @hidden */
  67923. export var volumetricLightScatteringPassVertexShader: {
  67924. name: string;
  67925. shader: string;
  67926. };
  67927. }
  67928. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  67929. /** @hidden */
  67930. export var volumetricLightScatteringPassPixelShader: {
  67931. name: string;
  67932. shader: string;
  67933. };
  67934. }
  67935. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  67936. import { Vector3 } from "babylonjs/Maths/math.vector";
  67937. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67938. import { Mesh } from "babylonjs/Meshes/mesh";
  67939. import { Camera } from "babylonjs/Cameras/camera";
  67940. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67941. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67942. import { Scene } from "babylonjs/scene";
  67943. import "babylonjs/Meshes/Builders/planeBuilder";
  67944. import "babylonjs/Shaders/depth.vertex";
  67945. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  67946. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  67947. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  67948. import { Engine } from "babylonjs/Engines/engine";
  67949. /**
  67950. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  67951. */
  67952. export class VolumetricLightScatteringPostProcess extends PostProcess {
  67953. private _volumetricLightScatteringPass;
  67954. private _volumetricLightScatteringRTT;
  67955. private _viewPort;
  67956. private _screenCoordinates;
  67957. private _cachedDefines;
  67958. /**
  67959. * If not undefined, the mesh position is computed from the attached node position
  67960. */
  67961. attachedNode: {
  67962. position: Vector3;
  67963. };
  67964. /**
  67965. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  67966. */
  67967. customMeshPosition: Vector3;
  67968. /**
  67969. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  67970. */
  67971. useCustomMeshPosition: boolean;
  67972. /**
  67973. * If the post-process should inverse the light scattering direction
  67974. */
  67975. invert: boolean;
  67976. /**
  67977. * The internal mesh used by the post-process
  67978. */
  67979. mesh: Mesh;
  67980. /**
  67981. * @hidden
  67982. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  67983. */
  67984. get useDiffuseColor(): boolean;
  67985. set useDiffuseColor(useDiffuseColor: boolean);
  67986. /**
  67987. * Array containing the excluded meshes not rendered in the internal pass
  67988. */
  67989. excludedMeshes: AbstractMesh[];
  67990. /**
  67991. * Controls the overall intensity of the post-process
  67992. */
  67993. exposure: number;
  67994. /**
  67995. * Dissipates each sample's contribution in range [0, 1]
  67996. */
  67997. decay: number;
  67998. /**
  67999. * Controls the overall intensity of each sample
  68000. */
  68001. weight: number;
  68002. /**
  68003. * Controls the density of each sample
  68004. */
  68005. density: number;
  68006. /**
  68007. * @constructor
  68008. * @param name The post-process name
  68009. * @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)
  68010. * @param camera The camera that the post-process will be attached to
  68011. * @param mesh The mesh used to create the light scattering
  68012. * @param samples The post-process quality, default 100
  68013. * @param samplingModeThe post-process filtering mode
  68014. * @param engine The babylon engine
  68015. * @param reusable If the post-process is reusable
  68016. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  68017. */
  68018. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  68019. /**
  68020. * Returns the string "VolumetricLightScatteringPostProcess"
  68021. * @returns "VolumetricLightScatteringPostProcess"
  68022. */
  68023. getClassName(): string;
  68024. private _isReady;
  68025. /**
  68026. * Sets the new light position for light scattering effect
  68027. * @param position The new custom light position
  68028. */
  68029. setCustomMeshPosition(position: Vector3): void;
  68030. /**
  68031. * Returns the light position for light scattering effect
  68032. * @return Vector3 The custom light position
  68033. */
  68034. getCustomMeshPosition(): Vector3;
  68035. /**
  68036. * Disposes the internal assets and detaches the post-process from the camera
  68037. */
  68038. dispose(camera: Camera): void;
  68039. /**
  68040. * Returns the render target texture used by the post-process
  68041. * @return the render target texture used by the post-process
  68042. */
  68043. getPass(): RenderTargetTexture;
  68044. private _meshExcluded;
  68045. private _createPass;
  68046. private _updateMeshScreenCoordinates;
  68047. /**
  68048. * Creates a default mesh for the Volumeric Light Scattering post-process
  68049. * @param name The mesh name
  68050. * @param scene The scene where to create the mesh
  68051. * @return the default mesh
  68052. */
  68053. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  68054. }
  68055. }
  68056. declare module "babylonjs/PostProcesses/index" {
  68057. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  68058. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  68059. export * from "babylonjs/PostProcesses/bloomEffect";
  68060. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  68061. export * from "babylonjs/PostProcesses/blurPostProcess";
  68062. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68063. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  68064. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  68065. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  68066. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  68067. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  68068. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  68069. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  68070. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  68071. export * from "babylonjs/PostProcesses/filterPostProcess";
  68072. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  68073. export * from "babylonjs/PostProcesses/grainPostProcess";
  68074. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  68075. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68076. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  68077. export * from "babylonjs/PostProcesses/passPostProcess";
  68078. export * from "babylonjs/PostProcesses/postProcess";
  68079. export * from "babylonjs/PostProcesses/postProcessManager";
  68080. export * from "babylonjs/PostProcesses/refractionPostProcess";
  68081. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  68082. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  68083. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  68084. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  68085. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  68086. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  68087. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  68088. }
  68089. declare module "babylonjs/Probes/index" {
  68090. export * from "babylonjs/Probes/reflectionProbe";
  68091. }
  68092. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  68093. import { Scene } from "babylonjs/scene";
  68094. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68095. import { SmartArray } from "babylonjs/Misc/smartArray";
  68096. import { ISceneComponent } from "babylonjs/sceneComponent";
  68097. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  68098. import "babylonjs/Meshes/Builders/boxBuilder";
  68099. import "babylonjs/Shaders/color.fragment";
  68100. import "babylonjs/Shaders/color.vertex";
  68101. import { Color3 } from "babylonjs/Maths/math.color";
  68102. module "babylonjs/scene" {
  68103. interface Scene {
  68104. /** @hidden (Backing field) */
  68105. _boundingBoxRenderer: BoundingBoxRenderer;
  68106. /** @hidden (Backing field) */
  68107. _forceShowBoundingBoxes: boolean;
  68108. /**
  68109. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  68110. */
  68111. forceShowBoundingBoxes: boolean;
  68112. /**
  68113. * Gets the bounding box renderer associated with the scene
  68114. * @returns a BoundingBoxRenderer
  68115. */
  68116. getBoundingBoxRenderer(): BoundingBoxRenderer;
  68117. }
  68118. }
  68119. module "babylonjs/Meshes/abstractMesh" {
  68120. interface AbstractMesh {
  68121. /** @hidden (Backing field) */
  68122. _showBoundingBox: boolean;
  68123. /**
  68124. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  68125. */
  68126. showBoundingBox: boolean;
  68127. }
  68128. }
  68129. /**
  68130. * Component responsible of rendering the bounding box of the meshes in a scene.
  68131. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  68132. */
  68133. export class BoundingBoxRenderer implements ISceneComponent {
  68134. /**
  68135. * The component name helpfull to identify the component in the list of scene components.
  68136. */
  68137. readonly name: string;
  68138. /**
  68139. * The scene the component belongs to.
  68140. */
  68141. scene: Scene;
  68142. /**
  68143. * Color of the bounding box lines placed in front of an object
  68144. */
  68145. frontColor: Color3;
  68146. /**
  68147. * Color of the bounding box lines placed behind an object
  68148. */
  68149. backColor: Color3;
  68150. /**
  68151. * Defines if the renderer should show the back lines or not
  68152. */
  68153. showBackLines: boolean;
  68154. /**
  68155. * @hidden
  68156. */
  68157. renderList: SmartArray<BoundingBox>;
  68158. private _colorShader;
  68159. private _vertexBuffers;
  68160. private _indexBuffer;
  68161. private _fillIndexBuffer;
  68162. private _fillIndexData;
  68163. /**
  68164. * Instantiates a new bounding box renderer in a scene.
  68165. * @param scene the scene the renderer renders in
  68166. */
  68167. constructor(scene: Scene);
  68168. /**
  68169. * Registers the component in a given scene
  68170. */
  68171. register(): void;
  68172. private _evaluateSubMesh;
  68173. private _activeMesh;
  68174. private _prepareRessources;
  68175. private _createIndexBuffer;
  68176. /**
  68177. * Rebuilds the elements related to this component in case of
  68178. * context lost for instance.
  68179. */
  68180. rebuild(): void;
  68181. /**
  68182. * @hidden
  68183. */
  68184. reset(): void;
  68185. /**
  68186. * Render the bounding boxes of a specific rendering group
  68187. * @param renderingGroupId defines the rendering group to render
  68188. */
  68189. render(renderingGroupId: number): void;
  68190. /**
  68191. * In case of occlusion queries, we can render the occlusion bounding box through this method
  68192. * @param mesh Define the mesh to render the occlusion bounding box for
  68193. */
  68194. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  68195. /**
  68196. * Dispose and release the resources attached to this renderer.
  68197. */
  68198. dispose(): void;
  68199. }
  68200. }
  68201. declare module "babylonjs/Shaders/depth.fragment" {
  68202. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  68203. /** @hidden */
  68204. export var depthPixelShader: {
  68205. name: string;
  68206. shader: string;
  68207. };
  68208. }
  68209. declare module "babylonjs/Rendering/depthRenderer" {
  68210. import { Nullable } from "babylonjs/types";
  68211. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68212. import { Scene } from "babylonjs/scene";
  68213. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68214. import { Camera } from "babylonjs/Cameras/camera";
  68215. import "babylonjs/Shaders/depth.fragment";
  68216. import "babylonjs/Shaders/depth.vertex";
  68217. /**
  68218. * This represents a depth renderer in Babylon.
  68219. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  68220. */
  68221. export class DepthRenderer {
  68222. private _scene;
  68223. private _depthMap;
  68224. private _effect;
  68225. private readonly _storeNonLinearDepth;
  68226. private readonly _clearColor;
  68227. /** Get if the depth renderer is using packed depth or not */
  68228. readonly isPacked: boolean;
  68229. private _cachedDefines;
  68230. private _camera;
  68231. /**
  68232. * Specifiess that the depth renderer will only be used within
  68233. * the camera it is created for.
  68234. * This can help forcing its rendering during the camera processing.
  68235. */
  68236. useOnlyInActiveCamera: boolean;
  68237. /** @hidden */
  68238. static _SceneComponentInitialization: (scene: Scene) => void;
  68239. /**
  68240. * Instantiates a depth renderer
  68241. * @param scene The scene the renderer belongs to
  68242. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  68243. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  68244. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  68245. */
  68246. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  68247. /**
  68248. * Creates the depth rendering effect and checks if the effect is ready.
  68249. * @param subMesh The submesh to be used to render the depth map of
  68250. * @param useInstances If multiple world instances should be used
  68251. * @returns if the depth renderer is ready to render the depth map
  68252. */
  68253. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68254. /**
  68255. * Gets the texture which the depth map will be written to.
  68256. * @returns The depth map texture
  68257. */
  68258. getDepthMap(): RenderTargetTexture;
  68259. /**
  68260. * Disposes of the depth renderer.
  68261. */
  68262. dispose(): void;
  68263. }
  68264. }
  68265. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  68266. import { Nullable } from "babylonjs/types";
  68267. import { Scene } from "babylonjs/scene";
  68268. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  68269. import { Camera } from "babylonjs/Cameras/camera";
  68270. import { ISceneComponent } from "babylonjs/sceneComponent";
  68271. module "babylonjs/scene" {
  68272. interface Scene {
  68273. /** @hidden (Backing field) */
  68274. _depthRenderer: {
  68275. [id: string]: DepthRenderer;
  68276. };
  68277. /**
  68278. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  68279. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  68280. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  68281. * @returns the created depth renderer
  68282. */
  68283. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  68284. /**
  68285. * Disables a depth renderer for a given camera
  68286. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  68287. */
  68288. disableDepthRenderer(camera?: Nullable<Camera>): void;
  68289. }
  68290. }
  68291. /**
  68292. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  68293. * in several rendering techniques.
  68294. */
  68295. export class DepthRendererSceneComponent implements ISceneComponent {
  68296. /**
  68297. * The component name helpfull to identify the component in the list of scene components.
  68298. */
  68299. readonly name: string;
  68300. /**
  68301. * The scene the component belongs to.
  68302. */
  68303. scene: Scene;
  68304. /**
  68305. * Creates a new instance of the component for the given scene
  68306. * @param scene Defines the scene to register the component in
  68307. */
  68308. constructor(scene: Scene);
  68309. /**
  68310. * Registers the component in a given scene
  68311. */
  68312. register(): void;
  68313. /**
  68314. * Rebuilds the elements related to this component in case of
  68315. * context lost for instance.
  68316. */
  68317. rebuild(): void;
  68318. /**
  68319. * Disposes the component and the associated ressources
  68320. */
  68321. dispose(): void;
  68322. private _gatherRenderTargets;
  68323. private _gatherActiveCameraRenderTargets;
  68324. }
  68325. }
  68326. declare module "babylonjs/Shaders/outline.fragment" {
  68327. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  68328. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  68329. /** @hidden */
  68330. export var outlinePixelShader: {
  68331. name: string;
  68332. shader: string;
  68333. };
  68334. }
  68335. declare module "babylonjs/Shaders/outline.vertex" {
  68336. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  68337. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  68338. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  68339. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  68340. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  68341. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  68342. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  68343. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  68344. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  68345. /** @hidden */
  68346. export var outlineVertexShader: {
  68347. name: string;
  68348. shader: string;
  68349. };
  68350. }
  68351. declare module "babylonjs/Rendering/outlineRenderer" {
  68352. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68353. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  68354. import { Scene } from "babylonjs/scene";
  68355. import { ISceneComponent } from "babylonjs/sceneComponent";
  68356. import "babylonjs/Shaders/outline.fragment";
  68357. import "babylonjs/Shaders/outline.vertex";
  68358. module "babylonjs/scene" {
  68359. interface Scene {
  68360. /** @hidden */
  68361. _outlineRenderer: OutlineRenderer;
  68362. /**
  68363. * Gets the outline renderer associated with the scene
  68364. * @returns a OutlineRenderer
  68365. */
  68366. getOutlineRenderer(): OutlineRenderer;
  68367. }
  68368. }
  68369. module "babylonjs/Meshes/abstractMesh" {
  68370. interface AbstractMesh {
  68371. /** @hidden (Backing field) */
  68372. _renderOutline: boolean;
  68373. /**
  68374. * Gets or sets a boolean indicating if the outline must be rendered as well
  68375. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  68376. */
  68377. renderOutline: boolean;
  68378. /** @hidden (Backing field) */
  68379. _renderOverlay: boolean;
  68380. /**
  68381. * Gets or sets a boolean indicating if the overlay must be rendered as well
  68382. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  68383. */
  68384. renderOverlay: boolean;
  68385. }
  68386. }
  68387. /**
  68388. * This class is responsible to draw bothe outline/overlay of meshes.
  68389. * It should not be used directly but through the available method on mesh.
  68390. */
  68391. export class OutlineRenderer implements ISceneComponent {
  68392. /**
  68393. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  68394. */
  68395. private static _StencilReference;
  68396. /**
  68397. * The name of the component. Each component must have a unique name.
  68398. */
  68399. name: string;
  68400. /**
  68401. * The scene the component belongs to.
  68402. */
  68403. scene: Scene;
  68404. /**
  68405. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  68406. */
  68407. zOffset: number;
  68408. private _engine;
  68409. private _effect;
  68410. private _cachedDefines;
  68411. private _savedDepthWrite;
  68412. /**
  68413. * Instantiates a new outline renderer. (There could be only one per scene).
  68414. * @param scene Defines the scene it belongs to
  68415. */
  68416. constructor(scene: Scene);
  68417. /**
  68418. * Register the component to one instance of a scene.
  68419. */
  68420. register(): void;
  68421. /**
  68422. * Rebuilds the elements related to this component in case of
  68423. * context lost for instance.
  68424. */
  68425. rebuild(): void;
  68426. /**
  68427. * Disposes the component and the associated ressources.
  68428. */
  68429. dispose(): void;
  68430. /**
  68431. * Renders the outline in the canvas.
  68432. * @param subMesh Defines the sumesh to render
  68433. * @param batch Defines the batch of meshes in case of instances
  68434. * @param useOverlay Defines if the rendering is for the overlay or the outline
  68435. */
  68436. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  68437. /**
  68438. * Returns whether or not the outline renderer is ready for a given submesh.
  68439. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  68440. * @param subMesh Defines the submesh to check readyness for
  68441. * @param useInstances Defines wheter wee are trying to render instances or not
  68442. * @returns true if ready otherwise false
  68443. */
  68444. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68445. private _beforeRenderingMesh;
  68446. private _afterRenderingMesh;
  68447. }
  68448. }
  68449. declare module "babylonjs/Rendering/index" {
  68450. export * from "babylonjs/Rendering/boundingBoxRenderer";
  68451. export * from "babylonjs/Rendering/depthRenderer";
  68452. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  68453. export * from "babylonjs/Rendering/edgesRenderer";
  68454. export * from "babylonjs/Rendering/geometryBufferRenderer";
  68455. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68456. export * from "babylonjs/Rendering/outlineRenderer";
  68457. export * from "babylonjs/Rendering/renderingGroup";
  68458. export * from "babylonjs/Rendering/renderingManager";
  68459. export * from "babylonjs/Rendering/utilityLayerRenderer";
  68460. }
  68461. declare module "babylonjs/Sprites/ISprites" {
  68462. /**
  68463. * Defines the basic options interface of a Sprite Frame Source Size.
  68464. */
  68465. export interface ISpriteJSONSpriteSourceSize {
  68466. /**
  68467. * number of the original width of the Frame
  68468. */
  68469. w: number;
  68470. /**
  68471. * number of the original height of the Frame
  68472. */
  68473. h: number;
  68474. }
  68475. /**
  68476. * Defines the basic options interface of a Sprite Frame Data.
  68477. */
  68478. export interface ISpriteJSONSpriteFrameData {
  68479. /**
  68480. * number of the x offset of the Frame
  68481. */
  68482. x: number;
  68483. /**
  68484. * number of the y offset of the Frame
  68485. */
  68486. y: number;
  68487. /**
  68488. * number of the width of the Frame
  68489. */
  68490. w: number;
  68491. /**
  68492. * number of the height of the Frame
  68493. */
  68494. h: number;
  68495. }
  68496. /**
  68497. * Defines the basic options interface of a JSON Sprite.
  68498. */
  68499. export interface ISpriteJSONSprite {
  68500. /**
  68501. * string name of the Frame
  68502. */
  68503. filename: string;
  68504. /**
  68505. * ISpriteJSONSpriteFrame basic object of the frame data
  68506. */
  68507. frame: ISpriteJSONSpriteFrameData;
  68508. /**
  68509. * boolean to flag is the frame was rotated.
  68510. */
  68511. rotated: boolean;
  68512. /**
  68513. * boolean to flag is the frame was trimmed.
  68514. */
  68515. trimmed: boolean;
  68516. /**
  68517. * ISpriteJSONSpriteFrame basic object of the source data
  68518. */
  68519. spriteSourceSize: ISpriteJSONSpriteFrameData;
  68520. /**
  68521. * ISpriteJSONSpriteFrame basic object of the source data
  68522. */
  68523. sourceSize: ISpriteJSONSpriteSourceSize;
  68524. }
  68525. /**
  68526. * Defines the basic options interface of a JSON atlas.
  68527. */
  68528. export interface ISpriteJSONAtlas {
  68529. /**
  68530. * Array of objects that contain the frame data.
  68531. */
  68532. frames: Array<ISpriteJSONSprite>;
  68533. /**
  68534. * object basic object containing the sprite meta data.
  68535. */
  68536. meta?: object;
  68537. }
  68538. }
  68539. declare module "babylonjs/Shaders/spriteMap.fragment" {
  68540. /** @hidden */
  68541. export var spriteMapPixelShader: {
  68542. name: string;
  68543. shader: string;
  68544. };
  68545. }
  68546. declare module "babylonjs/Shaders/spriteMap.vertex" {
  68547. /** @hidden */
  68548. export var spriteMapVertexShader: {
  68549. name: string;
  68550. shader: string;
  68551. };
  68552. }
  68553. declare module "babylonjs/Sprites/spriteMap" {
  68554. import { IDisposable, Scene } from "babylonjs/scene";
  68555. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  68556. import { Texture } from "babylonjs/Materials/Textures/texture";
  68557. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  68558. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  68559. import "babylonjs/Meshes/Builders/planeBuilder";
  68560. import "babylonjs/Shaders/spriteMap.fragment";
  68561. import "babylonjs/Shaders/spriteMap.vertex";
  68562. /**
  68563. * Defines the basic options interface of a SpriteMap
  68564. */
  68565. export interface ISpriteMapOptions {
  68566. /**
  68567. * Vector2 of the number of cells in the grid.
  68568. */
  68569. stageSize?: Vector2;
  68570. /**
  68571. * Vector2 of the size of the output plane in World Units.
  68572. */
  68573. outputSize?: Vector2;
  68574. /**
  68575. * Vector3 of the position of the output plane in World Units.
  68576. */
  68577. outputPosition?: Vector3;
  68578. /**
  68579. * Vector3 of the rotation of the output plane.
  68580. */
  68581. outputRotation?: Vector3;
  68582. /**
  68583. * number of layers that the system will reserve in resources.
  68584. */
  68585. layerCount?: number;
  68586. /**
  68587. * number of max animation frames a single cell will reserve in resources.
  68588. */
  68589. maxAnimationFrames?: number;
  68590. /**
  68591. * number cell index of the base tile when the system compiles.
  68592. */
  68593. baseTile?: number;
  68594. /**
  68595. * boolean flip the sprite after its been repositioned by the framing data.
  68596. */
  68597. flipU?: boolean;
  68598. /**
  68599. * Vector3 scalar of the global RGB values of the SpriteMap.
  68600. */
  68601. colorMultiply?: Vector3;
  68602. }
  68603. /**
  68604. * Defines the IDisposable interface in order to be cleanable from resources.
  68605. */
  68606. export interface ISpriteMap extends IDisposable {
  68607. /**
  68608. * String name of the SpriteMap.
  68609. */
  68610. name: string;
  68611. /**
  68612. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  68613. */
  68614. atlasJSON: ISpriteJSONAtlas;
  68615. /**
  68616. * Texture of the SpriteMap.
  68617. */
  68618. spriteSheet: Texture;
  68619. /**
  68620. * The parameters to initialize the SpriteMap with.
  68621. */
  68622. options: ISpriteMapOptions;
  68623. }
  68624. /**
  68625. * Class used to manage a grid restricted sprite deployment on an Output plane.
  68626. */
  68627. export class SpriteMap implements ISpriteMap {
  68628. /** The Name of the spriteMap */
  68629. name: string;
  68630. /** The JSON file with the frame and meta data */
  68631. atlasJSON: ISpriteJSONAtlas;
  68632. /** The systems Sprite Sheet Texture */
  68633. spriteSheet: Texture;
  68634. /** Arguments passed with the Constructor */
  68635. options: ISpriteMapOptions;
  68636. /** Public Sprite Storage array, parsed from atlasJSON */
  68637. sprites: Array<ISpriteJSONSprite>;
  68638. /** Returns the Number of Sprites in the System */
  68639. get spriteCount(): number;
  68640. /** Returns the Position of Output Plane*/
  68641. get position(): Vector3;
  68642. /** Returns the Position of Output Plane*/
  68643. set position(v: Vector3);
  68644. /** Returns the Rotation of Output Plane*/
  68645. get rotation(): Vector3;
  68646. /** Returns the Rotation of Output Plane*/
  68647. set rotation(v: Vector3);
  68648. /** Sets the AnimationMap*/
  68649. get animationMap(): RawTexture;
  68650. /** Sets the AnimationMap*/
  68651. set animationMap(v: RawTexture);
  68652. /** Scene that the SpriteMap was created in */
  68653. private _scene;
  68654. /** Texture Buffer of Float32 that holds tile frame data*/
  68655. private _frameMap;
  68656. /** Texture Buffers of Float32 that holds tileMap data*/
  68657. private _tileMaps;
  68658. /** Texture Buffer of Float32 that holds Animation Data*/
  68659. private _animationMap;
  68660. /** Custom ShaderMaterial Central to the System*/
  68661. private _material;
  68662. /** Custom ShaderMaterial Central to the System*/
  68663. private _output;
  68664. /** Systems Time Ticker*/
  68665. private _time;
  68666. /**
  68667. * Creates a new SpriteMap
  68668. * @param name defines the SpriteMaps Name
  68669. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  68670. * @param spriteSheet is the Texture that the Sprites are on.
  68671. * @param options a basic deployment configuration
  68672. * @param scene The Scene that the map is deployed on
  68673. */
  68674. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  68675. /**
  68676. * Returns tileID location
  68677. * @returns Vector2 the cell position ID
  68678. */
  68679. getTileID(): Vector2;
  68680. /**
  68681. * Gets the UV location of the mouse over the SpriteMap.
  68682. * @returns Vector2 the UV position of the mouse interaction
  68683. */
  68684. getMousePosition(): Vector2;
  68685. /**
  68686. * Creates the "frame" texture Buffer
  68687. * -------------------------------------
  68688. * Structure of frames
  68689. * "filename": "Falling-Water-2.png",
  68690. * "frame": {"x":69,"y":103,"w":24,"h":32},
  68691. * "rotated": true,
  68692. * "trimmed": true,
  68693. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  68694. * "sourceSize": {"w":32,"h":32}
  68695. * @returns RawTexture of the frameMap
  68696. */
  68697. private _createFrameBuffer;
  68698. /**
  68699. * Creates the tileMap texture Buffer
  68700. * @param buffer normally and array of numbers, or a false to generate from scratch
  68701. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  68702. * @returns RawTexture of the tileMap
  68703. */
  68704. private _createTileBuffer;
  68705. /**
  68706. * Modifies the data of the tileMaps
  68707. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  68708. * @param pos is the iVector2 Coordinates of the Tile
  68709. * @param tile The SpriteIndex of the new Tile
  68710. */
  68711. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  68712. /**
  68713. * Creates the animationMap texture Buffer
  68714. * @param buffer normally and array of numbers, or a false to generate from scratch
  68715. * @returns RawTexture of the animationMap
  68716. */
  68717. private _createTileAnimationBuffer;
  68718. /**
  68719. * Modifies the data of the animationMap
  68720. * @param cellID is the Index of the Sprite
  68721. * @param _frame is the target Animation frame
  68722. * @param toCell is the Target Index of the next frame of the animation
  68723. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  68724. * @param speed is a global scalar of the time variable on the map.
  68725. */
  68726. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  68727. /**
  68728. * Exports the .tilemaps file
  68729. */
  68730. saveTileMaps(): void;
  68731. /**
  68732. * Imports the .tilemaps file
  68733. * @param url of the .tilemaps file
  68734. */
  68735. loadTileMaps(url: string): void;
  68736. /**
  68737. * Release associated resources
  68738. */
  68739. dispose(): void;
  68740. }
  68741. }
  68742. declare module "babylonjs/Sprites/spritePackedManager" {
  68743. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  68744. import { Scene } from "babylonjs/scene";
  68745. /**
  68746. * Class used to manage multiple sprites of different sizes on the same spritesheet
  68747. * @see http://doc.babylonjs.com/babylon101/sprites
  68748. */
  68749. export class SpritePackedManager extends SpriteManager {
  68750. /** defines the packed manager's name */
  68751. name: string;
  68752. /**
  68753. * Creates a new sprite manager from a packed sprite sheet
  68754. * @param name defines the manager's name
  68755. * @param imgUrl defines the sprite sheet url
  68756. * @param capacity defines the maximum allowed number of sprites
  68757. * @param scene defines the hosting scene
  68758. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  68759. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  68760. * @param samplingMode defines the smapling mode to use with spritesheet
  68761. * @param fromPacked set to true; do not alter
  68762. */
  68763. constructor(
  68764. /** defines the packed manager's name */
  68765. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  68766. }
  68767. }
  68768. declare module "babylonjs/Sprites/index" {
  68769. export * from "babylonjs/Sprites/sprite";
  68770. export * from "babylonjs/Sprites/ISprites";
  68771. export * from "babylonjs/Sprites/spriteManager";
  68772. export * from "babylonjs/Sprites/spriteMap";
  68773. export * from "babylonjs/Sprites/spritePackedManager";
  68774. export * from "babylonjs/Sprites/spriteSceneComponent";
  68775. }
  68776. declare module "babylonjs/States/index" {
  68777. export * from "babylonjs/States/alphaCullingState";
  68778. export * from "babylonjs/States/depthCullingState";
  68779. export * from "babylonjs/States/stencilState";
  68780. }
  68781. declare module "babylonjs/Misc/assetsManager" {
  68782. import { Scene } from "babylonjs/scene";
  68783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68784. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  68785. import { Skeleton } from "babylonjs/Bones/skeleton";
  68786. import { Observable } from "babylonjs/Misc/observable";
  68787. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68788. import { Texture } from "babylonjs/Materials/Textures/texture";
  68789. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  68790. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  68791. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  68792. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  68793. /**
  68794. * Defines the list of states available for a task inside a AssetsManager
  68795. */
  68796. export enum AssetTaskState {
  68797. /**
  68798. * Initialization
  68799. */
  68800. INIT = 0,
  68801. /**
  68802. * Running
  68803. */
  68804. RUNNING = 1,
  68805. /**
  68806. * Done
  68807. */
  68808. DONE = 2,
  68809. /**
  68810. * Error
  68811. */
  68812. ERROR = 3
  68813. }
  68814. /**
  68815. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  68816. */
  68817. export abstract class AbstractAssetTask {
  68818. /**
  68819. * Task name
  68820. */ name: string;
  68821. /**
  68822. * Callback called when the task is successful
  68823. */
  68824. onSuccess: (task: any) => void;
  68825. /**
  68826. * Callback called when the task is not successful
  68827. */
  68828. onError: (task: any, message?: string, exception?: any) => void;
  68829. /**
  68830. * Creates a new AssetsManager
  68831. * @param name defines the name of the task
  68832. */
  68833. constructor(
  68834. /**
  68835. * Task name
  68836. */ name: string);
  68837. private _isCompleted;
  68838. private _taskState;
  68839. private _errorObject;
  68840. /**
  68841. * Get if the task is completed
  68842. */
  68843. get isCompleted(): boolean;
  68844. /**
  68845. * Gets the current state of the task
  68846. */
  68847. get taskState(): AssetTaskState;
  68848. /**
  68849. * Gets the current error object (if task is in error)
  68850. */
  68851. get errorObject(): {
  68852. message?: string;
  68853. exception?: any;
  68854. };
  68855. /**
  68856. * Internal only
  68857. * @hidden
  68858. */
  68859. _setErrorObject(message?: string, exception?: any): void;
  68860. /**
  68861. * Execute the current task
  68862. * @param scene defines the scene where you want your assets to be loaded
  68863. * @param onSuccess is a callback called when the task is successfully executed
  68864. * @param onError is a callback called if an error occurs
  68865. */
  68866. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68867. /**
  68868. * Execute the current task
  68869. * @param scene defines the scene where you want your assets to be loaded
  68870. * @param onSuccess is a callback called when the task is successfully executed
  68871. * @param onError is a callback called if an error occurs
  68872. */
  68873. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68874. /**
  68875. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  68876. * This can be used with failed tasks that have the reason for failure fixed.
  68877. */
  68878. reset(): void;
  68879. private onErrorCallback;
  68880. private onDoneCallback;
  68881. }
  68882. /**
  68883. * Define the interface used by progress events raised during assets loading
  68884. */
  68885. export interface IAssetsProgressEvent {
  68886. /**
  68887. * Defines the number of remaining tasks to process
  68888. */
  68889. remainingCount: number;
  68890. /**
  68891. * Defines the total number of tasks
  68892. */
  68893. totalCount: number;
  68894. /**
  68895. * Defines the task that was just processed
  68896. */
  68897. task: AbstractAssetTask;
  68898. }
  68899. /**
  68900. * Class used to share progress information about assets loading
  68901. */
  68902. export class AssetsProgressEvent implements IAssetsProgressEvent {
  68903. /**
  68904. * Defines the number of remaining tasks to process
  68905. */
  68906. remainingCount: number;
  68907. /**
  68908. * Defines the total number of tasks
  68909. */
  68910. totalCount: number;
  68911. /**
  68912. * Defines the task that was just processed
  68913. */
  68914. task: AbstractAssetTask;
  68915. /**
  68916. * Creates a AssetsProgressEvent
  68917. * @param remainingCount defines the number of remaining tasks to process
  68918. * @param totalCount defines the total number of tasks
  68919. * @param task defines the task that was just processed
  68920. */
  68921. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  68922. }
  68923. /**
  68924. * Define a task used by AssetsManager to load meshes
  68925. */
  68926. export class MeshAssetTask extends AbstractAssetTask {
  68927. /**
  68928. * Defines the name of the task
  68929. */
  68930. name: string;
  68931. /**
  68932. * Defines the list of mesh's names you want to load
  68933. */
  68934. meshesNames: any;
  68935. /**
  68936. * Defines the root url to use as a base to load your meshes and associated resources
  68937. */
  68938. rootUrl: string;
  68939. /**
  68940. * Defines the filename of the scene to load from
  68941. */
  68942. sceneFilename: string;
  68943. /**
  68944. * Gets the list of loaded meshes
  68945. */
  68946. loadedMeshes: Array<AbstractMesh>;
  68947. /**
  68948. * Gets the list of loaded particle systems
  68949. */
  68950. loadedParticleSystems: Array<IParticleSystem>;
  68951. /**
  68952. * Gets the list of loaded skeletons
  68953. */
  68954. loadedSkeletons: Array<Skeleton>;
  68955. /**
  68956. * Gets the list of loaded animation groups
  68957. */
  68958. loadedAnimationGroups: Array<AnimationGroup>;
  68959. /**
  68960. * Callback called when the task is successful
  68961. */
  68962. onSuccess: (task: MeshAssetTask) => void;
  68963. /**
  68964. * Callback called when the task is successful
  68965. */
  68966. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  68967. /**
  68968. * Creates a new MeshAssetTask
  68969. * @param name defines the name of the task
  68970. * @param meshesNames defines the list of mesh's names you want to load
  68971. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  68972. * @param sceneFilename defines the filename of the scene to load from
  68973. */
  68974. constructor(
  68975. /**
  68976. * Defines the name of the task
  68977. */
  68978. name: string,
  68979. /**
  68980. * Defines the list of mesh's names you want to load
  68981. */
  68982. meshesNames: any,
  68983. /**
  68984. * Defines the root url to use as a base to load your meshes and associated resources
  68985. */
  68986. rootUrl: string,
  68987. /**
  68988. * Defines the filename of the scene to load from
  68989. */
  68990. sceneFilename: string);
  68991. /**
  68992. * Execute the current task
  68993. * @param scene defines the scene where you want your assets to be loaded
  68994. * @param onSuccess is a callback called when the task is successfully executed
  68995. * @param onError is a callback called if an error occurs
  68996. */
  68997. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68998. }
  68999. /**
  69000. * Define a task used by AssetsManager to load text content
  69001. */
  69002. export class TextFileAssetTask extends AbstractAssetTask {
  69003. /**
  69004. * Defines the name of the task
  69005. */
  69006. name: string;
  69007. /**
  69008. * Defines the location of the file to load
  69009. */
  69010. url: string;
  69011. /**
  69012. * Gets the loaded text string
  69013. */
  69014. text: string;
  69015. /**
  69016. * Callback called when the task is successful
  69017. */
  69018. onSuccess: (task: TextFileAssetTask) => void;
  69019. /**
  69020. * Callback called when the task is successful
  69021. */
  69022. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  69023. /**
  69024. * Creates a new TextFileAssetTask object
  69025. * @param name defines the name of the task
  69026. * @param url defines the location of the file to load
  69027. */
  69028. constructor(
  69029. /**
  69030. * Defines the name of the task
  69031. */
  69032. name: string,
  69033. /**
  69034. * Defines the location of the file to load
  69035. */
  69036. url: string);
  69037. /**
  69038. * Execute the current task
  69039. * @param scene defines the scene where you want your assets to be loaded
  69040. * @param onSuccess is a callback called when the task is successfully executed
  69041. * @param onError is a callback called if an error occurs
  69042. */
  69043. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69044. }
  69045. /**
  69046. * Define a task used by AssetsManager to load binary data
  69047. */
  69048. export class BinaryFileAssetTask extends AbstractAssetTask {
  69049. /**
  69050. * Defines the name of the task
  69051. */
  69052. name: string;
  69053. /**
  69054. * Defines the location of the file to load
  69055. */
  69056. url: string;
  69057. /**
  69058. * Gets the lodaded data (as an array buffer)
  69059. */
  69060. data: ArrayBuffer;
  69061. /**
  69062. * Callback called when the task is successful
  69063. */
  69064. onSuccess: (task: BinaryFileAssetTask) => void;
  69065. /**
  69066. * Callback called when the task is successful
  69067. */
  69068. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  69069. /**
  69070. * Creates a new BinaryFileAssetTask object
  69071. * @param name defines the name of the new task
  69072. * @param url defines the location of the file to load
  69073. */
  69074. constructor(
  69075. /**
  69076. * Defines the name of the task
  69077. */
  69078. name: string,
  69079. /**
  69080. * Defines the location of the file to load
  69081. */
  69082. url: string);
  69083. /**
  69084. * Execute the current task
  69085. * @param scene defines the scene where you want your assets to be loaded
  69086. * @param onSuccess is a callback called when the task is successfully executed
  69087. * @param onError is a callback called if an error occurs
  69088. */
  69089. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69090. }
  69091. /**
  69092. * Define a task used by AssetsManager to load images
  69093. */
  69094. export class ImageAssetTask extends AbstractAssetTask {
  69095. /**
  69096. * Defines the name of the task
  69097. */
  69098. name: string;
  69099. /**
  69100. * Defines the location of the image to load
  69101. */
  69102. url: string;
  69103. /**
  69104. * Gets the loaded images
  69105. */
  69106. image: HTMLImageElement;
  69107. /**
  69108. * Callback called when the task is successful
  69109. */
  69110. onSuccess: (task: ImageAssetTask) => void;
  69111. /**
  69112. * Callback called when the task is successful
  69113. */
  69114. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  69115. /**
  69116. * Creates a new ImageAssetTask
  69117. * @param name defines the name of the task
  69118. * @param url defines the location of the image to load
  69119. */
  69120. constructor(
  69121. /**
  69122. * Defines the name of the task
  69123. */
  69124. name: string,
  69125. /**
  69126. * Defines the location of the image to load
  69127. */
  69128. url: string);
  69129. /**
  69130. * Execute the current task
  69131. * @param scene defines the scene where you want your assets to be loaded
  69132. * @param onSuccess is a callback called when the task is successfully executed
  69133. * @param onError is a callback called if an error occurs
  69134. */
  69135. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69136. }
  69137. /**
  69138. * Defines the interface used by texture loading tasks
  69139. */
  69140. export interface ITextureAssetTask<TEX extends BaseTexture> {
  69141. /**
  69142. * Gets the loaded texture
  69143. */
  69144. texture: TEX;
  69145. }
  69146. /**
  69147. * Define a task used by AssetsManager to load 2D textures
  69148. */
  69149. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  69150. /**
  69151. * Defines the name of the task
  69152. */
  69153. name: string;
  69154. /**
  69155. * Defines the location of the file to load
  69156. */
  69157. url: string;
  69158. /**
  69159. * Defines if mipmap should not be generated (default is false)
  69160. */
  69161. noMipmap?: boolean | undefined;
  69162. /**
  69163. * Defines if texture must be inverted on Y axis (default is false)
  69164. */
  69165. invertY?: boolean | undefined;
  69166. /**
  69167. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69168. */
  69169. samplingMode: number;
  69170. /**
  69171. * Gets the loaded texture
  69172. */
  69173. texture: Texture;
  69174. /**
  69175. * Callback called when the task is successful
  69176. */
  69177. onSuccess: (task: TextureAssetTask) => void;
  69178. /**
  69179. * Callback called when the task is successful
  69180. */
  69181. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  69182. /**
  69183. * Creates a new TextureAssetTask object
  69184. * @param name defines the name of the task
  69185. * @param url defines the location of the file to load
  69186. * @param noMipmap defines if mipmap should not be generated (default is false)
  69187. * @param invertY defines if texture must be inverted on Y axis (default is false)
  69188. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69189. */
  69190. constructor(
  69191. /**
  69192. * Defines the name of the task
  69193. */
  69194. name: string,
  69195. /**
  69196. * Defines the location of the file to load
  69197. */
  69198. url: string,
  69199. /**
  69200. * Defines if mipmap should not be generated (default is false)
  69201. */
  69202. noMipmap?: boolean | undefined,
  69203. /**
  69204. * Defines if texture must be inverted on Y axis (default is false)
  69205. */
  69206. invertY?: boolean | undefined,
  69207. /**
  69208. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69209. */
  69210. samplingMode?: number);
  69211. /**
  69212. * Execute the current task
  69213. * @param scene defines the scene where you want your assets to be loaded
  69214. * @param onSuccess is a callback called when the task is successfully executed
  69215. * @param onError is a callback called if an error occurs
  69216. */
  69217. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69218. }
  69219. /**
  69220. * Define a task used by AssetsManager to load cube textures
  69221. */
  69222. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  69223. /**
  69224. * Defines the name of the task
  69225. */
  69226. name: string;
  69227. /**
  69228. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69229. */
  69230. url: string;
  69231. /**
  69232. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69233. */
  69234. extensions?: string[] | undefined;
  69235. /**
  69236. * Defines if mipmaps should not be generated (default is false)
  69237. */
  69238. noMipmap?: boolean | undefined;
  69239. /**
  69240. * Defines the explicit list of files (undefined by default)
  69241. */
  69242. files?: string[] | undefined;
  69243. /**
  69244. * Gets the loaded texture
  69245. */
  69246. texture: CubeTexture;
  69247. /**
  69248. * Callback called when the task is successful
  69249. */
  69250. onSuccess: (task: CubeTextureAssetTask) => void;
  69251. /**
  69252. * Callback called when the task is successful
  69253. */
  69254. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  69255. /**
  69256. * Creates a new CubeTextureAssetTask
  69257. * @param name defines the name of the task
  69258. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69259. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69260. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69261. * @param files defines the explicit list of files (undefined by default)
  69262. */
  69263. constructor(
  69264. /**
  69265. * Defines the name of the task
  69266. */
  69267. name: string,
  69268. /**
  69269. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69270. */
  69271. url: string,
  69272. /**
  69273. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69274. */
  69275. extensions?: string[] | undefined,
  69276. /**
  69277. * Defines if mipmaps should not be generated (default is false)
  69278. */
  69279. noMipmap?: boolean | undefined,
  69280. /**
  69281. * Defines the explicit list of files (undefined by default)
  69282. */
  69283. files?: string[] | undefined);
  69284. /**
  69285. * Execute the current task
  69286. * @param scene defines the scene where you want your assets to be loaded
  69287. * @param onSuccess is a callback called when the task is successfully executed
  69288. * @param onError is a callback called if an error occurs
  69289. */
  69290. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69291. }
  69292. /**
  69293. * Define a task used by AssetsManager to load HDR cube textures
  69294. */
  69295. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  69296. /**
  69297. * Defines the name of the task
  69298. */
  69299. name: string;
  69300. /**
  69301. * Defines the location of the file to load
  69302. */
  69303. url: string;
  69304. /**
  69305. * Defines the desired size (the more it increases the longer the generation will be)
  69306. */
  69307. size: number;
  69308. /**
  69309. * Defines if mipmaps should not be generated (default is false)
  69310. */
  69311. noMipmap: boolean;
  69312. /**
  69313. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69314. */
  69315. generateHarmonics: boolean;
  69316. /**
  69317. * 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)
  69318. */
  69319. gammaSpace: boolean;
  69320. /**
  69321. * Internal Use Only
  69322. */
  69323. reserved: boolean;
  69324. /**
  69325. * Gets the loaded texture
  69326. */
  69327. texture: HDRCubeTexture;
  69328. /**
  69329. * Callback called when the task is successful
  69330. */
  69331. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  69332. /**
  69333. * Callback called when the task is successful
  69334. */
  69335. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  69336. /**
  69337. * Creates a new HDRCubeTextureAssetTask object
  69338. * @param name defines the name of the task
  69339. * @param url defines the location of the file to load
  69340. * @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.
  69341. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69342. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69343. * @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)
  69344. * @param reserved Internal use only
  69345. */
  69346. constructor(
  69347. /**
  69348. * Defines the name of the task
  69349. */
  69350. name: string,
  69351. /**
  69352. * Defines the location of the file to load
  69353. */
  69354. url: string,
  69355. /**
  69356. * Defines the desired size (the more it increases the longer the generation will be)
  69357. */
  69358. size: number,
  69359. /**
  69360. * Defines if mipmaps should not be generated (default is false)
  69361. */
  69362. noMipmap?: boolean,
  69363. /**
  69364. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69365. */
  69366. generateHarmonics?: boolean,
  69367. /**
  69368. * 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)
  69369. */
  69370. gammaSpace?: boolean,
  69371. /**
  69372. * Internal Use Only
  69373. */
  69374. reserved?: boolean);
  69375. /**
  69376. * Execute the current task
  69377. * @param scene defines the scene where you want your assets to be loaded
  69378. * @param onSuccess is a callback called when the task is successfully executed
  69379. * @param onError is a callback called if an error occurs
  69380. */
  69381. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69382. }
  69383. /**
  69384. * Define a task used by AssetsManager to load Equirectangular cube textures
  69385. */
  69386. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  69387. /**
  69388. * Defines the name of the task
  69389. */
  69390. name: string;
  69391. /**
  69392. * Defines the location of the file to load
  69393. */
  69394. url: string;
  69395. /**
  69396. * Defines the desired size (the more it increases the longer the generation will be)
  69397. */
  69398. size: number;
  69399. /**
  69400. * Defines if mipmaps should not be generated (default is false)
  69401. */
  69402. noMipmap: boolean;
  69403. /**
  69404. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  69405. * but the standard material would require them in Gamma space) (default is true)
  69406. */
  69407. gammaSpace: boolean;
  69408. /**
  69409. * Gets the loaded texture
  69410. */
  69411. texture: EquiRectangularCubeTexture;
  69412. /**
  69413. * Callback called when the task is successful
  69414. */
  69415. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  69416. /**
  69417. * Callback called when the task is successful
  69418. */
  69419. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  69420. /**
  69421. * Creates a new EquiRectangularCubeTextureAssetTask object
  69422. * @param name defines the name of the task
  69423. * @param url defines the location of the file to load
  69424. * @param size defines the desired size (the more it increases the longer the generation will be)
  69425. * If the size is omitted this implies you are using a preprocessed cubemap.
  69426. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69427. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  69428. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  69429. * (default is true)
  69430. */
  69431. constructor(
  69432. /**
  69433. * Defines the name of the task
  69434. */
  69435. name: string,
  69436. /**
  69437. * Defines the location of the file to load
  69438. */
  69439. url: string,
  69440. /**
  69441. * Defines the desired size (the more it increases the longer the generation will be)
  69442. */
  69443. size: number,
  69444. /**
  69445. * Defines if mipmaps should not be generated (default is false)
  69446. */
  69447. noMipmap?: boolean,
  69448. /**
  69449. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  69450. * but the standard material would require them in Gamma space) (default is true)
  69451. */
  69452. gammaSpace?: boolean);
  69453. /**
  69454. * Execute the current task
  69455. * @param scene defines the scene where you want your assets to be loaded
  69456. * @param onSuccess is a callback called when the task is successfully executed
  69457. * @param onError is a callback called if an error occurs
  69458. */
  69459. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69460. }
  69461. /**
  69462. * This class can be used to easily import assets into a scene
  69463. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  69464. */
  69465. export class AssetsManager {
  69466. private _scene;
  69467. private _isLoading;
  69468. protected _tasks: AbstractAssetTask[];
  69469. protected _waitingTasksCount: number;
  69470. protected _totalTasksCount: number;
  69471. /**
  69472. * Callback called when all tasks are processed
  69473. */
  69474. onFinish: (tasks: AbstractAssetTask[]) => void;
  69475. /**
  69476. * Callback called when a task is successful
  69477. */
  69478. onTaskSuccess: (task: AbstractAssetTask) => void;
  69479. /**
  69480. * Callback called when a task had an error
  69481. */
  69482. onTaskError: (task: AbstractAssetTask) => void;
  69483. /**
  69484. * Callback called when a task is done (whatever the result is)
  69485. */
  69486. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  69487. /**
  69488. * Observable called when all tasks are processed
  69489. */
  69490. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  69491. /**
  69492. * Observable called when a task had an error
  69493. */
  69494. onTaskErrorObservable: Observable<AbstractAssetTask>;
  69495. /**
  69496. * Observable called when all tasks were executed
  69497. */
  69498. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  69499. /**
  69500. * Observable called when a task is done (whatever the result is)
  69501. */
  69502. onProgressObservable: Observable<IAssetsProgressEvent>;
  69503. /**
  69504. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  69505. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  69506. */
  69507. useDefaultLoadingScreen: boolean;
  69508. /**
  69509. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  69510. * when all assets have been downloaded.
  69511. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  69512. */
  69513. autoHideLoadingUI: boolean;
  69514. /**
  69515. * Creates a new AssetsManager
  69516. * @param scene defines the scene to work on
  69517. */
  69518. constructor(scene: Scene);
  69519. /**
  69520. * Add a MeshAssetTask to the list of active tasks
  69521. * @param taskName defines the name of the new task
  69522. * @param meshesNames defines the name of meshes to load
  69523. * @param rootUrl defines the root url to use to locate files
  69524. * @param sceneFilename defines the filename of the scene file
  69525. * @returns a new MeshAssetTask object
  69526. */
  69527. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  69528. /**
  69529. * Add a TextFileAssetTask to the list of active tasks
  69530. * @param taskName defines the name of the new task
  69531. * @param url defines the url of the file to load
  69532. * @returns a new TextFileAssetTask object
  69533. */
  69534. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  69535. /**
  69536. * Add a BinaryFileAssetTask to the list of active tasks
  69537. * @param taskName defines the name of the new task
  69538. * @param url defines the url of the file to load
  69539. * @returns a new BinaryFileAssetTask object
  69540. */
  69541. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  69542. /**
  69543. * Add a ImageAssetTask to the list of active tasks
  69544. * @param taskName defines the name of the new task
  69545. * @param url defines the url of the file to load
  69546. * @returns a new ImageAssetTask object
  69547. */
  69548. addImageTask(taskName: string, url: string): ImageAssetTask;
  69549. /**
  69550. * Add a TextureAssetTask to the list of active tasks
  69551. * @param taskName defines the name of the new task
  69552. * @param url defines the url of the file to load
  69553. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69554. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  69555. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  69556. * @returns a new TextureAssetTask object
  69557. */
  69558. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  69559. /**
  69560. * Add a CubeTextureAssetTask to the list of active tasks
  69561. * @param taskName defines the name of the new task
  69562. * @param url defines the url of the file to load
  69563. * @param extensions defines the extension to use to load the cube map (can be null)
  69564. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69565. * @param files defines the list of files to load (can be null)
  69566. * @returns a new CubeTextureAssetTask object
  69567. */
  69568. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  69569. /**
  69570. *
  69571. * Add a HDRCubeTextureAssetTask to the list of active tasks
  69572. * @param taskName defines the name of the new task
  69573. * @param url defines the url of the file to load
  69574. * @param size defines the size you want for the cubemap (can be null)
  69575. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69576. * @param generateHarmonics defines if you want to automatically generate (true by default)
  69577. * @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)
  69578. * @param reserved Internal use only
  69579. * @returns a new HDRCubeTextureAssetTask object
  69580. */
  69581. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  69582. /**
  69583. *
  69584. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  69585. * @param taskName defines the name of the new task
  69586. * @param url defines the url of the file to load
  69587. * @param size defines the size you want for the cubemap (can be null)
  69588. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  69589. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  69590. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  69591. * @returns a new EquiRectangularCubeTextureAssetTask object
  69592. */
  69593. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  69594. /**
  69595. * Remove a task from the assets manager.
  69596. * @param task the task to remove
  69597. */
  69598. removeTask(task: AbstractAssetTask): void;
  69599. private _decreaseWaitingTasksCount;
  69600. private _runTask;
  69601. /**
  69602. * Reset the AssetsManager and remove all tasks
  69603. * @return the current instance of the AssetsManager
  69604. */
  69605. reset(): AssetsManager;
  69606. /**
  69607. * Start the loading process
  69608. * @return the current instance of the AssetsManager
  69609. */
  69610. load(): AssetsManager;
  69611. /**
  69612. * Start the loading process as an async operation
  69613. * @return a promise returning the list of failed tasks
  69614. */
  69615. loadAsync(): Promise<void>;
  69616. }
  69617. }
  69618. declare module "babylonjs/Misc/deferred" {
  69619. /**
  69620. * Wrapper class for promise with external resolve and reject.
  69621. */
  69622. export class Deferred<T> {
  69623. /**
  69624. * The promise associated with this deferred object.
  69625. */
  69626. readonly promise: Promise<T>;
  69627. private _resolve;
  69628. private _reject;
  69629. /**
  69630. * The resolve method of the promise associated with this deferred object.
  69631. */
  69632. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  69633. /**
  69634. * The reject method of the promise associated with this deferred object.
  69635. */
  69636. get reject(): (reason?: any) => void;
  69637. /**
  69638. * Constructor for this deferred object.
  69639. */
  69640. constructor();
  69641. }
  69642. }
  69643. declare module "babylonjs/Misc/meshExploder" {
  69644. import { Mesh } from "babylonjs/Meshes/mesh";
  69645. /**
  69646. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  69647. */
  69648. export class MeshExploder {
  69649. private _centerMesh;
  69650. private _meshes;
  69651. private _meshesOrigins;
  69652. private _toCenterVectors;
  69653. private _scaledDirection;
  69654. private _newPosition;
  69655. private _centerPosition;
  69656. /**
  69657. * Explodes meshes from a center mesh.
  69658. * @param meshes The meshes to explode.
  69659. * @param centerMesh The mesh to be center of explosion.
  69660. */
  69661. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  69662. private _setCenterMesh;
  69663. /**
  69664. * Get class name
  69665. * @returns "MeshExploder"
  69666. */
  69667. getClassName(): string;
  69668. /**
  69669. * "Exploded meshes"
  69670. * @returns Array of meshes with the centerMesh at index 0.
  69671. */
  69672. getMeshes(): Array<Mesh>;
  69673. /**
  69674. * Explodes meshes giving a specific direction
  69675. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  69676. */
  69677. explode(direction?: number): void;
  69678. }
  69679. }
  69680. declare module "babylonjs/Misc/filesInput" {
  69681. import { Engine } from "babylonjs/Engines/engine";
  69682. import { Scene } from "babylonjs/scene";
  69683. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  69684. /**
  69685. * Class used to help managing file picking and drag'n'drop
  69686. */
  69687. export class FilesInput {
  69688. /**
  69689. * List of files ready to be loaded
  69690. */
  69691. static get FilesToLoad(): {
  69692. [key: string]: File;
  69693. };
  69694. /**
  69695. * Callback called when a file is processed
  69696. */
  69697. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  69698. private _engine;
  69699. private _currentScene;
  69700. private _sceneLoadedCallback;
  69701. private _progressCallback;
  69702. private _additionalRenderLoopLogicCallback;
  69703. private _textureLoadingCallback;
  69704. private _startingProcessingFilesCallback;
  69705. private _onReloadCallback;
  69706. private _errorCallback;
  69707. private _elementToMonitor;
  69708. private _sceneFileToLoad;
  69709. private _filesToLoad;
  69710. /**
  69711. * Creates a new FilesInput
  69712. * @param engine defines the rendering engine
  69713. * @param scene defines the hosting scene
  69714. * @param sceneLoadedCallback callback called when scene is loaded
  69715. * @param progressCallback callback called to track progress
  69716. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  69717. * @param textureLoadingCallback callback called when a texture is loading
  69718. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  69719. * @param onReloadCallback callback called when a reload is requested
  69720. * @param errorCallback callback call if an error occurs
  69721. */
  69722. 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);
  69723. private _dragEnterHandler;
  69724. private _dragOverHandler;
  69725. private _dropHandler;
  69726. /**
  69727. * Calls this function to listen to drag'n'drop events on a specific DOM element
  69728. * @param elementToMonitor defines the DOM element to track
  69729. */
  69730. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  69731. /**
  69732. * Release all associated resources
  69733. */
  69734. dispose(): void;
  69735. private renderFunction;
  69736. private drag;
  69737. private drop;
  69738. private _traverseFolder;
  69739. private _processFiles;
  69740. /**
  69741. * Load files from a drop event
  69742. * @param event defines the drop event to use as source
  69743. */
  69744. loadFiles(event: any): void;
  69745. private _processReload;
  69746. /**
  69747. * Reload the current scene from the loaded files
  69748. */
  69749. reload(): void;
  69750. }
  69751. }
  69752. declare module "babylonjs/Misc/HighDynamicRange/index" {
  69753. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  69754. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  69755. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  69756. }
  69757. declare module "babylonjs/Misc/sceneOptimizer" {
  69758. import { Scene, IDisposable } from "babylonjs/scene";
  69759. import { Observable } from "babylonjs/Misc/observable";
  69760. /**
  69761. * Defines the root class used to create scene optimization to use with SceneOptimizer
  69762. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69763. */
  69764. export class SceneOptimization {
  69765. /**
  69766. * Defines the priority of this optimization (0 by default which means first in the list)
  69767. */
  69768. priority: number;
  69769. /**
  69770. * Gets a string describing the action executed by the current optimization
  69771. * @returns description string
  69772. */
  69773. getDescription(): string;
  69774. /**
  69775. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69776. * @param scene defines the current scene where to apply this optimization
  69777. * @param optimizer defines the current optimizer
  69778. * @returns true if everything that can be done was applied
  69779. */
  69780. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69781. /**
  69782. * Creates the SceneOptimization object
  69783. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69784. * @param desc defines the description associated with the optimization
  69785. */
  69786. constructor(
  69787. /**
  69788. * Defines the priority of this optimization (0 by default which means first in the list)
  69789. */
  69790. priority?: number);
  69791. }
  69792. /**
  69793. * Defines an optimization used to reduce the size of render target textures
  69794. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69795. */
  69796. export class TextureOptimization extends SceneOptimization {
  69797. /**
  69798. * Defines the priority of this optimization (0 by default which means first in the list)
  69799. */
  69800. priority: number;
  69801. /**
  69802. * 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
  69803. */
  69804. maximumSize: number;
  69805. /**
  69806. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69807. */
  69808. step: number;
  69809. /**
  69810. * Gets a string describing the action executed by the current optimization
  69811. * @returns description string
  69812. */
  69813. getDescription(): string;
  69814. /**
  69815. * Creates the TextureOptimization object
  69816. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69817. * @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
  69818. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69819. */
  69820. constructor(
  69821. /**
  69822. * Defines the priority of this optimization (0 by default which means first in the list)
  69823. */
  69824. priority?: number,
  69825. /**
  69826. * 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
  69827. */
  69828. maximumSize?: number,
  69829. /**
  69830. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  69831. */
  69832. step?: number);
  69833. /**
  69834. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69835. * @param scene defines the current scene where to apply this optimization
  69836. * @param optimizer defines the current optimizer
  69837. * @returns true if everything that can be done was applied
  69838. */
  69839. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69840. }
  69841. /**
  69842. * Defines an optimization used to increase or decrease the rendering resolution
  69843. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69844. */
  69845. export class HardwareScalingOptimization extends SceneOptimization {
  69846. /**
  69847. * Defines the priority of this optimization (0 by default which means first in the list)
  69848. */
  69849. priority: number;
  69850. /**
  69851. * Defines the maximum scale to use (2 by default)
  69852. */
  69853. maximumScale: number;
  69854. /**
  69855. * Defines the step to use between two passes (0.5 by default)
  69856. */
  69857. step: number;
  69858. private _currentScale;
  69859. private _directionOffset;
  69860. /**
  69861. * Gets a string describing the action executed by the current optimization
  69862. * @return description string
  69863. */
  69864. getDescription(): string;
  69865. /**
  69866. * Creates the HardwareScalingOptimization object
  69867. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69868. * @param maximumScale defines the maximum scale to use (2 by default)
  69869. * @param step defines the step to use between two passes (0.5 by default)
  69870. */
  69871. constructor(
  69872. /**
  69873. * Defines the priority of this optimization (0 by default which means first in the list)
  69874. */
  69875. priority?: number,
  69876. /**
  69877. * Defines the maximum scale to use (2 by default)
  69878. */
  69879. maximumScale?: number,
  69880. /**
  69881. * Defines the step to use between two passes (0.5 by default)
  69882. */
  69883. step?: number);
  69884. /**
  69885. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69886. * @param scene defines the current scene where to apply this optimization
  69887. * @param optimizer defines the current optimizer
  69888. * @returns true if everything that can be done was applied
  69889. */
  69890. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69891. }
  69892. /**
  69893. * Defines an optimization used to remove shadows
  69894. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69895. */
  69896. export class ShadowsOptimization extends SceneOptimization {
  69897. /**
  69898. * Gets a string describing the action executed by the current optimization
  69899. * @return description string
  69900. */
  69901. getDescription(): string;
  69902. /**
  69903. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69904. * @param scene defines the current scene where to apply this optimization
  69905. * @param optimizer defines the current optimizer
  69906. * @returns true if everything that can be done was applied
  69907. */
  69908. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69909. }
  69910. /**
  69911. * Defines an optimization used to turn post-processes off
  69912. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69913. */
  69914. export class PostProcessesOptimization extends SceneOptimization {
  69915. /**
  69916. * Gets a string describing the action executed by the current optimization
  69917. * @return description string
  69918. */
  69919. getDescription(): string;
  69920. /**
  69921. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69922. * @param scene defines the current scene where to apply this optimization
  69923. * @param optimizer defines the current optimizer
  69924. * @returns true if everything that can be done was applied
  69925. */
  69926. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69927. }
  69928. /**
  69929. * Defines an optimization used to turn lens flares off
  69930. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69931. */
  69932. export class LensFlaresOptimization extends SceneOptimization {
  69933. /**
  69934. * Gets a string describing the action executed by the current optimization
  69935. * @return description string
  69936. */
  69937. getDescription(): string;
  69938. /**
  69939. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69940. * @param scene defines the current scene where to apply this optimization
  69941. * @param optimizer defines the current optimizer
  69942. * @returns true if everything that can be done was applied
  69943. */
  69944. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69945. }
  69946. /**
  69947. * Defines an optimization based on user defined callback.
  69948. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69949. */
  69950. export class CustomOptimization extends SceneOptimization {
  69951. /**
  69952. * Callback called to apply the custom optimization.
  69953. */
  69954. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  69955. /**
  69956. * Callback called to get custom description
  69957. */
  69958. onGetDescription: () => string;
  69959. /**
  69960. * Gets a string describing the action executed by the current optimization
  69961. * @returns description string
  69962. */
  69963. getDescription(): string;
  69964. /**
  69965. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69966. * @param scene defines the current scene where to apply this optimization
  69967. * @param optimizer defines the current optimizer
  69968. * @returns true if everything that can be done was applied
  69969. */
  69970. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69971. }
  69972. /**
  69973. * Defines an optimization used to turn particles off
  69974. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69975. */
  69976. export class ParticlesOptimization extends SceneOptimization {
  69977. /**
  69978. * Gets a string describing the action executed by the current optimization
  69979. * @return description string
  69980. */
  69981. getDescription(): string;
  69982. /**
  69983. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  69984. * @param scene defines the current scene where to apply this optimization
  69985. * @param optimizer defines the current optimizer
  69986. * @returns true if everything that can be done was applied
  69987. */
  69988. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  69989. }
  69990. /**
  69991. * Defines an optimization used to turn render targets off
  69992. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69993. */
  69994. export class RenderTargetsOptimization extends SceneOptimization {
  69995. /**
  69996. * Gets a string describing the action executed by the current optimization
  69997. * @return description string
  69998. */
  69999. getDescription(): string;
  70000. /**
  70001. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70002. * @param scene defines the current scene where to apply this optimization
  70003. * @param optimizer defines the current optimizer
  70004. * @returns true if everything that can be done was applied
  70005. */
  70006. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70007. }
  70008. /**
  70009. * Defines an optimization used to merge meshes with compatible materials
  70010. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70011. */
  70012. export class MergeMeshesOptimization extends SceneOptimization {
  70013. private static _UpdateSelectionTree;
  70014. /**
  70015. * Gets or sets a boolean which defines if optimization octree has to be updated
  70016. */
  70017. static get UpdateSelectionTree(): boolean;
  70018. /**
  70019. * Gets or sets a boolean which defines if optimization octree has to be updated
  70020. */
  70021. static set UpdateSelectionTree(value: boolean);
  70022. /**
  70023. * Gets a string describing the action executed by the current optimization
  70024. * @return description string
  70025. */
  70026. getDescription(): string;
  70027. private _canBeMerged;
  70028. /**
  70029. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70030. * @param scene defines the current scene where to apply this optimization
  70031. * @param optimizer defines the current optimizer
  70032. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  70033. * @returns true if everything that can be done was applied
  70034. */
  70035. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  70036. }
  70037. /**
  70038. * Defines a list of options used by SceneOptimizer
  70039. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70040. */
  70041. export class SceneOptimizerOptions {
  70042. /**
  70043. * Defines the target frame rate to reach (60 by default)
  70044. */
  70045. targetFrameRate: number;
  70046. /**
  70047. * Defines the interval between two checkes (2000ms by default)
  70048. */
  70049. trackerDuration: number;
  70050. /**
  70051. * Gets the list of optimizations to apply
  70052. */
  70053. optimizations: SceneOptimization[];
  70054. /**
  70055. * Creates a new list of options used by SceneOptimizer
  70056. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  70057. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  70058. */
  70059. constructor(
  70060. /**
  70061. * Defines the target frame rate to reach (60 by default)
  70062. */
  70063. targetFrameRate?: number,
  70064. /**
  70065. * Defines the interval between two checkes (2000ms by default)
  70066. */
  70067. trackerDuration?: number);
  70068. /**
  70069. * Add a new optimization
  70070. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  70071. * @returns the current SceneOptimizerOptions
  70072. */
  70073. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  70074. /**
  70075. * Add a new custom optimization
  70076. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  70077. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  70078. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70079. * @returns the current SceneOptimizerOptions
  70080. */
  70081. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  70082. /**
  70083. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  70084. * @param targetFrameRate defines the target frame rate (60 by default)
  70085. * @returns a SceneOptimizerOptions object
  70086. */
  70087. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70088. /**
  70089. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  70090. * @param targetFrameRate defines the target frame rate (60 by default)
  70091. * @returns a SceneOptimizerOptions object
  70092. */
  70093. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70094. /**
  70095. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  70096. * @param targetFrameRate defines the target frame rate (60 by default)
  70097. * @returns a SceneOptimizerOptions object
  70098. */
  70099. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70100. }
  70101. /**
  70102. * Class used to run optimizations in order to reach a target frame rate
  70103. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70104. */
  70105. export class SceneOptimizer implements IDisposable {
  70106. private _isRunning;
  70107. private _options;
  70108. private _scene;
  70109. private _currentPriorityLevel;
  70110. private _targetFrameRate;
  70111. private _trackerDuration;
  70112. private _currentFrameRate;
  70113. private _sceneDisposeObserver;
  70114. private _improvementMode;
  70115. /**
  70116. * Defines an observable called when the optimizer reaches the target frame rate
  70117. */
  70118. onSuccessObservable: Observable<SceneOptimizer>;
  70119. /**
  70120. * Defines an observable called when the optimizer enables an optimization
  70121. */
  70122. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  70123. /**
  70124. * Defines an observable called when the optimizer is not able to reach the target frame rate
  70125. */
  70126. onFailureObservable: Observable<SceneOptimizer>;
  70127. /**
  70128. * Gets a boolean indicating if the optimizer is in improvement mode
  70129. */
  70130. get isInImprovementMode(): boolean;
  70131. /**
  70132. * Gets the current priority level (0 at start)
  70133. */
  70134. get currentPriorityLevel(): number;
  70135. /**
  70136. * Gets the current frame rate checked by the SceneOptimizer
  70137. */
  70138. get currentFrameRate(): number;
  70139. /**
  70140. * Gets or sets the current target frame rate (60 by default)
  70141. */
  70142. get targetFrameRate(): number;
  70143. /**
  70144. * Gets or sets the current target frame rate (60 by default)
  70145. */
  70146. set targetFrameRate(value: number);
  70147. /**
  70148. * Gets or sets the current interval between two checks (every 2000ms by default)
  70149. */
  70150. get trackerDuration(): number;
  70151. /**
  70152. * Gets or sets the current interval between two checks (every 2000ms by default)
  70153. */
  70154. set trackerDuration(value: number);
  70155. /**
  70156. * Gets the list of active optimizations
  70157. */
  70158. get optimizations(): SceneOptimization[];
  70159. /**
  70160. * Creates a new SceneOptimizer
  70161. * @param scene defines the scene to work on
  70162. * @param options defines the options to use with the SceneOptimizer
  70163. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  70164. * @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)
  70165. */
  70166. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  70167. /**
  70168. * Stops the current optimizer
  70169. */
  70170. stop(): void;
  70171. /**
  70172. * Reset the optimizer to initial step (current priority level = 0)
  70173. */
  70174. reset(): void;
  70175. /**
  70176. * Start the optimizer. By default it will try to reach a specific framerate
  70177. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  70178. */
  70179. start(): void;
  70180. private _checkCurrentState;
  70181. /**
  70182. * Release all resources
  70183. */
  70184. dispose(): void;
  70185. /**
  70186. * Helper function to create a SceneOptimizer with one single line of code
  70187. * @param scene defines the scene to work on
  70188. * @param options defines the options to use with the SceneOptimizer
  70189. * @param onSuccess defines a callback to call on success
  70190. * @param onFailure defines a callback to call on failure
  70191. * @returns the new SceneOptimizer object
  70192. */
  70193. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  70194. }
  70195. }
  70196. declare module "babylonjs/Misc/sceneSerializer" {
  70197. import { Scene } from "babylonjs/scene";
  70198. /**
  70199. * Class used to serialize a scene into a string
  70200. */
  70201. export class SceneSerializer {
  70202. /**
  70203. * Clear cache used by a previous serialization
  70204. */
  70205. static ClearCache(): void;
  70206. /**
  70207. * Serialize a scene into a JSON compatible object
  70208. * @param scene defines the scene to serialize
  70209. * @returns a JSON compatible object
  70210. */
  70211. static Serialize(scene: Scene): any;
  70212. /**
  70213. * Serialize a mesh into a JSON compatible object
  70214. * @param toSerialize defines the mesh to serialize
  70215. * @param withParents defines if parents must be serialized as well
  70216. * @param withChildren defines if children must be serialized as well
  70217. * @returns a JSON compatible object
  70218. */
  70219. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  70220. }
  70221. }
  70222. declare module "babylonjs/Misc/textureTools" {
  70223. import { Texture } from "babylonjs/Materials/Textures/texture";
  70224. /**
  70225. * Class used to host texture specific utilities
  70226. */
  70227. export class TextureTools {
  70228. /**
  70229. * Uses the GPU to create a copy texture rescaled at a given size
  70230. * @param texture Texture to copy from
  70231. * @param width defines the desired width
  70232. * @param height defines the desired height
  70233. * @param useBilinearMode defines if bilinear mode has to be used
  70234. * @return the generated texture
  70235. */
  70236. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  70237. }
  70238. }
  70239. declare module "babylonjs/Misc/videoRecorder" {
  70240. import { Nullable } from "babylonjs/types";
  70241. import { Engine } from "babylonjs/Engines/engine";
  70242. /**
  70243. * This represents the different options available for the video capture.
  70244. */
  70245. export interface VideoRecorderOptions {
  70246. /** Defines the mime type of the video. */
  70247. mimeType: string;
  70248. /** Defines the FPS the video should be recorded at. */
  70249. fps: number;
  70250. /** Defines the chunk size for the recording data. */
  70251. recordChunckSize: number;
  70252. /** The audio tracks to attach to the recording. */
  70253. audioTracks?: MediaStreamTrack[];
  70254. }
  70255. /**
  70256. * This can help with recording videos from BabylonJS.
  70257. * This is based on the available WebRTC functionalities of the browser.
  70258. *
  70259. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  70260. */
  70261. export class VideoRecorder {
  70262. private static readonly _defaultOptions;
  70263. /**
  70264. * Returns whether or not the VideoRecorder is available in your browser.
  70265. * @param engine Defines the Babylon Engine.
  70266. * @returns true if supported otherwise false.
  70267. */
  70268. static IsSupported(engine: Engine): boolean;
  70269. private readonly _options;
  70270. private _canvas;
  70271. private _mediaRecorder;
  70272. private _recordedChunks;
  70273. private _fileName;
  70274. private _resolve;
  70275. private _reject;
  70276. /**
  70277. * True when a recording is already in progress.
  70278. */
  70279. get isRecording(): boolean;
  70280. /**
  70281. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  70282. * @param engine Defines the BabylonJS Engine you wish to record.
  70283. * @param options Defines options that can be used to customize the capture.
  70284. */
  70285. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  70286. /**
  70287. * Stops the current recording before the default capture timeout passed in the startRecording function.
  70288. */
  70289. stopRecording(): void;
  70290. /**
  70291. * Starts recording the canvas for a max duration specified in parameters.
  70292. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  70293. * If null no automatic download will start and you can rely on the promise to get the data back.
  70294. * @param maxDuration Defines the maximum recording time in seconds.
  70295. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  70296. * @return A promise callback at the end of the recording with the video data in Blob.
  70297. */
  70298. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  70299. /**
  70300. * Releases internal resources used during the recording.
  70301. */
  70302. dispose(): void;
  70303. private _handleDataAvailable;
  70304. private _handleError;
  70305. private _handleStop;
  70306. }
  70307. }
  70308. declare module "babylonjs/Misc/screenshotTools" {
  70309. import { Camera } from "babylonjs/Cameras/camera";
  70310. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  70311. import { Engine } from "babylonjs/Engines/engine";
  70312. /**
  70313. * Class containing a set of static utilities functions for screenshots
  70314. */
  70315. export class ScreenshotTools {
  70316. /**
  70317. * Captures a screenshot of the current rendering
  70318. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70319. * @param engine defines the rendering engine
  70320. * @param camera defines the source camera
  70321. * @param size This parameter can be set to a single number or to an object with the
  70322. * following (optional) properties: precision, width, height. If a single number is passed,
  70323. * it will be used for both width and height. If an object is passed, the screenshot size
  70324. * will be derived from the parameters. The precision property is a multiplier allowing
  70325. * rendering at a higher or lower resolution
  70326. * @param successCallback defines the callback receives a single parameter which contains the
  70327. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  70328. * src parameter of an <img> to display it
  70329. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  70330. * Check your browser for supported MIME types
  70331. */
  70332. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  70333. /**
  70334. * Captures a screenshot of the current rendering
  70335. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70336. * @param engine defines the rendering engine
  70337. * @param camera defines the source camera
  70338. * @param size This parameter can be set to a single number or to an object with the
  70339. * following (optional) properties: precision, width, height. If a single number is passed,
  70340. * it will be used for both width and height. If an object is passed, the screenshot size
  70341. * will be derived from the parameters. The precision property is a multiplier allowing
  70342. * rendering at a higher or lower resolution
  70343. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  70344. * Check your browser for supported MIME types
  70345. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  70346. * to the src parameter of an <img> to display it
  70347. */
  70348. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  70349. /**
  70350. * Generates an image screenshot from the specified camera.
  70351. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70352. * @param engine The engine to use for rendering
  70353. * @param camera The camera to use for rendering
  70354. * @param size This parameter can be set to a single number or to an object with the
  70355. * following (optional) properties: precision, width, height. If a single number is passed,
  70356. * it will be used for both width and height. If an object is passed, the screenshot size
  70357. * will be derived from the parameters. The precision property is a multiplier allowing
  70358. * rendering at a higher or lower resolution
  70359. * @param successCallback The callback receives a single parameter which contains the
  70360. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  70361. * src parameter of an <img> to display it
  70362. * @param mimeType The MIME type of the screenshot image (default: image/png).
  70363. * Check your browser for supported MIME types
  70364. * @param samples Texture samples (default: 1)
  70365. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  70366. * @param fileName A name for for the downloaded file.
  70367. */
  70368. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  70369. /**
  70370. * Generates an image screenshot from the specified camera.
  70371. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70372. * @param engine The engine to use for rendering
  70373. * @param camera The camera to use for rendering
  70374. * @param size This parameter can be set to a single number or to an object with the
  70375. * following (optional) properties: precision, width, height. If a single number is passed,
  70376. * it will be used for both width and height. If an object is passed, the screenshot size
  70377. * will be derived from the parameters. The precision property is a multiplier allowing
  70378. * rendering at a higher or lower resolution
  70379. * @param mimeType The MIME type of the screenshot image (default: image/png).
  70380. * Check your browser for supported MIME types
  70381. * @param samples Texture samples (default: 1)
  70382. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  70383. * @param fileName A name for for the downloaded file.
  70384. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  70385. * to the src parameter of an <img> to display it
  70386. */
  70387. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  70388. /**
  70389. * Gets height and width for screenshot size
  70390. * @private
  70391. */
  70392. private static _getScreenshotSize;
  70393. }
  70394. }
  70395. declare module "babylonjs/Misc/dataReader" {
  70396. /**
  70397. * Interface for a data buffer
  70398. */
  70399. export interface IDataBuffer {
  70400. /**
  70401. * Reads bytes from the data buffer.
  70402. * @param byteOffset The byte offset to read
  70403. * @param byteLength The byte length to read
  70404. * @returns A promise that resolves when the bytes are read
  70405. */
  70406. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  70407. /**
  70408. * The byte length of the buffer.
  70409. */
  70410. readonly byteLength: number;
  70411. }
  70412. /**
  70413. * Utility class for reading from a data buffer
  70414. */
  70415. export class DataReader {
  70416. /**
  70417. * The data buffer associated with this data reader.
  70418. */
  70419. readonly buffer: IDataBuffer;
  70420. /**
  70421. * The current byte offset from the beginning of the data buffer.
  70422. */
  70423. byteOffset: number;
  70424. private _dataView;
  70425. private _dataByteOffset;
  70426. /**
  70427. * Constructor
  70428. * @param buffer The buffer to read
  70429. */
  70430. constructor(buffer: IDataBuffer);
  70431. /**
  70432. * Loads the given byte length.
  70433. * @param byteLength The byte length to load
  70434. * @returns A promise that resolves when the load is complete
  70435. */
  70436. loadAsync(byteLength: number): Promise<void>;
  70437. /**
  70438. * Read a unsigned 32-bit integer from the currently loaded data range.
  70439. * @returns The 32-bit integer read
  70440. */
  70441. readUint32(): number;
  70442. /**
  70443. * Read a byte array from the currently loaded data range.
  70444. * @param byteLength The byte length to read
  70445. * @returns The byte array read
  70446. */
  70447. readUint8Array(byteLength: number): Uint8Array;
  70448. /**
  70449. * Read a string from the currently loaded data range.
  70450. * @param byteLength The byte length to read
  70451. * @returns The string read
  70452. */
  70453. readString(byteLength: number): string;
  70454. /**
  70455. * Skips the given byte length the currently loaded data range.
  70456. * @param byteLength The byte length to skip
  70457. */
  70458. skipBytes(byteLength: number): void;
  70459. }
  70460. }
  70461. declare module "babylonjs/Misc/index" {
  70462. export * from "babylonjs/Misc/andOrNotEvaluator";
  70463. export * from "babylonjs/Misc/assetsManager";
  70464. export * from "babylonjs/Misc/basis";
  70465. export * from "babylonjs/Misc/dds";
  70466. export * from "babylonjs/Misc/decorators";
  70467. export * from "babylonjs/Misc/deferred";
  70468. export * from "babylonjs/Misc/environmentTextureTools";
  70469. export * from "babylonjs/Misc/meshExploder";
  70470. export * from "babylonjs/Misc/filesInput";
  70471. export * from "babylonjs/Misc/HighDynamicRange/index";
  70472. export * from "babylonjs/Misc/khronosTextureContainer";
  70473. export * from "babylonjs/Misc/observable";
  70474. export * from "babylonjs/Misc/performanceMonitor";
  70475. export * from "babylonjs/Misc/promise";
  70476. export * from "babylonjs/Misc/sceneOptimizer";
  70477. export * from "babylonjs/Misc/sceneSerializer";
  70478. export * from "babylonjs/Misc/smartArray";
  70479. export * from "babylonjs/Misc/stringDictionary";
  70480. export * from "babylonjs/Misc/tags";
  70481. export * from "babylonjs/Misc/textureTools";
  70482. export * from "babylonjs/Misc/tga";
  70483. export * from "babylonjs/Misc/tools";
  70484. export * from "babylonjs/Misc/videoRecorder";
  70485. export * from "babylonjs/Misc/virtualJoystick";
  70486. export * from "babylonjs/Misc/workerPool";
  70487. export * from "babylonjs/Misc/logger";
  70488. export * from "babylonjs/Misc/typeStore";
  70489. export * from "babylonjs/Misc/filesInputStore";
  70490. export * from "babylonjs/Misc/deepCopier";
  70491. export * from "babylonjs/Misc/pivotTools";
  70492. export * from "babylonjs/Misc/precisionDate";
  70493. export * from "babylonjs/Misc/screenshotTools";
  70494. export * from "babylonjs/Misc/typeStore";
  70495. export * from "babylonjs/Misc/webRequest";
  70496. export * from "babylonjs/Misc/iInspectable";
  70497. export * from "babylonjs/Misc/brdfTextureTools";
  70498. export * from "babylonjs/Misc/rgbdTextureTools";
  70499. export * from "babylonjs/Misc/gradients";
  70500. export * from "babylonjs/Misc/perfCounter";
  70501. export * from "babylonjs/Misc/fileRequest";
  70502. export * from "babylonjs/Misc/customAnimationFrameRequester";
  70503. export * from "babylonjs/Misc/retryStrategy";
  70504. export * from "babylonjs/Misc/interfaces/screenshotSize";
  70505. export * from "babylonjs/Misc/canvasGenerator";
  70506. export * from "babylonjs/Misc/fileTools";
  70507. export * from "babylonjs/Misc/stringTools";
  70508. export * from "babylonjs/Misc/dataReader";
  70509. }
  70510. declare module "babylonjs/index" {
  70511. export * from "babylonjs/abstractScene";
  70512. export * from "babylonjs/Actions/index";
  70513. export * from "babylonjs/Animations/index";
  70514. export * from "babylonjs/assetContainer";
  70515. export * from "babylonjs/Audio/index";
  70516. export * from "babylonjs/Behaviors/index";
  70517. export * from "babylonjs/Bones/index";
  70518. export * from "babylonjs/Cameras/index";
  70519. export * from "babylonjs/Collisions/index";
  70520. export * from "babylonjs/Culling/index";
  70521. export * from "babylonjs/Debug/index";
  70522. export * from "babylonjs/Engines/index";
  70523. export * from "babylonjs/Events/index";
  70524. export * from "babylonjs/Gamepads/index";
  70525. export * from "babylonjs/Gizmos/index";
  70526. export * from "babylonjs/Helpers/index";
  70527. export * from "babylonjs/Instrumentation/index";
  70528. export * from "babylonjs/Layers/index";
  70529. export * from "babylonjs/LensFlares/index";
  70530. export * from "babylonjs/Lights/index";
  70531. export * from "babylonjs/Loading/index";
  70532. export * from "babylonjs/Materials/index";
  70533. export * from "babylonjs/Maths/index";
  70534. export * from "babylonjs/Meshes/index";
  70535. export * from "babylonjs/Morph/index";
  70536. export * from "babylonjs/Navigation/index";
  70537. export * from "babylonjs/node";
  70538. export * from "babylonjs/Offline/index";
  70539. export * from "babylonjs/Particles/index";
  70540. export * from "babylonjs/Physics/index";
  70541. export * from "babylonjs/PostProcesses/index";
  70542. export * from "babylonjs/Probes/index";
  70543. export * from "babylonjs/Rendering/index";
  70544. export * from "babylonjs/scene";
  70545. export * from "babylonjs/sceneComponent";
  70546. export * from "babylonjs/Sprites/index";
  70547. export * from "babylonjs/States/index";
  70548. export * from "babylonjs/Misc/index";
  70549. export * from "babylonjs/types";
  70550. }
  70551. declare module "babylonjs/Animations/pathCursor" {
  70552. import { Vector3 } from "babylonjs/Maths/math.vector";
  70553. import { Path2 } from "babylonjs/Maths/math.path";
  70554. /**
  70555. * A cursor which tracks a point on a path
  70556. */
  70557. export class PathCursor {
  70558. private path;
  70559. /**
  70560. * Stores path cursor callbacks for when an onchange event is triggered
  70561. */
  70562. private _onchange;
  70563. /**
  70564. * The value of the path cursor
  70565. */
  70566. value: number;
  70567. /**
  70568. * The animation array of the path cursor
  70569. */
  70570. animations: Animation[];
  70571. /**
  70572. * Initializes the path cursor
  70573. * @param path The path to track
  70574. */
  70575. constructor(path: Path2);
  70576. /**
  70577. * Gets the cursor point on the path
  70578. * @returns A point on the path cursor at the cursor location
  70579. */
  70580. getPoint(): Vector3;
  70581. /**
  70582. * Moves the cursor ahead by the step amount
  70583. * @param step The amount to move the cursor forward
  70584. * @returns This path cursor
  70585. */
  70586. moveAhead(step?: number): PathCursor;
  70587. /**
  70588. * Moves the cursor behind by the step amount
  70589. * @param step The amount to move the cursor back
  70590. * @returns This path cursor
  70591. */
  70592. moveBack(step?: number): PathCursor;
  70593. /**
  70594. * Moves the cursor by the step amount
  70595. * If the step amount is greater than one, an exception is thrown
  70596. * @param step The amount to move the cursor
  70597. * @returns This path cursor
  70598. */
  70599. move(step: number): PathCursor;
  70600. /**
  70601. * Ensures that the value is limited between zero and one
  70602. * @returns This path cursor
  70603. */
  70604. private ensureLimits;
  70605. /**
  70606. * Runs onchange callbacks on change (used by the animation engine)
  70607. * @returns This path cursor
  70608. */
  70609. private raiseOnChange;
  70610. /**
  70611. * Executes a function on change
  70612. * @param f A path cursor onchange callback
  70613. * @returns This path cursor
  70614. */
  70615. onchange(f: (cursor: PathCursor) => void): PathCursor;
  70616. }
  70617. }
  70618. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  70619. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  70620. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  70621. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  70622. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  70623. }
  70624. declare module "babylonjs/Engines/Processors/Expressions/index" {
  70625. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  70626. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  70627. }
  70628. declare module "babylonjs/Engines/Processors/index" {
  70629. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  70630. export * from "babylonjs/Engines/Processors/Expressions/index";
  70631. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  70632. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  70633. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  70634. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  70635. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  70636. export * from "babylonjs/Engines/Processors/shaderProcessor";
  70637. }
  70638. declare module "babylonjs/Legacy/legacy" {
  70639. import * as Babylon from "babylonjs/index";
  70640. export * from "babylonjs/index";
  70641. }
  70642. declare module "babylonjs/Shaders/blur.fragment" {
  70643. /** @hidden */
  70644. export var blurPixelShader: {
  70645. name: string;
  70646. shader: string;
  70647. };
  70648. }
  70649. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  70650. /** @hidden */
  70651. export var pointCloudVertexDeclaration: {
  70652. name: string;
  70653. shader: string;
  70654. };
  70655. }
  70656. declare module "babylonjs" {
  70657. export * from "babylonjs/Legacy/legacy";
  70658. }
  70659. declare module BABYLON {
  70660. /** Alias type for value that can be null */
  70661. export type Nullable<T> = T | null;
  70662. /**
  70663. * Alias type for number that are floats
  70664. * @ignorenaming
  70665. */
  70666. export type float = number;
  70667. /**
  70668. * Alias type for number that are doubles.
  70669. * @ignorenaming
  70670. */
  70671. export type double = number;
  70672. /**
  70673. * Alias type for number that are integer
  70674. * @ignorenaming
  70675. */
  70676. export type int = number;
  70677. /** Alias type for number array or Float32Array */
  70678. export type FloatArray = number[] | Float32Array;
  70679. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  70680. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  70681. /**
  70682. * Alias for types that can be used by a Buffer or VertexBuffer.
  70683. */
  70684. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  70685. /**
  70686. * Alias type for primitive types
  70687. * @ignorenaming
  70688. */
  70689. type Primitive = undefined | null | boolean | string | number | Function;
  70690. /**
  70691. * Type modifier to make all the properties of an object Readonly
  70692. */
  70693. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  70694. /**
  70695. * Type modifier to make all the properties of an object Readonly recursively
  70696. */
  70697. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  70698. /**
  70699. * Type modifier to make object properties readonly.
  70700. */
  70701. export type DeepImmutableObject<T> = {
  70702. readonly [K in keyof T]: DeepImmutable<T[K]>;
  70703. };
  70704. /** @hidden */
  70705. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  70706. }
  70707. }
  70708. declare module BABYLON {
  70709. /**
  70710. * A class serves as a medium between the observable and its observers
  70711. */
  70712. export class EventState {
  70713. /**
  70714. * Create a new EventState
  70715. * @param mask defines the mask associated with this state
  70716. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  70717. * @param target defines the original target of the state
  70718. * @param currentTarget defines the current target of the state
  70719. */
  70720. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  70721. /**
  70722. * Initialize the current event state
  70723. * @param mask defines the mask associated with this state
  70724. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  70725. * @param target defines the original target of the state
  70726. * @param currentTarget defines the current target of the state
  70727. * @returns the current event state
  70728. */
  70729. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  70730. /**
  70731. * An Observer can set this property to true to prevent subsequent observers of being notified
  70732. */
  70733. skipNextObservers: boolean;
  70734. /**
  70735. * Get the mask value that were used to trigger the event corresponding to this EventState object
  70736. */
  70737. mask: number;
  70738. /**
  70739. * The object that originally notified the event
  70740. */
  70741. target?: any;
  70742. /**
  70743. * The current object in the bubbling phase
  70744. */
  70745. currentTarget?: any;
  70746. /**
  70747. * This will be populated with the return value of the last function that was executed.
  70748. * If it is the first function in the callback chain it will be the event data.
  70749. */
  70750. lastReturnValue?: any;
  70751. }
  70752. /**
  70753. * Represent an Observer registered to a given Observable object.
  70754. */
  70755. export class Observer<T> {
  70756. /**
  70757. * Defines the callback to call when the observer is notified
  70758. */
  70759. callback: (eventData: T, eventState: EventState) => void;
  70760. /**
  70761. * Defines the mask of the observer (used to filter notifications)
  70762. */
  70763. mask: number;
  70764. /**
  70765. * Defines the current scope used to restore the JS context
  70766. */
  70767. scope: any;
  70768. /** @hidden */
  70769. _willBeUnregistered: boolean;
  70770. /**
  70771. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  70772. */
  70773. unregisterOnNextCall: boolean;
  70774. /**
  70775. * Creates a new observer
  70776. * @param callback defines the callback to call when the observer is notified
  70777. * @param mask defines the mask of the observer (used to filter notifications)
  70778. * @param scope defines the current scope used to restore the JS context
  70779. */
  70780. constructor(
  70781. /**
  70782. * Defines the callback to call when the observer is notified
  70783. */
  70784. callback: (eventData: T, eventState: EventState) => void,
  70785. /**
  70786. * Defines the mask of the observer (used to filter notifications)
  70787. */
  70788. mask: number,
  70789. /**
  70790. * Defines the current scope used to restore the JS context
  70791. */
  70792. scope?: any);
  70793. }
  70794. /**
  70795. * Represent a list of observers registered to multiple Observables object.
  70796. */
  70797. export class MultiObserver<T> {
  70798. private _observers;
  70799. private _observables;
  70800. /**
  70801. * Release associated resources
  70802. */
  70803. dispose(): void;
  70804. /**
  70805. * Raise a callback when one of the observable will notify
  70806. * @param observables defines a list of observables to watch
  70807. * @param callback defines the callback to call on notification
  70808. * @param mask defines the mask used to filter notifications
  70809. * @param scope defines the current scope used to restore the JS context
  70810. * @returns the new MultiObserver
  70811. */
  70812. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  70813. }
  70814. /**
  70815. * The Observable class is a simple implementation of the Observable pattern.
  70816. *
  70817. * 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.
  70818. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  70819. * 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).
  70820. * 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.
  70821. */
  70822. export class Observable<T> {
  70823. private _observers;
  70824. private _eventState;
  70825. private _onObserverAdded;
  70826. /**
  70827. * Gets the list of observers
  70828. */
  70829. get observers(): Array<Observer<T>>;
  70830. /**
  70831. * Creates a new observable
  70832. * @param onObserverAdded defines a callback to call when a new observer is added
  70833. */
  70834. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  70835. /**
  70836. * Create a new Observer with the specified callback
  70837. * @param callback the callback that will be executed for that Observer
  70838. * @param mask the mask used to filter observers
  70839. * @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.
  70840. * @param scope optional scope for the callback to be called from
  70841. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  70842. * @returns the new observer created for the callback
  70843. */
  70844. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  70845. /**
  70846. * Create a new Observer with the specified callback and unregisters after the next notification
  70847. * @param callback the callback that will be executed for that Observer
  70848. * @returns the new observer created for the callback
  70849. */
  70850. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  70851. /**
  70852. * Remove an Observer from the Observable object
  70853. * @param observer the instance of the Observer to remove
  70854. * @returns false if it doesn't belong to this Observable
  70855. */
  70856. remove(observer: Nullable<Observer<T>>): boolean;
  70857. /**
  70858. * Remove a callback from the Observable object
  70859. * @param callback the callback to remove
  70860. * @param scope optional scope. If used only the callbacks with this scope will be removed
  70861. * @returns false if it doesn't belong to this Observable
  70862. */
  70863. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  70864. private _deferUnregister;
  70865. private _remove;
  70866. /**
  70867. * Moves the observable to the top of the observer list making it get called first when notified
  70868. * @param observer the observer to move
  70869. */
  70870. makeObserverTopPriority(observer: Observer<T>): void;
  70871. /**
  70872. * Moves the observable to the bottom of the observer list making it get called last when notified
  70873. * @param observer the observer to move
  70874. */
  70875. makeObserverBottomPriority(observer: Observer<T>): void;
  70876. /**
  70877. * Notify all Observers by calling their respective callback with the given data
  70878. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  70879. * @param eventData defines the data to send to all observers
  70880. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  70881. * @param target defines the original target of the state
  70882. * @param currentTarget defines the current target of the state
  70883. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  70884. */
  70885. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  70886. /**
  70887. * Calling this will execute each callback, expecting it to be a promise or return a value.
  70888. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  70889. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  70890. * and it is crucial that all callbacks will be executed.
  70891. * The order of the callbacks is kept, callbacks are not executed parallel.
  70892. *
  70893. * @param eventData The data to be sent to each callback
  70894. * @param mask is used to filter observers defaults to -1
  70895. * @param target defines the callback target (see EventState)
  70896. * @param currentTarget defines he current object in the bubbling phase
  70897. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  70898. */
  70899. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  70900. /**
  70901. * Notify a specific observer
  70902. * @param observer defines the observer to notify
  70903. * @param eventData defines the data to be sent to each callback
  70904. * @param mask is used to filter observers defaults to -1
  70905. */
  70906. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  70907. /**
  70908. * Gets a boolean indicating if the observable has at least one observer
  70909. * @returns true is the Observable has at least one Observer registered
  70910. */
  70911. hasObservers(): boolean;
  70912. /**
  70913. * Clear the list of observers
  70914. */
  70915. clear(): void;
  70916. /**
  70917. * Clone the current observable
  70918. * @returns a new observable
  70919. */
  70920. clone(): Observable<T>;
  70921. /**
  70922. * Does this observable handles observer registered with a given mask
  70923. * @param mask defines the mask to be tested
  70924. * @return whether or not one observer registered with the given mask is handeled
  70925. **/
  70926. hasSpecificMask(mask?: number): boolean;
  70927. }
  70928. }
  70929. declare module BABYLON {
  70930. /**
  70931. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  70932. * Babylon.js
  70933. */
  70934. export class DomManagement {
  70935. /**
  70936. * Checks if the window object exists
  70937. * @returns true if the window object exists
  70938. */
  70939. static IsWindowObjectExist(): boolean;
  70940. /**
  70941. * Checks if the navigator object exists
  70942. * @returns true if the navigator object exists
  70943. */
  70944. static IsNavigatorAvailable(): boolean;
  70945. /**
  70946. * Extracts text content from a DOM element hierarchy
  70947. * @param element defines the root element
  70948. * @returns a string
  70949. */
  70950. static GetDOMTextContent(element: HTMLElement): string;
  70951. }
  70952. }
  70953. declare module BABYLON {
  70954. /**
  70955. * Logger used througouht the application to allow configuration of
  70956. * the log level required for the messages.
  70957. */
  70958. export class Logger {
  70959. /**
  70960. * No log
  70961. */
  70962. static readonly NoneLogLevel: number;
  70963. /**
  70964. * Only message logs
  70965. */
  70966. static readonly MessageLogLevel: number;
  70967. /**
  70968. * Only warning logs
  70969. */
  70970. static readonly WarningLogLevel: number;
  70971. /**
  70972. * Only error logs
  70973. */
  70974. static readonly ErrorLogLevel: number;
  70975. /**
  70976. * All logs
  70977. */
  70978. static readonly AllLogLevel: number;
  70979. private static _LogCache;
  70980. /**
  70981. * Gets a value indicating the number of loading errors
  70982. * @ignorenaming
  70983. */
  70984. static errorsCount: number;
  70985. /**
  70986. * Callback called when a new log is added
  70987. */
  70988. static OnNewCacheEntry: (entry: string) => void;
  70989. private static _AddLogEntry;
  70990. private static _FormatMessage;
  70991. private static _LogDisabled;
  70992. private static _LogEnabled;
  70993. private static _WarnDisabled;
  70994. private static _WarnEnabled;
  70995. private static _ErrorDisabled;
  70996. private static _ErrorEnabled;
  70997. /**
  70998. * Log a message to the console
  70999. */
  71000. static Log: (message: string) => void;
  71001. /**
  71002. * Write a warning message to the console
  71003. */
  71004. static Warn: (message: string) => void;
  71005. /**
  71006. * Write an error message to the console
  71007. */
  71008. static Error: (message: string) => void;
  71009. /**
  71010. * Gets current log cache (list of logs)
  71011. */
  71012. static get LogCache(): string;
  71013. /**
  71014. * Clears the log cache
  71015. */
  71016. static ClearLogCache(): void;
  71017. /**
  71018. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  71019. */
  71020. static set LogLevels(level: number);
  71021. }
  71022. }
  71023. declare module BABYLON {
  71024. /** @hidden */
  71025. export class _TypeStore {
  71026. /** @hidden */
  71027. static RegisteredTypes: {
  71028. [key: string]: Object;
  71029. };
  71030. /** @hidden */
  71031. static GetClass(fqdn: string): any;
  71032. }
  71033. }
  71034. declare module BABYLON {
  71035. /**
  71036. * Helper to manipulate strings
  71037. */
  71038. export class StringTools {
  71039. /**
  71040. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  71041. * @param str Source string
  71042. * @param suffix Suffix to search for in the source string
  71043. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71044. */
  71045. static EndsWith(str: string, suffix: string): boolean;
  71046. /**
  71047. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  71048. * @param str Source string
  71049. * @param suffix Suffix to search for in the source string
  71050. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71051. */
  71052. static StartsWith(str: string, suffix: string): boolean;
  71053. /**
  71054. * Decodes a buffer into a string
  71055. * @param buffer The buffer to decode
  71056. * @returns The decoded string
  71057. */
  71058. static Decode(buffer: Uint8Array | Uint16Array): string;
  71059. /**
  71060. * Encode a buffer to a base64 string
  71061. * @param buffer defines the buffer to encode
  71062. * @returns the encoded string
  71063. */
  71064. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  71065. }
  71066. }
  71067. declare module BABYLON {
  71068. /**
  71069. * Class containing a set of static utilities functions for deep copy.
  71070. */
  71071. export class DeepCopier {
  71072. /**
  71073. * Tries to copy an object by duplicating every property
  71074. * @param source defines the source object
  71075. * @param destination defines the target object
  71076. * @param doNotCopyList defines a list of properties to avoid
  71077. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  71078. */
  71079. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  71080. }
  71081. }
  71082. declare module BABYLON {
  71083. /**
  71084. * Class containing a set of static utilities functions for precision date
  71085. */
  71086. export class PrecisionDate {
  71087. /**
  71088. * Gets either window.performance.now() if supported or Date.now() else
  71089. */
  71090. static get Now(): number;
  71091. }
  71092. }
  71093. declare module BABYLON {
  71094. /** @hidden */
  71095. export class _DevTools {
  71096. static WarnImport(name: string): string;
  71097. }
  71098. }
  71099. declare module BABYLON {
  71100. /**
  71101. * Interface used to define the mechanism to get data from the network
  71102. */
  71103. export interface IWebRequest {
  71104. /**
  71105. * Returns client's response url
  71106. */
  71107. responseURL: string;
  71108. /**
  71109. * Returns client's status
  71110. */
  71111. status: number;
  71112. /**
  71113. * Returns client's status as a text
  71114. */
  71115. statusText: string;
  71116. }
  71117. }
  71118. declare module BABYLON {
  71119. /**
  71120. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  71121. */
  71122. export class WebRequest implements IWebRequest {
  71123. private _xhr;
  71124. /**
  71125. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  71126. * i.e. when loading files, where the server/service expects an Authorization header
  71127. */
  71128. static CustomRequestHeaders: {
  71129. [key: string]: string;
  71130. };
  71131. /**
  71132. * Add callback functions in this array to update all the requests before they get sent to the network
  71133. */
  71134. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  71135. private _injectCustomRequestHeaders;
  71136. /**
  71137. * Gets or sets a function to be called when loading progress changes
  71138. */
  71139. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  71140. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  71141. /**
  71142. * Returns client's state
  71143. */
  71144. get readyState(): number;
  71145. /**
  71146. * Returns client's status
  71147. */
  71148. get status(): number;
  71149. /**
  71150. * Returns client's status as a text
  71151. */
  71152. get statusText(): string;
  71153. /**
  71154. * Returns client's response
  71155. */
  71156. get response(): any;
  71157. /**
  71158. * Returns client's response url
  71159. */
  71160. get responseURL(): string;
  71161. /**
  71162. * Returns client's response as text
  71163. */
  71164. get responseText(): string;
  71165. /**
  71166. * Gets or sets the expected response type
  71167. */
  71168. get responseType(): XMLHttpRequestResponseType;
  71169. set responseType(value: XMLHttpRequestResponseType);
  71170. /** @hidden */
  71171. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  71172. /** @hidden */
  71173. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  71174. /**
  71175. * Cancels any network activity
  71176. */
  71177. abort(): void;
  71178. /**
  71179. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  71180. * @param body defines an optional request body
  71181. */
  71182. send(body?: Document | BodyInit | null): void;
  71183. /**
  71184. * Sets the request method, request URL
  71185. * @param method defines the method to use (GET, POST, etc..)
  71186. * @param url defines the url to connect with
  71187. */
  71188. open(method: string, url: string): void;
  71189. /**
  71190. * Sets the value of a request header.
  71191. * @param name The name of the header whose value is to be set
  71192. * @param value The value to set as the body of the header
  71193. */
  71194. setRequestHeader(name: string, value: string): void;
  71195. /**
  71196. * Get the string containing the text of a particular header's value.
  71197. * @param name The name of the header
  71198. * @returns The string containing the text of the given header name
  71199. */
  71200. getResponseHeader(name: string): Nullable<string>;
  71201. }
  71202. }
  71203. declare module BABYLON {
  71204. /**
  71205. * File request interface
  71206. */
  71207. export interface IFileRequest {
  71208. /**
  71209. * Raised when the request is complete (success or error).
  71210. */
  71211. onCompleteObservable: Observable<IFileRequest>;
  71212. /**
  71213. * Aborts the request for a file.
  71214. */
  71215. abort: () => void;
  71216. }
  71217. }
  71218. declare module BABYLON {
  71219. /**
  71220. * Define options used to create a render target texture
  71221. */
  71222. export class RenderTargetCreationOptions {
  71223. /**
  71224. * Specifies is mipmaps must be generated
  71225. */
  71226. generateMipMaps?: boolean;
  71227. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  71228. generateDepthBuffer?: boolean;
  71229. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  71230. generateStencilBuffer?: boolean;
  71231. /** Defines texture type (int by default) */
  71232. type?: number;
  71233. /** Defines sampling mode (trilinear by default) */
  71234. samplingMode?: number;
  71235. /** Defines format (RGBA by default) */
  71236. format?: number;
  71237. }
  71238. }
  71239. declare module BABYLON {
  71240. /**
  71241. * @hidden
  71242. **/
  71243. export class _TimeToken {
  71244. _startTimeQuery: Nullable<WebGLQuery>;
  71245. _endTimeQuery: Nullable<WebGLQuery>;
  71246. _timeElapsedQuery: Nullable<WebGLQuery>;
  71247. _timeElapsedQueryEnded: boolean;
  71248. }
  71249. }
  71250. declare module BABYLON {
  71251. /** Defines the cross module used constants to avoid circular dependncies */
  71252. export class Constants {
  71253. /** Defines that alpha blending is disabled */
  71254. static readonly ALPHA_DISABLE: number;
  71255. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  71256. static readonly ALPHA_ADD: number;
  71257. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  71258. static readonly ALPHA_COMBINE: number;
  71259. /** Defines that alpha blending is DEST - SRC * DEST */
  71260. static readonly ALPHA_SUBTRACT: number;
  71261. /** Defines that alpha blending is SRC * DEST */
  71262. static readonly ALPHA_MULTIPLY: number;
  71263. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  71264. static readonly ALPHA_MAXIMIZED: number;
  71265. /** Defines that alpha blending is SRC + DEST */
  71266. static readonly ALPHA_ONEONE: number;
  71267. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  71268. static readonly ALPHA_PREMULTIPLIED: number;
  71269. /**
  71270. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  71271. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  71272. */
  71273. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  71274. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  71275. static readonly ALPHA_INTERPOLATE: number;
  71276. /**
  71277. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  71278. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  71279. */
  71280. static readonly ALPHA_SCREENMODE: number;
  71281. /**
  71282. * Defines that alpha blending is SRC + DST
  71283. * Alpha will be set to SRC ALPHA + DST ALPHA
  71284. */
  71285. static readonly ALPHA_ONEONE_ONEONE: number;
  71286. /**
  71287. * Defines that alpha blending is SRC * DST ALPHA + DST
  71288. * Alpha will be set to 0
  71289. */
  71290. static readonly ALPHA_ALPHATOCOLOR: number;
  71291. /**
  71292. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  71293. */
  71294. static readonly ALPHA_REVERSEONEMINUS: number;
  71295. /**
  71296. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  71297. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  71298. */
  71299. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  71300. /**
  71301. * Defines that alpha blending is SRC + DST
  71302. * Alpha will be set to SRC ALPHA
  71303. */
  71304. static readonly ALPHA_ONEONE_ONEZERO: number;
  71305. /**
  71306. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  71307. * Alpha will be set to DST ALPHA
  71308. */
  71309. static readonly ALPHA_EXCLUSION: number;
  71310. /** Defines that alpha blending equation a SUM */
  71311. static readonly ALPHA_EQUATION_ADD: number;
  71312. /** Defines that alpha blending equation a SUBSTRACTION */
  71313. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  71314. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  71315. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  71316. /** Defines that alpha blending equation a MAX operation */
  71317. static readonly ALPHA_EQUATION_MAX: number;
  71318. /** Defines that alpha blending equation a MIN operation */
  71319. static readonly ALPHA_EQUATION_MIN: number;
  71320. /**
  71321. * Defines that alpha blending equation a DARKEN operation:
  71322. * It takes the min of the src and sums the alpha channels.
  71323. */
  71324. static readonly ALPHA_EQUATION_DARKEN: number;
  71325. /** Defines that the ressource is not delayed*/
  71326. static readonly DELAYLOADSTATE_NONE: number;
  71327. /** Defines that the ressource was successfully delay loaded */
  71328. static readonly DELAYLOADSTATE_LOADED: number;
  71329. /** Defines that the ressource is currently delay loading */
  71330. static readonly DELAYLOADSTATE_LOADING: number;
  71331. /** Defines that the ressource is delayed and has not started loading */
  71332. static readonly DELAYLOADSTATE_NOTLOADED: number;
  71333. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  71334. static readonly NEVER: number;
  71335. /** 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 */
  71336. static readonly ALWAYS: number;
  71337. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  71338. static readonly LESS: number;
  71339. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  71340. static readonly EQUAL: number;
  71341. /** 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 */
  71342. static readonly LEQUAL: number;
  71343. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  71344. static readonly GREATER: number;
  71345. /** 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 */
  71346. static readonly GEQUAL: number;
  71347. /** 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 */
  71348. static readonly NOTEQUAL: number;
  71349. /** Passed to stencilOperation to specify that stencil value must be kept */
  71350. static readonly KEEP: number;
  71351. /** Passed to stencilOperation to specify that stencil value must be replaced */
  71352. static readonly REPLACE: number;
  71353. /** Passed to stencilOperation to specify that stencil value must be incremented */
  71354. static readonly INCR: number;
  71355. /** Passed to stencilOperation to specify that stencil value must be decremented */
  71356. static readonly DECR: number;
  71357. /** Passed to stencilOperation to specify that stencil value must be inverted */
  71358. static readonly INVERT: number;
  71359. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  71360. static readonly INCR_WRAP: number;
  71361. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  71362. static readonly DECR_WRAP: number;
  71363. /** Texture is not repeating outside of 0..1 UVs */
  71364. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  71365. /** Texture is repeating outside of 0..1 UVs */
  71366. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  71367. /** Texture is repeating and mirrored */
  71368. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  71369. /** ALPHA */
  71370. static readonly TEXTUREFORMAT_ALPHA: number;
  71371. /** LUMINANCE */
  71372. static readonly TEXTUREFORMAT_LUMINANCE: number;
  71373. /** LUMINANCE_ALPHA */
  71374. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  71375. /** RGB */
  71376. static readonly TEXTUREFORMAT_RGB: number;
  71377. /** RGBA */
  71378. static readonly TEXTUREFORMAT_RGBA: number;
  71379. /** RED */
  71380. static readonly TEXTUREFORMAT_RED: number;
  71381. /** RED (2nd reference) */
  71382. static readonly TEXTUREFORMAT_R: number;
  71383. /** RG */
  71384. static readonly TEXTUREFORMAT_RG: number;
  71385. /** RED_INTEGER */
  71386. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  71387. /** RED_INTEGER (2nd reference) */
  71388. static readonly TEXTUREFORMAT_R_INTEGER: number;
  71389. /** RG_INTEGER */
  71390. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  71391. /** RGB_INTEGER */
  71392. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  71393. /** RGBA_INTEGER */
  71394. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  71395. /** UNSIGNED_BYTE */
  71396. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  71397. /** UNSIGNED_BYTE (2nd reference) */
  71398. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  71399. /** FLOAT */
  71400. static readonly TEXTURETYPE_FLOAT: number;
  71401. /** HALF_FLOAT */
  71402. static readonly TEXTURETYPE_HALF_FLOAT: number;
  71403. /** BYTE */
  71404. static readonly TEXTURETYPE_BYTE: number;
  71405. /** SHORT */
  71406. static readonly TEXTURETYPE_SHORT: number;
  71407. /** UNSIGNED_SHORT */
  71408. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  71409. /** INT */
  71410. static readonly TEXTURETYPE_INT: number;
  71411. /** UNSIGNED_INT */
  71412. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  71413. /** UNSIGNED_SHORT_4_4_4_4 */
  71414. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  71415. /** UNSIGNED_SHORT_5_5_5_1 */
  71416. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  71417. /** UNSIGNED_SHORT_5_6_5 */
  71418. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  71419. /** UNSIGNED_INT_2_10_10_10_REV */
  71420. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  71421. /** UNSIGNED_INT_24_8 */
  71422. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  71423. /** UNSIGNED_INT_10F_11F_11F_REV */
  71424. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  71425. /** UNSIGNED_INT_5_9_9_9_REV */
  71426. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  71427. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  71428. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  71429. /** nearest is mag = nearest and min = nearest and mip = nearest */
  71430. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  71431. /** Bilinear is mag = linear and min = linear and mip = nearest */
  71432. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  71433. /** Trilinear is mag = linear and min = linear and mip = linear */
  71434. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  71435. /** nearest is mag = nearest and min = nearest and mip = linear */
  71436. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  71437. /** Bilinear is mag = linear and min = linear and mip = nearest */
  71438. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  71439. /** Trilinear is mag = linear and min = linear and mip = linear */
  71440. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  71441. /** mag = nearest and min = nearest and mip = nearest */
  71442. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  71443. /** mag = nearest and min = linear and mip = nearest */
  71444. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  71445. /** mag = nearest and min = linear and mip = linear */
  71446. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  71447. /** mag = nearest and min = linear and mip = none */
  71448. static readonly TEXTURE_NEAREST_LINEAR: number;
  71449. /** mag = nearest and min = nearest and mip = none */
  71450. static readonly TEXTURE_NEAREST_NEAREST: number;
  71451. /** mag = linear and min = nearest and mip = nearest */
  71452. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  71453. /** mag = linear and min = nearest and mip = linear */
  71454. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  71455. /** mag = linear and min = linear and mip = none */
  71456. static readonly TEXTURE_LINEAR_LINEAR: number;
  71457. /** mag = linear and min = nearest and mip = none */
  71458. static readonly TEXTURE_LINEAR_NEAREST: number;
  71459. /** Explicit coordinates mode */
  71460. static readonly TEXTURE_EXPLICIT_MODE: number;
  71461. /** Spherical coordinates mode */
  71462. static readonly TEXTURE_SPHERICAL_MODE: number;
  71463. /** Planar coordinates mode */
  71464. static readonly TEXTURE_PLANAR_MODE: number;
  71465. /** Cubic coordinates mode */
  71466. static readonly TEXTURE_CUBIC_MODE: number;
  71467. /** Projection coordinates mode */
  71468. static readonly TEXTURE_PROJECTION_MODE: number;
  71469. /** Skybox coordinates mode */
  71470. static readonly TEXTURE_SKYBOX_MODE: number;
  71471. /** Inverse Cubic coordinates mode */
  71472. static readonly TEXTURE_INVCUBIC_MODE: number;
  71473. /** Equirectangular coordinates mode */
  71474. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  71475. /** Equirectangular Fixed coordinates mode */
  71476. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  71477. /** Equirectangular Fixed Mirrored coordinates mode */
  71478. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  71479. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  71480. static readonly SCALEMODE_FLOOR: number;
  71481. /** Defines that texture rescaling will look for the nearest power of 2 size */
  71482. static readonly SCALEMODE_NEAREST: number;
  71483. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  71484. static readonly SCALEMODE_CEILING: number;
  71485. /**
  71486. * The dirty texture flag value
  71487. */
  71488. static readonly MATERIAL_TextureDirtyFlag: number;
  71489. /**
  71490. * The dirty light flag value
  71491. */
  71492. static readonly MATERIAL_LightDirtyFlag: number;
  71493. /**
  71494. * The dirty fresnel flag value
  71495. */
  71496. static readonly MATERIAL_FresnelDirtyFlag: number;
  71497. /**
  71498. * The dirty attribute flag value
  71499. */
  71500. static readonly MATERIAL_AttributesDirtyFlag: number;
  71501. /**
  71502. * The dirty misc flag value
  71503. */
  71504. static readonly MATERIAL_MiscDirtyFlag: number;
  71505. /**
  71506. * The all dirty flag value
  71507. */
  71508. static readonly MATERIAL_AllDirtyFlag: number;
  71509. /**
  71510. * Returns the triangle fill mode
  71511. */
  71512. static readonly MATERIAL_TriangleFillMode: number;
  71513. /**
  71514. * Returns the wireframe mode
  71515. */
  71516. static readonly MATERIAL_WireFrameFillMode: number;
  71517. /**
  71518. * Returns the point fill mode
  71519. */
  71520. static readonly MATERIAL_PointFillMode: number;
  71521. /**
  71522. * Returns the point list draw mode
  71523. */
  71524. static readonly MATERIAL_PointListDrawMode: number;
  71525. /**
  71526. * Returns the line list draw mode
  71527. */
  71528. static readonly MATERIAL_LineListDrawMode: number;
  71529. /**
  71530. * Returns the line loop draw mode
  71531. */
  71532. static readonly MATERIAL_LineLoopDrawMode: number;
  71533. /**
  71534. * Returns the line strip draw mode
  71535. */
  71536. static readonly MATERIAL_LineStripDrawMode: number;
  71537. /**
  71538. * Returns the triangle strip draw mode
  71539. */
  71540. static readonly MATERIAL_TriangleStripDrawMode: number;
  71541. /**
  71542. * Returns the triangle fan draw mode
  71543. */
  71544. static readonly MATERIAL_TriangleFanDrawMode: number;
  71545. /**
  71546. * Stores the clock-wise side orientation
  71547. */
  71548. static readonly MATERIAL_ClockWiseSideOrientation: number;
  71549. /**
  71550. * Stores the counter clock-wise side orientation
  71551. */
  71552. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  71553. /**
  71554. * Nothing
  71555. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71556. */
  71557. static readonly ACTION_NothingTrigger: number;
  71558. /**
  71559. * On pick
  71560. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71561. */
  71562. static readonly ACTION_OnPickTrigger: number;
  71563. /**
  71564. * On left pick
  71565. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71566. */
  71567. static readonly ACTION_OnLeftPickTrigger: number;
  71568. /**
  71569. * On right pick
  71570. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71571. */
  71572. static readonly ACTION_OnRightPickTrigger: number;
  71573. /**
  71574. * On center pick
  71575. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71576. */
  71577. static readonly ACTION_OnCenterPickTrigger: number;
  71578. /**
  71579. * On pick down
  71580. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71581. */
  71582. static readonly ACTION_OnPickDownTrigger: number;
  71583. /**
  71584. * On double pick
  71585. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71586. */
  71587. static readonly ACTION_OnDoublePickTrigger: number;
  71588. /**
  71589. * On pick up
  71590. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71591. */
  71592. static readonly ACTION_OnPickUpTrigger: number;
  71593. /**
  71594. * On pick out.
  71595. * This trigger will only be raised if you also declared a OnPickDown
  71596. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71597. */
  71598. static readonly ACTION_OnPickOutTrigger: number;
  71599. /**
  71600. * On long press
  71601. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71602. */
  71603. static readonly ACTION_OnLongPressTrigger: number;
  71604. /**
  71605. * On pointer over
  71606. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71607. */
  71608. static readonly ACTION_OnPointerOverTrigger: number;
  71609. /**
  71610. * On pointer out
  71611. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71612. */
  71613. static readonly ACTION_OnPointerOutTrigger: number;
  71614. /**
  71615. * On every frame
  71616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71617. */
  71618. static readonly ACTION_OnEveryFrameTrigger: number;
  71619. /**
  71620. * On intersection enter
  71621. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71622. */
  71623. static readonly ACTION_OnIntersectionEnterTrigger: number;
  71624. /**
  71625. * On intersection exit
  71626. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71627. */
  71628. static readonly ACTION_OnIntersectionExitTrigger: number;
  71629. /**
  71630. * On key down
  71631. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71632. */
  71633. static readonly ACTION_OnKeyDownTrigger: number;
  71634. /**
  71635. * On key up
  71636. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71637. */
  71638. static readonly ACTION_OnKeyUpTrigger: number;
  71639. /**
  71640. * Billboard mode will only apply to Y axis
  71641. */
  71642. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  71643. /**
  71644. * Billboard mode will apply to all axes
  71645. */
  71646. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  71647. /**
  71648. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  71649. */
  71650. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  71651. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  71652. * Test order :
  71653. * Is the bounding sphere outside the frustum ?
  71654. * If not, are the bounding box vertices outside the frustum ?
  71655. * It not, then the cullable object is in the frustum.
  71656. */
  71657. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  71658. /** Culling strategy : Bounding Sphere Only.
  71659. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  71660. * It's also less accurate than the standard because some not visible objects can still be selected.
  71661. * Test : is the bounding sphere outside the frustum ?
  71662. * If not, then the cullable object is in the frustum.
  71663. */
  71664. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  71665. /** Culling strategy : Optimistic Inclusion.
  71666. * This in an inclusion test first, then the standard exclusion test.
  71667. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  71668. * 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.
  71669. * Anyway, it's as accurate as the standard strategy.
  71670. * Test :
  71671. * Is the cullable object bounding sphere center in the frustum ?
  71672. * If not, apply the default culling strategy.
  71673. */
  71674. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  71675. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  71676. * This in an inclusion test first, then the bounding sphere only exclusion test.
  71677. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  71678. * 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.
  71679. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  71680. * Test :
  71681. * Is the cullable object bounding sphere center in the frustum ?
  71682. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  71683. */
  71684. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  71685. /**
  71686. * No logging while loading
  71687. */
  71688. static readonly SCENELOADER_NO_LOGGING: number;
  71689. /**
  71690. * Minimal logging while loading
  71691. */
  71692. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  71693. /**
  71694. * Summary logging while loading
  71695. */
  71696. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  71697. /**
  71698. * Detailled logging while loading
  71699. */
  71700. static readonly SCENELOADER_DETAILED_LOGGING: number;
  71701. }
  71702. }
  71703. declare module BABYLON {
  71704. /**
  71705. * This represents the required contract to create a new type of texture loader.
  71706. */
  71707. export interface IInternalTextureLoader {
  71708. /**
  71709. * Defines wether the loader supports cascade loading the different faces.
  71710. */
  71711. supportCascades: boolean;
  71712. /**
  71713. * This returns if the loader support the current file information.
  71714. * @param extension defines the file extension of the file being loaded
  71715. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71716. * @param fallback defines the fallback internal texture if any
  71717. * @param isBase64 defines whether the texture is encoded as a base64
  71718. * @param isBuffer defines whether the texture data are stored as a buffer
  71719. * @returns true if the loader can load the specified file
  71720. */
  71721. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  71722. /**
  71723. * Transform the url before loading if required.
  71724. * @param rootUrl the url of the texture
  71725. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71726. * @returns the transformed texture
  71727. */
  71728. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  71729. /**
  71730. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  71731. * @param rootUrl the url of the texture
  71732. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71733. * @returns the fallback texture
  71734. */
  71735. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  71736. /**
  71737. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  71738. * @param data contains the texture data
  71739. * @param texture defines the BabylonJS internal texture
  71740. * @param createPolynomials will be true if polynomials have been requested
  71741. * @param onLoad defines the callback to trigger once the texture is ready
  71742. * @param onError defines the callback to trigger in case of error
  71743. */
  71744. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  71745. /**
  71746. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  71747. * @param data contains the texture data
  71748. * @param texture defines the BabylonJS internal texture
  71749. * @param callback defines the method to call once ready to upload
  71750. */
  71751. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  71752. }
  71753. }
  71754. declare module BABYLON {
  71755. /**
  71756. * Class used to store and describe the pipeline context associated with an effect
  71757. */
  71758. export interface IPipelineContext {
  71759. /**
  71760. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  71761. */
  71762. isAsync: boolean;
  71763. /**
  71764. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  71765. */
  71766. isReady: boolean;
  71767. /** @hidden */
  71768. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  71769. }
  71770. }
  71771. declare module BABYLON {
  71772. /**
  71773. * Class used to store gfx data (like WebGLBuffer)
  71774. */
  71775. export class DataBuffer {
  71776. /**
  71777. * Gets or sets the number of objects referencing this buffer
  71778. */
  71779. references: number;
  71780. /** Gets or sets the size of the underlying buffer */
  71781. capacity: number;
  71782. /**
  71783. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  71784. */
  71785. is32Bits: boolean;
  71786. /**
  71787. * Gets the underlying buffer
  71788. */
  71789. get underlyingResource(): any;
  71790. }
  71791. }
  71792. declare module BABYLON {
  71793. /** @hidden */
  71794. export interface IShaderProcessor {
  71795. attributeProcessor?: (attribute: string) => string;
  71796. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  71797. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  71798. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  71799. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  71800. lineProcessor?: (line: string, isFragment: boolean) => string;
  71801. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71802. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71803. }
  71804. }
  71805. declare module BABYLON {
  71806. /** @hidden */
  71807. export interface ProcessingOptions {
  71808. defines: string[];
  71809. indexParameters: any;
  71810. isFragment: boolean;
  71811. shouldUseHighPrecisionShader: boolean;
  71812. supportsUniformBuffers: boolean;
  71813. shadersRepository: string;
  71814. includesShadersStore: {
  71815. [key: string]: string;
  71816. };
  71817. processor?: IShaderProcessor;
  71818. version: string;
  71819. platformName: string;
  71820. lookForClosingBracketForUniformBuffer?: boolean;
  71821. }
  71822. }
  71823. declare module BABYLON {
  71824. /** @hidden */
  71825. export class ShaderCodeNode {
  71826. line: string;
  71827. children: ShaderCodeNode[];
  71828. additionalDefineKey?: string;
  71829. additionalDefineValue?: string;
  71830. isValid(preprocessors: {
  71831. [key: string]: string;
  71832. }): boolean;
  71833. process(preprocessors: {
  71834. [key: string]: string;
  71835. }, options: ProcessingOptions): string;
  71836. }
  71837. }
  71838. declare module BABYLON {
  71839. /** @hidden */
  71840. export class ShaderCodeCursor {
  71841. private _lines;
  71842. lineIndex: number;
  71843. get currentLine(): string;
  71844. get canRead(): boolean;
  71845. set lines(value: string[]);
  71846. }
  71847. }
  71848. declare module BABYLON {
  71849. /** @hidden */
  71850. export class ShaderCodeConditionNode extends ShaderCodeNode {
  71851. process(preprocessors: {
  71852. [key: string]: string;
  71853. }, options: ProcessingOptions): string;
  71854. }
  71855. }
  71856. declare module BABYLON {
  71857. /** @hidden */
  71858. export class ShaderDefineExpression {
  71859. isTrue(preprocessors: {
  71860. [key: string]: string;
  71861. }): boolean;
  71862. }
  71863. }
  71864. declare module BABYLON {
  71865. /** @hidden */
  71866. export class ShaderCodeTestNode extends ShaderCodeNode {
  71867. testExpression: ShaderDefineExpression;
  71868. isValid(preprocessors: {
  71869. [key: string]: string;
  71870. }): boolean;
  71871. }
  71872. }
  71873. declare module BABYLON {
  71874. /** @hidden */
  71875. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  71876. define: string;
  71877. not: boolean;
  71878. constructor(define: string, not?: boolean);
  71879. isTrue(preprocessors: {
  71880. [key: string]: string;
  71881. }): boolean;
  71882. }
  71883. }
  71884. declare module BABYLON {
  71885. /** @hidden */
  71886. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  71887. leftOperand: ShaderDefineExpression;
  71888. rightOperand: ShaderDefineExpression;
  71889. isTrue(preprocessors: {
  71890. [key: string]: string;
  71891. }): boolean;
  71892. }
  71893. }
  71894. declare module BABYLON {
  71895. /** @hidden */
  71896. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  71897. leftOperand: ShaderDefineExpression;
  71898. rightOperand: ShaderDefineExpression;
  71899. isTrue(preprocessors: {
  71900. [key: string]: string;
  71901. }): boolean;
  71902. }
  71903. }
  71904. declare module BABYLON {
  71905. /** @hidden */
  71906. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  71907. define: string;
  71908. operand: string;
  71909. testValue: string;
  71910. constructor(define: string, operand: string, testValue: string);
  71911. isTrue(preprocessors: {
  71912. [key: string]: string;
  71913. }): boolean;
  71914. }
  71915. }
  71916. declare module BABYLON {
  71917. /**
  71918. * Class used to enable access to offline support
  71919. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71920. */
  71921. export interface IOfflineProvider {
  71922. /**
  71923. * Gets a boolean indicating if scene must be saved in the database
  71924. */
  71925. enableSceneOffline: boolean;
  71926. /**
  71927. * Gets a boolean indicating if textures must be saved in the database
  71928. */
  71929. enableTexturesOffline: boolean;
  71930. /**
  71931. * Open the offline support and make it available
  71932. * @param successCallback defines the callback to call on success
  71933. * @param errorCallback defines the callback to call on error
  71934. */
  71935. open(successCallback: () => void, errorCallback: () => void): void;
  71936. /**
  71937. * Loads an image from the offline support
  71938. * @param url defines the url to load from
  71939. * @param image defines the target DOM image
  71940. */
  71941. loadImage(url: string, image: HTMLImageElement): void;
  71942. /**
  71943. * Loads a file from offline support
  71944. * @param url defines the URL to load from
  71945. * @param sceneLoaded defines a callback to call on success
  71946. * @param progressCallBack defines a callback to call when progress changed
  71947. * @param errorCallback defines a callback to call on error
  71948. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71949. */
  71950. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71951. }
  71952. }
  71953. declare module BABYLON {
  71954. /**
  71955. * Class used to help managing file picking and drag'n'drop
  71956. * File Storage
  71957. */
  71958. export class FilesInputStore {
  71959. /**
  71960. * List of files ready to be loaded
  71961. */
  71962. static FilesToLoad: {
  71963. [key: string]: File;
  71964. };
  71965. }
  71966. }
  71967. declare module BABYLON {
  71968. /**
  71969. * Class used to define a retry strategy when error happens while loading assets
  71970. */
  71971. export class RetryStrategy {
  71972. /**
  71973. * Function used to defines an exponential back off strategy
  71974. * @param maxRetries defines the maximum number of retries (3 by default)
  71975. * @param baseInterval defines the interval between retries
  71976. * @returns the strategy function to use
  71977. */
  71978. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  71979. }
  71980. }
  71981. declare module BABYLON {
  71982. /**
  71983. * @ignore
  71984. * Application error to support additional information when loading a file
  71985. */
  71986. export abstract class BaseError extends Error {
  71987. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  71988. }
  71989. }
  71990. declare module BABYLON {
  71991. /** @ignore */
  71992. export class LoadFileError extends BaseError {
  71993. request?: WebRequest;
  71994. file?: File;
  71995. /**
  71996. * Creates a new LoadFileError
  71997. * @param message defines the message of the error
  71998. * @param request defines the optional web request
  71999. * @param file defines the optional file
  72000. */
  72001. constructor(message: string, object?: WebRequest | File);
  72002. }
  72003. /** @ignore */
  72004. export class RequestFileError extends BaseError {
  72005. request: WebRequest;
  72006. /**
  72007. * Creates a new LoadFileError
  72008. * @param message defines the message of the error
  72009. * @param request defines the optional web request
  72010. */
  72011. constructor(message: string, request: WebRequest);
  72012. }
  72013. /** @ignore */
  72014. export class ReadFileError extends BaseError {
  72015. file: File;
  72016. /**
  72017. * Creates a new ReadFileError
  72018. * @param message defines the message of the error
  72019. * @param file defines the optional file
  72020. */
  72021. constructor(message: string, file: File);
  72022. }
  72023. /**
  72024. * @hidden
  72025. */
  72026. export class FileTools {
  72027. /**
  72028. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  72029. */
  72030. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  72031. /**
  72032. * Gets or sets the base URL to use to load assets
  72033. */
  72034. static BaseUrl: string;
  72035. /**
  72036. * Default behaviour for cors in the application.
  72037. * It can be a string if the expected behavior is identical in the entire app.
  72038. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  72039. */
  72040. static CorsBehavior: string | ((url: string | string[]) => string);
  72041. /**
  72042. * Gets or sets a function used to pre-process url before using them to load assets
  72043. */
  72044. static PreprocessUrl: (url: string) => string;
  72045. /**
  72046. * Removes unwanted characters from an url
  72047. * @param url defines the url to clean
  72048. * @returns the cleaned url
  72049. */
  72050. private static _CleanUrl;
  72051. /**
  72052. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  72053. * @param url define the url we are trying
  72054. * @param element define the dom element where to configure the cors policy
  72055. */
  72056. static SetCorsBehavior(url: string | string[], element: {
  72057. crossOrigin: string | null;
  72058. }): void;
  72059. /**
  72060. * Loads an image as an HTMLImageElement.
  72061. * @param input url string, ArrayBuffer, or Blob to load
  72062. * @param onLoad callback called when the image successfully loads
  72063. * @param onError callback called when the image fails to load
  72064. * @param offlineProvider offline provider for caching
  72065. * @param mimeType optional mime type
  72066. * @returns the HTMLImageElement of the loaded image
  72067. */
  72068. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  72069. /**
  72070. * Reads a file from a File object
  72071. * @param file defines the file to load
  72072. * @param onSuccess defines the callback to call when data is loaded
  72073. * @param onProgress defines the callback to call during loading process
  72074. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  72075. * @param onError defines the callback to call when an error occurs
  72076. * @returns a file request object
  72077. */
  72078. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  72079. /**
  72080. * Loads a file from a url
  72081. * @param url url to load
  72082. * @param onSuccess callback called when the file successfully loads
  72083. * @param onProgress callback called while file is loading (if the server supports this mode)
  72084. * @param offlineProvider defines the offline provider for caching
  72085. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  72086. * @param onError callback called when the file fails to load
  72087. * @returns a file request object
  72088. */
  72089. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  72090. /**
  72091. * Loads a file
  72092. * @param url url to load
  72093. * @param onSuccess callback called when the file successfully loads
  72094. * @param onProgress callback called while file is loading (if the server supports this mode)
  72095. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  72096. * @param onError callback called when the file fails to load
  72097. * @param onOpened callback called when the web request is opened
  72098. * @returns a file request object
  72099. */
  72100. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  72101. /**
  72102. * Checks if the loaded document was accessed via `file:`-Protocol.
  72103. * @returns boolean
  72104. */
  72105. static IsFileURL(): boolean;
  72106. }
  72107. }
  72108. declare module BABYLON {
  72109. /** @hidden */
  72110. export class ShaderProcessor {
  72111. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  72112. private static _ProcessPrecision;
  72113. private static _ExtractOperation;
  72114. private static _BuildSubExpression;
  72115. private static _BuildExpression;
  72116. private static _MoveCursorWithinIf;
  72117. private static _MoveCursor;
  72118. private static _EvaluatePreProcessors;
  72119. private static _PreparePreProcessors;
  72120. private static _ProcessShaderConversion;
  72121. private static _ProcessIncludes;
  72122. /**
  72123. * Loads a file from a url
  72124. * @param url url to load
  72125. * @param onSuccess callback called when the file successfully loads
  72126. * @param onProgress callback called while file is loading (if the server supports this mode)
  72127. * @param offlineProvider defines the offline provider for caching
  72128. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  72129. * @param onError callback called when the file fails to load
  72130. * @returns a file request object
  72131. * @hidden
  72132. */
  72133. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  72134. }
  72135. }
  72136. declare module BABYLON {
  72137. /**
  72138. * @hidden
  72139. */
  72140. export interface IColor4Like {
  72141. r: float;
  72142. g: float;
  72143. b: float;
  72144. a: float;
  72145. }
  72146. /**
  72147. * @hidden
  72148. */
  72149. export interface IColor3Like {
  72150. r: float;
  72151. g: float;
  72152. b: float;
  72153. }
  72154. /**
  72155. * @hidden
  72156. */
  72157. export interface IVector4Like {
  72158. x: float;
  72159. y: float;
  72160. z: float;
  72161. w: float;
  72162. }
  72163. /**
  72164. * @hidden
  72165. */
  72166. export interface IVector3Like {
  72167. x: float;
  72168. y: float;
  72169. z: float;
  72170. }
  72171. /**
  72172. * @hidden
  72173. */
  72174. export interface IVector2Like {
  72175. x: float;
  72176. y: float;
  72177. }
  72178. /**
  72179. * @hidden
  72180. */
  72181. export interface IMatrixLike {
  72182. toArray(): DeepImmutable<Float32Array>;
  72183. updateFlag: int;
  72184. }
  72185. /**
  72186. * @hidden
  72187. */
  72188. export interface IViewportLike {
  72189. x: float;
  72190. y: float;
  72191. width: float;
  72192. height: float;
  72193. }
  72194. /**
  72195. * @hidden
  72196. */
  72197. export interface IPlaneLike {
  72198. normal: IVector3Like;
  72199. d: float;
  72200. normalize(): void;
  72201. }
  72202. }
  72203. declare module BABYLON {
  72204. /**
  72205. * Interface used to define common properties for effect fallbacks
  72206. */
  72207. export interface IEffectFallbacks {
  72208. /**
  72209. * Removes the defines that should be removed when falling back.
  72210. * @param currentDefines defines the current define statements for the shader.
  72211. * @param effect defines the current effect we try to compile
  72212. * @returns The resulting defines with defines of the current rank removed.
  72213. */
  72214. reduce(currentDefines: string, effect: Effect): string;
  72215. /**
  72216. * Removes the fallback from the bound mesh.
  72217. */
  72218. unBindMesh(): void;
  72219. /**
  72220. * Checks to see if more fallbacks are still availible.
  72221. */
  72222. hasMoreFallbacks: boolean;
  72223. }
  72224. }
  72225. declare module BABYLON {
  72226. /**
  72227. * Class used to evalaute queries containing `and` and `or` operators
  72228. */
  72229. export class AndOrNotEvaluator {
  72230. /**
  72231. * Evaluate a query
  72232. * @param query defines the query to evaluate
  72233. * @param evaluateCallback defines the callback used to filter result
  72234. * @returns true if the query matches
  72235. */
  72236. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  72237. private static _HandleParenthesisContent;
  72238. private static _SimplifyNegation;
  72239. }
  72240. }
  72241. declare module BABYLON {
  72242. /**
  72243. * Class used to store custom tags
  72244. */
  72245. export class Tags {
  72246. /**
  72247. * Adds support for tags on the given object
  72248. * @param obj defines the object to use
  72249. */
  72250. static EnableFor(obj: any): void;
  72251. /**
  72252. * Removes tags support
  72253. * @param obj defines the object to use
  72254. */
  72255. static DisableFor(obj: any): void;
  72256. /**
  72257. * Gets a boolean indicating if the given object has tags
  72258. * @param obj defines the object to use
  72259. * @returns a boolean
  72260. */
  72261. static HasTags(obj: any): boolean;
  72262. /**
  72263. * Gets the tags available on a given object
  72264. * @param obj defines the object to use
  72265. * @param asString defines if the tags must be returned as a string instead of an array of strings
  72266. * @returns the tags
  72267. */
  72268. static GetTags(obj: any, asString?: boolean): any;
  72269. /**
  72270. * Adds tags to an object
  72271. * @param obj defines the object to use
  72272. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  72273. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  72274. */
  72275. static AddTagsTo(obj: any, tagsString: string): void;
  72276. /**
  72277. * @hidden
  72278. */
  72279. static _AddTagTo(obj: any, tag: string): void;
  72280. /**
  72281. * Removes specific tags from a specific object
  72282. * @param obj defines the object to use
  72283. * @param tagsString defines the tags to remove
  72284. */
  72285. static RemoveTagsFrom(obj: any, tagsString: string): void;
  72286. /**
  72287. * @hidden
  72288. */
  72289. static _RemoveTagFrom(obj: any, tag: string): void;
  72290. /**
  72291. * Defines if tags hosted on an object match a given query
  72292. * @param obj defines the object to use
  72293. * @param tagsQuery defines the tag query
  72294. * @returns a boolean
  72295. */
  72296. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  72297. }
  72298. }
  72299. declare module BABYLON {
  72300. /**
  72301. * Scalar computation library
  72302. */
  72303. export class Scalar {
  72304. /**
  72305. * Two pi constants convenient for computation.
  72306. */
  72307. static TwoPi: number;
  72308. /**
  72309. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  72310. * @param a number
  72311. * @param b number
  72312. * @param epsilon (default = 1.401298E-45)
  72313. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  72314. */
  72315. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  72316. /**
  72317. * Returns a string : the upper case translation of the number i to hexadecimal.
  72318. * @param i number
  72319. * @returns the upper case translation of the number i to hexadecimal.
  72320. */
  72321. static ToHex(i: number): string;
  72322. /**
  72323. * Returns -1 if value is negative and +1 is value is positive.
  72324. * @param value the value
  72325. * @returns the value itself if it's equal to zero.
  72326. */
  72327. static Sign(value: number): number;
  72328. /**
  72329. * Returns the value itself if it's between min and max.
  72330. * Returns min if the value is lower than min.
  72331. * Returns max if the value is greater than max.
  72332. * @param value the value to clmap
  72333. * @param min the min value to clamp to (default: 0)
  72334. * @param max the max value to clamp to (default: 1)
  72335. * @returns the clamped value
  72336. */
  72337. static Clamp(value: number, min?: number, max?: number): number;
  72338. /**
  72339. * the log2 of value.
  72340. * @param value the value to compute log2 of
  72341. * @returns the log2 of value.
  72342. */
  72343. static Log2(value: number): number;
  72344. /**
  72345. * Loops the value, so that it is never larger than length and never smaller than 0.
  72346. *
  72347. * This is similar to the modulo operator but it works with floating point numbers.
  72348. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  72349. * With t = 5 and length = 2.5, the result would be 0.0.
  72350. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  72351. * @param value the value
  72352. * @param length the length
  72353. * @returns the looped value
  72354. */
  72355. static Repeat(value: number, length: number): number;
  72356. /**
  72357. * Normalize the value between 0.0 and 1.0 using min and max values
  72358. * @param value value to normalize
  72359. * @param min max to normalize between
  72360. * @param max min to normalize between
  72361. * @returns the normalized value
  72362. */
  72363. static Normalize(value: number, min: number, max: number): number;
  72364. /**
  72365. * Denormalize the value from 0.0 and 1.0 using min and max values
  72366. * @param normalized value to denormalize
  72367. * @param min max to denormalize between
  72368. * @param max min to denormalize between
  72369. * @returns the denormalized value
  72370. */
  72371. static Denormalize(normalized: number, min: number, max: number): number;
  72372. /**
  72373. * Calculates the shortest difference between two given angles given in degrees.
  72374. * @param current current angle in degrees
  72375. * @param target target angle in degrees
  72376. * @returns the delta
  72377. */
  72378. static DeltaAngle(current: number, target: number): number;
  72379. /**
  72380. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  72381. * @param tx value
  72382. * @param length length
  72383. * @returns The returned value will move back and forth between 0 and length
  72384. */
  72385. static PingPong(tx: number, length: number): number;
  72386. /**
  72387. * Interpolates between min and max with smoothing at the limits.
  72388. *
  72389. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  72390. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  72391. * @param from from
  72392. * @param to to
  72393. * @param tx value
  72394. * @returns the smooth stepped value
  72395. */
  72396. static SmoothStep(from: number, to: number, tx: number): number;
  72397. /**
  72398. * Moves a value current towards target.
  72399. *
  72400. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  72401. * Negative values of maxDelta pushes the value away from target.
  72402. * @param current current value
  72403. * @param target target value
  72404. * @param maxDelta max distance to move
  72405. * @returns resulting value
  72406. */
  72407. static MoveTowards(current: number, target: number, maxDelta: number): number;
  72408. /**
  72409. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  72410. *
  72411. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  72412. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  72413. * @param current current value
  72414. * @param target target value
  72415. * @param maxDelta max distance to move
  72416. * @returns resulting angle
  72417. */
  72418. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  72419. /**
  72420. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  72421. * @param start start value
  72422. * @param end target value
  72423. * @param amount amount to lerp between
  72424. * @returns the lerped value
  72425. */
  72426. static Lerp(start: number, end: number, amount: number): number;
  72427. /**
  72428. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  72429. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  72430. * @param start start value
  72431. * @param end target value
  72432. * @param amount amount to lerp between
  72433. * @returns the lerped value
  72434. */
  72435. static LerpAngle(start: number, end: number, amount: number): number;
  72436. /**
  72437. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  72438. * @param a start value
  72439. * @param b target value
  72440. * @param value value between a and b
  72441. * @returns the inverseLerp value
  72442. */
  72443. static InverseLerp(a: number, b: number, value: number): number;
  72444. /**
  72445. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  72446. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  72447. * @param value1 spline value
  72448. * @param tangent1 spline value
  72449. * @param value2 spline value
  72450. * @param tangent2 spline value
  72451. * @param amount input value
  72452. * @returns hermite result
  72453. */
  72454. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  72455. /**
  72456. * Returns a random float number between and min and max values
  72457. * @param min min value of random
  72458. * @param max max value of random
  72459. * @returns random value
  72460. */
  72461. static RandomRange(min: number, max: number): number;
  72462. /**
  72463. * This function returns percentage of a number in a given range.
  72464. *
  72465. * RangeToPercent(40,20,60) will return 0.5 (50%)
  72466. * RangeToPercent(34,0,100) will return 0.34 (34%)
  72467. * @param number to convert to percentage
  72468. * @param min min range
  72469. * @param max max range
  72470. * @returns the percentage
  72471. */
  72472. static RangeToPercent(number: number, min: number, max: number): number;
  72473. /**
  72474. * This function returns number that corresponds to the percentage in a given range.
  72475. *
  72476. * PercentToRange(0.34,0,100) will return 34.
  72477. * @param percent to convert to number
  72478. * @param min min range
  72479. * @param max max range
  72480. * @returns the number
  72481. */
  72482. static PercentToRange(percent: number, min: number, max: number): number;
  72483. /**
  72484. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  72485. * @param angle The angle to normalize in radian.
  72486. * @return The converted angle.
  72487. */
  72488. static NormalizeRadians(angle: number): number;
  72489. }
  72490. }
  72491. declare module BABYLON {
  72492. /**
  72493. * Constant used to convert a value to gamma space
  72494. * @ignorenaming
  72495. */
  72496. export const ToGammaSpace: number;
  72497. /**
  72498. * Constant used to convert a value to linear space
  72499. * @ignorenaming
  72500. */
  72501. export const ToLinearSpace = 2.2;
  72502. /**
  72503. * Constant used to define the minimal number value in Babylon.js
  72504. * @ignorenaming
  72505. */
  72506. let Epsilon: number;
  72507. }
  72508. declare module BABYLON {
  72509. /**
  72510. * Class used to represent a viewport on screen
  72511. */
  72512. export class Viewport {
  72513. /** viewport left coordinate */
  72514. x: number;
  72515. /** viewport top coordinate */
  72516. y: number;
  72517. /**viewport width */
  72518. width: number;
  72519. /** viewport height */
  72520. height: number;
  72521. /**
  72522. * Creates a Viewport object located at (x, y) and sized (width, height)
  72523. * @param x defines viewport left coordinate
  72524. * @param y defines viewport top coordinate
  72525. * @param width defines the viewport width
  72526. * @param height defines the viewport height
  72527. */
  72528. constructor(
  72529. /** viewport left coordinate */
  72530. x: number,
  72531. /** viewport top coordinate */
  72532. y: number,
  72533. /**viewport width */
  72534. width: number,
  72535. /** viewport height */
  72536. height: number);
  72537. /**
  72538. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  72539. * @param renderWidth defines the rendering width
  72540. * @param renderHeight defines the rendering height
  72541. * @returns a new Viewport
  72542. */
  72543. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  72544. /**
  72545. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  72546. * @param renderWidth defines the rendering width
  72547. * @param renderHeight defines the rendering height
  72548. * @param ref defines the target viewport
  72549. * @returns the current viewport
  72550. */
  72551. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  72552. /**
  72553. * Returns a new Viewport copied from the current one
  72554. * @returns a new Viewport
  72555. */
  72556. clone(): Viewport;
  72557. }
  72558. }
  72559. declare module BABYLON {
  72560. /**
  72561. * Class containing a set of static utilities functions for arrays.
  72562. */
  72563. export class ArrayTools {
  72564. /**
  72565. * Returns an array of the given size filled with element built from the given constructor and the paramters
  72566. * @param size the number of element to construct and put in the array
  72567. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  72568. * @returns a new array filled with new objects
  72569. */
  72570. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  72571. }
  72572. }
  72573. declare module BABYLON {
  72574. /**
  72575. * Class representing a vector containing 2 coordinates
  72576. */
  72577. export class Vector2 {
  72578. /** defines the first coordinate */
  72579. x: number;
  72580. /** defines the second coordinate */
  72581. y: number;
  72582. /**
  72583. * Creates a new Vector2 from the given x and y coordinates
  72584. * @param x defines the first coordinate
  72585. * @param y defines the second coordinate
  72586. */
  72587. constructor(
  72588. /** defines the first coordinate */
  72589. x?: number,
  72590. /** defines the second coordinate */
  72591. y?: number);
  72592. /**
  72593. * Gets a string with the Vector2 coordinates
  72594. * @returns a string with the Vector2 coordinates
  72595. */
  72596. toString(): string;
  72597. /**
  72598. * Gets class name
  72599. * @returns the string "Vector2"
  72600. */
  72601. getClassName(): string;
  72602. /**
  72603. * Gets current vector hash code
  72604. * @returns the Vector2 hash code as a number
  72605. */
  72606. getHashCode(): number;
  72607. /**
  72608. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  72609. * @param array defines the source array
  72610. * @param index defines the offset in source array
  72611. * @returns the current Vector2
  72612. */
  72613. toArray(array: FloatArray, index?: number): Vector2;
  72614. /**
  72615. * Copy the current vector to an array
  72616. * @returns a new array with 2 elements: the Vector2 coordinates.
  72617. */
  72618. asArray(): number[];
  72619. /**
  72620. * Sets the Vector2 coordinates with the given Vector2 coordinates
  72621. * @param source defines the source Vector2
  72622. * @returns the current updated Vector2
  72623. */
  72624. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  72625. /**
  72626. * Sets the Vector2 coordinates with the given floats
  72627. * @param x defines the first coordinate
  72628. * @param y defines the second coordinate
  72629. * @returns the current updated Vector2
  72630. */
  72631. copyFromFloats(x: number, y: number): Vector2;
  72632. /**
  72633. * Sets the Vector2 coordinates with the given floats
  72634. * @param x defines the first coordinate
  72635. * @param y defines the second coordinate
  72636. * @returns the current updated Vector2
  72637. */
  72638. set(x: number, y: number): Vector2;
  72639. /**
  72640. * Add another vector with the current one
  72641. * @param otherVector defines the other vector
  72642. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  72643. */
  72644. add(otherVector: DeepImmutable<Vector2>): Vector2;
  72645. /**
  72646. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  72647. * @param otherVector defines the other vector
  72648. * @param result defines the target vector
  72649. * @returns the unmodified current Vector2
  72650. */
  72651. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72652. /**
  72653. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  72654. * @param otherVector defines the other vector
  72655. * @returns the current updated Vector2
  72656. */
  72657. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72658. /**
  72659. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  72660. * @param otherVector defines the other vector
  72661. * @returns a new Vector2
  72662. */
  72663. addVector3(otherVector: Vector3): Vector2;
  72664. /**
  72665. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  72666. * @param otherVector defines the other vector
  72667. * @returns a new Vector2
  72668. */
  72669. subtract(otherVector: Vector2): Vector2;
  72670. /**
  72671. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  72672. * @param otherVector defines the other vector
  72673. * @param result defines the target vector
  72674. * @returns the unmodified current Vector2
  72675. */
  72676. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72677. /**
  72678. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  72679. * @param otherVector defines the other vector
  72680. * @returns the current updated Vector2
  72681. */
  72682. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72683. /**
  72684. * Multiplies in place the current Vector2 coordinates by the given ones
  72685. * @param otherVector defines the other vector
  72686. * @returns the current updated Vector2
  72687. */
  72688. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72689. /**
  72690. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  72691. * @param otherVector defines the other vector
  72692. * @returns a new Vector2
  72693. */
  72694. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  72695. /**
  72696. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  72697. * @param otherVector defines the other vector
  72698. * @param result defines the target vector
  72699. * @returns the unmodified current Vector2
  72700. */
  72701. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72702. /**
  72703. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  72704. * @param x defines the first coordinate
  72705. * @param y defines the second coordinate
  72706. * @returns a new Vector2
  72707. */
  72708. multiplyByFloats(x: number, y: number): Vector2;
  72709. /**
  72710. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  72711. * @param otherVector defines the other vector
  72712. * @returns a new Vector2
  72713. */
  72714. divide(otherVector: Vector2): Vector2;
  72715. /**
  72716. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  72717. * @param otherVector defines the other vector
  72718. * @param result defines the target vector
  72719. * @returns the unmodified current Vector2
  72720. */
  72721. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  72722. /**
  72723. * Divides the current Vector2 coordinates by the given ones
  72724. * @param otherVector defines the other vector
  72725. * @returns the current updated Vector2
  72726. */
  72727. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  72728. /**
  72729. * Gets a new Vector2 with current Vector2 negated coordinates
  72730. * @returns a new Vector2
  72731. */
  72732. negate(): Vector2;
  72733. /**
  72734. * Multiply the Vector2 coordinates by scale
  72735. * @param scale defines the scaling factor
  72736. * @returns the current updated Vector2
  72737. */
  72738. scaleInPlace(scale: number): Vector2;
  72739. /**
  72740. * Returns a new Vector2 scaled by "scale" from the current Vector2
  72741. * @param scale defines the scaling factor
  72742. * @returns a new Vector2
  72743. */
  72744. scale(scale: number): Vector2;
  72745. /**
  72746. * Scale the current Vector2 values by a factor to a given Vector2
  72747. * @param scale defines the scale factor
  72748. * @param result defines the Vector2 object where to store the result
  72749. * @returns the unmodified current Vector2
  72750. */
  72751. scaleToRef(scale: number, result: Vector2): Vector2;
  72752. /**
  72753. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  72754. * @param scale defines the scale factor
  72755. * @param result defines the Vector2 object where to store the result
  72756. * @returns the unmodified current Vector2
  72757. */
  72758. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  72759. /**
  72760. * Gets a boolean if two vectors are equals
  72761. * @param otherVector defines the other vector
  72762. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  72763. */
  72764. equals(otherVector: DeepImmutable<Vector2>): boolean;
  72765. /**
  72766. * Gets a boolean if two vectors are equals (using an epsilon value)
  72767. * @param otherVector defines the other vector
  72768. * @param epsilon defines the minimal distance to consider equality
  72769. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  72770. */
  72771. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  72772. /**
  72773. * Gets a new Vector2 from current Vector2 floored values
  72774. * @returns a new Vector2
  72775. */
  72776. floor(): Vector2;
  72777. /**
  72778. * Gets a new Vector2 from current Vector2 floored values
  72779. * @returns a new Vector2
  72780. */
  72781. fract(): Vector2;
  72782. /**
  72783. * Gets the length of the vector
  72784. * @returns the vector length (float)
  72785. */
  72786. length(): number;
  72787. /**
  72788. * Gets the vector squared length
  72789. * @returns the vector squared length (float)
  72790. */
  72791. lengthSquared(): number;
  72792. /**
  72793. * Normalize the vector
  72794. * @returns the current updated Vector2
  72795. */
  72796. normalize(): Vector2;
  72797. /**
  72798. * Gets a new Vector2 copied from the Vector2
  72799. * @returns a new Vector2
  72800. */
  72801. clone(): Vector2;
  72802. /**
  72803. * Gets a new Vector2(0, 0)
  72804. * @returns a new Vector2
  72805. */
  72806. static Zero(): Vector2;
  72807. /**
  72808. * Gets a new Vector2(1, 1)
  72809. * @returns a new Vector2
  72810. */
  72811. static One(): Vector2;
  72812. /**
  72813. * Gets a new Vector2 set from the given index element of the given array
  72814. * @param array defines the data source
  72815. * @param offset defines the offset in the data source
  72816. * @returns a new Vector2
  72817. */
  72818. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  72819. /**
  72820. * Sets "result" from the given index element of the given array
  72821. * @param array defines the data source
  72822. * @param offset defines the offset in the data source
  72823. * @param result defines the target vector
  72824. */
  72825. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  72826. /**
  72827. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  72828. * @param value1 defines 1st point of control
  72829. * @param value2 defines 2nd point of control
  72830. * @param value3 defines 3rd point of control
  72831. * @param value4 defines 4th point of control
  72832. * @param amount defines the interpolation factor
  72833. * @returns a new Vector2
  72834. */
  72835. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  72836. /**
  72837. * 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".
  72838. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  72839. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  72840. * @param value defines the value to clamp
  72841. * @param min defines the lower limit
  72842. * @param max defines the upper limit
  72843. * @returns a new Vector2
  72844. */
  72845. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  72846. /**
  72847. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  72848. * @param value1 defines the 1st control point
  72849. * @param tangent1 defines the outgoing tangent
  72850. * @param value2 defines the 2nd control point
  72851. * @param tangent2 defines the incoming tangent
  72852. * @param amount defines the interpolation factor
  72853. * @returns a new Vector2
  72854. */
  72855. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  72856. /**
  72857. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  72858. * @param start defines the start vector
  72859. * @param end defines the end vector
  72860. * @param amount defines the interpolation factor
  72861. * @returns a new Vector2
  72862. */
  72863. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  72864. /**
  72865. * Gets the dot product of the vector "left" and the vector "right"
  72866. * @param left defines first vector
  72867. * @param right defines second vector
  72868. * @returns the dot product (float)
  72869. */
  72870. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  72871. /**
  72872. * Returns a new Vector2 equal to the normalized given vector
  72873. * @param vector defines the vector to normalize
  72874. * @returns a new Vector2
  72875. */
  72876. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  72877. /**
  72878. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  72879. * @param left defines 1st vector
  72880. * @param right defines 2nd vector
  72881. * @returns a new Vector2
  72882. */
  72883. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  72884. /**
  72885. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  72886. * @param left defines 1st vector
  72887. * @param right defines 2nd vector
  72888. * @returns a new Vector2
  72889. */
  72890. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  72891. /**
  72892. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  72893. * @param vector defines the vector to transform
  72894. * @param transformation defines the matrix to apply
  72895. * @returns a new Vector2
  72896. */
  72897. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  72898. /**
  72899. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  72900. * @param vector defines the vector to transform
  72901. * @param transformation defines the matrix to apply
  72902. * @param result defines the target vector
  72903. */
  72904. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  72905. /**
  72906. * Determines if a given vector is included in a triangle
  72907. * @param p defines the vector to test
  72908. * @param p0 defines 1st triangle point
  72909. * @param p1 defines 2nd triangle point
  72910. * @param p2 defines 3rd triangle point
  72911. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  72912. */
  72913. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  72914. /**
  72915. * Gets the distance between the vectors "value1" and "value2"
  72916. * @param value1 defines first vector
  72917. * @param value2 defines second vector
  72918. * @returns the distance between vectors
  72919. */
  72920. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  72921. /**
  72922. * Returns the squared distance between the vectors "value1" and "value2"
  72923. * @param value1 defines first vector
  72924. * @param value2 defines second vector
  72925. * @returns the squared distance between vectors
  72926. */
  72927. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  72928. /**
  72929. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  72930. * @param value1 defines first vector
  72931. * @param value2 defines second vector
  72932. * @returns a new Vector2
  72933. */
  72934. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  72935. /**
  72936. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  72937. * @param p defines the middle point
  72938. * @param segA defines one point of the segment
  72939. * @param segB defines the other point of the segment
  72940. * @returns the shortest distance
  72941. */
  72942. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  72943. }
  72944. /**
  72945. * Class used to store (x,y,z) vector representation
  72946. * A Vector3 is the main object used in 3D geometry
  72947. * It can represent etiher the coordinates of a point the space, either a direction
  72948. * Reminder: js uses a left handed forward facing system
  72949. */
  72950. export class Vector3 {
  72951. /**
  72952. * Defines the first coordinates (on X axis)
  72953. */
  72954. x: number;
  72955. /**
  72956. * Defines the second coordinates (on Y axis)
  72957. */
  72958. y: number;
  72959. /**
  72960. * Defines the third coordinates (on Z axis)
  72961. */
  72962. z: number;
  72963. private static _UpReadOnly;
  72964. private static _ZeroReadOnly;
  72965. /**
  72966. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  72967. * @param x defines the first coordinates (on X axis)
  72968. * @param y defines the second coordinates (on Y axis)
  72969. * @param z defines the third coordinates (on Z axis)
  72970. */
  72971. constructor(
  72972. /**
  72973. * Defines the first coordinates (on X axis)
  72974. */
  72975. x?: number,
  72976. /**
  72977. * Defines the second coordinates (on Y axis)
  72978. */
  72979. y?: number,
  72980. /**
  72981. * Defines the third coordinates (on Z axis)
  72982. */
  72983. z?: number);
  72984. /**
  72985. * Creates a string representation of the Vector3
  72986. * @returns a string with the Vector3 coordinates.
  72987. */
  72988. toString(): string;
  72989. /**
  72990. * Gets the class name
  72991. * @returns the string "Vector3"
  72992. */
  72993. getClassName(): string;
  72994. /**
  72995. * Creates the Vector3 hash code
  72996. * @returns a number which tends to be unique between Vector3 instances
  72997. */
  72998. getHashCode(): number;
  72999. /**
  73000. * Creates an array containing three elements : the coordinates of the Vector3
  73001. * @returns a new array of numbers
  73002. */
  73003. asArray(): number[];
  73004. /**
  73005. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  73006. * @param array defines the destination array
  73007. * @param index defines the offset in the destination array
  73008. * @returns the current Vector3
  73009. */
  73010. toArray(array: FloatArray, index?: number): Vector3;
  73011. /**
  73012. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  73013. * @returns a new Quaternion object, computed from the Vector3 coordinates
  73014. */
  73015. toQuaternion(): Quaternion;
  73016. /**
  73017. * Adds the given vector to the current Vector3
  73018. * @param otherVector defines the second operand
  73019. * @returns the current updated Vector3
  73020. */
  73021. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  73022. /**
  73023. * Adds the given coordinates to the current Vector3
  73024. * @param x defines the x coordinate of the operand
  73025. * @param y defines the y coordinate of the operand
  73026. * @param z defines the z coordinate of the operand
  73027. * @returns the current updated Vector3
  73028. */
  73029. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  73030. /**
  73031. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  73032. * @param otherVector defines the second operand
  73033. * @returns the resulting Vector3
  73034. */
  73035. add(otherVector: DeepImmutable<Vector3>): Vector3;
  73036. /**
  73037. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  73038. * @param otherVector defines the second operand
  73039. * @param result defines the Vector3 object where to store the result
  73040. * @returns the current Vector3
  73041. */
  73042. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73043. /**
  73044. * Subtract the given vector from the current Vector3
  73045. * @param otherVector defines the second operand
  73046. * @returns the current updated Vector3
  73047. */
  73048. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  73049. /**
  73050. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  73051. * @param otherVector defines the second operand
  73052. * @returns the resulting Vector3
  73053. */
  73054. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  73055. /**
  73056. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  73057. * @param otherVector defines the second operand
  73058. * @param result defines the Vector3 object where to store the result
  73059. * @returns the current Vector3
  73060. */
  73061. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73062. /**
  73063. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  73064. * @param x defines the x coordinate of the operand
  73065. * @param y defines the y coordinate of the operand
  73066. * @param z defines the z coordinate of the operand
  73067. * @returns the resulting Vector3
  73068. */
  73069. subtractFromFloats(x: number, y: number, z: number): Vector3;
  73070. /**
  73071. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  73072. * @param x defines the x coordinate of the operand
  73073. * @param y defines the y coordinate of the operand
  73074. * @param z defines the z coordinate of the operand
  73075. * @param result defines the Vector3 object where to store the result
  73076. * @returns the current Vector3
  73077. */
  73078. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  73079. /**
  73080. * Gets a new Vector3 set with the current Vector3 negated coordinates
  73081. * @returns a new Vector3
  73082. */
  73083. negate(): Vector3;
  73084. /**
  73085. * Multiplies the Vector3 coordinates by the float "scale"
  73086. * @param scale defines the multiplier factor
  73087. * @returns the current updated Vector3
  73088. */
  73089. scaleInPlace(scale: number): Vector3;
  73090. /**
  73091. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  73092. * @param scale defines the multiplier factor
  73093. * @returns a new Vector3
  73094. */
  73095. scale(scale: number): Vector3;
  73096. /**
  73097. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  73098. * @param scale defines the multiplier factor
  73099. * @param result defines the Vector3 object where to store the result
  73100. * @returns the current Vector3
  73101. */
  73102. scaleToRef(scale: number, result: Vector3): Vector3;
  73103. /**
  73104. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  73105. * @param scale defines the scale factor
  73106. * @param result defines the Vector3 object where to store the result
  73107. * @returns the unmodified current Vector3
  73108. */
  73109. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  73110. /**
  73111. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  73112. * @param otherVector defines the second operand
  73113. * @returns true if both vectors are equals
  73114. */
  73115. equals(otherVector: DeepImmutable<Vector3>): boolean;
  73116. /**
  73117. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  73118. * @param otherVector defines the second operand
  73119. * @param epsilon defines the minimal distance to define values as equals
  73120. * @returns true if both vectors are distant less than epsilon
  73121. */
  73122. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  73123. /**
  73124. * Returns true if the current Vector3 coordinates equals the given floats
  73125. * @param x defines the x coordinate of the operand
  73126. * @param y defines the y coordinate of the operand
  73127. * @param z defines the z coordinate of the operand
  73128. * @returns true if both vectors are equals
  73129. */
  73130. equalsToFloats(x: number, y: number, z: number): boolean;
  73131. /**
  73132. * Multiplies the current Vector3 coordinates by the given ones
  73133. * @param otherVector defines the second operand
  73134. * @returns the current updated Vector3
  73135. */
  73136. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  73137. /**
  73138. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  73139. * @param otherVector defines the second operand
  73140. * @returns the new Vector3
  73141. */
  73142. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  73143. /**
  73144. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  73145. * @param otherVector defines the second operand
  73146. * @param result defines the Vector3 object where to store the result
  73147. * @returns the current Vector3
  73148. */
  73149. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73150. /**
  73151. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  73152. * @param x defines the x coordinate of the operand
  73153. * @param y defines the y coordinate of the operand
  73154. * @param z defines the z coordinate of the operand
  73155. * @returns the new Vector3
  73156. */
  73157. multiplyByFloats(x: number, y: number, z: number): Vector3;
  73158. /**
  73159. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  73160. * @param otherVector defines the second operand
  73161. * @returns the new Vector3
  73162. */
  73163. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  73164. /**
  73165. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  73166. * @param otherVector defines the second operand
  73167. * @param result defines the Vector3 object where to store the result
  73168. * @returns the current Vector3
  73169. */
  73170. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73171. /**
  73172. * Divides the current Vector3 coordinates by the given ones.
  73173. * @param otherVector defines the second operand
  73174. * @returns the current updated Vector3
  73175. */
  73176. divideInPlace(otherVector: Vector3): Vector3;
  73177. /**
  73178. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  73179. * @param other defines the second operand
  73180. * @returns the current updated Vector3
  73181. */
  73182. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  73183. /**
  73184. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  73185. * @param other defines the second operand
  73186. * @returns the current updated Vector3
  73187. */
  73188. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  73189. /**
  73190. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  73191. * @param x defines the x coordinate of the operand
  73192. * @param y defines the y coordinate of the operand
  73193. * @param z defines the z coordinate of the operand
  73194. * @returns the current updated Vector3
  73195. */
  73196. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  73197. /**
  73198. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  73199. * @param x defines the x coordinate of the operand
  73200. * @param y defines the y coordinate of the operand
  73201. * @param z defines the z coordinate of the operand
  73202. * @returns the current updated Vector3
  73203. */
  73204. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  73205. /**
  73206. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  73207. * Check if is non uniform within a certain amount of decimal places to account for this
  73208. * @param epsilon the amount the values can differ
  73209. * @returns if the the vector is non uniform to a certain number of decimal places
  73210. */
  73211. isNonUniformWithinEpsilon(epsilon: number): boolean;
  73212. /**
  73213. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  73214. */
  73215. get isNonUniform(): boolean;
  73216. /**
  73217. * Gets a new Vector3 from current Vector3 floored values
  73218. * @returns a new Vector3
  73219. */
  73220. floor(): Vector3;
  73221. /**
  73222. * Gets a new Vector3 from current Vector3 floored values
  73223. * @returns a new Vector3
  73224. */
  73225. fract(): Vector3;
  73226. /**
  73227. * Gets the length of the Vector3
  73228. * @returns the length of the Vector3
  73229. */
  73230. length(): number;
  73231. /**
  73232. * Gets the squared length of the Vector3
  73233. * @returns squared length of the Vector3
  73234. */
  73235. lengthSquared(): number;
  73236. /**
  73237. * Normalize the current Vector3.
  73238. * Please note that this is an in place operation.
  73239. * @returns the current updated Vector3
  73240. */
  73241. normalize(): Vector3;
  73242. /**
  73243. * Reorders the x y z properties of the vector in place
  73244. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  73245. * @returns the current updated vector
  73246. */
  73247. reorderInPlace(order: string): this;
  73248. /**
  73249. * Rotates the vector around 0,0,0 by a quaternion
  73250. * @param quaternion the rotation quaternion
  73251. * @param result vector to store the result
  73252. * @returns the resulting vector
  73253. */
  73254. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  73255. /**
  73256. * Rotates a vector around a given point
  73257. * @param quaternion the rotation quaternion
  73258. * @param point the point to rotate around
  73259. * @param result vector to store the result
  73260. * @returns the resulting vector
  73261. */
  73262. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  73263. /**
  73264. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  73265. * The cross product is then orthogonal to both current and "other"
  73266. * @param other defines the right operand
  73267. * @returns the cross product
  73268. */
  73269. cross(other: Vector3): Vector3;
  73270. /**
  73271. * Normalize the current Vector3 with the given input length.
  73272. * Please note that this is an in place operation.
  73273. * @param len the length of the vector
  73274. * @returns the current updated Vector3
  73275. */
  73276. normalizeFromLength(len: number): Vector3;
  73277. /**
  73278. * Normalize the current Vector3 to a new vector
  73279. * @returns the new Vector3
  73280. */
  73281. normalizeToNew(): Vector3;
  73282. /**
  73283. * Normalize the current Vector3 to the reference
  73284. * @param reference define the Vector3 to update
  73285. * @returns the updated Vector3
  73286. */
  73287. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  73288. /**
  73289. * Creates a new Vector3 copied from the current Vector3
  73290. * @returns the new Vector3
  73291. */
  73292. clone(): Vector3;
  73293. /**
  73294. * Copies the given vector coordinates to the current Vector3 ones
  73295. * @param source defines the source Vector3
  73296. * @returns the current updated Vector3
  73297. */
  73298. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  73299. /**
  73300. * Copies the given floats to the current Vector3 coordinates
  73301. * @param x defines the x coordinate of the operand
  73302. * @param y defines the y coordinate of the operand
  73303. * @param z defines the z coordinate of the operand
  73304. * @returns the current updated Vector3
  73305. */
  73306. copyFromFloats(x: number, y: number, z: number): Vector3;
  73307. /**
  73308. * Copies the given floats to the current Vector3 coordinates
  73309. * @param x defines the x coordinate of the operand
  73310. * @param y defines the y coordinate of the operand
  73311. * @param z defines the z coordinate of the operand
  73312. * @returns the current updated Vector3
  73313. */
  73314. set(x: number, y: number, z: number): Vector3;
  73315. /**
  73316. * Copies the given float to the current Vector3 coordinates
  73317. * @param v defines the x, y and z coordinates of the operand
  73318. * @returns the current updated Vector3
  73319. */
  73320. setAll(v: number): Vector3;
  73321. /**
  73322. * Get the clip factor between two vectors
  73323. * @param vector0 defines the first operand
  73324. * @param vector1 defines the second operand
  73325. * @param axis defines the axis to use
  73326. * @param size defines the size along the axis
  73327. * @returns the clip factor
  73328. */
  73329. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  73330. /**
  73331. * Get angle between two vectors
  73332. * @param vector0 angle between vector0 and vector1
  73333. * @param vector1 angle between vector0 and vector1
  73334. * @param normal direction of the normal
  73335. * @return the angle between vector0 and vector1
  73336. */
  73337. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  73338. /**
  73339. * Returns a new Vector3 set from the index "offset" of the given array
  73340. * @param array defines the source array
  73341. * @param offset defines the offset in the source array
  73342. * @returns the new Vector3
  73343. */
  73344. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  73345. /**
  73346. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  73347. * @param array defines the source array
  73348. * @param offset defines the offset in the source array
  73349. * @returns the new Vector3
  73350. * @deprecated Please use FromArray instead.
  73351. */
  73352. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  73353. /**
  73354. * Sets the given vector "result" with the element values from the index "offset" of the given array
  73355. * @param array defines the source array
  73356. * @param offset defines the offset in the source array
  73357. * @param result defines the Vector3 where to store the result
  73358. */
  73359. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  73360. /**
  73361. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  73362. * @param array defines the source array
  73363. * @param offset defines the offset in the source array
  73364. * @param result defines the Vector3 where to store the result
  73365. * @deprecated Please use FromArrayToRef instead.
  73366. */
  73367. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  73368. /**
  73369. * Sets the given vector "result" with the given floats.
  73370. * @param x defines the x coordinate of the source
  73371. * @param y defines the y coordinate of the source
  73372. * @param z defines the z coordinate of the source
  73373. * @param result defines the Vector3 where to store the result
  73374. */
  73375. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  73376. /**
  73377. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  73378. * @returns a new empty Vector3
  73379. */
  73380. static Zero(): Vector3;
  73381. /**
  73382. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  73383. * @returns a new unit Vector3
  73384. */
  73385. static One(): Vector3;
  73386. /**
  73387. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  73388. * @returns a new up Vector3
  73389. */
  73390. static Up(): Vector3;
  73391. /**
  73392. * Gets a up Vector3 that must not be updated
  73393. */
  73394. static get UpReadOnly(): DeepImmutable<Vector3>;
  73395. /**
  73396. * Gets a zero Vector3 that must not be updated
  73397. */
  73398. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  73399. /**
  73400. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  73401. * @returns a new down Vector3
  73402. */
  73403. static Down(): Vector3;
  73404. /**
  73405. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  73406. * @returns a new forward Vector3
  73407. */
  73408. static Forward(): Vector3;
  73409. /**
  73410. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  73411. * @returns a new forward Vector3
  73412. */
  73413. static Backward(): Vector3;
  73414. /**
  73415. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  73416. * @returns a new right Vector3
  73417. */
  73418. static Right(): Vector3;
  73419. /**
  73420. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  73421. * @returns a new left Vector3
  73422. */
  73423. static Left(): Vector3;
  73424. /**
  73425. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  73426. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  73427. * @param vector defines the Vector3 to transform
  73428. * @param transformation defines the transformation matrix
  73429. * @returns the transformed Vector3
  73430. */
  73431. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  73432. /**
  73433. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  73434. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  73435. * @param vector defines the Vector3 to transform
  73436. * @param transformation defines the transformation matrix
  73437. * @param result defines the Vector3 where to store the result
  73438. */
  73439. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  73440. /**
  73441. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  73442. * This method computes tranformed coordinates only, not transformed direction vectors
  73443. * @param x define the x coordinate of the source vector
  73444. * @param y define the y coordinate of the source vector
  73445. * @param z define the z coordinate of the source vector
  73446. * @param transformation defines the transformation matrix
  73447. * @param result defines the Vector3 where to store the result
  73448. */
  73449. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  73450. /**
  73451. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  73452. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73453. * @param vector defines the Vector3 to transform
  73454. * @param transformation defines the transformation matrix
  73455. * @returns the new Vector3
  73456. */
  73457. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  73458. /**
  73459. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  73460. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73461. * @param vector defines the Vector3 to transform
  73462. * @param transformation defines the transformation matrix
  73463. * @param result defines the Vector3 where to store the result
  73464. */
  73465. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  73466. /**
  73467. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  73468. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73469. * @param x define the x coordinate of the source vector
  73470. * @param y define the y coordinate of the source vector
  73471. * @param z define the z coordinate of the source vector
  73472. * @param transformation defines the transformation matrix
  73473. * @param result defines the Vector3 where to store the result
  73474. */
  73475. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  73476. /**
  73477. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  73478. * @param value1 defines the first control point
  73479. * @param value2 defines the second control point
  73480. * @param value3 defines the third control point
  73481. * @param value4 defines the fourth control point
  73482. * @param amount defines the amount on the spline to use
  73483. * @returns the new Vector3
  73484. */
  73485. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  73486. /**
  73487. * 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"
  73488. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  73489. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  73490. * @param value defines the current value
  73491. * @param min defines the lower range value
  73492. * @param max defines the upper range value
  73493. * @returns the new Vector3
  73494. */
  73495. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  73496. /**
  73497. * 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"
  73498. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  73499. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  73500. * @param value defines the current value
  73501. * @param min defines the lower range value
  73502. * @param max defines the upper range value
  73503. * @param result defines the Vector3 where to store the result
  73504. */
  73505. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  73506. /**
  73507. * Checks if a given vector is inside a specific range
  73508. * @param v defines the vector to test
  73509. * @param min defines the minimum range
  73510. * @param max defines the maximum range
  73511. */
  73512. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  73513. /**
  73514. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  73515. * @param value1 defines the first control point
  73516. * @param tangent1 defines the first tangent vector
  73517. * @param value2 defines the second control point
  73518. * @param tangent2 defines the second tangent vector
  73519. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  73520. * @returns the new Vector3
  73521. */
  73522. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  73523. /**
  73524. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  73525. * @param start defines the start value
  73526. * @param end defines the end value
  73527. * @param amount max defines amount between both (between 0 and 1)
  73528. * @returns the new Vector3
  73529. */
  73530. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  73531. /**
  73532. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  73533. * @param start defines the start value
  73534. * @param end defines the end value
  73535. * @param amount max defines amount between both (between 0 and 1)
  73536. * @param result defines the Vector3 where to store the result
  73537. */
  73538. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  73539. /**
  73540. * Returns the dot product (float) between the vectors "left" and "right"
  73541. * @param left defines the left operand
  73542. * @param right defines the right operand
  73543. * @returns the dot product
  73544. */
  73545. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  73546. /**
  73547. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  73548. * The cross product is then orthogonal to both "left" and "right"
  73549. * @param left defines the left operand
  73550. * @param right defines the right operand
  73551. * @returns the cross product
  73552. */
  73553. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  73554. /**
  73555. * Sets the given vector "result" with the cross product of "left" and "right"
  73556. * The cross product is then orthogonal to both "left" and "right"
  73557. * @param left defines the left operand
  73558. * @param right defines the right operand
  73559. * @param result defines the Vector3 where to store the result
  73560. */
  73561. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  73562. /**
  73563. * Returns a new Vector3 as the normalization of the given vector
  73564. * @param vector defines the Vector3 to normalize
  73565. * @returns the new Vector3
  73566. */
  73567. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  73568. /**
  73569. * Sets the given vector "result" with the normalization of the given first vector
  73570. * @param vector defines the Vector3 to normalize
  73571. * @param result defines the Vector3 where to store the result
  73572. */
  73573. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  73574. /**
  73575. * Project a Vector3 onto screen space
  73576. * @param vector defines the Vector3 to project
  73577. * @param world defines the world matrix to use
  73578. * @param transform defines the transform (view x projection) matrix to use
  73579. * @param viewport defines the screen viewport to use
  73580. * @returns the new Vector3
  73581. */
  73582. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  73583. /** @hidden */
  73584. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  73585. /**
  73586. * Unproject from screen space to object space
  73587. * @param source defines the screen space Vector3 to use
  73588. * @param viewportWidth defines the current width of the viewport
  73589. * @param viewportHeight defines the current height of the viewport
  73590. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73591. * @param transform defines the transform (view x projection) matrix to use
  73592. * @returns the new Vector3
  73593. */
  73594. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  73595. /**
  73596. * Unproject from screen space to object space
  73597. * @param source defines the screen space Vector3 to use
  73598. * @param viewportWidth defines the current width of the viewport
  73599. * @param viewportHeight defines the current height of the viewport
  73600. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73601. * @param view defines the view matrix to use
  73602. * @param projection defines the projection matrix to use
  73603. * @returns the new Vector3
  73604. */
  73605. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  73606. /**
  73607. * Unproject from screen space to object space
  73608. * @param source defines the screen space Vector3 to use
  73609. * @param viewportWidth defines the current width of the viewport
  73610. * @param viewportHeight defines the current height of the viewport
  73611. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73612. * @param view defines the view matrix to use
  73613. * @param projection defines the projection matrix to use
  73614. * @param result defines the Vector3 where to store the result
  73615. */
  73616. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  73617. /**
  73618. * Unproject from screen space to object space
  73619. * @param sourceX defines the screen space x coordinate to use
  73620. * @param sourceY defines the screen space y coordinate to use
  73621. * @param sourceZ defines the screen space z coordinate to use
  73622. * @param viewportWidth defines the current width of the viewport
  73623. * @param viewportHeight defines the current height of the viewport
  73624. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73625. * @param view defines the view matrix to use
  73626. * @param projection defines the projection matrix to use
  73627. * @param result defines the Vector3 where to store the result
  73628. */
  73629. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  73630. /**
  73631. * Gets the minimal coordinate values between two Vector3
  73632. * @param left defines the first operand
  73633. * @param right defines the second operand
  73634. * @returns the new Vector3
  73635. */
  73636. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  73637. /**
  73638. * Gets the maximal coordinate values between two Vector3
  73639. * @param left defines the first operand
  73640. * @param right defines the second operand
  73641. * @returns the new Vector3
  73642. */
  73643. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  73644. /**
  73645. * Returns the distance between the vectors "value1" and "value2"
  73646. * @param value1 defines the first operand
  73647. * @param value2 defines the second operand
  73648. * @returns the distance
  73649. */
  73650. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  73651. /**
  73652. * Returns the squared distance between the vectors "value1" and "value2"
  73653. * @param value1 defines the first operand
  73654. * @param value2 defines the second operand
  73655. * @returns the squared distance
  73656. */
  73657. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  73658. /**
  73659. * Returns a new Vector3 located at the center between "value1" and "value2"
  73660. * @param value1 defines the first operand
  73661. * @param value2 defines the second operand
  73662. * @returns the new Vector3
  73663. */
  73664. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  73665. /**
  73666. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  73667. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  73668. * to something in order to rotate it from its local system to the given target system
  73669. * Note: axis1, axis2 and axis3 are normalized during this operation
  73670. * @param axis1 defines the first axis
  73671. * @param axis2 defines the second axis
  73672. * @param axis3 defines the third axis
  73673. * @returns a new Vector3
  73674. */
  73675. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  73676. /**
  73677. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  73678. * @param axis1 defines the first axis
  73679. * @param axis2 defines the second axis
  73680. * @param axis3 defines the third axis
  73681. * @param ref defines the Vector3 where to store the result
  73682. */
  73683. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  73684. }
  73685. /**
  73686. * Vector4 class created for EulerAngle class conversion to Quaternion
  73687. */
  73688. export class Vector4 {
  73689. /** x value of the vector */
  73690. x: number;
  73691. /** y value of the vector */
  73692. y: number;
  73693. /** z value of the vector */
  73694. z: number;
  73695. /** w value of the vector */
  73696. w: number;
  73697. /**
  73698. * Creates a Vector4 object from the given floats.
  73699. * @param x x value of the vector
  73700. * @param y y value of the vector
  73701. * @param z z value of the vector
  73702. * @param w w value of the vector
  73703. */
  73704. constructor(
  73705. /** x value of the vector */
  73706. x: number,
  73707. /** y value of the vector */
  73708. y: number,
  73709. /** z value of the vector */
  73710. z: number,
  73711. /** w value of the vector */
  73712. w: number);
  73713. /**
  73714. * Returns the string with the Vector4 coordinates.
  73715. * @returns a string containing all the vector values
  73716. */
  73717. toString(): string;
  73718. /**
  73719. * Returns the string "Vector4".
  73720. * @returns "Vector4"
  73721. */
  73722. getClassName(): string;
  73723. /**
  73724. * Returns the Vector4 hash code.
  73725. * @returns a unique hash code
  73726. */
  73727. getHashCode(): number;
  73728. /**
  73729. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  73730. * @returns the resulting array
  73731. */
  73732. asArray(): number[];
  73733. /**
  73734. * Populates the given array from the given index with the Vector4 coordinates.
  73735. * @param array array to populate
  73736. * @param index index of the array to start at (default: 0)
  73737. * @returns the Vector4.
  73738. */
  73739. toArray(array: FloatArray, index?: number): Vector4;
  73740. /**
  73741. * Adds the given vector to the current Vector4.
  73742. * @param otherVector the vector to add
  73743. * @returns the updated Vector4.
  73744. */
  73745. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  73746. /**
  73747. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  73748. * @param otherVector the vector to add
  73749. * @returns the resulting vector
  73750. */
  73751. add(otherVector: DeepImmutable<Vector4>): Vector4;
  73752. /**
  73753. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  73754. * @param otherVector the vector to add
  73755. * @param result the vector to store the result
  73756. * @returns the current Vector4.
  73757. */
  73758. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73759. /**
  73760. * Subtract in place the given vector from the current Vector4.
  73761. * @param otherVector the vector to subtract
  73762. * @returns the updated Vector4.
  73763. */
  73764. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  73765. /**
  73766. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  73767. * @param otherVector the vector to add
  73768. * @returns the new vector with the result
  73769. */
  73770. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  73771. /**
  73772. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  73773. * @param otherVector the vector to subtract
  73774. * @param result the vector to store the result
  73775. * @returns the current Vector4.
  73776. */
  73777. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73778. /**
  73779. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73780. */
  73781. /**
  73782. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73783. * @param x value to subtract
  73784. * @param y value to subtract
  73785. * @param z value to subtract
  73786. * @param w value to subtract
  73787. * @returns new vector containing the result
  73788. */
  73789. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  73790. /**
  73791. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73792. * @param x value to subtract
  73793. * @param y value to subtract
  73794. * @param z value to subtract
  73795. * @param w value to subtract
  73796. * @param result the vector to store the result in
  73797. * @returns the current Vector4.
  73798. */
  73799. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  73800. /**
  73801. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  73802. * @returns a new vector with the negated values
  73803. */
  73804. negate(): Vector4;
  73805. /**
  73806. * Multiplies the current Vector4 coordinates by scale (float).
  73807. * @param scale the number to scale with
  73808. * @returns the updated Vector4.
  73809. */
  73810. scaleInPlace(scale: number): Vector4;
  73811. /**
  73812. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  73813. * @param scale the number to scale with
  73814. * @returns a new vector with the result
  73815. */
  73816. scale(scale: number): Vector4;
  73817. /**
  73818. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  73819. * @param scale the number to scale with
  73820. * @param result a vector to store the result in
  73821. * @returns the current Vector4.
  73822. */
  73823. scaleToRef(scale: number, result: Vector4): Vector4;
  73824. /**
  73825. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  73826. * @param scale defines the scale factor
  73827. * @param result defines the Vector4 object where to store the result
  73828. * @returns the unmodified current Vector4
  73829. */
  73830. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  73831. /**
  73832. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  73833. * @param otherVector the vector to compare against
  73834. * @returns true if they are equal
  73835. */
  73836. equals(otherVector: DeepImmutable<Vector4>): boolean;
  73837. /**
  73838. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  73839. * @param otherVector vector to compare against
  73840. * @param epsilon (Default: very small number)
  73841. * @returns true if they are equal
  73842. */
  73843. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  73844. /**
  73845. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  73846. * @param x x value to compare against
  73847. * @param y y value to compare against
  73848. * @param z z value to compare against
  73849. * @param w w value to compare against
  73850. * @returns true if equal
  73851. */
  73852. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  73853. /**
  73854. * Multiplies in place the current Vector4 by the given one.
  73855. * @param otherVector vector to multiple with
  73856. * @returns the updated Vector4.
  73857. */
  73858. multiplyInPlace(otherVector: Vector4): Vector4;
  73859. /**
  73860. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  73861. * @param otherVector vector to multiple with
  73862. * @returns resulting new vector
  73863. */
  73864. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  73865. /**
  73866. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  73867. * @param otherVector vector to multiple with
  73868. * @param result vector to store the result
  73869. * @returns the current Vector4.
  73870. */
  73871. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73872. /**
  73873. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  73874. * @param x x value multiply with
  73875. * @param y y value multiply with
  73876. * @param z z value multiply with
  73877. * @param w w value multiply with
  73878. * @returns resulting new vector
  73879. */
  73880. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  73881. /**
  73882. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  73883. * @param otherVector vector to devide with
  73884. * @returns resulting new vector
  73885. */
  73886. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  73887. /**
  73888. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  73889. * @param otherVector vector to devide with
  73890. * @param result vector to store the result
  73891. * @returns the current Vector4.
  73892. */
  73893. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  73894. /**
  73895. * Divides the current Vector3 coordinates by the given ones.
  73896. * @param otherVector vector to devide with
  73897. * @returns the updated Vector3.
  73898. */
  73899. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  73900. /**
  73901. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  73902. * @param other defines the second operand
  73903. * @returns the current updated Vector4
  73904. */
  73905. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  73906. /**
  73907. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  73908. * @param other defines the second operand
  73909. * @returns the current updated Vector4
  73910. */
  73911. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  73912. /**
  73913. * Gets a new Vector4 from current Vector4 floored values
  73914. * @returns a new Vector4
  73915. */
  73916. floor(): Vector4;
  73917. /**
  73918. * Gets a new Vector4 from current Vector3 floored values
  73919. * @returns a new Vector4
  73920. */
  73921. fract(): Vector4;
  73922. /**
  73923. * Returns the Vector4 length (float).
  73924. * @returns the length
  73925. */
  73926. length(): number;
  73927. /**
  73928. * Returns the Vector4 squared length (float).
  73929. * @returns the length squared
  73930. */
  73931. lengthSquared(): number;
  73932. /**
  73933. * Normalizes in place the Vector4.
  73934. * @returns the updated Vector4.
  73935. */
  73936. normalize(): Vector4;
  73937. /**
  73938. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  73939. * @returns this converted to a new vector3
  73940. */
  73941. toVector3(): Vector3;
  73942. /**
  73943. * Returns a new Vector4 copied from the current one.
  73944. * @returns the new cloned vector
  73945. */
  73946. clone(): Vector4;
  73947. /**
  73948. * Updates the current Vector4 with the given one coordinates.
  73949. * @param source the source vector to copy from
  73950. * @returns the updated Vector4.
  73951. */
  73952. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  73953. /**
  73954. * Updates the current Vector4 coordinates with the given floats.
  73955. * @param x float to copy from
  73956. * @param y float to copy from
  73957. * @param z float to copy from
  73958. * @param w float to copy from
  73959. * @returns the updated Vector4.
  73960. */
  73961. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  73962. /**
  73963. * Updates the current Vector4 coordinates with the given floats.
  73964. * @param x float to set from
  73965. * @param y float to set from
  73966. * @param z float to set from
  73967. * @param w float to set from
  73968. * @returns the updated Vector4.
  73969. */
  73970. set(x: number, y: number, z: number, w: number): Vector4;
  73971. /**
  73972. * Copies the given float to the current Vector3 coordinates
  73973. * @param v defines the x, y, z and w coordinates of the operand
  73974. * @returns the current updated Vector3
  73975. */
  73976. setAll(v: number): Vector4;
  73977. /**
  73978. * Returns a new Vector4 set from the starting index of the given array.
  73979. * @param array the array to pull values from
  73980. * @param offset the offset into the array to start at
  73981. * @returns the new vector
  73982. */
  73983. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  73984. /**
  73985. * Updates the given vector "result" from the starting index of the given array.
  73986. * @param array the array to pull values from
  73987. * @param offset the offset into the array to start at
  73988. * @param result the vector to store the result in
  73989. */
  73990. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  73991. /**
  73992. * Updates the given vector "result" from the starting index of the given Float32Array.
  73993. * @param array the array to pull values from
  73994. * @param offset the offset into the array to start at
  73995. * @param result the vector to store the result in
  73996. */
  73997. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  73998. /**
  73999. * Updates the given vector "result" coordinates from the given floats.
  74000. * @param x float to set from
  74001. * @param y float to set from
  74002. * @param z float to set from
  74003. * @param w float to set from
  74004. * @param result the vector to the floats in
  74005. */
  74006. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  74007. /**
  74008. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  74009. * @returns the new vector
  74010. */
  74011. static Zero(): Vector4;
  74012. /**
  74013. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  74014. * @returns the new vector
  74015. */
  74016. static One(): Vector4;
  74017. /**
  74018. * Returns a new normalized Vector4 from the given one.
  74019. * @param vector the vector to normalize
  74020. * @returns the vector
  74021. */
  74022. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  74023. /**
  74024. * Updates the given vector "result" from the normalization of the given one.
  74025. * @param vector the vector to normalize
  74026. * @param result the vector to store the result in
  74027. */
  74028. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  74029. /**
  74030. * Returns a vector with the minimum values from the left and right vectors
  74031. * @param left left vector to minimize
  74032. * @param right right vector to minimize
  74033. * @returns a new vector with the minimum of the left and right vector values
  74034. */
  74035. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  74036. /**
  74037. * Returns a vector with the maximum values from the left and right vectors
  74038. * @param left left vector to maximize
  74039. * @param right right vector to maximize
  74040. * @returns a new vector with the maximum of the left and right vector values
  74041. */
  74042. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  74043. /**
  74044. * Returns the distance (float) between the vectors "value1" and "value2".
  74045. * @param value1 value to calulate the distance between
  74046. * @param value2 value to calulate the distance between
  74047. * @return the distance between the two vectors
  74048. */
  74049. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  74050. /**
  74051. * Returns the squared distance (float) between the vectors "value1" and "value2".
  74052. * @param value1 value to calulate the distance between
  74053. * @param value2 value to calulate the distance between
  74054. * @return the distance between the two vectors squared
  74055. */
  74056. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  74057. /**
  74058. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  74059. * @param value1 value to calulate the center between
  74060. * @param value2 value to calulate the center between
  74061. * @return the center between the two vectors
  74062. */
  74063. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  74064. /**
  74065. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  74066. * This methods computes transformed normalized direction vectors only.
  74067. * @param vector the vector to transform
  74068. * @param transformation the transformation matrix to apply
  74069. * @returns the new vector
  74070. */
  74071. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  74072. /**
  74073. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  74074. * This methods computes transformed normalized direction vectors only.
  74075. * @param vector the vector to transform
  74076. * @param transformation the transformation matrix to apply
  74077. * @param result the vector to store the result in
  74078. */
  74079. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  74080. /**
  74081. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  74082. * This methods computes transformed normalized direction vectors only.
  74083. * @param x value to transform
  74084. * @param y value to transform
  74085. * @param z value to transform
  74086. * @param w value to transform
  74087. * @param transformation the transformation matrix to apply
  74088. * @param result the vector to store the results in
  74089. */
  74090. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  74091. /**
  74092. * Creates a new Vector4 from a Vector3
  74093. * @param source defines the source data
  74094. * @param w defines the 4th component (default is 0)
  74095. * @returns a new Vector4
  74096. */
  74097. static FromVector3(source: Vector3, w?: number): Vector4;
  74098. }
  74099. /**
  74100. * Class used to store quaternion data
  74101. * @see https://en.wikipedia.org/wiki/Quaternion
  74102. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  74103. */
  74104. export class Quaternion {
  74105. /** defines the first component (0 by default) */
  74106. x: number;
  74107. /** defines the second component (0 by default) */
  74108. y: number;
  74109. /** defines the third component (0 by default) */
  74110. z: number;
  74111. /** defines the fourth component (1.0 by default) */
  74112. w: number;
  74113. /**
  74114. * Creates a new Quaternion from the given floats
  74115. * @param x defines the first component (0 by default)
  74116. * @param y defines the second component (0 by default)
  74117. * @param z defines the third component (0 by default)
  74118. * @param w defines the fourth component (1.0 by default)
  74119. */
  74120. constructor(
  74121. /** defines the first component (0 by default) */
  74122. x?: number,
  74123. /** defines the second component (0 by default) */
  74124. y?: number,
  74125. /** defines the third component (0 by default) */
  74126. z?: number,
  74127. /** defines the fourth component (1.0 by default) */
  74128. w?: number);
  74129. /**
  74130. * Gets a string representation for the current quaternion
  74131. * @returns a string with the Quaternion coordinates
  74132. */
  74133. toString(): string;
  74134. /**
  74135. * Gets the class name of the quaternion
  74136. * @returns the string "Quaternion"
  74137. */
  74138. getClassName(): string;
  74139. /**
  74140. * Gets a hash code for this quaternion
  74141. * @returns the quaternion hash code
  74142. */
  74143. getHashCode(): number;
  74144. /**
  74145. * Copy the quaternion to an array
  74146. * @returns a new array populated with 4 elements from the quaternion coordinates
  74147. */
  74148. asArray(): number[];
  74149. /**
  74150. * Check if two quaternions are equals
  74151. * @param otherQuaternion defines the second operand
  74152. * @return true if the current quaternion and the given one coordinates are strictly equals
  74153. */
  74154. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  74155. /**
  74156. * Clone the current quaternion
  74157. * @returns a new quaternion copied from the current one
  74158. */
  74159. clone(): Quaternion;
  74160. /**
  74161. * Copy a quaternion to the current one
  74162. * @param other defines the other quaternion
  74163. * @returns the updated current quaternion
  74164. */
  74165. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  74166. /**
  74167. * Updates the current quaternion with the given float coordinates
  74168. * @param x defines the x coordinate
  74169. * @param y defines the y coordinate
  74170. * @param z defines the z coordinate
  74171. * @param w defines the w coordinate
  74172. * @returns the updated current quaternion
  74173. */
  74174. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  74175. /**
  74176. * Updates the current quaternion from the given float coordinates
  74177. * @param x defines the x coordinate
  74178. * @param y defines the y coordinate
  74179. * @param z defines the z coordinate
  74180. * @param w defines the w coordinate
  74181. * @returns the updated current quaternion
  74182. */
  74183. set(x: number, y: number, z: number, w: number): Quaternion;
  74184. /**
  74185. * Adds two quaternions
  74186. * @param other defines the second operand
  74187. * @returns a new quaternion as the addition result of the given one and the current quaternion
  74188. */
  74189. add(other: DeepImmutable<Quaternion>): Quaternion;
  74190. /**
  74191. * Add a quaternion to the current one
  74192. * @param other defines the quaternion to add
  74193. * @returns the current quaternion
  74194. */
  74195. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  74196. /**
  74197. * Subtract two quaternions
  74198. * @param other defines the second operand
  74199. * @returns a new quaternion as the subtraction result of the given one from the current one
  74200. */
  74201. subtract(other: Quaternion): Quaternion;
  74202. /**
  74203. * Multiplies the current quaternion by a scale factor
  74204. * @param value defines the scale factor
  74205. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  74206. */
  74207. scale(value: number): Quaternion;
  74208. /**
  74209. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  74210. * @param scale defines the scale factor
  74211. * @param result defines the Quaternion object where to store the result
  74212. * @returns the unmodified current quaternion
  74213. */
  74214. scaleToRef(scale: number, result: Quaternion): Quaternion;
  74215. /**
  74216. * Multiplies in place the current quaternion by a scale factor
  74217. * @param value defines the scale factor
  74218. * @returns the current modified quaternion
  74219. */
  74220. scaleInPlace(value: number): Quaternion;
  74221. /**
  74222. * Scale the current quaternion values by a factor and add the result to a given quaternion
  74223. * @param scale defines the scale factor
  74224. * @param result defines the Quaternion object where to store the result
  74225. * @returns the unmodified current quaternion
  74226. */
  74227. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  74228. /**
  74229. * Multiplies two quaternions
  74230. * @param q1 defines the second operand
  74231. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  74232. */
  74233. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  74234. /**
  74235. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  74236. * @param q1 defines the second operand
  74237. * @param result defines the target quaternion
  74238. * @returns the current quaternion
  74239. */
  74240. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  74241. /**
  74242. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  74243. * @param q1 defines the second operand
  74244. * @returns the currentupdated quaternion
  74245. */
  74246. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  74247. /**
  74248. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  74249. * @param ref defines the target quaternion
  74250. * @returns the current quaternion
  74251. */
  74252. conjugateToRef(ref: Quaternion): Quaternion;
  74253. /**
  74254. * Conjugates in place (1-q) the current quaternion
  74255. * @returns the current updated quaternion
  74256. */
  74257. conjugateInPlace(): Quaternion;
  74258. /**
  74259. * Conjugates in place (1-q) the current quaternion
  74260. * @returns a new quaternion
  74261. */
  74262. conjugate(): Quaternion;
  74263. /**
  74264. * Gets length of current quaternion
  74265. * @returns the quaternion length (float)
  74266. */
  74267. length(): number;
  74268. /**
  74269. * Normalize in place the current quaternion
  74270. * @returns the current updated quaternion
  74271. */
  74272. normalize(): Quaternion;
  74273. /**
  74274. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  74275. * @param order is a reserved parameter and is ignore for now
  74276. * @returns a new Vector3 containing the Euler angles
  74277. */
  74278. toEulerAngles(order?: string): Vector3;
  74279. /**
  74280. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  74281. * @param result defines the vector which will be filled with the Euler angles
  74282. * @param order is a reserved parameter and is ignore for now
  74283. * @returns the current unchanged quaternion
  74284. */
  74285. toEulerAnglesToRef(result: Vector3): Quaternion;
  74286. /**
  74287. * Updates the given rotation matrix with the current quaternion values
  74288. * @param result defines the target matrix
  74289. * @returns the current unchanged quaternion
  74290. */
  74291. toRotationMatrix(result: Matrix): Quaternion;
  74292. /**
  74293. * Updates the current quaternion from the given rotation matrix values
  74294. * @param matrix defines the source matrix
  74295. * @returns the current updated quaternion
  74296. */
  74297. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  74298. /**
  74299. * Creates a new quaternion from a rotation matrix
  74300. * @param matrix defines the source matrix
  74301. * @returns a new quaternion created from the given rotation matrix values
  74302. */
  74303. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  74304. /**
  74305. * Updates the given quaternion with the given rotation matrix values
  74306. * @param matrix defines the source matrix
  74307. * @param result defines the target quaternion
  74308. */
  74309. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  74310. /**
  74311. * Returns the dot product (float) between the quaternions "left" and "right"
  74312. * @param left defines the left operand
  74313. * @param right defines the right operand
  74314. * @returns the dot product
  74315. */
  74316. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  74317. /**
  74318. * Checks if the two quaternions are close to each other
  74319. * @param quat0 defines the first quaternion to check
  74320. * @param quat1 defines the second quaternion to check
  74321. * @returns true if the two quaternions are close to each other
  74322. */
  74323. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  74324. /**
  74325. * Creates an empty quaternion
  74326. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  74327. */
  74328. static Zero(): Quaternion;
  74329. /**
  74330. * Inverse a given quaternion
  74331. * @param q defines the source quaternion
  74332. * @returns a new quaternion as the inverted current quaternion
  74333. */
  74334. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  74335. /**
  74336. * Inverse a given quaternion
  74337. * @param q defines the source quaternion
  74338. * @param result the quaternion the result will be stored in
  74339. * @returns the result quaternion
  74340. */
  74341. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  74342. /**
  74343. * Creates an identity quaternion
  74344. * @returns the identity quaternion
  74345. */
  74346. static Identity(): Quaternion;
  74347. /**
  74348. * Gets a boolean indicating if the given quaternion is identity
  74349. * @param quaternion defines the quaternion to check
  74350. * @returns true if the quaternion is identity
  74351. */
  74352. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  74353. /**
  74354. * Creates a quaternion from a rotation around an axis
  74355. * @param axis defines the axis to use
  74356. * @param angle defines the angle to use
  74357. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  74358. */
  74359. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  74360. /**
  74361. * Creates a rotation around an axis and stores it into the given quaternion
  74362. * @param axis defines the axis to use
  74363. * @param angle defines the angle to use
  74364. * @param result defines the target quaternion
  74365. * @returns the target quaternion
  74366. */
  74367. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  74368. /**
  74369. * Creates a new quaternion from data stored into an array
  74370. * @param array defines the data source
  74371. * @param offset defines the offset in the source array where the data starts
  74372. * @returns a new quaternion
  74373. */
  74374. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  74375. /**
  74376. * Create a quaternion from Euler rotation angles
  74377. * @param x Pitch
  74378. * @param y Yaw
  74379. * @param z Roll
  74380. * @returns the new Quaternion
  74381. */
  74382. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  74383. /**
  74384. * Updates a quaternion from Euler rotation angles
  74385. * @param x Pitch
  74386. * @param y Yaw
  74387. * @param z Roll
  74388. * @param result the quaternion to store the result
  74389. * @returns the updated quaternion
  74390. */
  74391. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  74392. /**
  74393. * Create a quaternion from Euler rotation vector
  74394. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  74395. * @returns the new Quaternion
  74396. */
  74397. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  74398. /**
  74399. * Updates a quaternion from Euler rotation vector
  74400. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  74401. * @param result the quaternion to store the result
  74402. * @returns the updated quaternion
  74403. */
  74404. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  74405. /**
  74406. * Creates a new quaternion from the given Euler float angles (y, x, z)
  74407. * @param yaw defines the rotation around Y axis
  74408. * @param pitch defines the rotation around X axis
  74409. * @param roll defines the rotation around Z axis
  74410. * @returns the new quaternion
  74411. */
  74412. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  74413. /**
  74414. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  74415. * @param yaw defines the rotation around Y axis
  74416. * @param pitch defines the rotation around X axis
  74417. * @param roll defines the rotation around Z axis
  74418. * @param result defines the target quaternion
  74419. */
  74420. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  74421. /**
  74422. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  74423. * @param alpha defines the rotation around first axis
  74424. * @param beta defines the rotation around second axis
  74425. * @param gamma defines the rotation around third axis
  74426. * @returns the new quaternion
  74427. */
  74428. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  74429. /**
  74430. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  74431. * @param alpha defines the rotation around first axis
  74432. * @param beta defines the rotation around second axis
  74433. * @param gamma defines the rotation around third axis
  74434. * @param result defines the target quaternion
  74435. */
  74436. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  74437. /**
  74438. * 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)
  74439. * @param axis1 defines the first axis
  74440. * @param axis2 defines the second axis
  74441. * @param axis3 defines the third axis
  74442. * @returns the new quaternion
  74443. */
  74444. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  74445. /**
  74446. * 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
  74447. * @param axis1 defines the first axis
  74448. * @param axis2 defines the second axis
  74449. * @param axis3 defines the third axis
  74450. * @param ref defines the target quaternion
  74451. */
  74452. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  74453. /**
  74454. * Interpolates between two quaternions
  74455. * @param left defines first quaternion
  74456. * @param right defines second quaternion
  74457. * @param amount defines the gradient to use
  74458. * @returns the new interpolated quaternion
  74459. */
  74460. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  74461. /**
  74462. * Interpolates between two quaternions and stores it into a target quaternion
  74463. * @param left defines first quaternion
  74464. * @param right defines second quaternion
  74465. * @param amount defines the gradient to use
  74466. * @param result defines the target quaternion
  74467. */
  74468. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  74469. /**
  74470. * Interpolate between two quaternions using Hermite interpolation
  74471. * @param value1 defines first quaternion
  74472. * @param tangent1 defines the incoming tangent
  74473. * @param value2 defines second quaternion
  74474. * @param tangent2 defines the outgoing tangent
  74475. * @param amount defines the target quaternion
  74476. * @returns the new interpolated quaternion
  74477. */
  74478. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  74479. }
  74480. /**
  74481. * Class used to store matrix data (4x4)
  74482. */
  74483. export class Matrix {
  74484. private static _updateFlagSeed;
  74485. private static _identityReadOnly;
  74486. private _isIdentity;
  74487. private _isIdentityDirty;
  74488. private _isIdentity3x2;
  74489. private _isIdentity3x2Dirty;
  74490. /**
  74491. * Gets the update flag of the matrix which is an unique number for the matrix.
  74492. * It will be incremented every time the matrix data change.
  74493. * You can use it to speed the comparison between two versions of the same matrix.
  74494. */
  74495. updateFlag: number;
  74496. private readonly _m;
  74497. /**
  74498. * Gets the internal data of the matrix
  74499. */
  74500. get m(): DeepImmutable<Float32Array>;
  74501. /** @hidden */
  74502. _markAsUpdated(): void;
  74503. /** @hidden */
  74504. private _updateIdentityStatus;
  74505. /**
  74506. * Creates an empty matrix (filled with zeros)
  74507. */
  74508. constructor();
  74509. /**
  74510. * Check if the current matrix is identity
  74511. * @returns true is the matrix is the identity matrix
  74512. */
  74513. isIdentity(): boolean;
  74514. /**
  74515. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  74516. * @returns true is the matrix is the identity matrix
  74517. */
  74518. isIdentityAs3x2(): boolean;
  74519. /**
  74520. * Gets the determinant of the matrix
  74521. * @returns the matrix determinant
  74522. */
  74523. determinant(): number;
  74524. /**
  74525. * Returns the matrix as a Float32Array
  74526. * @returns the matrix underlying array
  74527. */
  74528. toArray(): DeepImmutable<Float32Array>;
  74529. /**
  74530. * Returns the matrix as a Float32Array
  74531. * @returns the matrix underlying array.
  74532. */
  74533. asArray(): DeepImmutable<Float32Array>;
  74534. /**
  74535. * Inverts the current matrix in place
  74536. * @returns the current inverted matrix
  74537. */
  74538. invert(): Matrix;
  74539. /**
  74540. * Sets all the matrix elements to zero
  74541. * @returns the current matrix
  74542. */
  74543. reset(): Matrix;
  74544. /**
  74545. * Adds the current matrix with a second one
  74546. * @param other defines the matrix to add
  74547. * @returns a new matrix as the addition of the current matrix and the given one
  74548. */
  74549. add(other: DeepImmutable<Matrix>): Matrix;
  74550. /**
  74551. * Sets the given matrix "result" to the addition of the current matrix and the given one
  74552. * @param other defines the matrix to add
  74553. * @param result defines the target matrix
  74554. * @returns the current matrix
  74555. */
  74556. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  74557. /**
  74558. * Adds in place the given matrix to the current matrix
  74559. * @param other defines the second operand
  74560. * @returns the current updated matrix
  74561. */
  74562. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  74563. /**
  74564. * Sets the given matrix to the current inverted Matrix
  74565. * @param other defines the target matrix
  74566. * @returns the unmodified current matrix
  74567. */
  74568. invertToRef(other: Matrix): Matrix;
  74569. /**
  74570. * add a value at the specified position in the current Matrix
  74571. * @param index the index of the value within the matrix. between 0 and 15.
  74572. * @param value the value to be added
  74573. * @returns the current updated matrix
  74574. */
  74575. addAtIndex(index: number, value: number): Matrix;
  74576. /**
  74577. * mutiply the specified position in the current Matrix by a value
  74578. * @param index the index of the value within the matrix. between 0 and 15.
  74579. * @param value the value to be added
  74580. * @returns the current updated matrix
  74581. */
  74582. multiplyAtIndex(index: number, value: number): Matrix;
  74583. /**
  74584. * Inserts the translation vector (using 3 floats) in the current matrix
  74585. * @param x defines the 1st component of the translation
  74586. * @param y defines the 2nd component of the translation
  74587. * @param z defines the 3rd component of the translation
  74588. * @returns the current updated matrix
  74589. */
  74590. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  74591. /**
  74592. * Adds the translation vector (using 3 floats) in the current matrix
  74593. * @param x defines the 1st component of the translation
  74594. * @param y defines the 2nd component of the translation
  74595. * @param z defines the 3rd component of the translation
  74596. * @returns the current updated matrix
  74597. */
  74598. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  74599. /**
  74600. * Inserts the translation vector in the current matrix
  74601. * @param vector3 defines the translation to insert
  74602. * @returns the current updated matrix
  74603. */
  74604. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  74605. /**
  74606. * Gets the translation value of the current matrix
  74607. * @returns a new Vector3 as the extracted translation from the matrix
  74608. */
  74609. getTranslation(): Vector3;
  74610. /**
  74611. * Fill a Vector3 with the extracted translation from the matrix
  74612. * @param result defines the Vector3 where to store the translation
  74613. * @returns the current matrix
  74614. */
  74615. getTranslationToRef(result: Vector3): Matrix;
  74616. /**
  74617. * Remove rotation and scaling part from the matrix
  74618. * @returns the updated matrix
  74619. */
  74620. removeRotationAndScaling(): Matrix;
  74621. /**
  74622. * Multiply two matrices
  74623. * @param other defines the second operand
  74624. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  74625. */
  74626. multiply(other: DeepImmutable<Matrix>): Matrix;
  74627. /**
  74628. * Copy the current matrix from the given one
  74629. * @param other defines the source matrix
  74630. * @returns the current updated matrix
  74631. */
  74632. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  74633. /**
  74634. * Populates the given array from the starting index with the current matrix values
  74635. * @param array defines the target array
  74636. * @param offset defines the offset in the target array where to start storing values
  74637. * @returns the current matrix
  74638. */
  74639. copyToArray(array: Float32Array, offset?: number): Matrix;
  74640. /**
  74641. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  74642. * @param other defines the second operand
  74643. * @param result defines the matrix where to store the multiplication
  74644. * @returns the current matrix
  74645. */
  74646. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  74647. /**
  74648. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  74649. * @param other defines the second operand
  74650. * @param result defines the array where to store the multiplication
  74651. * @param offset defines the offset in the target array where to start storing values
  74652. * @returns the current matrix
  74653. */
  74654. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  74655. /**
  74656. * Check equality between this matrix and a second one
  74657. * @param value defines the second matrix to compare
  74658. * @returns true is the current matrix and the given one values are strictly equal
  74659. */
  74660. equals(value: DeepImmutable<Matrix>): boolean;
  74661. /**
  74662. * Clone the current matrix
  74663. * @returns a new matrix from the current matrix
  74664. */
  74665. clone(): Matrix;
  74666. /**
  74667. * Returns the name of the current matrix class
  74668. * @returns the string "Matrix"
  74669. */
  74670. getClassName(): string;
  74671. /**
  74672. * Gets the hash code of the current matrix
  74673. * @returns the hash code
  74674. */
  74675. getHashCode(): number;
  74676. /**
  74677. * Decomposes the current Matrix into a translation, rotation and scaling components
  74678. * @param scale defines the scale vector3 given as a reference to update
  74679. * @param rotation defines the rotation quaternion given as a reference to update
  74680. * @param translation defines the translation vector3 given as a reference to update
  74681. * @returns true if operation was successful
  74682. */
  74683. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  74684. /**
  74685. * Gets specific row of the matrix
  74686. * @param index defines the number of the row to get
  74687. * @returns the index-th row of the current matrix as a new Vector4
  74688. */
  74689. getRow(index: number): Nullable<Vector4>;
  74690. /**
  74691. * Sets the index-th row of the current matrix to the vector4 values
  74692. * @param index defines the number of the row to set
  74693. * @param row defines the target vector4
  74694. * @returns the updated current matrix
  74695. */
  74696. setRow(index: number, row: Vector4): Matrix;
  74697. /**
  74698. * Compute the transpose of the matrix
  74699. * @returns the new transposed matrix
  74700. */
  74701. transpose(): Matrix;
  74702. /**
  74703. * Compute the transpose of the matrix and store it in a given matrix
  74704. * @param result defines the target matrix
  74705. * @returns the current matrix
  74706. */
  74707. transposeToRef(result: Matrix): Matrix;
  74708. /**
  74709. * Sets the index-th row of the current matrix with the given 4 x float values
  74710. * @param index defines the row index
  74711. * @param x defines the x component to set
  74712. * @param y defines the y component to set
  74713. * @param z defines the z component to set
  74714. * @param w defines the w component to set
  74715. * @returns the updated current matrix
  74716. */
  74717. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  74718. /**
  74719. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  74720. * @param scale defines the scale factor
  74721. * @returns a new matrix
  74722. */
  74723. scale(scale: number): Matrix;
  74724. /**
  74725. * Scale the current matrix values by a factor to a given result matrix
  74726. * @param scale defines the scale factor
  74727. * @param result defines the matrix to store the result
  74728. * @returns the current matrix
  74729. */
  74730. scaleToRef(scale: number, result: Matrix): Matrix;
  74731. /**
  74732. * Scale the current matrix values by a factor and add the result to a given matrix
  74733. * @param scale defines the scale factor
  74734. * @param result defines the Matrix to store the result
  74735. * @returns the current matrix
  74736. */
  74737. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  74738. /**
  74739. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  74740. * @param ref matrix to store the result
  74741. */
  74742. toNormalMatrix(ref: Matrix): void;
  74743. /**
  74744. * Gets only rotation part of the current matrix
  74745. * @returns a new matrix sets to the extracted rotation matrix from the current one
  74746. */
  74747. getRotationMatrix(): Matrix;
  74748. /**
  74749. * Extracts the rotation matrix from the current one and sets it as the given "result"
  74750. * @param result defines the target matrix to store data to
  74751. * @returns the current matrix
  74752. */
  74753. getRotationMatrixToRef(result: Matrix): Matrix;
  74754. /**
  74755. * Toggles model matrix from being right handed to left handed in place and vice versa
  74756. */
  74757. toggleModelMatrixHandInPlace(): void;
  74758. /**
  74759. * Toggles projection matrix from being right handed to left handed in place and vice versa
  74760. */
  74761. toggleProjectionMatrixHandInPlace(): void;
  74762. /**
  74763. * Creates a matrix from an array
  74764. * @param array defines the source array
  74765. * @param offset defines an offset in the source array
  74766. * @returns a new Matrix set from the starting index of the given array
  74767. */
  74768. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  74769. /**
  74770. * Copy the content of an array into a given matrix
  74771. * @param array defines the source array
  74772. * @param offset defines an offset in the source array
  74773. * @param result defines the target matrix
  74774. */
  74775. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  74776. /**
  74777. * Stores an array into a matrix after having multiplied each component by a given factor
  74778. * @param array defines the source array
  74779. * @param offset defines the offset in the source array
  74780. * @param scale defines the scaling factor
  74781. * @param result defines the target matrix
  74782. */
  74783. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  74784. /**
  74785. * Gets an identity matrix that must not be updated
  74786. */
  74787. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  74788. /**
  74789. * Stores a list of values (16) inside a given matrix
  74790. * @param initialM11 defines 1st value of 1st row
  74791. * @param initialM12 defines 2nd value of 1st row
  74792. * @param initialM13 defines 3rd value of 1st row
  74793. * @param initialM14 defines 4th value of 1st row
  74794. * @param initialM21 defines 1st value of 2nd row
  74795. * @param initialM22 defines 2nd value of 2nd row
  74796. * @param initialM23 defines 3rd value of 2nd row
  74797. * @param initialM24 defines 4th value of 2nd row
  74798. * @param initialM31 defines 1st value of 3rd row
  74799. * @param initialM32 defines 2nd value of 3rd row
  74800. * @param initialM33 defines 3rd value of 3rd row
  74801. * @param initialM34 defines 4th value of 3rd row
  74802. * @param initialM41 defines 1st value of 4th row
  74803. * @param initialM42 defines 2nd value of 4th row
  74804. * @param initialM43 defines 3rd value of 4th row
  74805. * @param initialM44 defines 4th value of 4th row
  74806. * @param result defines the target matrix
  74807. */
  74808. 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;
  74809. /**
  74810. * Creates new matrix from a list of values (16)
  74811. * @param initialM11 defines 1st value of 1st row
  74812. * @param initialM12 defines 2nd value of 1st row
  74813. * @param initialM13 defines 3rd value of 1st row
  74814. * @param initialM14 defines 4th value of 1st row
  74815. * @param initialM21 defines 1st value of 2nd row
  74816. * @param initialM22 defines 2nd value of 2nd row
  74817. * @param initialM23 defines 3rd value of 2nd row
  74818. * @param initialM24 defines 4th value of 2nd row
  74819. * @param initialM31 defines 1st value of 3rd row
  74820. * @param initialM32 defines 2nd value of 3rd row
  74821. * @param initialM33 defines 3rd value of 3rd row
  74822. * @param initialM34 defines 4th value of 3rd row
  74823. * @param initialM41 defines 1st value of 4th row
  74824. * @param initialM42 defines 2nd value of 4th row
  74825. * @param initialM43 defines 3rd value of 4th row
  74826. * @param initialM44 defines 4th value of 4th row
  74827. * @returns the new matrix
  74828. */
  74829. 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;
  74830. /**
  74831. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  74832. * @param scale defines the scale vector3
  74833. * @param rotation defines the rotation quaternion
  74834. * @param translation defines the translation vector3
  74835. * @returns a new matrix
  74836. */
  74837. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  74838. /**
  74839. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  74840. * @param scale defines the scale vector3
  74841. * @param rotation defines the rotation quaternion
  74842. * @param translation defines the translation vector3
  74843. * @param result defines the target matrix
  74844. */
  74845. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  74846. /**
  74847. * Creates a new identity matrix
  74848. * @returns a new identity matrix
  74849. */
  74850. static Identity(): Matrix;
  74851. /**
  74852. * Creates a new identity matrix and stores the result in a given matrix
  74853. * @param result defines the target matrix
  74854. */
  74855. static IdentityToRef(result: Matrix): void;
  74856. /**
  74857. * Creates a new zero matrix
  74858. * @returns a new zero matrix
  74859. */
  74860. static Zero(): Matrix;
  74861. /**
  74862. * Creates a new rotation matrix for "angle" radians around the X axis
  74863. * @param angle defines the angle (in radians) to use
  74864. * @return the new matrix
  74865. */
  74866. static RotationX(angle: number): Matrix;
  74867. /**
  74868. * Creates a new matrix as the invert of a given matrix
  74869. * @param source defines the source matrix
  74870. * @returns the new matrix
  74871. */
  74872. static Invert(source: DeepImmutable<Matrix>): Matrix;
  74873. /**
  74874. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  74875. * @param angle defines the angle (in radians) to use
  74876. * @param result defines the target matrix
  74877. */
  74878. static RotationXToRef(angle: number, result: Matrix): void;
  74879. /**
  74880. * Creates a new rotation matrix for "angle" radians around the Y axis
  74881. * @param angle defines the angle (in radians) to use
  74882. * @return the new matrix
  74883. */
  74884. static RotationY(angle: number): Matrix;
  74885. /**
  74886. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  74887. * @param angle defines the angle (in radians) to use
  74888. * @param result defines the target matrix
  74889. */
  74890. static RotationYToRef(angle: number, result: Matrix): void;
  74891. /**
  74892. * Creates a new rotation matrix for "angle" radians around the Z axis
  74893. * @param angle defines the angle (in radians) to use
  74894. * @return the new matrix
  74895. */
  74896. static RotationZ(angle: number): Matrix;
  74897. /**
  74898. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  74899. * @param angle defines the angle (in radians) to use
  74900. * @param result defines the target matrix
  74901. */
  74902. static RotationZToRef(angle: number, result: Matrix): void;
  74903. /**
  74904. * Creates a new rotation matrix for "angle" radians around the given axis
  74905. * @param axis defines the axis to use
  74906. * @param angle defines the angle (in radians) to use
  74907. * @return the new matrix
  74908. */
  74909. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  74910. /**
  74911. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  74912. * @param axis defines the axis to use
  74913. * @param angle defines the angle (in radians) to use
  74914. * @param result defines the target matrix
  74915. */
  74916. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  74917. /**
  74918. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  74919. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  74920. * @param from defines the vector to align
  74921. * @param to defines the vector to align to
  74922. * @param result defines the target matrix
  74923. */
  74924. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  74925. /**
  74926. * Creates a rotation matrix
  74927. * @param yaw defines the yaw angle in radians (Y axis)
  74928. * @param pitch defines the pitch angle in radians (X axis)
  74929. * @param roll defines the roll angle in radians (X axis)
  74930. * @returns the new rotation matrix
  74931. */
  74932. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  74933. /**
  74934. * Creates a rotation matrix and stores it in a given matrix
  74935. * @param yaw defines the yaw angle in radians (Y axis)
  74936. * @param pitch defines the pitch angle in radians (X axis)
  74937. * @param roll defines the roll angle in radians (X axis)
  74938. * @param result defines the target matrix
  74939. */
  74940. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  74941. /**
  74942. * Creates a scaling matrix
  74943. * @param x defines the scale factor on X axis
  74944. * @param y defines the scale factor on Y axis
  74945. * @param z defines the scale factor on Z axis
  74946. * @returns the new matrix
  74947. */
  74948. static Scaling(x: number, y: number, z: number): Matrix;
  74949. /**
  74950. * Creates a scaling matrix and stores it in a given matrix
  74951. * @param x defines the scale factor on X axis
  74952. * @param y defines the scale factor on Y axis
  74953. * @param z defines the scale factor on Z axis
  74954. * @param result defines the target matrix
  74955. */
  74956. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  74957. /**
  74958. * Creates a translation matrix
  74959. * @param x defines the translation on X axis
  74960. * @param y defines the translation on Y axis
  74961. * @param z defines the translationon Z axis
  74962. * @returns the new matrix
  74963. */
  74964. static Translation(x: number, y: number, z: number): Matrix;
  74965. /**
  74966. * Creates a translation matrix and stores it in a given matrix
  74967. * @param x defines the translation on X axis
  74968. * @param y defines the translation on Y axis
  74969. * @param z defines the translationon Z axis
  74970. * @param result defines the target matrix
  74971. */
  74972. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  74973. /**
  74974. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  74975. * @param startValue defines the start value
  74976. * @param endValue defines the end value
  74977. * @param gradient defines the gradient factor
  74978. * @returns the new matrix
  74979. */
  74980. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  74981. /**
  74982. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  74983. * @param startValue defines the start value
  74984. * @param endValue defines the end value
  74985. * @param gradient defines the gradient factor
  74986. * @param result defines the Matrix object where to store data
  74987. */
  74988. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  74989. /**
  74990. * Builds a new matrix whose values are computed by:
  74991. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  74992. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  74993. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  74994. * @param startValue defines the first matrix
  74995. * @param endValue defines the second matrix
  74996. * @param gradient defines the gradient between the two matrices
  74997. * @returns the new matrix
  74998. */
  74999. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  75000. /**
  75001. * Update a matrix to values which are computed by:
  75002. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  75003. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  75004. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  75005. * @param startValue defines the first matrix
  75006. * @param endValue defines the second matrix
  75007. * @param gradient defines the gradient between the two matrices
  75008. * @param result defines the target matrix
  75009. */
  75010. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  75011. /**
  75012. * 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"
  75013. * This function works in left handed mode
  75014. * @param eye defines the final position of the entity
  75015. * @param target defines where the entity should look at
  75016. * @param up defines the up vector for the entity
  75017. * @returns the new matrix
  75018. */
  75019. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  75020. /**
  75021. * 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".
  75022. * This function works in left handed mode
  75023. * @param eye defines the final position of the entity
  75024. * @param target defines where the entity should look at
  75025. * @param up defines the up vector for the entity
  75026. * @param result defines the target matrix
  75027. */
  75028. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  75029. /**
  75030. * 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"
  75031. * This function works in right handed mode
  75032. * @param eye defines the final position of the entity
  75033. * @param target defines where the entity should look at
  75034. * @param up defines the up vector for the entity
  75035. * @returns the new matrix
  75036. */
  75037. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  75038. /**
  75039. * 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".
  75040. * This function works in right handed mode
  75041. * @param eye defines the final position of the entity
  75042. * @param target defines where the entity should look at
  75043. * @param up defines the up vector for the entity
  75044. * @param result defines the target matrix
  75045. */
  75046. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  75047. /**
  75048. * Create a left-handed orthographic projection matrix
  75049. * @param width defines the viewport width
  75050. * @param height defines the viewport height
  75051. * @param znear defines the near clip plane
  75052. * @param zfar defines the far clip plane
  75053. * @returns a new matrix as a left-handed orthographic projection matrix
  75054. */
  75055. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  75056. /**
  75057. * Store a left-handed orthographic projection to a given matrix
  75058. * @param width defines the viewport width
  75059. * @param height defines the viewport height
  75060. * @param znear defines the near clip plane
  75061. * @param zfar defines the far clip plane
  75062. * @param result defines the target matrix
  75063. */
  75064. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  75065. /**
  75066. * Create a left-handed orthographic projection matrix
  75067. * @param left defines the viewport left coordinate
  75068. * @param right defines the viewport right coordinate
  75069. * @param bottom defines the viewport bottom coordinate
  75070. * @param top defines the viewport top coordinate
  75071. * @param znear defines the near clip plane
  75072. * @param zfar defines the far clip plane
  75073. * @returns a new matrix as a left-handed orthographic projection matrix
  75074. */
  75075. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  75076. /**
  75077. * Stores a left-handed orthographic projection into a given matrix
  75078. * @param left defines the viewport left coordinate
  75079. * @param right defines the viewport right coordinate
  75080. * @param bottom defines the viewport bottom coordinate
  75081. * @param top defines the viewport top coordinate
  75082. * @param znear defines the near clip plane
  75083. * @param zfar defines the far clip plane
  75084. * @param result defines the target matrix
  75085. */
  75086. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  75087. /**
  75088. * Creates a right-handed orthographic projection matrix
  75089. * @param left defines the viewport left coordinate
  75090. * @param right defines the viewport right coordinate
  75091. * @param bottom defines the viewport bottom coordinate
  75092. * @param top defines the viewport top coordinate
  75093. * @param znear defines the near clip plane
  75094. * @param zfar defines the far clip plane
  75095. * @returns a new matrix as a right-handed orthographic projection matrix
  75096. */
  75097. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  75098. /**
  75099. * Stores a right-handed orthographic projection into a given matrix
  75100. * @param left defines the viewport left coordinate
  75101. * @param right defines the viewport right coordinate
  75102. * @param bottom defines the viewport bottom coordinate
  75103. * @param top defines the viewport top coordinate
  75104. * @param znear defines the near clip plane
  75105. * @param zfar defines the far clip plane
  75106. * @param result defines the target matrix
  75107. */
  75108. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  75109. /**
  75110. * Creates a left-handed perspective projection matrix
  75111. * @param width defines the viewport width
  75112. * @param height defines the viewport height
  75113. * @param znear defines the near clip plane
  75114. * @param zfar defines the far clip plane
  75115. * @returns a new matrix as a left-handed perspective projection matrix
  75116. */
  75117. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  75118. /**
  75119. * Creates a left-handed perspective projection matrix
  75120. * @param fov defines the horizontal field of view
  75121. * @param aspect defines the aspect ratio
  75122. * @param znear defines the near clip plane
  75123. * @param zfar defines the far clip plane
  75124. * @returns a new matrix as a left-handed perspective projection matrix
  75125. */
  75126. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  75127. /**
  75128. * Stores a left-handed perspective projection into a given matrix
  75129. * @param fov defines the horizontal field of view
  75130. * @param aspect defines the aspect ratio
  75131. * @param znear defines the near clip plane
  75132. * @param zfar defines the far clip plane
  75133. * @param result defines the target matrix
  75134. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75135. */
  75136. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75137. /**
  75138. * Stores a left-handed perspective projection into a given matrix with depth reversed
  75139. * @param fov defines the horizontal field of view
  75140. * @param aspect defines the aspect ratio
  75141. * @param znear defines the near clip plane
  75142. * @param zfar not used as infinity is used as far clip
  75143. * @param result defines the target matrix
  75144. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75145. */
  75146. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75147. /**
  75148. * Creates a right-handed perspective projection matrix
  75149. * @param fov defines the horizontal field of view
  75150. * @param aspect defines the aspect ratio
  75151. * @param znear defines the near clip plane
  75152. * @param zfar defines the far clip plane
  75153. * @returns a new matrix as a right-handed perspective projection matrix
  75154. */
  75155. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  75156. /**
  75157. * Stores a right-handed perspective projection into a given matrix
  75158. * @param fov defines the horizontal field of view
  75159. * @param aspect defines the aspect ratio
  75160. * @param znear defines the near clip plane
  75161. * @param zfar defines the far clip plane
  75162. * @param result defines the target matrix
  75163. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75164. */
  75165. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75166. /**
  75167. * Stores a right-handed perspective projection into a given matrix
  75168. * @param fov defines the horizontal field of view
  75169. * @param aspect defines the aspect ratio
  75170. * @param znear defines the near clip plane
  75171. * @param zfar not used as infinity is used as far clip
  75172. * @param result defines the target matrix
  75173. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75174. */
  75175. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75176. /**
  75177. * Stores a perspective projection for WebVR info a given matrix
  75178. * @param fov defines the field of view
  75179. * @param znear defines the near clip plane
  75180. * @param zfar defines the far clip plane
  75181. * @param result defines the target matrix
  75182. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  75183. */
  75184. static PerspectiveFovWebVRToRef(fov: {
  75185. upDegrees: number;
  75186. downDegrees: number;
  75187. leftDegrees: number;
  75188. rightDegrees: number;
  75189. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  75190. /**
  75191. * Computes a complete transformation matrix
  75192. * @param viewport defines the viewport to use
  75193. * @param world defines the world matrix
  75194. * @param view defines the view matrix
  75195. * @param projection defines the projection matrix
  75196. * @param zmin defines the near clip plane
  75197. * @param zmax defines the far clip plane
  75198. * @returns the transformation matrix
  75199. */
  75200. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  75201. /**
  75202. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  75203. * @param matrix defines the matrix to use
  75204. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  75205. */
  75206. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  75207. /**
  75208. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  75209. * @param matrix defines the matrix to use
  75210. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  75211. */
  75212. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  75213. /**
  75214. * Compute the transpose of a given matrix
  75215. * @param matrix defines the matrix to transpose
  75216. * @returns the new matrix
  75217. */
  75218. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  75219. /**
  75220. * Compute the transpose of a matrix and store it in a target matrix
  75221. * @param matrix defines the matrix to transpose
  75222. * @param result defines the target matrix
  75223. */
  75224. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  75225. /**
  75226. * Computes a reflection matrix from a plane
  75227. * @param plane defines the reflection plane
  75228. * @returns a new matrix
  75229. */
  75230. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  75231. /**
  75232. * Computes a reflection matrix from a plane
  75233. * @param plane defines the reflection plane
  75234. * @param result defines the target matrix
  75235. */
  75236. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  75237. /**
  75238. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  75239. * @param xaxis defines the value of the 1st axis
  75240. * @param yaxis defines the value of the 2nd axis
  75241. * @param zaxis defines the value of the 3rd axis
  75242. * @param result defines the target matrix
  75243. */
  75244. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  75245. /**
  75246. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  75247. * @param quat defines the quaternion to use
  75248. * @param result defines the target matrix
  75249. */
  75250. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  75251. }
  75252. /**
  75253. * @hidden
  75254. */
  75255. export class TmpVectors {
  75256. static Vector2: Vector2[];
  75257. static Vector3: Vector3[];
  75258. static Vector4: Vector4[];
  75259. static Quaternion: Quaternion[];
  75260. static Matrix: Matrix[];
  75261. }
  75262. }
  75263. declare module BABYLON {
  75264. /**
  75265. * Defines potential orientation for back face culling
  75266. */
  75267. export enum Orientation {
  75268. /**
  75269. * Clockwise
  75270. */
  75271. CW = 0,
  75272. /** Counter clockwise */
  75273. CCW = 1
  75274. }
  75275. /** Class used to represent a Bezier curve */
  75276. export class BezierCurve {
  75277. /**
  75278. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  75279. * @param t defines the time
  75280. * @param x1 defines the left coordinate on X axis
  75281. * @param y1 defines the left coordinate on Y axis
  75282. * @param x2 defines the right coordinate on X axis
  75283. * @param y2 defines the right coordinate on Y axis
  75284. * @returns the interpolated value
  75285. */
  75286. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  75287. }
  75288. /**
  75289. * Defines angle representation
  75290. */
  75291. export class Angle {
  75292. private _radians;
  75293. /**
  75294. * Creates an Angle object of "radians" radians (float).
  75295. * @param radians the angle in radians
  75296. */
  75297. constructor(radians: number);
  75298. /**
  75299. * Get value in degrees
  75300. * @returns the Angle value in degrees (float)
  75301. */
  75302. degrees(): number;
  75303. /**
  75304. * Get value in radians
  75305. * @returns the Angle value in radians (float)
  75306. */
  75307. radians(): number;
  75308. /**
  75309. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  75310. * @param a defines first vector
  75311. * @param b defines second vector
  75312. * @returns a new Angle
  75313. */
  75314. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  75315. /**
  75316. * Gets a new Angle object from the given float in radians
  75317. * @param radians defines the angle value in radians
  75318. * @returns a new Angle
  75319. */
  75320. static FromRadians(radians: number): Angle;
  75321. /**
  75322. * Gets a new Angle object from the given float in degrees
  75323. * @param degrees defines the angle value in degrees
  75324. * @returns a new Angle
  75325. */
  75326. static FromDegrees(degrees: number): Angle;
  75327. }
  75328. /**
  75329. * This represents an arc in a 2d space.
  75330. */
  75331. export class Arc2 {
  75332. /** Defines the start point of the arc */
  75333. startPoint: Vector2;
  75334. /** Defines the mid point of the arc */
  75335. midPoint: Vector2;
  75336. /** Defines the end point of the arc */
  75337. endPoint: Vector2;
  75338. /**
  75339. * Defines the center point of the arc.
  75340. */
  75341. centerPoint: Vector2;
  75342. /**
  75343. * Defines the radius of the arc.
  75344. */
  75345. radius: number;
  75346. /**
  75347. * Defines the angle of the arc (from mid point to end point).
  75348. */
  75349. angle: Angle;
  75350. /**
  75351. * Defines the start angle of the arc (from start point to middle point).
  75352. */
  75353. startAngle: Angle;
  75354. /**
  75355. * Defines the orientation of the arc (clock wise/counter clock wise).
  75356. */
  75357. orientation: Orientation;
  75358. /**
  75359. * Creates an Arc object from the three given points : start, middle and end.
  75360. * @param startPoint Defines the start point of the arc
  75361. * @param midPoint Defines the midlle point of the arc
  75362. * @param endPoint Defines the end point of the arc
  75363. */
  75364. constructor(
  75365. /** Defines the start point of the arc */
  75366. startPoint: Vector2,
  75367. /** Defines the mid point of the arc */
  75368. midPoint: Vector2,
  75369. /** Defines the end point of the arc */
  75370. endPoint: Vector2);
  75371. }
  75372. /**
  75373. * Represents a 2D path made up of multiple 2D points
  75374. */
  75375. export class Path2 {
  75376. private _points;
  75377. private _length;
  75378. /**
  75379. * If the path start and end point are the same
  75380. */
  75381. closed: boolean;
  75382. /**
  75383. * Creates a Path2 object from the starting 2D coordinates x and y.
  75384. * @param x the starting points x value
  75385. * @param y the starting points y value
  75386. */
  75387. constructor(x: number, y: number);
  75388. /**
  75389. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  75390. * @param x the added points x value
  75391. * @param y the added points y value
  75392. * @returns the updated Path2.
  75393. */
  75394. addLineTo(x: number, y: number): Path2;
  75395. /**
  75396. * 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.
  75397. * @param midX middle point x value
  75398. * @param midY middle point y value
  75399. * @param endX end point x value
  75400. * @param endY end point y value
  75401. * @param numberOfSegments (default: 36)
  75402. * @returns the updated Path2.
  75403. */
  75404. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  75405. /**
  75406. * Closes the Path2.
  75407. * @returns the Path2.
  75408. */
  75409. close(): Path2;
  75410. /**
  75411. * Gets the sum of the distance between each sequential point in the path
  75412. * @returns the Path2 total length (float).
  75413. */
  75414. length(): number;
  75415. /**
  75416. * Gets the points which construct the path
  75417. * @returns the Path2 internal array of points.
  75418. */
  75419. getPoints(): Vector2[];
  75420. /**
  75421. * Retreives the point at the distance aways from the starting point
  75422. * @param normalizedLengthPosition the length along the path to retreive the point from
  75423. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  75424. */
  75425. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  75426. /**
  75427. * Creates a new path starting from an x and y position
  75428. * @param x starting x value
  75429. * @param y starting y value
  75430. * @returns a new Path2 starting at the coordinates (x, y).
  75431. */
  75432. static StartingAt(x: number, y: number): Path2;
  75433. }
  75434. /**
  75435. * Represents a 3D path made up of multiple 3D points
  75436. */
  75437. export class Path3D {
  75438. /**
  75439. * an array of Vector3, the curve axis of the Path3D
  75440. */
  75441. path: Vector3[];
  75442. private _curve;
  75443. private _distances;
  75444. private _tangents;
  75445. private _normals;
  75446. private _binormals;
  75447. private _raw;
  75448. private _alignTangentsWithPath;
  75449. private readonly _pointAtData;
  75450. /**
  75451. * new Path3D(path, normal, raw)
  75452. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  75453. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  75454. * @param path an array of Vector3, the curve axis of the Path3D
  75455. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  75456. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  75457. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  75458. */
  75459. constructor(
  75460. /**
  75461. * an array of Vector3, the curve axis of the Path3D
  75462. */
  75463. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  75464. /**
  75465. * Returns the Path3D array of successive Vector3 designing its curve.
  75466. * @returns the Path3D array of successive Vector3 designing its curve.
  75467. */
  75468. getCurve(): Vector3[];
  75469. /**
  75470. * Returns the Path3D array of successive Vector3 designing its curve.
  75471. * @returns the Path3D array of successive Vector3 designing its curve.
  75472. */
  75473. getPoints(): Vector3[];
  75474. /**
  75475. * @returns the computed length (float) of the path.
  75476. */
  75477. length(): number;
  75478. /**
  75479. * Returns an array populated with tangent vectors on each Path3D curve point.
  75480. * @returns an array populated with tangent vectors on each Path3D curve point.
  75481. */
  75482. getTangents(): Vector3[];
  75483. /**
  75484. * Returns an array populated with normal vectors on each Path3D curve point.
  75485. * @returns an array populated with normal vectors on each Path3D curve point.
  75486. */
  75487. getNormals(): Vector3[];
  75488. /**
  75489. * Returns an array populated with binormal vectors on each Path3D curve point.
  75490. * @returns an array populated with binormal vectors on each Path3D curve point.
  75491. */
  75492. getBinormals(): Vector3[];
  75493. /**
  75494. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  75495. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  75496. */
  75497. getDistances(): number[];
  75498. /**
  75499. * Returns an interpolated point along this path
  75500. * @param position the position of the point along this path, from 0.0 to 1.0
  75501. * @returns a new Vector3 as the point
  75502. */
  75503. getPointAt(position: number): Vector3;
  75504. /**
  75505. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  75506. * @param position the position of the point along this path, from 0.0 to 1.0
  75507. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  75508. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  75509. */
  75510. getTangentAt(position: number, interpolated?: boolean): Vector3;
  75511. /**
  75512. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  75513. * @param position the position of the point along this path, from 0.0 to 1.0
  75514. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  75515. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  75516. */
  75517. getNormalAt(position: number, interpolated?: boolean): Vector3;
  75518. /**
  75519. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  75520. * @param position the position of the point along this path, from 0.0 to 1.0
  75521. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  75522. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  75523. */
  75524. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  75525. /**
  75526. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  75527. * @param position the position of the point along this path, from 0.0 to 1.0
  75528. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  75529. */
  75530. getDistanceAt(position: number): number;
  75531. /**
  75532. * Returns the array index of the previous point of an interpolated point along this path
  75533. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  75534. * @returns the array index
  75535. */
  75536. getPreviousPointIndexAt(position: number): number;
  75537. /**
  75538. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  75539. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  75540. * @returns the sub position
  75541. */
  75542. getSubPositionAt(position: number): number;
  75543. /**
  75544. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  75545. * @param target the vector of which to get the closest position to
  75546. * @returns the position of the closest virtual point on this path to the target vector
  75547. */
  75548. getClosestPositionTo(target: Vector3): number;
  75549. /**
  75550. * Returns a sub path (slice) of this path
  75551. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  75552. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  75553. * @returns a sub path (slice) of this path
  75554. */
  75555. slice(start?: number, end?: number): Path3D;
  75556. /**
  75557. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  75558. * @param path path which all values are copied into the curves points
  75559. * @param firstNormal which should be projected onto the curve
  75560. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  75561. * @returns the same object updated.
  75562. */
  75563. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  75564. private _compute;
  75565. private _getFirstNonNullVector;
  75566. private _getLastNonNullVector;
  75567. private _normalVector;
  75568. /**
  75569. * Updates the point at data for an interpolated point along this curve
  75570. * @param position the position of the point along this curve, from 0.0 to 1.0
  75571. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  75572. * @returns the (updated) point at data
  75573. */
  75574. private _updatePointAtData;
  75575. /**
  75576. * Updates the point at data from the specified parameters
  75577. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  75578. * @param point the interpolated point
  75579. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  75580. */
  75581. private _setPointAtData;
  75582. /**
  75583. * Updates the point at interpolation matrix for the tangents, normals and binormals
  75584. */
  75585. private _updateInterpolationMatrix;
  75586. }
  75587. /**
  75588. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  75589. * A Curve3 is designed from a series of successive Vector3.
  75590. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  75591. */
  75592. export class Curve3 {
  75593. private _points;
  75594. private _length;
  75595. /**
  75596. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  75597. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  75598. * @param v1 (Vector3) the control point
  75599. * @param v2 (Vector3) the end point of the Quadratic Bezier
  75600. * @param nbPoints (integer) the wanted number of points in the curve
  75601. * @returns the created Curve3
  75602. */
  75603. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  75604. /**
  75605. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  75606. * @param v0 (Vector3) the origin point of the Cubic Bezier
  75607. * @param v1 (Vector3) the first control point
  75608. * @param v2 (Vector3) the second control point
  75609. * @param v3 (Vector3) the end point of the Cubic Bezier
  75610. * @param nbPoints (integer) the wanted number of points in the curve
  75611. * @returns the created Curve3
  75612. */
  75613. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  75614. /**
  75615. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  75616. * @param p1 (Vector3) the origin point of the Hermite Spline
  75617. * @param t1 (Vector3) the tangent vector at the origin point
  75618. * @param p2 (Vector3) the end point of the Hermite Spline
  75619. * @param t2 (Vector3) the tangent vector at the end point
  75620. * @param nbPoints (integer) the wanted number of points in the curve
  75621. * @returns the created Curve3
  75622. */
  75623. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  75624. /**
  75625. * Returns a Curve3 object along a CatmullRom Spline curve :
  75626. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  75627. * @param nbPoints (integer) the wanted number of points between each curve control points
  75628. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  75629. * @returns the created Curve3
  75630. */
  75631. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  75632. /**
  75633. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  75634. * A Curve3 is designed from a series of successive Vector3.
  75635. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  75636. * @param points points which make up the curve
  75637. */
  75638. constructor(points: Vector3[]);
  75639. /**
  75640. * @returns the Curve3 stored array of successive Vector3
  75641. */
  75642. getPoints(): Vector3[];
  75643. /**
  75644. * @returns the computed length (float) of the curve.
  75645. */
  75646. length(): number;
  75647. /**
  75648. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  75649. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  75650. * curveA and curveB keep unchanged.
  75651. * @param curve the curve to continue from this curve
  75652. * @returns the newly constructed curve
  75653. */
  75654. continue(curve: DeepImmutable<Curve3>): Curve3;
  75655. private _computeLength;
  75656. }
  75657. }
  75658. declare module BABYLON {
  75659. /**
  75660. * This represents the main contract an easing function should follow.
  75661. * Easing functions are used throughout the animation system.
  75662. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75663. */
  75664. export interface IEasingFunction {
  75665. /**
  75666. * Given an input gradient between 0 and 1, this returns the corrseponding value
  75667. * of the easing function.
  75668. * The link below provides some of the most common examples of easing functions.
  75669. * @see https://easings.net/
  75670. * @param gradient Defines the value between 0 and 1 we want the easing value for
  75671. * @returns the corresponding value on the curve defined by the easing function
  75672. */
  75673. ease(gradient: number): number;
  75674. }
  75675. /**
  75676. * Base class used for every default easing function.
  75677. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75678. */
  75679. export class EasingFunction implements IEasingFunction {
  75680. /**
  75681. * Interpolation follows the mathematical formula associated with the easing function.
  75682. */
  75683. static readonly EASINGMODE_EASEIN: number;
  75684. /**
  75685. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  75686. */
  75687. static readonly EASINGMODE_EASEOUT: number;
  75688. /**
  75689. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  75690. */
  75691. static readonly EASINGMODE_EASEINOUT: number;
  75692. private _easingMode;
  75693. /**
  75694. * Sets the easing mode of the current function.
  75695. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  75696. */
  75697. setEasingMode(easingMode: number): void;
  75698. /**
  75699. * Gets the current easing mode.
  75700. * @returns the easing mode
  75701. */
  75702. getEasingMode(): number;
  75703. /**
  75704. * @hidden
  75705. */
  75706. easeInCore(gradient: number): number;
  75707. /**
  75708. * Given an input gradient between 0 and 1, this returns the corresponding value
  75709. * of the easing function.
  75710. * @param gradient Defines the value between 0 and 1 we want the easing value for
  75711. * @returns the corresponding value on the curve defined by the easing function
  75712. */
  75713. ease(gradient: number): number;
  75714. }
  75715. /**
  75716. * Easing function with a circle shape (see link below).
  75717. * @see https://easings.net/#easeInCirc
  75718. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75719. */
  75720. export class CircleEase extends EasingFunction implements IEasingFunction {
  75721. /** @hidden */
  75722. easeInCore(gradient: number): number;
  75723. }
  75724. /**
  75725. * Easing function with a ease back shape (see link below).
  75726. * @see https://easings.net/#easeInBack
  75727. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75728. */
  75729. export class BackEase extends EasingFunction implements IEasingFunction {
  75730. /** Defines the amplitude of the function */
  75731. amplitude: number;
  75732. /**
  75733. * Instantiates a back ease easing
  75734. * @see https://easings.net/#easeInBack
  75735. * @param amplitude Defines the amplitude of the function
  75736. */
  75737. constructor(
  75738. /** Defines the amplitude of the function */
  75739. amplitude?: number);
  75740. /** @hidden */
  75741. easeInCore(gradient: number): number;
  75742. }
  75743. /**
  75744. * Easing function with a bouncing shape (see link below).
  75745. * @see https://easings.net/#easeInBounce
  75746. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75747. */
  75748. export class BounceEase extends EasingFunction implements IEasingFunction {
  75749. /** Defines the number of bounces */
  75750. bounces: number;
  75751. /** Defines the amplitude of the bounce */
  75752. bounciness: number;
  75753. /**
  75754. * Instantiates a bounce easing
  75755. * @see https://easings.net/#easeInBounce
  75756. * @param bounces Defines the number of bounces
  75757. * @param bounciness Defines the amplitude of the bounce
  75758. */
  75759. constructor(
  75760. /** Defines the number of bounces */
  75761. bounces?: number,
  75762. /** Defines the amplitude of the bounce */
  75763. bounciness?: number);
  75764. /** @hidden */
  75765. easeInCore(gradient: number): number;
  75766. }
  75767. /**
  75768. * Easing function with a power of 3 shape (see link below).
  75769. * @see https://easings.net/#easeInCubic
  75770. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75771. */
  75772. export class CubicEase extends EasingFunction implements IEasingFunction {
  75773. /** @hidden */
  75774. easeInCore(gradient: number): number;
  75775. }
  75776. /**
  75777. * Easing function with an elastic shape (see link below).
  75778. * @see https://easings.net/#easeInElastic
  75779. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75780. */
  75781. export class ElasticEase extends EasingFunction implements IEasingFunction {
  75782. /** Defines the number of oscillations*/
  75783. oscillations: number;
  75784. /** Defines the amplitude of the oscillations*/
  75785. springiness: number;
  75786. /**
  75787. * Instantiates an elastic easing function
  75788. * @see https://easings.net/#easeInElastic
  75789. * @param oscillations Defines the number of oscillations
  75790. * @param springiness Defines the amplitude of the oscillations
  75791. */
  75792. constructor(
  75793. /** Defines the number of oscillations*/
  75794. oscillations?: number,
  75795. /** Defines the amplitude of the oscillations*/
  75796. springiness?: number);
  75797. /** @hidden */
  75798. easeInCore(gradient: number): number;
  75799. }
  75800. /**
  75801. * Easing function with an exponential shape (see link below).
  75802. * @see https://easings.net/#easeInExpo
  75803. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75804. */
  75805. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  75806. /** Defines the exponent of the function */
  75807. exponent: number;
  75808. /**
  75809. * Instantiates an exponential easing function
  75810. * @see https://easings.net/#easeInExpo
  75811. * @param exponent Defines the exponent of the function
  75812. */
  75813. constructor(
  75814. /** Defines the exponent of the function */
  75815. exponent?: number);
  75816. /** @hidden */
  75817. easeInCore(gradient: number): number;
  75818. }
  75819. /**
  75820. * Easing function with a power shape (see link below).
  75821. * @see https://easings.net/#easeInQuad
  75822. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75823. */
  75824. export class PowerEase extends EasingFunction implements IEasingFunction {
  75825. /** Defines the power of the function */
  75826. power: number;
  75827. /**
  75828. * Instantiates an power base easing function
  75829. * @see https://easings.net/#easeInQuad
  75830. * @param power Defines the power of the function
  75831. */
  75832. constructor(
  75833. /** Defines the power of the function */
  75834. power?: number);
  75835. /** @hidden */
  75836. easeInCore(gradient: number): number;
  75837. }
  75838. /**
  75839. * Easing function with a power of 2 shape (see link below).
  75840. * @see https://easings.net/#easeInQuad
  75841. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75842. */
  75843. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  75844. /** @hidden */
  75845. easeInCore(gradient: number): number;
  75846. }
  75847. /**
  75848. * Easing function with a power of 4 shape (see link below).
  75849. * @see https://easings.net/#easeInQuart
  75850. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75851. */
  75852. export class QuarticEase extends EasingFunction implements IEasingFunction {
  75853. /** @hidden */
  75854. easeInCore(gradient: number): number;
  75855. }
  75856. /**
  75857. * Easing function with a power of 5 shape (see link below).
  75858. * @see https://easings.net/#easeInQuint
  75859. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75860. */
  75861. export class QuinticEase extends EasingFunction implements IEasingFunction {
  75862. /** @hidden */
  75863. easeInCore(gradient: number): number;
  75864. }
  75865. /**
  75866. * Easing function with a sin shape (see link below).
  75867. * @see https://easings.net/#easeInSine
  75868. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75869. */
  75870. export class SineEase extends EasingFunction implements IEasingFunction {
  75871. /** @hidden */
  75872. easeInCore(gradient: number): number;
  75873. }
  75874. /**
  75875. * Easing function with a bezier shape (see link below).
  75876. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  75877. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  75878. */
  75879. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  75880. /** Defines the x component of the start tangent in the bezier curve */
  75881. x1: number;
  75882. /** Defines the y component of the start tangent in the bezier curve */
  75883. y1: number;
  75884. /** Defines the x component of the end tangent in the bezier curve */
  75885. x2: number;
  75886. /** Defines the y component of the end tangent in the bezier curve */
  75887. y2: number;
  75888. /**
  75889. * Instantiates a bezier function
  75890. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  75891. * @param x1 Defines the x component of the start tangent in the bezier curve
  75892. * @param y1 Defines the y component of the start tangent in the bezier curve
  75893. * @param x2 Defines the x component of the end tangent in the bezier curve
  75894. * @param y2 Defines the y component of the end tangent in the bezier curve
  75895. */
  75896. constructor(
  75897. /** Defines the x component of the start tangent in the bezier curve */
  75898. x1?: number,
  75899. /** Defines the y component of the start tangent in the bezier curve */
  75900. y1?: number,
  75901. /** Defines the x component of the end tangent in the bezier curve */
  75902. x2?: number,
  75903. /** Defines the y component of the end tangent in the bezier curve */
  75904. y2?: number);
  75905. /** @hidden */
  75906. easeInCore(gradient: number): number;
  75907. }
  75908. }
  75909. declare module BABYLON {
  75910. /**
  75911. * Class used to hold a RBG color
  75912. */
  75913. export class Color3 {
  75914. /**
  75915. * Defines the red component (between 0 and 1, default is 0)
  75916. */
  75917. r: number;
  75918. /**
  75919. * Defines the green component (between 0 and 1, default is 0)
  75920. */
  75921. g: number;
  75922. /**
  75923. * Defines the blue component (between 0 and 1, default is 0)
  75924. */
  75925. b: number;
  75926. /**
  75927. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  75928. * @param r defines the red component (between 0 and 1, default is 0)
  75929. * @param g defines the green component (between 0 and 1, default is 0)
  75930. * @param b defines the blue component (between 0 and 1, default is 0)
  75931. */
  75932. constructor(
  75933. /**
  75934. * Defines the red component (between 0 and 1, default is 0)
  75935. */
  75936. r?: number,
  75937. /**
  75938. * Defines the green component (between 0 and 1, default is 0)
  75939. */
  75940. g?: number,
  75941. /**
  75942. * Defines the blue component (between 0 and 1, default is 0)
  75943. */
  75944. b?: number);
  75945. /**
  75946. * Creates a string with the Color3 current values
  75947. * @returns the string representation of the Color3 object
  75948. */
  75949. toString(): string;
  75950. /**
  75951. * Returns the string "Color3"
  75952. * @returns "Color3"
  75953. */
  75954. getClassName(): string;
  75955. /**
  75956. * Compute the Color3 hash code
  75957. * @returns an unique number that can be used to hash Color3 objects
  75958. */
  75959. getHashCode(): number;
  75960. /**
  75961. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  75962. * @param array defines the array where to store the r,g,b components
  75963. * @param index defines an optional index in the target array to define where to start storing values
  75964. * @returns the current Color3 object
  75965. */
  75966. toArray(array: FloatArray, index?: number): Color3;
  75967. /**
  75968. * Returns a new Color4 object from the current Color3 and the given alpha
  75969. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  75970. * @returns a new Color4 object
  75971. */
  75972. toColor4(alpha?: number): Color4;
  75973. /**
  75974. * Returns a new array populated with 3 numeric elements : red, green and blue values
  75975. * @returns the new array
  75976. */
  75977. asArray(): number[];
  75978. /**
  75979. * Returns the luminance value
  75980. * @returns a float value
  75981. */
  75982. toLuminance(): number;
  75983. /**
  75984. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  75985. * @param otherColor defines the second operand
  75986. * @returns the new Color3 object
  75987. */
  75988. multiply(otherColor: DeepImmutable<Color3>): Color3;
  75989. /**
  75990. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  75991. * @param otherColor defines the second operand
  75992. * @param result defines the Color3 object where to store the result
  75993. * @returns the current Color3
  75994. */
  75995. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  75996. /**
  75997. * Determines equality between Color3 objects
  75998. * @param otherColor defines the second operand
  75999. * @returns true if the rgb values are equal to the given ones
  76000. */
  76001. equals(otherColor: DeepImmutable<Color3>): boolean;
  76002. /**
  76003. * Determines equality between the current Color3 object and a set of r,b,g values
  76004. * @param r defines the red component to check
  76005. * @param g defines the green component to check
  76006. * @param b defines the blue component to check
  76007. * @returns true if the rgb values are equal to the given ones
  76008. */
  76009. equalsFloats(r: number, g: number, b: number): boolean;
  76010. /**
  76011. * Multiplies in place each rgb value by scale
  76012. * @param scale defines the scaling factor
  76013. * @returns the updated Color3
  76014. */
  76015. scale(scale: number): Color3;
  76016. /**
  76017. * Multiplies the rgb values by scale and stores the result into "result"
  76018. * @param scale defines the scaling factor
  76019. * @param result defines the Color3 object where to store the result
  76020. * @returns the unmodified current Color3
  76021. */
  76022. scaleToRef(scale: number, result: Color3): Color3;
  76023. /**
  76024. * Scale the current Color3 values by a factor and add the result to a given Color3
  76025. * @param scale defines the scale factor
  76026. * @param result defines color to store the result into
  76027. * @returns the unmodified current Color3
  76028. */
  76029. scaleAndAddToRef(scale: number, result: Color3): Color3;
  76030. /**
  76031. * Clamps the rgb values by the min and max values and stores the result into "result"
  76032. * @param min defines minimum clamping value (default is 0)
  76033. * @param max defines maximum clamping value (default is 1)
  76034. * @param result defines color to store the result into
  76035. * @returns the original Color3
  76036. */
  76037. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  76038. /**
  76039. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  76040. * @param otherColor defines the second operand
  76041. * @returns the new Color3
  76042. */
  76043. add(otherColor: DeepImmutable<Color3>): Color3;
  76044. /**
  76045. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  76046. * @param otherColor defines the second operand
  76047. * @param result defines Color3 object to store the result into
  76048. * @returns the unmodified current Color3
  76049. */
  76050. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  76051. /**
  76052. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  76053. * @param otherColor defines the second operand
  76054. * @returns the new Color3
  76055. */
  76056. subtract(otherColor: DeepImmutable<Color3>): Color3;
  76057. /**
  76058. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  76059. * @param otherColor defines the second operand
  76060. * @param result defines Color3 object to store the result into
  76061. * @returns the unmodified current Color3
  76062. */
  76063. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  76064. /**
  76065. * Copy the current object
  76066. * @returns a new Color3 copied the current one
  76067. */
  76068. clone(): Color3;
  76069. /**
  76070. * Copies the rgb values from the source in the current Color3
  76071. * @param source defines the source Color3 object
  76072. * @returns the updated Color3 object
  76073. */
  76074. copyFrom(source: DeepImmutable<Color3>): Color3;
  76075. /**
  76076. * Updates the Color3 rgb values from the given floats
  76077. * @param r defines the red component to read from
  76078. * @param g defines the green component to read from
  76079. * @param b defines the blue component to read from
  76080. * @returns the current Color3 object
  76081. */
  76082. copyFromFloats(r: number, g: number, b: number): Color3;
  76083. /**
  76084. * Updates the Color3 rgb values from the given floats
  76085. * @param r defines the red component to read from
  76086. * @param g defines the green component to read from
  76087. * @param b defines the blue component to read from
  76088. * @returns the current Color3 object
  76089. */
  76090. set(r: number, g: number, b: number): Color3;
  76091. /**
  76092. * Compute the Color3 hexadecimal code as a string
  76093. * @returns a string containing the hexadecimal representation of the Color3 object
  76094. */
  76095. toHexString(): string;
  76096. /**
  76097. * Computes a new Color3 converted from the current one to linear space
  76098. * @returns a new Color3 object
  76099. */
  76100. toLinearSpace(): Color3;
  76101. /**
  76102. * Converts current color in rgb space to HSV values
  76103. * @returns a new color3 representing the HSV values
  76104. */
  76105. toHSV(): Color3;
  76106. /**
  76107. * Converts current color in rgb space to HSV values
  76108. * @param result defines the Color3 where to store the HSV values
  76109. */
  76110. toHSVToRef(result: Color3): void;
  76111. /**
  76112. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  76113. * @param convertedColor defines the Color3 object where to store the linear space version
  76114. * @returns the unmodified Color3
  76115. */
  76116. toLinearSpaceToRef(convertedColor: Color3): Color3;
  76117. /**
  76118. * Computes a new Color3 converted from the current one to gamma space
  76119. * @returns a new Color3 object
  76120. */
  76121. toGammaSpace(): Color3;
  76122. /**
  76123. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  76124. * @param convertedColor defines the Color3 object where to store the gamma space version
  76125. * @returns the unmodified Color3
  76126. */
  76127. toGammaSpaceToRef(convertedColor: Color3): Color3;
  76128. private static _BlackReadOnly;
  76129. /**
  76130. * Convert Hue, saturation and value to a Color3 (RGB)
  76131. * @param hue defines the hue
  76132. * @param saturation defines the saturation
  76133. * @param value defines the value
  76134. * @param result defines the Color3 where to store the RGB values
  76135. */
  76136. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  76137. /**
  76138. * Creates a new Color3 from the string containing valid hexadecimal values
  76139. * @param hex defines a string containing valid hexadecimal values
  76140. * @returns a new Color3 object
  76141. */
  76142. static FromHexString(hex: string): Color3;
  76143. /**
  76144. * Creates a new Color3 from the starting index of the given array
  76145. * @param array defines the source array
  76146. * @param offset defines an offset in the source array
  76147. * @returns a new Color3 object
  76148. */
  76149. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  76150. /**
  76151. * Creates a new Color3 from integer values (< 256)
  76152. * @param r defines the red component to read from (value between 0 and 255)
  76153. * @param g defines the green component to read from (value between 0 and 255)
  76154. * @param b defines the blue component to read from (value between 0 and 255)
  76155. * @returns a new Color3 object
  76156. */
  76157. static FromInts(r: number, g: number, b: number): Color3;
  76158. /**
  76159. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  76160. * @param start defines the start Color3 value
  76161. * @param end defines the end Color3 value
  76162. * @param amount defines the gradient value between start and end
  76163. * @returns a new Color3 object
  76164. */
  76165. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  76166. /**
  76167. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  76168. * @param left defines the start value
  76169. * @param right defines the end value
  76170. * @param amount defines the gradient factor
  76171. * @param result defines the Color3 object where to store the result
  76172. */
  76173. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  76174. /**
  76175. * Returns a Color3 value containing a red color
  76176. * @returns a new Color3 object
  76177. */
  76178. static Red(): Color3;
  76179. /**
  76180. * Returns a Color3 value containing a green color
  76181. * @returns a new Color3 object
  76182. */
  76183. static Green(): Color3;
  76184. /**
  76185. * Returns a Color3 value containing a blue color
  76186. * @returns a new Color3 object
  76187. */
  76188. static Blue(): Color3;
  76189. /**
  76190. * Returns a Color3 value containing a black color
  76191. * @returns a new Color3 object
  76192. */
  76193. static Black(): Color3;
  76194. /**
  76195. * Gets a Color3 value containing a black color that must not be updated
  76196. */
  76197. static get BlackReadOnly(): DeepImmutable<Color3>;
  76198. /**
  76199. * Returns a Color3 value containing a white color
  76200. * @returns a new Color3 object
  76201. */
  76202. static White(): Color3;
  76203. /**
  76204. * Returns a Color3 value containing a purple color
  76205. * @returns a new Color3 object
  76206. */
  76207. static Purple(): Color3;
  76208. /**
  76209. * Returns a Color3 value containing a magenta color
  76210. * @returns a new Color3 object
  76211. */
  76212. static Magenta(): Color3;
  76213. /**
  76214. * Returns a Color3 value containing a yellow color
  76215. * @returns a new Color3 object
  76216. */
  76217. static Yellow(): Color3;
  76218. /**
  76219. * Returns a Color3 value containing a gray color
  76220. * @returns a new Color3 object
  76221. */
  76222. static Gray(): Color3;
  76223. /**
  76224. * Returns a Color3 value containing a teal color
  76225. * @returns a new Color3 object
  76226. */
  76227. static Teal(): Color3;
  76228. /**
  76229. * Returns a Color3 value containing a random color
  76230. * @returns a new Color3 object
  76231. */
  76232. static Random(): Color3;
  76233. }
  76234. /**
  76235. * Class used to hold a RBGA color
  76236. */
  76237. export class Color4 {
  76238. /**
  76239. * Defines the red component (between 0 and 1, default is 0)
  76240. */
  76241. r: number;
  76242. /**
  76243. * Defines the green component (between 0 and 1, default is 0)
  76244. */
  76245. g: number;
  76246. /**
  76247. * Defines the blue component (between 0 and 1, default is 0)
  76248. */
  76249. b: number;
  76250. /**
  76251. * Defines the alpha component (between 0 and 1, default is 1)
  76252. */
  76253. a: number;
  76254. /**
  76255. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  76256. * @param r defines the red component (between 0 and 1, default is 0)
  76257. * @param g defines the green component (between 0 and 1, default is 0)
  76258. * @param b defines the blue component (between 0 and 1, default is 0)
  76259. * @param a defines the alpha component (between 0 and 1, default is 1)
  76260. */
  76261. constructor(
  76262. /**
  76263. * Defines the red component (between 0 and 1, default is 0)
  76264. */
  76265. r?: number,
  76266. /**
  76267. * Defines the green component (between 0 and 1, default is 0)
  76268. */
  76269. g?: number,
  76270. /**
  76271. * Defines the blue component (between 0 and 1, default is 0)
  76272. */
  76273. b?: number,
  76274. /**
  76275. * Defines the alpha component (between 0 and 1, default is 1)
  76276. */
  76277. a?: number);
  76278. /**
  76279. * Adds in place the given Color4 values to the current Color4 object
  76280. * @param right defines the second operand
  76281. * @returns the current updated Color4 object
  76282. */
  76283. addInPlace(right: DeepImmutable<Color4>): Color4;
  76284. /**
  76285. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  76286. * @returns the new array
  76287. */
  76288. asArray(): number[];
  76289. /**
  76290. * Stores from the starting index in the given array the Color4 successive values
  76291. * @param array defines the array where to store the r,g,b components
  76292. * @param index defines an optional index in the target array to define where to start storing values
  76293. * @returns the current Color4 object
  76294. */
  76295. toArray(array: number[], index?: number): Color4;
  76296. /**
  76297. * Determines equality between Color4 objects
  76298. * @param otherColor defines the second operand
  76299. * @returns true if the rgba values are equal to the given ones
  76300. */
  76301. equals(otherColor: DeepImmutable<Color4>): boolean;
  76302. /**
  76303. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  76304. * @param right defines the second operand
  76305. * @returns a new Color4 object
  76306. */
  76307. add(right: DeepImmutable<Color4>): Color4;
  76308. /**
  76309. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  76310. * @param right defines the second operand
  76311. * @returns a new Color4 object
  76312. */
  76313. subtract(right: DeepImmutable<Color4>): Color4;
  76314. /**
  76315. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  76316. * @param right defines the second operand
  76317. * @param result defines the Color4 object where to store the result
  76318. * @returns the current Color4 object
  76319. */
  76320. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  76321. /**
  76322. * Creates a new Color4 with the current Color4 values multiplied by scale
  76323. * @param scale defines the scaling factor to apply
  76324. * @returns a new Color4 object
  76325. */
  76326. scale(scale: number): Color4;
  76327. /**
  76328. * Multiplies the current Color4 values by scale and stores the result in "result"
  76329. * @param scale defines the scaling factor to apply
  76330. * @param result defines the Color4 object where to store the result
  76331. * @returns the current unmodified Color4
  76332. */
  76333. scaleToRef(scale: number, result: Color4): Color4;
  76334. /**
  76335. * Scale the current Color4 values by a factor and add the result to a given Color4
  76336. * @param scale defines the scale factor
  76337. * @param result defines the Color4 object where to store the result
  76338. * @returns the unmodified current Color4
  76339. */
  76340. scaleAndAddToRef(scale: number, result: Color4): Color4;
  76341. /**
  76342. * Clamps the rgb values by the min and max values and stores the result into "result"
  76343. * @param min defines minimum clamping value (default is 0)
  76344. * @param max defines maximum clamping value (default is 1)
  76345. * @param result defines color to store the result into.
  76346. * @returns the cuurent Color4
  76347. */
  76348. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  76349. /**
  76350. * Multipy an Color4 value by another and return a new Color4 object
  76351. * @param color defines the Color4 value to multiply by
  76352. * @returns a new Color4 object
  76353. */
  76354. multiply(color: Color4): Color4;
  76355. /**
  76356. * Multipy a Color4 value by another and push the result in a reference value
  76357. * @param color defines the Color4 value to multiply by
  76358. * @param result defines the Color4 to fill the result in
  76359. * @returns the result Color4
  76360. */
  76361. multiplyToRef(color: Color4, result: Color4): Color4;
  76362. /**
  76363. * Creates a string with the Color4 current values
  76364. * @returns the string representation of the Color4 object
  76365. */
  76366. toString(): string;
  76367. /**
  76368. * Returns the string "Color4"
  76369. * @returns "Color4"
  76370. */
  76371. getClassName(): string;
  76372. /**
  76373. * Compute the Color4 hash code
  76374. * @returns an unique number that can be used to hash Color4 objects
  76375. */
  76376. getHashCode(): number;
  76377. /**
  76378. * Creates a new Color4 copied from the current one
  76379. * @returns a new Color4 object
  76380. */
  76381. clone(): Color4;
  76382. /**
  76383. * Copies the given Color4 values into the current one
  76384. * @param source defines the source Color4 object
  76385. * @returns the current updated Color4 object
  76386. */
  76387. copyFrom(source: Color4): Color4;
  76388. /**
  76389. * Copies the given float values into the current one
  76390. * @param r defines the red component to read from
  76391. * @param g defines the green component to read from
  76392. * @param b defines the blue component to read from
  76393. * @param a defines the alpha component to read from
  76394. * @returns the current updated Color4 object
  76395. */
  76396. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  76397. /**
  76398. * Copies the given float values into the current one
  76399. * @param r defines the red component to read from
  76400. * @param g defines the green component to read from
  76401. * @param b defines the blue component to read from
  76402. * @param a defines the alpha component to read from
  76403. * @returns the current updated Color4 object
  76404. */
  76405. set(r: number, g: number, b: number, a: number): Color4;
  76406. /**
  76407. * Compute the Color4 hexadecimal code as a string
  76408. * @returns a string containing the hexadecimal representation of the Color4 object
  76409. */
  76410. toHexString(): string;
  76411. /**
  76412. * Computes a new Color4 converted from the current one to linear space
  76413. * @returns a new Color4 object
  76414. */
  76415. toLinearSpace(): Color4;
  76416. /**
  76417. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  76418. * @param convertedColor defines the Color4 object where to store the linear space version
  76419. * @returns the unmodified Color4
  76420. */
  76421. toLinearSpaceToRef(convertedColor: Color4): Color4;
  76422. /**
  76423. * Computes a new Color4 converted from the current one to gamma space
  76424. * @returns a new Color4 object
  76425. */
  76426. toGammaSpace(): Color4;
  76427. /**
  76428. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  76429. * @param convertedColor defines the Color4 object where to store the gamma space version
  76430. * @returns the unmodified Color4
  76431. */
  76432. toGammaSpaceToRef(convertedColor: Color4): Color4;
  76433. /**
  76434. * Creates a new Color4 from the string containing valid hexadecimal values
  76435. * @param hex defines a string containing valid hexadecimal values
  76436. * @returns a new Color4 object
  76437. */
  76438. static FromHexString(hex: string): Color4;
  76439. /**
  76440. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  76441. * @param left defines the start value
  76442. * @param right defines the end value
  76443. * @param amount defines the gradient factor
  76444. * @returns a new Color4 object
  76445. */
  76446. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  76447. /**
  76448. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  76449. * @param left defines the start value
  76450. * @param right defines the end value
  76451. * @param amount defines the gradient factor
  76452. * @param result defines the Color4 object where to store data
  76453. */
  76454. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  76455. /**
  76456. * Creates a new Color4 from a Color3 and an alpha value
  76457. * @param color3 defines the source Color3 to read from
  76458. * @param alpha defines the alpha component (1.0 by default)
  76459. * @returns a new Color4 object
  76460. */
  76461. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  76462. /**
  76463. * Creates a new Color4 from the starting index element of the given array
  76464. * @param array defines the source array to read from
  76465. * @param offset defines the offset in the source array
  76466. * @returns a new Color4 object
  76467. */
  76468. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  76469. /**
  76470. * Creates a new Color3 from integer values (< 256)
  76471. * @param r defines the red component to read from (value between 0 and 255)
  76472. * @param g defines the green component to read from (value between 0 and 255)
  76473. * @param b defines the blue component to read from (value between 0 and 255)
  76474. * @param a defines the alpha component to read from (value between 0 and 255)
  76475. * @returns a new Color3 object
  76476. */
  76477. static FromInts(r: number, g: number, b: number, a: number): Color4;
  76478. /**
  76479. * Check the content of a given array and convert it to an array containing RGBA data
  76480. * If the original array was already containing count * 4 values then it is returned directly
  76481. * @param colors defines the array to check
  76482. * @param count defines the number of RGBA data to expect
  76483. * @returns an array containing count * 4 values (RGBA)
  76484. */
  76485. static CheckColors4(colors: number[], count: number): number[];
  76486. }
  76487. /**
  76488. * @hidden
  76489. */
  76490. export class TmpColors {
  76491. static Color3: Color3[];
  76492. static Color4: Color4[];
  76493. }
  76494. }
  76495. declare module BABYLON {
  76496. /**
  76497. * Defines an interface which represents an animation key frame
  76498. */
  76499. export interface IAnimationKey {
  76500. /**
  76501. * Frame of the key frame
  76502. */
  76503. frame: number;
  76504. /**
  76505. * Value at the specifies key frame
  76506. */
  76507. value: any;
  76508. /**
  76509. * The input tangent for the cubic hermite spline
  76510. */
  76511. inTangent?: any;
  76512. /**
  76513. * The output tangent for the cubic hermite spline
  76514. */
  76515. outTangent?: any;
  76516. /**
  76517. * The animation interpolation type
  76518. */
  76519. interpolation?: AnimationKeyInterpolation;
  76520. }
  76521. /**
  76522. * Enum for the animation key frame interpolation type
  76523. */
  76524. export enum AnimationKeyInterpolation {
  76525. /**
  76526. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  76527. */
  76528. STEP = 1
  76529. }
  76530. }
  76531. declare module BABYLON {
  76532. /**
  76533. * Represents the range of an animation
  76534. */
  76535. export class AnimationRange {
  76536. /**The name of the animation range**/
  76537. name: string;
  76538. /**The starting frame of the animation */
  76539. from: number;
  76540. /**The ending frame of the animation*/
  76541. to: number;
  76542. /**
  76543. * Initializes the range of an animation
  76544. * @param name The name of the animation range
  76545. * @param from The starting frame of the animation
  76546. * @param to The ending frame of the animation
  76547. */
  76548. constructor(
  76549. /**The name of the animation range**/
  76550. name: string,
  76551. /**The starting frame of the animation */
  76552. from: number,
  76553. /**The ending frame of the animation*/
  76554. to: number);
  76555. /**
  76556. * Makes a copy of the animation range
  76557. * @returns A copy of the animation range
  76558. */
  76559. clone(): AnimationRange;
  76560. }
  76561. }
  76562. declare module BABYLON {
  76563. /**
  76564. * Composed of a frame, and an action function
  76565. */
  76566. export class AnimationEvent {
  76567. /** The frame for which the event is triggered **/
  76568. frame: number;
  76569. /** The event to perform when triggered **/
  76570. action: (currentFrame: number) => void;
  76571. /** Specifies if the event should be triggered only once**/
  76572. onlyOnce?: boolean | undefined;
  76573. /**
  76574. * Specifies if the animation event is done
  76575. */
  76576. isDone: boolean;
  76577. /**
  76578. * Initializes the animation event
  76579. * @param frame The frame for which the event is triggered
  76580. * @param action The event to perform when triggered
  76581. * @param onlyOnce Specifies if the event should be triggered only once
  76582. */
  76583. constructor(
  76584. /** The frame for which the event is triggered **/
  76585. frame: number,
  76586. /** The event to perform when triggered **/
  76587. action: (currentFrame: number) => void,
  76588. /** Specifies if the event should be triggered only once**/
  76589. onlyOnce?: boolean | undefined);
  76590. /** @hidden */
  76591. _clone(): AnimationEvent;
  76592. }
  76593. }
  76594. declare module BABYLON {
  76595. /**
  76596. * Interface used to define a behavior
  76597. */
  76598. export interface Behavior<T> {
  76599. /** gets or sets behavior's name */
  76600. name: string;
  76601. /**
  76602. * Function called when the behavior needs to be initialized (after attaching it to a target)
  76603. */
  76604. init(): void;
  76605. /**
  76606. * Called when the behavior is attached to a target
  76607. * @param target defines the target where the behavior is attached to
  76608. */
  76609. attach(target: T): void;
  76610. /**
  76611. * Called when the behavior is detached from its target
  76612. */
  76613. detach(): void;
  76614. }
  76615. /**
  76616. * Interface implemented by classes supporting behaviors
  76617. */
  76618. export interface IBehaviorAware<T> {
  76619. /**
  76620. * Attach a behavior
  76621. * @param behavior defines the behavior to attach
  76622. * @returns the current host
  76623. */
  76624. addBehavior(behavior: Behavior<T>): T;
  76625. /**
  76626. * Remove a behavior from the current object
  76627. * @param behavior defines the behavior to detach
  76628. * @returns the current host
  76629. */
  76630. removeBehavior(behavior: Behavior<T>): T;
  76631. /**
  76632. * Gets a behavior using its name to search
  76633. * @param name defines the name to search
  76634. * @returns the behavior or null if not found
  76635. */
  76636. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  76637. }
  76638. }
  76639. declare module BABYLON {
  76640. /**
  76641. * Defines an array and its length.
  76642. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  76643. */
  76644. export interface ISmartArrayLike<T> {
  76645. /**
  76646. * The data of the array.
  76647. */
  76648. data: Array<T>;
  76649. /**
  76650. * The active length of the array.
  76651. */
  76652. length: number;
  76653. }
  76654. /**
  76655. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  76656. */
  76657. export class SmartArray<T> implements ISmartArrayLike<T> {
  76658. /**
  76659. * The full set of data from the array.
  76660. */
  76661. data: Array<T>;
  76662. /**
  76663. * The active length of the array.
  76664. */
  76665. length: number;
  76666. protected _id: number;
  76667. /**
  76668. * Instantiates a Smart Array.
  76669. * @param capacity defines the default capacity of the array.
  76670. */
  76671. constructor(capacity: number);
  76672. /**
  76673. * Pushes a value at the end of the active data.
  76674. * @param value defines the object to push in the array.
  76675. */
  76676. push(value: T): void;
  76677. /**
  76678. * Iterates over the active data and apply the lambda to them.
  76679. * @param func defines the action to apply on each value.
  76680. */
  76681. forEach(func: (content: T) => void): void;
  76682. /**
  76683. * Sorts the full sets of data.
  76684. * @param compareFn defines the comparison function to apply.
  76685. */
  76686. sort(compareFn: (a: T, b: T) => number): void;
  76687. /**
  76688. * Resets the active data to an empty array.
  76689. */
  76690. reset(): void;
  76691. /**
  76692. * Releases all the data from the array as well as the array.
  76693. */
  76694. dispose(): void;
  76695. /**
  76696. * Concats the active data with a given array.
  76697. * @param array defines the data to concatenate with.
  76698. */
  76699. concat(array: any): void;
  76700. /**
  76701. * Returns the position of a value in the active data.
  76702. * @param value defines the value to find the index for
  76703. * @returns the index if found in the active data otherwise -1
  76704. */
  76705. indexOf(value: T): number;
  76706. /**
  76707. * Returns whether an element is part of the active data.
  76708. * @param value defines the value to look for
  76709. * @returns true if found in the active data otherwise false
  76710. */
  76711. contains(value: T): boolean;
  76712. private static _GlobalId;
  76713. }
  76714. /**
  76715. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  76716. * The data in this array can only be present once
  76717. */
  76718. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  76719. private _duplicateId;
  76720. /**
  76721. * Pushes a value at the end of the active data.
  76722. * THIS DOES NOT PREVENT DUPPLICATE DATA
  76723. * @param value defines the object to push in the array.
  76724. */
  76725. push(value: T): void;
  76726. /**
  76727. * Pushes a value at the end of the active data.
  76728. * If the data is already present, it won t be added again
  76729. * @param value defines the object to push in the array.
  76730. * @returns true if added false if it was already present
  76731. */
  76732. pushNoDuplicate(value: T): boolean;
  76733. /**
  76734. * Resets the active data to an empty array.
  76735. */
  76736. reset(): void;
  76737. /**
  76738. * Concats the active data with a given array.
  76739. * This ensures no dupplicate will be present in the result.
  76740. * @param array defines the data to concatenate with.
  76741. */
  76742. concatWithNoDuplicate(array: any): void;
  76743. }
  76744. }
  76745. declare module BABYLON {
  76746. /**
  76747. * @ignore
  76748. * This is a list of all the different input types that are available in the application.
  76749. * Fo instance: ArcRotateCameraGamepadInput...
  76750. */
  76751. export var CameraInputTypes: {};
  76752. /**
  76753. * This is the contract to implement in order to create a new input class.
  76754. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  76755. */
  76756. export interface ICameraInput<TCamera extends Camera> {
  76757. /**
  76758. * Defines the camera the input is attached to.
  76759. */
  76760. camera: Nullable<TCamera>;
  76761. /**
  76762. * Gets the class name of the current intput.
  76763. * @returns the class name
  76764. */
  76765. getClassName(): string;
  76766. /**
  76767. * Get the friendly name associated with the input class.
  76768. * @returns the input friendly name
  76769. */
  76770. getSimpleName(): string;
  76771. /**
  76772. * Attach the input controls to a specific dom element to get the input from.
  76773. * @param element Defines the element the controls should be listened from
  76774. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76775. */
  76776. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76777. /**
  76778. * Detach the current controls from the specified dom element.
  76779. * @param element Defines the element to stop listening the inputs from
  76780. */
  76781. detachControl(element: Nullable<HTMLElement>): void;
  76782. /**
  76783. * Update the current camera state depending on the inputs that have been used this frame.
  76784. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76785. */
  76786. checkInputs?: () => void;
  76787. }
  76788. /**
  76789. * Represents a map of input types to input instance or input index to input instance.
  76790. */
  76791. export interface CameraInputsMap<TCamera extends Camera> {
  76792. /**
  76793. * Accessor to the input by input type.
  76794. */
  76795. [name: string]: ICameraInput<TCamera>;
  76796. /**
  76797. * Accessor to the input by input index.
  76798. */
  76799. [idx: number]: ICameraInput<TCamera>;
  76800. }
  76801. /**
  76802. * This represents the input manager used within a camera.
  76803. * It helps dealing with all the different kind of input attached to a camera.
  76804. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76805. */
  76806. export class CameraInputsManager<TCamera extends Camera> {
  76807. /**
  76808. * Defines the list of inputs attahed to the camera.
  76809. */
  76810. attached: CameraInputsMap<TCamera>;
  76811. /**
  76812. * Defines the dom element the camera is collecting inputs from.
  76813. * This is null if the controls have not been attached.
  76814. */
  76815. attachedElement: Nullable<HTMLElement>;
  76816. /**
  76817. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76818. */
  76819. noPreventDefault: boolean;
  76820. /**
  76821. * Defined the camera the input manager belongs to.
  76822. */
  76823. camera: TCamera;
  76824. /**
  76825. * Update the current camera state depending on the inputs that have been used this frame.
  76826. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76827. */
  76828. checkInputs: () => void;
  76829. /**
  76830. * Instantiate a new Camera Input Manager.
  76831. * @param camera Defines the camera the input manager blongs to
  76832. */
  76833. constructor(camera: TCamera);
  76834. /**
  76835. * Add an input method to a camera
  76836. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76837. * @param input camera input method
  76838. */
  76839. add(input: ICameraInput<TCamera>): void;
  76840. /**
  76841. * Remove a specific input method from a camera
  76842. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  76843. * @param inputToRemove camera input method
  76844. */
  76845. remove(inputToRemove: ICameraInput<TCamera>): void;
  76846. /**
  76847. * Remove a specific input type from a camera
  76848. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  76849. * @param inputType the type of the input to remove
  76850. */
  76851. removeByType(inputType: string): void;
  76852. private _addCheckInputs;
  76853. /**
  76854. * Attach the input controls to the currently attached dom element to listen the events from.
  76855. * @param input Defines the input to attach
  76856. */
  76857. attachInput(input: ICameraInput<TCamera>): void;
  76858. /**
  76859. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  76860. * @param element Defines the dom element to collect the events from
  76861. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76862. */
  76863. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  76864. /**
  76865. * Detach the current manager inputs controls from a specific dom element.
  76866. * @param element Defines the dom element to collect the events from
  76867. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  76868. */
  76869. detachElement(element: HTMLElement, disconnect?: boolean): void;
  76870. /**
  76871. * Rebuild the dynamic inputCheck function from the current list of
  76872. * defined inputs in the manager.
  76873. */
  76874. rebuildInputCheck(): void;
  76875. /**
  76876. * Remove all attached input methods from a camera
  76877. */
  76878. clear(): void;
  76879. /**
  76880. * Serialize the current input manager attached to a camera.
  76881. * This ensures than once parsed,
  76882. * the input associated to the camera will be identical to the current ones
  76883. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  76884. */
  76885. serialize(serializedCamera: any): void;
  76886. /**
  76887. * Parses an input manager serialized JSON to restore the previous list of inputs
  76888. * and states associated to a camera.
  76889. * @param parsedCamera Defines the JSON to parse
  76890. */
  76891. parse(parsedCamera: any): void;
  76892. }
  76893. }
  76894. declare module BABYLON {
  76895. /**
  76896. * Class used to store data that will be store in GPU memory
  76897. */
  76898. export class Buffer {
  76899. private _engine;
  76900. private _buffer;
  76901. /** @hidden */
  76902. _data: Nullable<DataArray>;
  76903. private _updatable;
  76904. private _instanced;
  76905. private _divisor;
  76906. /**
  76907. * Gets the byte stride.
  76908. */
  76909. readonly byteStride: number;
  76910. /**
  76911. * Constructor
  76912. * @param engine the engine
  76913. * @param data the data to use for this buffer
  76914. * @param updatable whether the data is updatable
  76915. * @param stride the stride (optional)
  76916. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  76917. * @param instanced whether the buffer is instanced (optional)
  76918. * @param useBytes set to true if the stride in in bytes (optional)
  76919. * @param divisor sets an optional divisor for instances (1 by default)
  76920. */
  76921. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  76922. /**
  76923. * Create a new VertexBuffer based on the current buffer
  76924. * @param kind defines the vertex buffer kind (position, normal, etc.)
  76925. * @param offset defines offset in the buffer (0 by default)
  76926. * @param size defines the size in floats of attributes (position is 3 for instance)
  76927. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  76928. * @param instanced defines if the vertex buffer contains indexed data
  76929. * @param useBytes defines if the offset and stride are in bytes *
  76930. * @param divisor sets an optional divisor for instances (1 by default)
  76931. * @returns the new vertex buffer
  76932. */
  76933. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  76934. /**
  76935. * Gets a boolean indicating if the Buffer is updatable?
  76936. * @returns true if the buffer is updatable
  76937. */
  76938. isUpdatable(): boolean;
  76939. /**
  76940. * Gets current buffer's data
  76941. * @returns a DataArray or null
  76942. */
  76943. getData(): Nullable<DataArray>;
  76944. /**
  76945. * Gets underlying native buffer
  76946. * @returns underlying native buffer
  76947. */
  76948. getBuffer(): Nullable<DataBuffer>;
  76949. /**
  76950. * Gets the stride in float32 units (i.e. byte stride / 4).
  76951. * May not be an integer if the byte stride is not divisible by 4.
  76952. * @returns the stride in float32 units
  76953. * @deprecated Please use byteStride instead.
  76954. */
  76955. getStrideSize(): number;
  76956. /**
  76957. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  76958. * @param data defines the data to store
  76959. */
  76960. create(data?: Nullable<DataArray>): void;
  76961. /** @hidden */
  76962. _rebuild(): void;
  76963. /**
  76964. * Update current buffer data
  76965. * @param data defines the data to store
  76966. */
  76967. update(data: DataArray): void;
  76968. /**
  76969. * Updates the data directly.
  76970. * @param data the new data
  76971. * @param offset the new offset
  76972. * @param vertexCount the vertex count (optional)
  76973. * @param useBytes set to true if the offset is in bytes
  76974. */
  76975. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  76976. /**
  76977. * Release all resources
  76978. */
  76979. dispose(): void;
  76980. }
  76981. /**
  76982. * Specialized buffer used to store vertex data
  76983. */
  76984. export class VertexBuffer {
  76985. /** @hidden */
  76986. _buffer: Buffer;
  76987. private _kind;
  76988. private _size;
  76989. private _ownsBuffer;
  76990. private _instanced;
  76991. private _instanceDivisor;
  76992. /**
  76993. * The byte type.
  76994. */
  76995. static readonly BYTE: number;
  76996. /**
  76997. * The unsigned byte type.
  76998. */
  76999. static readonly UNSIGNED_BYTE: number;
  77000. /**
  77001. * The short type.
  77002. */
  77003. static readonly SHORT: number;
  77004. /**
  77005. * The unsigned short type.
  77006. */
  77007. static readonly UNSIGNED_SHORT: number;
  77008. /**
  77009. * The integer type.
  77010. */
  77011. static readonly INT: number;
  77012. /**
  77013. * The unsigned integer type.
  77014. */
  77015. static readonly UNSIGNED_INT: number;
  77016. /**
  77017. * The float type.
  77018. */
  77019. static readonly FLOAT: number;
  77020. /**
  77021. * Gets or sets the instance divisor when in instanced mode
  77022. */
  77023. get instanceDivisor(): number;
  77024. set instanceDivisor(value: number);
  77025. /**
  77026. * Gets the byte stride.
  77027. */
  77028. readonly byteStride: number;
  77029. /**
  77030. * Gets the byte offset.
  77031. */
  77032. readonly byteOffset: number;
  77033. /**
  77034. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  77035. */
  77036. readonly normalized: boolean;
  77037. /**
  77038. * Gets the data type of each component in the array.
  77039. */
  77040. readonly type: number;
  77041. /**
  77042. * Constructor
  77043. * @param engine the engine
  77044. * @param data the data to use for this vertex buffer
  77045. * @param kind the vertex buffer kind
  77046. * @param updatable whether the data is updatable
  77047. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  77048. * @param stride the stride (optional)
  77049. * @param instanced whether the buffer is instanced (optional)
  77050. * @param offset the offset of the data (optional)
  77051. * @param size the number of components (optional)
  77052. * @param type the type of the component (optional)
  77053. * @param normalized whether the data contains normalized data (optional)
  77054. * @param useBytes set to true if stride and offset are in bytes (optional)
  77055. * @param divisor defines the instance divisor to use (1 by default)
  77056. */
  77057. 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, divisor?: number);
  77058. /** @hidden */
  77059. _rebuild(): void;
  77060. /**
  77061. * Returns the kind of the VertexBuffer (string)
  77062. * @returns a string
  77063. */
  77064. getKind(): string;
  77065. /**
  77066. * Gets a boolean indicating if the VertexBuffer is updatable?
  77067. * @returns true if the buffer is updatable
  77068. */
  77069. isUpdatable(): boolean;
  77070. /**
  77071. * Gets current buffer's data
  77072. * @returns a DataArray or null
  77073. */
  77074. getData(): Nullable<DataArray>;
  77075. /**
  77076. * Gets underlying native buffer
  77077. * @returns underlying native buffer
  77078. */
  77079. getBuffer(): Nullable<DataBuffer>;
  77080. /**
  77081. * Gets the stride in float32 units (i.e. byte stride / 4).
  77082. * May not be an integer if the byte stride is not divisible by 4.
  77083. * @returns the stride in float32 units
  77084. * @deprecated Please use byteStride instead.
  77085. */
  77086. getStrideSize(): number;
  77087. /**
  77088. * Returns the offset as a multiple of the type byte length.
  77089. * @returns the offset in bytes
  77090. * @deprecated Please use byteOffset instead.
  77091. */
  77092. getOffset(): number;
  77093. /**
  77094. * Returns the number of components per vertex attribute (integer)
  77095. * @returns the size in float
  77096. */
  77097. getSize(): number;
  77098. /**
  77099. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  77100. * @returns true if this buffer is instanced
  77101. */
  77102. getIsInstanced(): boolean;
  77103. /**
  77104. * Returns the instancing divisor, zero for non-instanced (integer).
  77105. * @returns a number
  77106. */
  77107. getInstanceDivisor(): number;
  77108. /**
  77109. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  77110. * @param data defines the data to store
  77111. */
  77112. create(data?: DataArray): void;
  77113. /**
  77114. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  77115. * This function will create a new buffer if the current one is not updatable
  77116. * @param data defines the data to store
  77117. */
  77118. update(data: DataArray): void;
  77119. /**
  77120. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  77121. * Returns the directly updated WebGLBuffer.
  77122. * @param data the new data
  77123. * @param offset the new offset
  77124. * @param useBytes set to true if the offset is in bytes
  77125. */
  77126. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  77127. /**
  77128. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  77129. */
  77130. dispose(): void;
  77131. /**
  77132. * Enumerates each value of this vertex buffer as numbers.
  77133. * @param count the number of values to enumerate
  77134. * @param callback the callback function called for each value
  77135. */
  77136. forEach(count: number, callback: (value: number, index: number) => void): void;
  77137. /**
  77138. * Positions
  77139. */
  77140. static readonly PositionKind: string;
  77141. /**
  77142. * Normals
  77143. */
  77144. static readonly NormalKind: string;
  77145. /**
  77146. * Tangents
  77147. */
  77148. static readonly TangentKind: string;
  77149. /**
  77150. * Texture coordinates
  77151. */
  77152. static readonly UVKind: string;
  77153. /**
  77154. * Texture coordinates 2
  77155. */
  77156. static readonly UV2Kind: string;
  77157. /**
  77158. * Texture coordinates 3
  77159. */
  77160. static readonly UV3Kind: string;
  77161. /**
  77162. * Texture coordinates 4
  77163. */
  77164. static readonly UV4Kind: string;
  77165. /**
  77166. * Texture coordinates 5
  77167. */
  77168. static readonly UV5Kind: string;
  77169. /**
  77170. * Texture coordinates 6
  77171. */
  77172. static readonly UV6Kind: string;
  77173. /**
  77174. * Colors
  77175. */
  77176. static readonly ColorKind: string;
  77177. /**
  77178. * Matrix indices (for bones)
  77179. */
  77180. static readonly MatricesIndicesKind: string;
  77181. /**
  77182. * Matrix weights (for bones)
  77183. */
  77184. static readonly MatricesWeightsKind: string;
  77185. /**
  77186. * Additional matrix indices (for bones)
  77187. */
  77188. static readonly MatricesIndicesExtraKind: string;
  77189. /**
  77190. * Additional matrix weights (for bones)
  77191. */
  77192. static readonly MatricesWeightsExtraKind: string;
  77193. /**
  77194. * Deduces the stride given a kind.
  77195. * @param kind The kind string to deduce
  77196. * @returns The deduced stride
  77197. */
  77198. static DeduceStride(kind: string): number;
  77199. /**
  77200. * Gets the byte length of the given type.
  77201. * @param type the type
  77202. * @returns the number of bytes
  77203. */
  77204. static GetTypeByteLength(type: number): number;
  77205. /**
  77206. * Enumerates each value of the given parameters as numbers.
  77207. * @param data the data to enumerate
  77208. * @param byteOffset the byte offset of the data
  77209. * @param byteStride the byte stride of the data
  77210. * @param componentCount the number of components per element
  77211. * @param componentType the type of the component
  77212. * @param count the number of values to enumerate
  77213. * @param normalized whether the data is normalized
  77214. * @param callback the callback function called for each value
  77215. */
  77216. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  77217. private static _GetFloatValue;
  77218. }
  77219. }
  77220. declare module BABYLON {
  77221. /**
  77222. * @hidden
  77223. */
  77224. export class IntersectionInfo {
  77225. bu: Nullable<number>;
  77226. bv: Nullable<number>;
  77227. distance: number;
  77228. faceId: number;
  77229. subMeshId: number;
  77230. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  77231. }
  77232. }
  77233. declare module BABYLON {
  77234. /**
  77235. * Represens a plane by the equation ax + by + cz + d = 0
  77236. */
  77237. export class Plane {
  77238. private static _TmpMatrix;
  77239. /**
  77240. * Normal of the plane (a,b,c)
  77241. */
  77242. normal: Vector3;
  77243. /**
  77244. * d component of the plane
  77245. */
  77246. d: number;
  77247. /**
  77248. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  77249. * @param a a component of the plane
  77250. * @param b b component of the plane
  77251. * @param c c component of the plane
  77252. * @param d d component of the plane
  77253. */
  77254. constructor(a: number, b: number, c: number, d: number);
  77255. /**
  77256. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  77257. */
  77258. asArray(): number[];
  77259. /**
  77260. * @returns a new plane copied from the current Plane.
  77261. */
  77262. clone(): Plane;
  77263. /**
  77264. * @returns the string "Plane".
  77265. */
  77266. getClassName(): string;
  77267. /**
  77268. * @returns the Plane hash code.
  77269. */
  77270. getHashCode(): number;
  77271. /**
  77272. * Normalize the current Plane in place.
  77273. * @returns the updated Plane.
  77274. */
  77275. normalize(): Plane;
  77276. /**
  77277. * Applies a transformation the plane and returns the result
  77278. * @param transformation the transformation matrix to be applied to the plane
  77279. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  77280. */
  77281. transform(transformation: DeepImmutable<Matrix>): Plane;
  77282. /**
  77283. * Calcualtte the dot product between the point and the plane normal
  77284. * @param point point to calculate the dot product with
  77285. * @returns the dot product (float) of the point coordinates and the plane normal.
  77286. */
  77287. dotCoordinate(point: DeepImmutable<Vector3>): number;
  77288. /**
  77289. * Updates the current Plane from the plane defined by the three given points.
  77290. * @param point1 one of the points used to contruct the plane
  77291. * @param point2 one of the points used to contruct the plane
  77292. * @param point3 one of the points used to contruct the plane
  77293. * @returns the updated Plane.
  77294. */
  77295. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  77296. /**
  77297. * Checks if the plane is facing a given direction
  77298. * @param direction the direction to check if the plane is facing
  77299. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  77300. * @returns True is the vector "direction" is the same side than the plane normal.
  77301. */
  77302. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  77303. /**
  77304. * Calculates the distance to a point
  77305. * @param point point to calculate distance to
  77306. * @returns the signed distance (float) from the given point to the Plane.
  77307. */
  77308. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  77309. /**
  77310. * Creates a plane from an array
  77311. * @param array the array to create a plane from
  77312. * @returns a new Plane from the given array.
  77313. */
  77314. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  77315. /**
  77316. * Creates a plane from three points
  77317. * @param point1 point used to create the plane
  77318. * @param point2 point used to create the plane
  77319. * @param point3 point used to create the plane
  77320. * @returns a new Plane defined by the three given points.
  77321. */
  77322. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  77323. /**
  77324. * Creates a plane from an origin point and a normal
  77325. * @param origin origin of the plane to be constructed
  77326. * @param normal normal of the plane to be constructed
  77327. * @returns a new Plane the normal vector to this plane at the given origin point.
  77328. * Note : the vector "normal" is updated because normalized.
  77329. */
  77330. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  77331. /**
  77332. * Calculates the distance from a plane and a point
  77333. * @param origin origin of the plane to be constructed
  77334. * @param normal normal of the plane to be constructed
  77335. * @param point point to calculate distance to
  77336. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  77337. */
  77338. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  77339. }
  77340. }
  77341. declare module BABYLON {
  77342. /**
  77343. * Class used to store bounding sphere information
  77344. */
  77345. export class BoundingSphere {
  77346. /**
  77347. * Gets the center of the bounding sphere in local space
  77348. */
  77349. readonly center: Vector3;
  77350. /**
  77351. * Radius of the bounding sphere in local space
  77352. */
  77353. radius: number;
  77354. /**
  77355. * Gets the center of the bounding sphere in world space
  77356. */
  77357. readonly centerWorld: Vector3;
  77358. /**
  77359. * Radius of the bounding sphere in world space
  77360. */
  77361. radiusWorld: number;
  77362. /**
  77363. * Gets the minimum vector in local space
  77364. */
  77365. readonly minimum: Vector3;
  77366. /**
  77367. * Gets the maximum vector in local space
  77368. */
  77369. readonly maximum: Vector3;
  77370. private _worldMatrix;
  77371. private static readonly TmpVector3;
  77372. /**
  77373. * Creates a new bounding sphere
  77374. * @param min defines the minimum vector (in local space)
  77375. * @param max defines the maximum vector (in local space)
  77376. * @param worldMatrix defines the new world matrix
  77377. */
  77378. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  77379. /**
  77380. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  77381. * @param min defines the new minimum vector (in local space)
  77382. * @param max defines the new maximum vector (in local space)
  77383. * @param worldMatrix defines the new world matrix
  77384. */
  77385. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  77386. /**
  77387. * Scale the current bounding sphere by applying a scale factor
  77388. * @param factor defines the scale factor to apply
  77389. * @returns the current bounding box
  77390. */
  77391. scale(factor: number): BoundingSphere;
  77392. /**
  77393. * Gets the world matrix of the bounding box
  77394. * @returns a matrix
  77395. */
  77396. getWorldMatrix(): DeepImmutable<Matrix>;
  77397. /** @hidden */
  77398. _update(worldMatrix: DeepImmutable<Matrix>): void;
  77399. /**
  77400. * Tests if the bounding sphere is intersecting the frustum planes
  77401. * @param frustumPlanes defines the frustum planes to test
  77402. * @returns true if there is an intersection
  77403. */
  77404. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77405. /**
  77406. * Tests if the bounding sphere center is in between the frustum planes.
  77407. * Used for optimistic fast inclusion.
  77408. * @param frustumPlanes defines the frustum planes to test
  77409. * @returns true if the sphere center is in between the frustum planes
  77410. */
  77411. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77412. /**
  77413. * Tests if a point is inside the bounding sphere
  77414. * @param point defines the point to test
  77415. * @returns true if the point is inside the bounding sphere
  77416. */
  77417. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  77418. /**
  77419. * Checks if two sphere intersct
  77420. * @param sphere0 sphere 0
  77421. * @param sphere1 sphere 1
  77422. * @returns true if the speres intersect
  77423. */
  77424. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  77425. }
  77426. }
  77427. declare module BABYLON {
  77428. /**
  77429. * Class used to store bounding box information
  77430. */
  77431. export class BoundingBox implements ICullable {
  77432. /**
  77433. * Gets the 8 vectors representing the bounding box in local space
  77434. */
  77435. readonly vectors: Vector3[];
  77436. /**
  77437. * Gets the center of the bounding box in local space
  77438. */
  77439. readonly center: Vector3;
  77440. /**
  77441. * Gets the center of the bounding box in world space
  77442. */
  77443. readonly centerWorld: Vector3;
  77444. /**
  77445. * Gets the extend size in local space
  77446. */
  77447. readonly extendSize: Vector3;
  77448. /**
  77449. * Gets the extend size in world space
  77450. */
  77451. readonly extendSizeWorld: Vector3;
  77452. /**
  77453. * Gets the OBB (object bounding box) directions
  77454. */
  77455. readonly directions: Vector3[];
  77456. /**
  77457. * Gets the 8 vectors representing the bounding box in world space
  77458. */
  77459. readonly vectorsWorld: Vector3[];
  77460. /**
  77461. * Gets the minimum vector in world space
  77462. */
  77463. readonly minimumWorld: Vector3;
  77464. /**
  77465. * Gets the maximum vector in world space
  77466. */
  77467. readonly maximumWorld: Vector3;
  77468. /**
  77469. * Gets the minimum vector in local space
  77470. */
  77471. readonly minimum: Vector3;
  77472. /**
  77473. * Gets the maximum vector in local space
  77474. */
  77475. readonly maximum: Vector3;
  77476. private _worldMatrix;
  77477. private static readonly TmpVector3;
  77478. /**
  77479. * @hidden
  77480. */
  77481. _tag: number;
  77482. /**
  77483. * Creates a new bounding box
  77484. * @param min defines the minimum vector (in local space)
  77485. * @param max defines the maximum vector (in local space)
  77486. * @param worldMatrix defines the new world matrix
  77487. */
  77488. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  77489. /**
  77490. * Recreates the entire bounding box from scratch as if we call the constructor in place
  77491. * @param min defines the new minimum vector (in local space)
  77492. * @param max defines the new maximum vector (in local space)
  77493. * @param worldMatrix defines the new world matrix
  77494. */
  77495. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  77496. /**
  77497. * Scale the current bounding box by applying a scale factor
  77498. * @param factor defines the scale factor to apply
  77499. * @returns the current bounding box
  77500. */
  77501. scale(factor: number): BoundingBox;
  77502. /**
  77503. * Gets the world matrix of the bounding box
  77504. * @returns a matrix
  77505. */
  77506. getWorldMatrix(): DeepImmutable<Matrix>;
  77507. /** @hidden */
  77508. _update(world: DeepImmutable<Matrix>): void;
  77509. /**
  77510. * Tests if the bounding box is intersecting the frustum planes
  77511. * @param frustumPlanes defines the frustum planes to test
  77512. * @returns true if there is an intersection
  77513. */
  77514. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77515. /**
  77516. * Tests if the bounding box is entirely inside the frustum planes
  77517. * @param frustumPlanes defines the frustum planes to test
  77518. * @returns true if there is an inclusion
  77519. */
  77520. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77521. /**
  77522. * Tests if a point is inside the bounding box
  77523. * @param point defines the point to test
  77524. * @returns true if the point is inside the bounding box
  77525. */
  77526. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  77527. /**
  77528. * Tests if the bounding box intersects with a bounding sphere
  77529. * @param sphere defines the sphere to test
  77530. * @returns true if there is an intersection
  77531. */
  77532. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  77533. /**
  77534. * Tests if the bounding box intersects with a box defined by a min and max vectors
  77535. * @param min defines the min vector to use
  77536. * @param max defines the max vector to use
  77537. * @returns true if there is an intersection
  77538. */
  77539. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  77540. /**
  77541. * Tests if two bounding boxes are intersections
  77542. * @param box0 defines the first box to test
  77543. * @param box1 defines the second box to test
  77544. * @returns true if there is an intersection
  77545. */
  77546. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  77547. /**
  77548. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  77549. * @param minPoint defines the minimum vector of the bounding box
  77550. * @param maxPoint defines the maximum vector of the bounding box
  77551. * @param sphereCenter defines the sphere center
  77552. * @param sphereRadius defines the sphere radius
  77553. * @returns true if there is an intersection
  77554. */
  77555. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  77556. /**
  77557. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  77558. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  77559. * @param frustumPlanes defines the frustum planes to test
  77560. * @return true if there is an inclusion
  77561. */
  77562. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77563. /**
  77564. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  77565. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  77566. * @param frustumPlanes defines the frustum planes to test
  77567. * @return true if there is an intersection
  77568. */
  77569. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77570. }
  77571. }
  77572. declare module BABYLON {
  77573. /** @hidden */
  77574. export class Collider {
  77575. /** Define if a collision was found */
  77576. collisionFound: boolean;
  77577. /**
  77578. * Define last intersection point in local space
  77579. */
  77580. intersectionPoint: Vector3;
  77581. /**
  77582. * Define last collided mesh
  77583. */
  77584. collidedMesh: Nullable<AbstractMesh>;
  77585. private _collisionPoint;
  77586. private _planeIntersectionPoint;
  77587. private _tempVector;
  77588. private _tempVector2;
  77589. private _tempVector3;
  77590. private _tempVector4;
  77591. private _edge;
  77592. private _baseToVertex;
  77593. private _destinationPoint;
  77594. private _slidePlaneNormal;
  77595. private _displacementVector;
  77596. /** @hidden */
  77597. _radius: Vector3;
  77598. /** @hidden */
  77599. _retry: number;
  77600. private _velocity;
  77601. private _basePoint;
  77602. private _epsilon;
  77603. /** @hidden */
  77604. _velocityWorldLength: number;
  77605. /** @hidden */
  77606. _basePointWorld: Vector3;
  77607. private _velocityWorld;
  77608. private _normalizedVelocity;
  77609. /** @hidden */
  77610. _initialVelocity: Vector3;
  77611. /** @hidden */
  77612. _initialPosition: Vector3;
  77613. private _nearestDistance;
  77614. private _collisionMask;
  77615. get collisionMask(): number;
  77616. set collisionMask(mask: number);
  77617. /**
  77618. * Gets the plane normal used to compute the sliding response (in local space)
  77619. */
  77620. get slidePlaneNormal(): Vector3;
  77621. /** @hidden */
  77622. _initialize(source: Vector3, dir: Vector3, e: number): void;
  77623. /** @hidden */
  77624. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  77625. /** @hidden */
  77626. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  77627. /** @hidden */
  77628. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  77629. /** @hidden */
  77630. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  77631. /** @hidden */
  77632. _getResponse(pos: Vector3, vel: Vector3): void;
  77633. }
  77634. }
  77635. declare module BABYLON {
  77636. /**
  77637. * Interface for cullable objects
  77638. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  77639. */
  77640. export interface ICullable {
  77641. /**
  77642. * Checks if the object or part of the object is in the frustum
  77643. * @param frustumPlanes Camera near/planes
  77644. * @returns true if the object is in frustum otherwise false
  77645. */
  77646. isInFrustum(frustumPlanes: Plane[]): boolean;
  77647. /**
  77648. * Checks if a cullable object (mesh...) is in the camera frustum
  77649. * Unlike isInFrustum this cheks the full bounding box
  77650. * @param frustumPlanes Camera near/planes
  77651. * @returns true if the object is in frustum otherwise false
  77652. */
  77653. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  77654. }
  77655. /**
  77656. * Info for a bounding data of a mesh
  77657. */
  77658. export class BoundingInfo implements ICullable {
  77659. /**
  77660. * Bounding box for the mesh
  77661. */
  77662. readonly boundingBox: BoundingBox;
  77663. /**
  77664. * Bounding sphere for the mesh
  77665. */
  77666. readonly boundingSphere: BoundingSphere;
  77667. private _isLocked;
  77668. private static readonly TmpVector3;
  77669. /**
  77670. * Constructs bounding info
  77671. * @param minimum min vector of the bounding box/sphere
  77672. * @param maximum max vector of the bounding box/sphere
  77673. * @param worldMatrix defines the new world matrix
  77674. */
  77675. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  77676. /**
  77677. * Recreates the entire bounding info from scratch as if we call the constructor in place
  77678. * @param min defines the new minimum vector (in local space)
  77679. * @param max defines the new maximum vector (in local space)
  77680. * @param worldMatrix defines the new world matrix
  77681. */
  77682. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  77683. /**
  77684. * min vector of the bounding box/sphere
  77685. */
  77686. get minimum(): Vector3;
  77687. /**
  77688. * max vector of the bounding box/sphere
  77689. */
  77690. get maximum(): Vector3;
  77691. /**
  77692. * If the info is locked and won't be updated to avoid perf overhead
  77693. */
  77694. get isLocked(): boolean;
  77695. set isLocked(value: boolean);
  77696. /**
  77697. * Updates the bounding sphere and box
  77698. * @param world world matrix to be used to update
  77699. */
  77700. update(world: DeepImmutable<Matrix>): void;
  77701. /**
  77702. * Recreate the bounding info to be centered around a specific point given a specific extend.
  77703. * @param center New center of the bounding info
  77704. * @param extend New extend of the bounding info
  77705. * @returns the current bounding info
  77706. */
  77707. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  77708. /**
  77709. * Scale the current bounding info by applying a scale factor
  77710. * @param factor defines the scale factor to apply
  77711. * @returns the current bounding info
  77712. */
  77713. scale(factor: number): BoundingInfo;
  77714. /**
  77715. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  77716. * @param frustumPlanes defines the frustum to test
  77717. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  77718. * @returns true if the bounding info is in the frustum planes
  77719. */
  77720. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  77721. /**
  77722. * Gets the world distance between the min and max points of the bounding box
  77723. */
  77724. get diagonalLength(): number;
  77725. /**
  77726. * Checks if a cullable object (mesh...) is in the camera frustum
  77727. * Unlike isInFrustum this cheks the full bounding box
  77728. * @param frustumPlanes Camera near/planes
  77729. * @returns true if the object is in frustum otherwise false
  77730. */
  77731. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  77732. /** @hidden */
  77733. _checkCollision(collider: Collider): boolean;
  77734. /**
  77735. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  77736. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  77737. * @param point the point to check intersection with
  77738. * @returns if the point intersects
  77739. */
  77740. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  77741. /**
  77742. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  77743. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  77744. * @param boundingInfo the bounding info to check intersection with
  77745. * @param precise if the intersection should be done using OBB
  77746. * @returns if the bounding info intersects
  77747. */
  77748. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  77749. }
  77750. }
  77751. declare module BABYLON {
  77752. /**
  77753. * Extracts minimum and maximum values from a list of indexed positions
  77754. * @param positions defines the positions to use
  77755. * @param indices defines the indices to the positions
  77756. * @param indexStart defines the start index
  77757. * @param indexCount defines the end index
  77758. * @param bias defines bias value to add to the result
  77759. * @return minimum and maximum values
  77760. */
  77761. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  77762. minimum: Vector3;
  77763. maximum: Vector3;
  77764. };
  77765. /**
  77766. * Extracts minimum and maximum values from a list of positions
  77767. * @param positions defines the positions to use
  77768. * @param start defines the start index in the positions array
  77769. * @param count defines the number of positions to handle
  77770. * @param bias defines bias value to add to the result
  77771. * @param stride defines the stride size to use (distance between two positions in the positions array)
  77772. * @return minimum and maximum values
  77773. */
  77774. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  77775. minimum: Vector3;
  77776. maximum: Vector3;
  77777. };
  77778. }
  77779. declare module BABYLON {
  77780. /** @hidden */
  77781. export class WebGLDataBuffer extends DataBuffer {
  77782. private _buffer;
  77783. constructor(resource: WebGLBuffer);
  77784. get underlyingResource(): any;
  77785. }
  77786. }
  77787. declare module BABYLON {
  77788. /** @hidden */
  77789. export class WebGLPipelineContext implements IPipelineContext {
  77790. engine: ThinEngine;
  77791. program: Nullable<WebGLProgram>;
  77792. context?: WebGLRenderingContext;
  77793. vertexShader?: WebGLShader;
  77794. fragmentShader?: WebGLShader;
  77795. isParallelCompiled: boolean;
  77796. onCompiled?: () => void;
  77797. transformFeedback?: WebGLTransformFeedback | null;
  77798. vertexCompilationError: Nullable<string>;
  77799. fragmentCompilationError: Nullable<string>;
  77800. programLinkError: Nullable<string>;
  77801. programValidationError: Nullable<string>;
  77802. get isAsync(): boolean;
  77803. get isReady(): boolean;
  77804. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  77805. }
  77806. }
  77807. declare module BABYLON {
  77808. interface ThinEngine {
  77809. /**
  77810. * Create an uniform buffer
  77811. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  77812. * @param elements defines the content of the uniform buffer
  77813. * @returns the webGL uniform buffer
  77814. */
  77815. createUniformBuffer(elements: FloatArray): DataBuffer;
  77816. /**
  77817. * Create a dynamic uniform buffer
  77818. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  77819. * @param elements defines the content of the uniform buffer
  77820. * @returns the webGL uniform buffer
  77821. */
  77822. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  77823. /**
  77824. * Update an existing uniform buffer
  77825. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  77826. * @param uniformBuffer defines the target uniform buffer
  77827. * @param elements defines the content to update
  77828. * @param offset defines the offset in the uniform buffer where update should start
  77829. * @param count defines the size of the data to update
  77830. */
  77831. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  77832. /**
  77833. * Bind an uniform buffer to the current webGL context
  77834. * @param buffer defines the buffer to bind
  77835. */
  77836. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  77837. /**
  77838. * Bind a buffer to the current webGL context at a given location
  77839. * @param buffer defines the buffer to bind
  77840. * @param location defines the index where to bind the buffer
  77841. */
  77842. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  77843. /**
  77844. * Bind a specific block at a given index in a specific shader program
  77845. * @param pipelineContext defines the pipeline context to use
  77846. * @param blockName defines the block name
  77847. * @param index defines the index where to bind the block
  77848. */
  77849. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  77850. }
  77851. }
  77852. declare module BABYLON {
  77853. /**
  77854. * Uniform buffer objects.
  77855. *
  77856. * Handles blocks of uniform on the GPU.
  77857. *
  77858. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  77859. *
  77860. * For more information, please refer to :
  77861. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  77862. */
  77863. export class UniformBuffer {
  77864. private _engine;
  77865. private _buffer;
  77866. private _data;
  77867. private _bufferData;
  77868. private _dynamic?;
  77869. private _uniformLocations;
  77870. private _uniformSizes;
  77871. private _uniformLocationPointer;
  77872. private _needSync;
  77873. private _noUBO;
  77874. private _currentEffect;
  77875. /** @hidden */
  77876. _alreadyBound: boolean;
  77877. private static _MAX_UNIFORM_SIZE;
  77878. private static _tempBuffer;
  77879. /**
  77880. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  77881. * This is dynamic to allow compat with webgl 1 and 2.
  77882. * You will need to pass the name of the uniform as well as the value.
  77883. */
  77884. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  77885. /**
  77886. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  77887. * This is dynamic to allow compat with webgl 1 and 2.
  77888. * You will need to pass the name of the uniform as well as the value.
  77889. */
  77890. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  77891. /**
  77892. * Lambda to Update a single float in a uniform buffer.
  77893. * This is dynamic to allow compat with webgl 1 and 2.
  77894. * You will need to pass the name of the uniform as well as the value.
  77895. */
  77896. updateFloat: (name: string, x: number) => void;
  77897. /**
  77898. * Lambda to Update a vec2 of float in a uniform buffer.
  77899. * This is dynamic to allow compat with webgl 1 and 2.
  77900. * You will need to pass the name of the uniform as well as the value.
  77901. */
  77902. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  77903. /**
  77904. * Lambda to Update a vec3 of float in a uniform buffer.
  77905. * This is dynamic to allow compat with webgl 1 and 2.
  77906. * You will need to pass the name of the uniform as well as the value.
  77907. */
  77908. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  77909. /**
  77910. * Lambda to Update a vec4 of float in a uniform buffer.
  77911. * This is dynamic to allow compat with webgl 1 and 2.
  77912. * You will need to pass the name of the uniform as well as the value.
  77913. */
  77914. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  77915. /**
  77916. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  77917. * This is dynamic to allow compat with webgl 1 and 2.
  77918. * You will need to pass the name of the uniform as well as the value.
  77919. */
  77920. updateMatrix: (name: string, mat: Matrix) => void;
  77921. /**
  77922. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  77923. * This is dynamic to allow compat with webgl 1 and 2.
  77924. * You will need to pass the name of the uniform as well as the value.
  77925. */
  77926. updateVector3: (name: string, vector: Vector3) => void;
  77927. /**
  77928. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  77929. * This is dynamic to allow compat with webgl 1 and 2.
  77930. * You will need to pass the name of the uniform as well as the value.
  77931. */
  77932. updateVector4: (name: string, vector: Vector4) => void;
  77933. /**
  77934. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  77935. * This is dynamic to allow compat with webgl 1 and 2.
  77936. * You will need to pass the name of the uniform as well as the value.
  77937. */
  77938. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  77939. /**
  77940. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  77941. * This is dynamic to allow compat with webgl 1 and 2.
  77942. * You will need to pass the name of the uniform as well as the value.
  77943. */
  77944. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  77945. /**
  77946. * Instantiates a new Uniform buffer objects.
  77947. *
  77948. * Handles blocks of uniform on the GPU.
  77949. *
  77950. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  77951. *
  77952. * For more information, please refer to :
  77953. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  77954. * @param engine Define the engine the buffer is associated with
  77955. * @param data Define the data contained in the buffer
  77956. * @param dynamic Define if the buffer is updatable
  77957. */
  77958. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  77959. /**
  77960. * Indicates if the buffer is using the WebGL2 UBO implementation,
  77961. * or just falling back on setUniformXXX calls.
  77962. */
  77963. get useUbo(): boolean;
  77964. /**
  77965. * Indicates if the WebGL underlying uniform buffer is in sync
  77966. * with the javascript cache data.
  77967. */
  77968. get isSync(): boolean;
  77969. /**
  77970. * Indicates if the WebGL underlying uniform buffer is dynamic.
  77971. * Also, a dynamic UniformBuffer will disable cache verification and always
  77972. * update the underlying WebGL uniform buffer to the GPU.
  77973. * @returns if Dynamic, otherwise false
  77974. */
  77975. isDynamic(): boolean;
  77976. /**
  77977. * The data cache on JS side.
  77978. * @returns the underlying data as a float array
  77979. */
  77980. getData(): Float32Array;
  77981. /**
  77982. * The underlying WebGL Uniform buffer.
  77983. * @returns the webgl buffer
  77984. */
  77985. getBuffer(): Nullable<DataBuffer>;
  77986. /**
  77987. * std140 layout specifies how to align data within an UBO structure.
  77988. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  77989. * for specs.
  77990. */
  77991. private _fillAlignment;
  77992. /**
  77993. * Adds an uniform in the buffer.
  77994. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  77995. * for the layout to be correct !
  77996. * @param name Name of the uniform, as used in the uniform block in the shader.
  77997. * @param size Data size, or data directly.
  77998. */
  77999. addUniform(name: string, size: number | number[]): void;
  78000. /**
  78001. * Adds a Matrix 4x4 to the uniform buffer.
  78002. * @param name Name of the uniform, as used in the uniform block in the shader.
  78003. * @param mat A 4x4 matrix.
  78004. */
  78005. addMatrix(name: string, mat: Matrix): void;
  78006. /**
  78007. * Adds a vec2 to the uniform buffer.
  78008. * @param name Name of the uniform, as used in the uniform block in the shader.
  78009. * @param x Define the x component value of the vec2
  78010. * @param y Define the y component value of the vec2
  78011. */
  78012. addFloat2(name: string, x: number, y: number): void;
  78013. /**
  78014. * Adds a vec3 to the uniform buffer.
  78015. * @param name Name of the uniform, as used in the uniform block in the shader.
  78016. * @param x Define the x component value of the vec3
  78017. * @param y Define the y component value of the vec3
  78018. * @param z Define the z component value of the vec3
  78019. */
  78020. addFloat3(name: string, x: number, y: number, z: number): void;
  78021. /**
  78022. * Adds a vec3 to the uniform buffer.
  78023. * @param name Name of the uniform, as used in the uniform block in the shader.
  78024. * @param color Define the vec3 from a Color
  78025. */
  78026. addColor3(name: string, color: Color3): void;
  78027. /**
  78028. * Adds a vec4 to the uniform buffer.
  78029. * @param name Name of the uniform, as used in the uniform block in the shader.
  78030. * @param color Define the rgb components from a Color
  78031. * @param alpha Define the a component of the vec4
  78032. */
  78033. addColor4(name: string, color: Color3, alpha: number): void;
  78034. /**
  78035. * Adds a vec3 to the uniform buffer.
  78036. * @param name Name of the uniform, as used in the uniform block in the shader.
  78037. * @param vector Define the vec3 components from a Vector
  78038. */
  78039. addVector3(name: string, vector: Vector3): void;
  78040. /**
  78041. * Adds a Matrix 3x3 to the uniform buffer.
  78042. * @param name Name of the uniform, as used in the uniform block in the shader.
  78043. */
  78044. addMatrix3x3(name: string): void;
  78045. /**
  78046. * Adds a Matrix 2x2 to the uniform buffer.
  78047. * @param name Name of the uniform, as used in the uniform block in the shader.
  78048. */
  78049. addMatrix2x2(name: string): void;
  78050. /**
  78051. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  78052. */
  78053. create(): void;
  78054. /** @hidden */
  78055. _rebuild(): void;
  78056. /**
  78057. * Updates the WebGL Uniform Buffer on the GPU.
  78058. * If the `dynamic` flag is set to true, no cache comparison is done.
  78059. * Otherwise, the buffer will be updated only if the cache differs.
  78060. */
  78061. update(): void;
  78062. /**
  78063. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  78064. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  78065. * @param data Define the flattened data
  78066. * @param size Define the size of the data.
  78067. */
  78068. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  78069. private _valueCache;
  78070. private _cacheMatrix;
  78071. private _updateMatrix3x3ForUniform;
  78072. private _updateMatrix3x3ForEffect;
  78073. private _updateMatrix2x2ForEffect;
  78074. private _updateMatrix2x2ForUniform;
  78075. private _updateFloatForEffect;
  78076. private _updateFloatForUniform;
  78077. private _updateFloat2ForEffect;
  78078. private _updateFloat2ForUniform;
  78079. private _updateFloat3ForEffect;
  78080. private _updateFloat3ForUniform;
  78081. private _updateFloat4ForEffect;
  78082. private _updateFloat4ForUniform;
  78083. private _updateMatrixForEffect;
  78084. private _updateMatrixForUniform;
  78085. private _updateVector3ForEffect;
  78086. private _updateVector3ForUniform;
  78087. private _updateVector4ForEffect;
  78088. private _updateVector4ForUniform;
  78089. private _updateColor3ForEffect;
  78090. private _updateColor3ForUniform;
  78091. private _updateColor4ForEffect;
  78092. private _updateColor4ForUniform;
  78093. /**
  78094. * Sets a sampler uniform on the effect.
  78095. * @param name Define the name of the sampler.
  78096. * @param texture Define the texture to set in the sampler
  78097. */
  78098. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  78099. /**
  78100. * Directly updates the value of the uniform in the cache AND on the GPU.
  78101. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  78102. * @param data Define the flattened data
  78103. */
  78104. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  78105. /**
  78106. * Binds this uniform buffer to an effect.
  78107. * @param effect Define the effect to bind the buffer to
  78108. * @param name Name of the uniform block in the shader.
  78109. */
  78110. bindToEffect(effect: Effect, name: string): void;
  78111. /**
  78112. * Disposes the uniform buffer.
  78113. */
  78114. dispose(): void;
  78115. }
  78116. }
  78117. declare module BABYLON {
  78118. /**
  78119. * Enum that determines the text-wrapping mode to use.
  78120. */
  78121. export enum InspectableType {
  78122. /**
  78123. * Checkbox for booleans
  78124. */
  78125. Checkbox = 0,
  78126. /**
  78127. * Sliders for numbers
  78128. */
  78129. Slider = 1,
  78130. /**
  78131. * Vector3
  78132. */
  78133. Vector3 = 2,
  78134. /**
  78135. * Quaternions
  78136. */
  78137. Quaternion = 3,
  78138. /**
  78139. * Color3
  78140. */
  78141. Color3 = 4,
  78142. /**
  78143. * String
  78144. */
  78145. String = 5
  78146. }
  78147. /**
  78148. * Interface used to define custom inspectable properties.
  78149. * This interface is used by the inspector to display custom property grids
  78150. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78151. */
  78152. export interface IInspectable {
  78153. /**
  78154. * Gets the label to display
  78155. */
  78156. label: string;
  78157. /**
  78158. * Gets the name of the property to edit
  78159. */
  78160. propertyName: string;
  78161. /**
  78162. * Gets the type of the editor to use
  78163. */
  78164. type: InspectableType;
  78165. /**
  78166. * Gets the minimum value of the property when using in "slider" mode
  78167. */
  78168. min?: number;
  78169. /**
  78170. * Gets the maximum value of the property when using in "slider" mode
  78171. */
  78172. max?: number;
  78173. /**
  78174. * Gets the setp to use when using in "slider" mode
  78175. */
  78176. step?: number;
  78177. }
  78178. }
  78179. declare module BABYLON {
  78180. /**
  78181. * Class used to provide helper for timing
  78182. */
  78183. export class TimingTools {
  78184. /**
  78185. * Polyfill for setImmediate
  78186. * @param action defines the action to execute after the current execution block
  78187. */
  78188. static SetImmediate(action: () => void): void;
  78189. }
  78190. }
  78191. declare module BABYLON {
  78192. /**
  78193. * Class used to enable instatition of objects by class name
  78194. */
  78195. export class InstantiationTools {
  78196. /**
  78197. * Use this object to register external classes like custom textures or material
  78198. * to allow the laoders to instantiate them
  78199. */
  78200. static RegisteredExternalClasses: {
  78201. [key: string]: Object;
  78202. };
  78203. /**
  78204. * Tries to instantiate a new object from a given class name
  78205. * @param className defines the class name to instantiate
  78206. * @returns the new object or null if the system was not able to do the instantiation
  78207. */
  78208. static Instantiate(className: string): any;
  78209. }
  78210. }
  78211. declare module BABYLON {
  78212. /**
  78213. * Define options used to create a depth texture
  78214. */
  78215. export class DepthTextureCreationOptions {
  78216. /** Specifies whether or not a stencil should be allocated in the texture */
  78217. generateStencil?: boolean;
  78218. /** Specifies whether or not bilinear filtering is enable on the texture */
  78219. bilinearFiltering?: boolean;
  78220. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  78221. comparisonFunction?: number;
  78222. /** Specifies if the created texture is a cube texture */
  78223. isCube?: boolean;
  78224. }
  78225. }
  78226. declare module BABYLON {
  78227. interface ThinEngine {
  78228. /**
  78229. * Creates a depth stencil cube texture.
  78230. * This is only available in WebGL 2.
  78231. * @param size The size of face edge in the cube texture.
  78232. * @param options The options defining the cube texture.
  78233. * @returns The cube texture
  78234. */
  78235. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  78236. /**
  78237. * Creates a cube texture
  78238. * @param rootUrl defines the url where the files to load is located
  78239. * @param scene defines the current scene
  78240. * @param files defines the list of files to load (1 per face)
  78241. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  78242. * @param onLoad defines an optional callback raised when the texture is loaded
  78243. * @param onError defines an optional callback raised if there is an issue to load the texture
  78244. * @param format defines the format of the data
  78245. * @param forcedExtension defines the extension to use to pick the right loader
  78246. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  78247. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  78248. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  78249. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  78250. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  78251. * @returns the cube texture as an InternalTexture
  78252. */
  78253. 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;
  78254. /**
  78255. * Creates a cube texture
  78256. * @param rootUrl defines the url where the files to load is located
  78257. * @param scene defines the current scene
  78258. * @param files defines the list of files to load (1 per face)
  78259. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  78260. * @param onLoad defines an optional callback raised when the texture is loaded
  78261. * @param onError defines an optional callback raised if there is an issue to load the texture
  78262. * @param format defines the format of the data
  78263. * @param forcedExtension defines the extension to use to pick the right loader
  78264. * @returns the cube texture as an InternalTexture
  78265. */
  78266. 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;
  78267. /**
  78268. * Creates a cube texture
  78269. * @param rootUrl defines the url where the files to load is located
  78270. * @param scene defines the current scene
  78271. * @param files defines the list of files to load (1 per face)
  78272. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  78273. * @param onLoad defines an optional callback raised when the texture is loaded
  78274. * @param onError defines an optional callback raised if there is an issue to load the texture
  78275. * @param format defines the format of the data
  78276. * @param forcedExtension defines the extension to use to pick the right loader
  78277. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  78278. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  78279. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  78280. * @returns the cube texture as an InternalTexture
  78281. */
  78282. 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;
  78283. /** @hidden */
  78284. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  78285. /** @hidden */
  78286. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  78287. /** @hidden */
  78288. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  78289. /** @hidden */
  78290. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  78291. /**
  78292. * @hidden
  78293. */
  78294. _setCubeMapTextureParams(loadMipmap: boolean): void;
  78295. }
  78296. }
  78297. declare module BABYLON {
  78298. /**
  78299. * Class for creating a cube texture
  78300. */
  78301. export class CubeTexture extends BaseTexture {
  78302. private _delayedOnLoad;
  78303. /**
  78304. * The url of the texture
  78305. */
  78306. url: string;
  78307. /**
  78308. * Gets or sets the center of the bounding box associated with the cube texture.
  78309. * It must define where the camera used to render the texture was set
  78310. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  78311. */
  78312. boundingBoxPosition: Vector3;
  78313. private _boundingBoxSize;
  78314. /**
  78315. * Gets or sets the size of the bounding box associated with the cube texture
  78316. * When defined, the cubemap will switch to local mode
  78317. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  78318. * @example https://www.babylonjs-playground.com/#RNASML
  78319. */
  78320. set boundingBoxSize(value: Vector3);
  78321. /**
  78322. * Returns the bounding box size
  78323. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  78324. */
  78325. get boundingBoxSize(): Vector3;
  78326. protected _rotationY: number;
  78327. /**
  78328. * Sets texture matrix rotation angle around Y axis in radians.
  78329. */
  78330. set rotationY(value: number);
  78331. /**
  78332. * Gets texture matrix rotation angle around Y axis radians.
  78333. */
  78334. get rotationY(): number;
  78335. /**
  78336. * Are mip maps generated for this texture or not.
  78337. */
  78338. get noMipmap(): boolean;
  78339. private _noMipmap;
  78340. private _files;
  78341. protected _forcedExtension: Nullable<string>;
  78342. private _extensions;
  78343. private _textureMatrix;
  78344. private _format;
  78345. private _createPolynomials;
  78346. /** @hidden */
  78347. _prefiltered: boolean;
  78348. /**
  78349. * Creates a cube texture from an array of image urls
  78350. * @param files defines an array of image urls
  78351. * @param scene defines the hosting scene
  78352. * @param noMipmap specifies if mip maps are not used
  78353. * @returns a cube texture
  78354. */
  78355. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  78356. /**
  78357. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  78358. * @param url defines the url of the prefiltered texture
  78359. * @param scene defines the scene the texture is attached to
  78360. * @param forcedExtension defines the extension of the file if different from the url
  78361. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  78362. * @return the prefiltered texture
  78363. */
  78364. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  78365. /**
  78366. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  78367. * as prefiltered data.
  78368. * @param rootUrl defines the url of the texture or the root name of the six images
  78369. * @param scene defines the scene the texture is attached to
  78370. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  78371. * @param noMipmap defines if mipmaps should be created or not
  78372. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  78373. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  78374. * @param onError defines a callback triggered in case of error during load
  78375. * @param format defines the internal format to use for the texture once loaded
  78376. * @param prefiltered defines whether or not the texture is created from prefiltered data
  78377. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  78378. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  78379. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  78380. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  78381. * @return the cube texture
  78382. */
  78383. 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);
  78384. /**
  78385. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  78386. */
  78387. get isPrefiltered(): boolean;
  78388. /**
  78389. * Get the current class name of the texture useful for serialization or dynamic coding.
  78390. * @returns "CubeTexture"
  78391. */
  78392. getClassName(): string;
  78393. /**
  78394. * Update the url (and optional buffer) of this texture if url was null during construction.
  78395. * @param url the url of the texture
  78396. * @param forcedExtension defines the extension to use
  78397. * @param onLoad callback called when the texture is loaded (defaults to null)
  78398. * @param prefiltered Defines whether the updated texture is prefiltered or not
  78399. */
  78400. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  78401. /**
  78402. * Delays loading of the cube texture
  78403. * @param forcedExtension defines the extension to use
  78404. */
  78405. delayLoad(forcedExtension?: string): void;
  78406. /**
  78407. * Returns the reflection texture matrix
  78408. * @returns the reflection texture matrix
  78409. */
  78410. getReflectionTextureMatrix(): Matrix;
  78411. /**
  78412. * Sets the reflection texture matrix
  78413. * @param value Reflection texture matrix
  78414. */
  78415. setReflectionTextureMatrix(value: Matrix): void;
  78416. /**
  78417. * Parses text to create a cube texture
  78418. * @param parsedTexture define the serialized text to read from
  78419. * @param scene defines the hosting scene
  78420. * @param rootUrl defines the root url of the cube texture
  78421. * @returns a cube texture
  78422. */
  78423. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  78424. /**
  78425. * Makes a clone, or deep copy, of the cube texture
  78426. * @returns a new cube texture
  78427. */
  78428. clone(): CubeTexture;
  78429. }
  78430. }
  78431. declare module BABYLON {
  78432. /**
  78433. * Manages the defines for the Material
  78434. */
  78435. export class MaterialDefines {
  78436. /** @hidden */
  78437. protected _keys: string[];
  78438. private _isDirty;
  78439. /** @hidden */
  78440. _renderId: number;
  78441. /** @hidden */
  78442. _areLightsDirty: boolean;
  78443. /** @hidden */
  78444. _areLightsDisposed: boolean;
  78445. /** @hidden */
  78446. _areAttributesDirty: boolean;
  78447. /** @hidden */
  78448. _areTexturesDirty: boolean;
  78449. /** @hidden */
  78450. _areFresnelDirty: boolean;
  78451. /** @hidden */
  78452. _areMiscDirty: boolean;
  78453. /** @hidden */
  78454. _areImageProcessingDirty: boolean;
  78455. /** @hidden */
  78456. _normals: boolean;
  78457. /** @hidden */
  78458. _uvs: boolean;
  78459. /** @hidden */
  78460. _needNormals: boolean;
  78461. /** @hidden */
  78462. _needUVs: boolean;
  78463. [id: string]: any;
  78464. /**
  78465. * Specifies if the material needs to be re-calculated
  78466. */
  78467. get isDirty(): boolean;
  78468. /**
  78469. * Marks the material to indicate that it has been re-calculated
  78470. */
  78471. markAsProcessed(): void;
  78472. /**
  78473. * Marks the material to indicate that it needs to be re-calculated
  78474. */
  78475. markAsUnprocessed(): void;
  78476. /**
  78477. * Marks the material to indicate all of its defines need to be re-calculated
  78478. */
  78479. markAllAsDirty(): void;
  78480. /**
  78481. * Marks the material to indicate that image processing needs to be re-calculated
  78482. */
  78483. markAsImageProcessingDirty(): void;
  78484. /**
  78485. * Marks the material to indicate the lights need to be re-calculated
  78486. * @param disposed Defines whether the light is dirty due to dispose or not
  78487. */
  78488. markAsLightDirty(disposed?: boolean): void;
  78489. /**
  78490. * Marks the attribute state as changed
  78491. */
  78492. markAsAttributesDirty(): void;
  78493. /**
  78494. * Marks the texture state as changed
  78495. */
  78496. markAsTexturesDirty(): void;
  78497. /**
  78498. * Marks the fresnel state as changed
  78499. */
  78500. markAsFresnelDirty(): void;
  78501. /**
  78502. * Marks the misc state as changed
  78503. */
  78504. markAsMiscDirty(): void;
  78505. /**
  78506. * Rebuilds the material defines
  78507. */
  78508. rebuild(): void;
  78509. /**
  78510. * Specifies if two material defines are equal
  78511. * @param other - A material define instance to compare to
  78512. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  78513. */
  78514. isEqual(other: MaterialDefines): boolean;
  78515. /**
  78516. * Clones this instance's defines to another instance
  78517. * @param other - material defines to clone values to
  78518. */
  78519. cloneTo(other: MaterialDefines): void;
  78520. /**
  78521. * Resets the material define values
  78522. */
  78523. reset(): void;
  78524. /**
  78525. * Converts the material define values to a string
  78526. * @returns - String of material define information
  78527. */
  78528. toString(): string;
  78529. }
  78530. }
  78531. declare module BABYLON {
  78532. /**
  78533. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  78534. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  78535. * 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;
  78536. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  78537. */
  78538. export class ColorCurves {
  78539. private _dirty;
  78540. private _tempColor;
  78541. private _globalCurve;
  78542. private _highlightsCurve;
  78543. private _midtonesCurve;
  78544. private _shadowsCurve;
  78545. private _positiveCurve;
  78546. private _negativeCurve;
  78547. private _globalHue;
  78548. private _globalDensity;
  78549. private _globalSaturation;
  78550. private _globalExposure;
  78551. /**
  78552. * Gets the global Hue value.
  78553. * 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).
  78554. */
  78555. get globalHue(): number;
  78556. /**
  78557. * Sets the global Hue value.
  78558. * 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).
  78559. */
  78560. set globalHue(value: number);
  78561. /**
  78562. * Gets the global Density value.
  78563. * 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.
  78564. * Values less than zero provide a filter of opposite hue.
  78565. */
  78566. get globalDensity(): number;
  78567. /**
  78568. * Sets the global Density value.
  78569. * 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.
  78570. * Values less than zero provide a filter of opposite hue.
  78571. */
  78572. set globalDensity(value: number);
  78573. /**
  78574. * Gets the global Saturation value.
  78575. * 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.
  78576. */
  78577. get globalSaturation(): number;
  78578. /**
  78579. * Sets the global Saturation value.
  78580. * 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.
  78581. */
  78582. set globalSaturation(value: number);
  78583. /**
  78584. * Gets the global Exposure value.
  78585. * 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.
  78586. */
  78587. get globalExposure(): number;
  78588. /**
  78589. * Sets the global Exposure value.
  78590. * 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.
  78591. */
  78592. set globalExposure(value: number);
  78593. private _highlightsHue;
  78594. private _highlightsDensity;
  78595. private _highlightsSaturation;
  78596. private _highlightsExposure;
  78597. /**
  78598. * Gets the highlights Hue value.
  78599. * 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).
  78600. */
  78601. get highlightsHue(): number;
  78602. /**
  78603. * Sets the highlights Hue value.
  78604. * 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).
  78605. */
  78606. set highlightsHue(value: number);
  78607. /**
  78608. * Gets the highlights Density value.
  78609. * 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.
  78610. * Values less than zero provide a filter of opposite hue.
  78611. */
  78612. get highlightsDensity(): number;
  78613. /**
  78614. * Sets the highlights Density value.
  78615. * 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.
  78616. * Values less than zero provide a filter of opposite hue.
  78617. */
  78618. set highlightsDensity(value: number);
  78619. /**
  78620. * Gets the highlights Saturation value.
  78621. * 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.
  78622. */
  78623. get highlightsSaturation(): number;
  78624. /**
  78625. * Sets the highlights Saturation value.
  78626. * 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.
  78627. */
  78628. set highlightsSaturation(value: number);
  78629. /**
  78630. * Gets the highlights Exposure value.
  78631. * 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.
  78632. */
  78633. get highlightsExposure(): number;
  78634. /**
  78635. * Sets the highlights Exposure value.
  78636. * 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.
  78637. */
  78638. set highlightsExposure(value: number);
  78639. private _midtonesHue;
  78640. private _midtonesDensity;
  78641. private _midtonesSaturation;
  78642. private _midtonesExposure;
  78643. /**
  78644. * Gets the midtones Hue value.
  78645. * 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).
  78646. */
  78647. get midtonesHue(): number;
  78648. /**
  78649. * Sets the midtones Hue value.
  78650. * 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).
  78651. */
  78652. set midtonesHue(value: number);
  78653. /**
  78654. * Gets the midtones Density value.
  78655. * 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.
  78656. * Values less than zero provide a filter of opposite hue.
  78657. */
  78658. get midtonesDensity(): number;
  78659. /**
  78660. * Sets the midtones Density value.
  78661. * 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.
  78662. * Values less than zero provide a filter of opposite hue.
  78663. */
  78664. set midtonesDensity(value: number);
  78665. /**
  78666. * Gets the midtones Saturation value.
  78667. * 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.
  78668. */
  78669. get midtonesSaturation(): number;
  78670. /**
  78671. * Sets the midtones Saturation value.
  78672. * 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.
  78673. */
  78674. set midtonesSaturation(value: number);
  78675. /**
  78676. * Gets the midtones Exposure value.
  78677. * 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.
  78678. */
  78679. get midtonesExposure(): number;
  78680. /**
  78681. * Sets the midtones Exposure value.
  78682. * 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.
  78683. */
  78684. set midtonesExposure(value: number);
  78685. private _shadowsHue;
  78686. private _shadowsDensity;
  78687. private _shadowsSaturation;
  78688. private _shadowsExposure;
  78689. /**
  78690. * Gets the shadows Hue value.
  78691. * 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).
  78692. */
  78693. get shadowsHue(): number;
  78694. /**
  78695. * Sets the shadows Hue value.
  78696. * 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).
  78697. */
  78698. set shadowsHue(value: number);
  78699. /**
  78700. * Gets the shadows Density value.
  78701. * 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.
  78702. * Values less than zero provide a filter of opposite hue.
  78703. */
  78704. get shadowsDensity(): number;
  78705. /**
  78706. * Sets the shadows Density value.
  78707. * 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.
  78708. * Values less than zero provide a filter of opposite hue.
  78709. */
  78710. set shadowsDensity(value: number);
  78711. /**
  78712. * Gets the shadows Saturation value.
  78713. * 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.
  78714. */
  78715. get shadowsSaturation(): number;
  78716. /**
  78717. * Sets the shadows Saturation value.
  78718. * 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.
  78719. */
  78720. set shadowsSaturation(value: number);
  78721. /**
  78722. * Gets the shadows Exposure value.
  78723. * 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.
  78724. */
  78725. get shadowsExposure(): number;
  78726. /**
  78727. * Sets the shadows Exposure value.
  78728. * 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.
  78729. */
  78730. set shadowsExposure(value: number);
  78731. /**
  78732. * Returns the class name
  78733. * @returns The class name
  78734. */
  78735. getClassName(): string;
  78736. /**
  78737. * Binds the color curves to the shader.
  78738. * @param colorCurves The color curve to bind
  78739. * @param effect The effect to bind to
  78740. * @param positiveUniform The positive uniform shader parameter
  78741. * @param neutralUniform The neutral uniform shader parameter
  78742. * @param negativeUniform The negative uniform shader parameter
  78743. */
  78744. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  78745. /**
  78746. * Prepare the list of uniforms associated with the ColorCurves effects.
  78747. * @param uniformsList The list of uniforms used in the effect
  78748. */
  78749. static PrepareUniforms(uniformsList: string[]): void;
  78750. /**
  78751. * Returns color grading data based on a hue, density, saturation and exposure value.
  78752. * @param filterHue The hue of the color filter.
  78753. * @param filterDensity The density of the color filter.
  78754. * @param saturation The saturation.
  78755. * @param exposure The exposure.
  78756. * @param result The result data container.
  78757. */
  78758. private getColorGradingDataToRef;
  78759. /**
  78760. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  78761. * @param value The input slider value in range [-100,100].
  78762. * @returns Adjusted value.
  78763. */
  78764. private static applyColorGradingSliderNonlinear;
  78765. /**
  78766. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  78767. * @param hue The hue (H) input.
  78768. * @param saturation The saturation (S) input.
  78769. * @param brightness The brightness (B) input.
  78770. * @result An RGBA color represented as Vector4.
  78771. */
  78772. private static fromHSBToRef;
  78773. /**
  78774. * Returns a value clamped between min and max
  78775. * @param value The value to clamp
  78776. * @param min The minimum of value
  78777. * @param max The maximum of value
  78778. * @returns The clamped value.
  78779. */
  78780. private static clamp;
  78781. /**
  78782. * Clones the current color curve instance.
  78783. * @return The cloned curves
  78784. */
  78785. clone(): ColorCurves;
  78786. /**
  78787. * Serializes the current color curve instance to a json representation.
  78788. * @return a JSON representation
  78789. */
  78790. serialize(): any;
  78791. /**
  78792. * Parses the color curve from a json representation.
  78793. * @param source the JSON source to parse
  78794. * @return The parsed curves
  78795. */
  78796. static Parse(source: any): ColorCurves;
  78797. }
  78798. }
  78799. declare module BABYLON {
  78800. /**
  78801. * Interface to follow in your material defines to integrate easily the
  78802. * Image proccessing functions.
  78803. * @hidden
  78804. */
  78805. export interface IImageProcessingConfigurationDefines {
  78806. IMAGEPROCESSING: boolean;
  78807. VIGNETTE: boolean;
  78808. VIGNETTEBLENDMODEMULTIPLY: boolean;
  78809. VIGNETTEBLENDMODEOPAQUE: boolean;
  78810. TONEMAPPING: boolean;
  78811. TONEMAPPING_ACES: boolean;
  78812. CONTRAST: boolean;
  78813. EXPOSURE: boolean;
  78814. COLORCURVES: boolean;
  78815. COLORGRADING: boolean;
  78816. COLORGRADING3D: boolean;
  78817. SAMPLER3DGREENDEPTH: boolean;
  78818. SAMPLER3DBGRMAP: boolean;
  78819. IMAGEPROCESSINGPOSTPROCESS: boolean;
  78820. }
  78821. /**
  78822. * @hidden
  78823. */
  78824. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  78825. IMAGEPROCESSING: boolean;
  78826. VIGNETTE: boolean;
  78827. VIGNETTEBLENDMODEMULTIPLY: boolean;
  78828. VIGNETTEBLENDMODEOPAQUE: boolean;
  78829. TONEMAPPING: boolean;
  78830. TONEMAPPING_ACES: boolean;
  78831. CONTRAST: boolean;
  78832. COLORCURVES: boolean;
  78833. COLORGRADING: boolean;
  78834. COLORGRADING3D: boolean;
  78835. SAMPLER3DGREENDEPTH: boolean;
  78836. SAMPLER3DBGRMAP: boolean;
  78837. IMAGEPROCESSINGPOSTPROCESS: boolean;
  78838. EXPOSURE: boolean;
  78839. constructor();
  78840. }
  78841. /**
  78842. * This groups together the common properties used for image processing either in direct forward pass
  78843. * or through post processing effect depending on the use of the image processing pipeline in your scene
  78844. * or not.
  78845. */
  78846. export class ImageProcessingConfiguration {
  78847. /**
  78848. * Default tone mapping applied in BabylonJS.
  78849. */
  78850. static readonly TONEMAPPING_STANDARD: number;
  78851. /**
  78852. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  78853. * to other engines rendering to increase portability.
  78854. */
  78855. static readonly TONEMAPPING_ACES: number;
  78856. /**
  78857. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  78858. */
  78859. colorCurves: Nullable<ColorCurves>;
  78860. private _colorCurvesEnabled;
  78861. /**
  78862. * Gets wether the color curves effect is enabled.
  78863. */
  78864. get colorCurvesEnabled(): boolean;
  78865. /**
  78866. * Sets wether the color curves effect is enabled.
  78867. */
  78868. set colorCurvesEnabled(value: boolean);
  78869. private _colorGradingTexture;
  78870. /**
  78871. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  78872. */
  78873. get colorGradingTexture(): Nullable<BaseTexture>;
  78874. /**
  78875. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  78876. */
  78877. set colorGradingTexture(value: Nullable<BaseTexture>);
  78878. private _colorGradingEnabled;
  78879. /**
  78880. * Gets wether the color grading effect is enabled.
  78881. */
  78882. get colorGradingEnabled(): boolean;
  78883. /**
  78884. * Sets wether the color grading effect is enabled.
  78885. */
  78886. set colorGradingEnabled(value: boolean);
  78887. private _colorGradingWithGreenDepth;
  78888. /**
  78889. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  78890. */
  78891. get colorGradingWithGreenDepth(): boolean;
  78892. /**
  78893. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  78894. */
  78895. set colorGradingWithGreenDepth(value: boolean);
  78896. private _colorGradingBGR;
  78897. /**
  78898. * Gets wether the color grading texture contains BGR values.
  78899. */
  78900. get colorGradingBGR(): boolean;
  78901. /**
  78902. * Sets wether the color grading texture contains BGR values.
  78903. */
  78904. set colorGradingBGR(value: boolean);
  78905. /** @hidden */
  78906. _exposure: number;
  78907. /**
  78908. * Gets the Exposure used in the effect.
  78909. */
  78910. get exposure(): number;
  78911. /**
  78912. * Sets the Exposure used in the effect.
  78913. */
  78914. set exposure(value: number);
  78915. private _toneMappingEnabled;
  78916. /**
  78917. * Gets wether the tone mapping effect is enabled.
  78918. */
  78919. get toneMappingEnabled(): boolean;
  78920. /**
  78921. * Sets wether the tone mapping effect is enabled.
  78922. */
  78923. set toneMappingEnabled(value: boolean);
  78924. private _toneMappingType;
  78925. /**
  78926. * Gets the type of tone mapping effect.
  78927. */
  78928. get toneMappingType(): number;
  78929. /**
  78930. * Sets the type of tone mapping effect used in BabylonJS.
  78931. */
  78932. set toneMappingType(value: number);
  78933. protected _contrast: number;
  78934. /**
  78935. * Gets the contrast used in the effect.
  78936. */
  78937. get contrast(): number;
  78938. /**
  78939. * Sets the contrast used in the effect.
  78940. */
  78941. set contrast(value: number);
  78942. /**
  78943. * Vignette stretch size.
  78944. */
  78945. vignetteStretch: number;
  78946. /**
  78947. * Vignette centre X Offset.
  78948. */
  78949. vignetteCentreX: number;
  78950. /**
  78951. * Vignette centre Y Offset.
  78952. */
  78953. vignetteCentreY: number;
  78954. /**
  78955. * Vignette weight or intensity of the vignette effect.
  78956. */
  78957. vignetteWeight: number;
  78958. /**
  78959. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  78960. * if vignetteEnabled is set to true.
  78961. */
  78962. vignetteColor: Color4;
  78963. /**
  78964. * Camera field of view used by the Vignette effect.
  78965. */
  78966. vignetteCameraFov: number;
  78967. private _vignetteBlendMode;
  78968. /**
  78969. * Gets the vignette blend mode allowing different kind of effect.
  78970. */
  78971. get vignetteBlendMode(): number;
  78972. /**
  78973. * Sets the vignette blend mode allowing different kind of effect.
  78974. */
  78975. set vignetteBlendMode(value: number);
  78976. private _vignetteEnabled;
  78977. /**
  78978. * Gets wether the vignette effect is enabled.
  78979. */
  78980. get vignetteEnabled(): boolean;
  78981. /**
  78982. * Sets wether the vignette effect is enabled.
  78983. */
  78984. set vignetteEnabled(value: boolean);
  78985. private _applyByPostProcess;
  78986. /**
  78987. * Gets wether the image processing is applied through a post process or not.
  78988. */
  78989. get applyByPostProcess(): boolean;
  78990. /**
  78991. * Sets wether the image processing is applied through a post process or not.
  78992. */
  78993. set applyByPostProcess(value: boolean);
  78994. private _isEnabled;
  78995. /**
  78996. * Gets wether the image processing is enabled or not.
  78997. */
  78998. get isEnabled(): boolean;
  78999. /**
  79000. * Sets wether the image processing is enabled or not.
  79001. */
  79002. set isEnabled(value: boolean);
  79003. /**
  79004. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  79005. */
  79006. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  79007. /**
  79008. * Method called each time the image processing information changes requires to recompile the effect.
  79009. */
  79010. protected _updateParameters(): void;
  79011. /**
  79012. * Gets the current class name.
  79013. * @return "ImageProcessingConfiguration"
  79014. */
  79015. getClassName(): string;
  79016. /**
  79017. * Prepare the list of uniforms associated with the Image Processing effects.
  79018. * @param uniforms The list of uniforms used in the effect
  79019. * @param defines the list of defines currently in use
  79020. */
  79021. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  79022. /**
  79023. * Prepare the list of samplers associated with the Image Processing effects.
  79024. * @param samplersList The list of uniforms used in the effect
  79025. * @param defines the list of defines currently in use
  79026. */
  79027. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  79028. /**
  79029. * Prepare the list of defines associated to the shader.
  79030. * @param defines the list of defines to complete
  79031. * @param forPostProcess Define if we are currently in post process mode or not
  79032. */
  79033. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  79034. /**
  79035. * Returns true if all the image processing information are ready.
  79036. * @returns True if ready, otherwise, false
  79037. */
  79038. isReady(): boolean;
  79039. /**
  79040. * Binds the image processing to the shader.
  79041. * @param effect The effect to bind to
  79042. * @param overrideAspectRatio Override the aspect ratio of the effect
  79043. */
  79044. bind(effect: Effect, overrideAspectRatio?: number): void;
  79045. /**
  79046. * Clones the current image processing instance.
  79047. * @return The cloned image processing
  79048. */
  79049. clone(): ImageProcessingConfiguration;
  79050. /**
  79051. * Serializes the current image processing instance to a json representation.
  79052. * @return a JSON representation
  79053. */
  79054. serialize(): any;
  79055. /**
  79056. * Parses the image processing from a json representation.
  79057. * @param source the JSON source to parse
  79058. * @return The parsed image processing
  79059. */
  79060. static Parse(source: any): ImageProcessingConfiguration;
  79061. private static _VIGNETTEMODE_MULTIPLY;
  79062. private static _VIGNETTEMODE_OPAQUE;
  79063. /**
  79064. * Used to apply the vignette as a mix with the pixel color.
  79065. */
  79066. static get VIGNETTEMODE_MULTIPLY(): number;
  79067. /**
  79068. * Used to apply the vignette as a replacement of the pixel color.
  79069. */
  79070. static get VIGNETTEMODE_OPAQUE(): number;
  79071. }
  79072. }
  79073. declare module BABYLON {
  79074. /** @hidden */
  79075. export var postprocessVertexShader: {
  79076. name: string;
  79077. shader: string;
  79078. };
  79079. }
  79080. declare module BABYLON {
  79081. interface ThinEngine {
  79082. /**
  79083. * Creates a new render target texture
  79084. * @param size defines the size of the texture
  79085. * @param options defines the options used to create the texture
  79086. * @returns a new render target texture stored in an InternalTexture
  79087. */
  79088. createRenderTargetTexture(size: number | {
  79089. width: number;
  79090. height: number;
  79091. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  79092. /**
  79093. * Creates a depth stencil texture.
  79094. * This is only available in WebGL 2 or with the depth texture extension available.
  79095. * @param size The size of face edge in the texture.
  79096. * @param options The options defining the texture.
  79097. * @returns The texture
  79098. */
  79099. createDepthStencilTexture(size: number | {
  79100. width: number;
  79101. height: number;
  79102. }, options: DepthTextureCreationOptions): InternalTexture;
  79103. /** @hidden */
  79104. _createDepthStencilTexture(size: number | {
  79105. width: number;
  79106. height: number;
  79107. }, options: DepthTextureCreationOptions): InternalTexture;
  79108. }
  79109. }
  79110. declare module BABYLON {
  79111. /** Defines supported spaces */
  79112. export enum Space {
  79113. /** Local (object) space */
  79114. LOCAL = 0,
  79115. /** World space */
  79116. WORLD = 1,
  79117. /** Bone space */
  79118. BONE = 2
  79119. }
  79120. /** Defines the 3 main axes */
  79121. export class Axis {
  79122. /** X axis */
  79123. static X: Vector3;
  79124. /** Y axis */
  79125. static Y: Vector3;
  79126. /** Z axis */
  79127. static Z: Vector3;
  79128. }
  79129. }
  79130. declare module BABYLON {
  79131. /**
  79132. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  79133. * This is the base of the follow, arc rotate cameras and Free camera
  79134. * @see http://doc.babylonjs.com/features/cameras
  79135. */
  79136. export class TargetCamera extends Camera {
  79137. private static _RigCamTransformMatrix;
  79138. private static _TargetTransformMatrix;
  79139. private static _TargetFocalPoint;
  79140. /**
  79141. * Define the current direction the camera is moving to
  79142. */
  79143. cameraDirection: Vector3;
  79144. /**
  79145. * Define the current rotation the camera is rotating to
  79146. */
  79147. cameraRotation: Vector2;
  79148. /**
  79149. * When set, the up vector of the camera will be updated by the rotation of the camera
  79150. */
  79151. updateUpVectorFromRotation: boolean;
  79152. private _tmpQuaternion;
  79153. /**
  79154. * Define the current rotation of the camera
  79155. */
  79156. rotation: Vector3;
  79157. /**
  79158. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  79159. */
  79160. rotationQuaternion: Quaternion;
  79161. /**
  79162. * Define the current speed of the camera
  79163. */
  79164. speed: number;
  79165. /**
  79166. * Add constraint to the camera to prevent it to move freely in all directions and
  79167. * around all axis.
  79168. */
  79169. noRotationConstraint: boolean;
  79170. /**
  79171. * Define the current target of the camera as an object or a position.
  79172. */
  79173. lockedTarget: any;
  79174. /** @hidden */
  79175. _currentTarget: Vector3;
  79176. /** @hidden */
  79177. _initialFocalDistance: number;
  79178. /** @hidden */
  79179. _viewMatrix: Matrix;
  79180. /** @hidden */
  79181. _camMatrix: Matrix;
  79182. /** @hidden */
  79183. _cameraTransformMatrix: Matrix;
  79184. /** @hidden */
  79185. _cameraRotationMatrix: Matrix;
  79186. /** @hidden */
  79187. _referencePoint: Vector3;
  79188. /** @hidden */
  79189. _transformedReferencePoint: Vector3;
  79190. protected _globalCurrentTarget: Vector3;
  79191. protected _globalCurrentUpVector: Vector3;
  79192. /** @hidden */
  79193. _reset: () => void;
  79194. private _defaultUp;
  79195. /**
  79196. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  79197. * This is the base of the follow, arc rotate cameras and Free camera
  79198. * @see http://doc.babylonjs.com/features/cameras
  79199. * @param name Defines the name of the camera in the scene
  79200. * @param position Defines the start position of the camera in the scene
  79201. * @param scene Defines the scene the camera belongs to
  79202. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79203. */
  79204. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79205. /**
  79206. * Gets the position in front of the camera at a given distance.
  79207. * @param distance The distance from the camera we want the position to be
  79208. * @returns the position
  79209. */
  79210. getFrontPosition(distance: number): Vector3;
  79211. /** @hidden */
  79212. _getLockedTargetPosition(): Nullable<Vector3>;
  79213. private _storedPosition;
  79214. private _storedRotation;
  79215. private _storedRotationQuaternion;
  79216. /**
  79217. * Store current camera state of the camera (fov, position, rotation, etc..)
  79218. * @returns the camera
  79219. */
  79220. storeState(): Camera;
  79221. /**
  79222. * Restored camera state. You must call storeState() first
  79223. * @returns whether it was successful or not
  79224. * @hidden
  79225. */
  79226. _restoreStateValues(): boolean;
  79227. /** @hidden */
  79228. _initCache(): void;
  79229. /** @hidden */
  79230. _updateCache(ignoreParentClass?: boolean): void;
  79231. /** @hidden */
  79232. _isSynchronizedViewMatrix(): boolean;
  79233. /** @hidden */
  79234. _computeLocalCameraSpeed(): number;
  79235. /**
  79236. * Defines the target the camera should look at.
  79237. * @param target Defines the new target as a Vector or a mesh
  79238. */
  79239. setTarget(target: Vector3): void;
  79240. /**
  79241. * Return the current target position of the camera. This value is expressed in local space.
  79242. * @returns the target position
  79243. */
  79244. getTarget(): Vector3;
  79245. /** @hidden */
  79246. _decideIfNeedsToMove(): boolean;
  79247. /** @hidden */
  79248. _updatePosition(): void;
  79249. /** @hidden */
  79250. _checkInputs(): void;
  79251. protected _updateCameraRotationMatrix(): void;
  79252. /**
  79253. * 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)
  79254. * @returns the current camera
  79255. */
  79256. private _rotateUpVectorWithCameraRotationMatrix;
  79257. private _cachedRotationZ;
  79258. private _cachedQuaternionRotationZ;
  79259. /** @hidden */
  79260. _getViewMatrix(): Matrix;
  79261. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  79262. /**
  79263. * @hidden
  79264. */
  79265. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  79266. /**
  79267. * @hidden
  79268. */
  79269. _updateRigCameras(): void;
  79270. private _getRigCamPositionAndTarget;
  79271. /**
  79272. * Gets the current object class name.
  79273. * @return the class name
  79274. */
  79275. getClassName(): string;
  79276. }
  79277. }
  79278. declare module BABYLON {
  79279. /**
  79280. * Gather the list of keyboard event types as constants.
  79281. */
  79282. export class KeyboardEventTypes {
  79283. /**
  79284. * The keydown event is fired when a key becomes active (pressed).
  79285. */
  79286. static readonly KEYDOWN: number;
  79287. /**
  79288. * The keyup event is fired when a key has been released.
  79289. */
  79290. static readonly KEYUP: number;
  79291. }
  79292. /**
  79293. * This class is used to store keyboard related info for the onKeyboardObservable event.
  79294. */
  79295. export class KeyboardInfo {
  79296. /**
  79297. * Defines the type of event (KeyboardEventTypes)
  79298. */
  79299. type: number;
  79300. /**
  79301. * Defines the related dom event
  79302. */
  79303. event: KeyboardEvent;
  79304. /**
  79305. * Instantiates a new keyboard info.
  79306. * This class is used to store keyboard related info for the onKeyboardObservable event.
  79307. * @param type Defines the type of event (KeyboardEventTypes)
  79308. * @param event Defines the related dom event
  79309. */
  79310. constructor(
  79311. /**
  79312. * Defines the type of event (KeyboardEventTypes)
  79313. */
  79314. type: number,
  79315. /**
  79316. * Defines the related dom event
  79317. */
  79318. event: KeyboardEvent);
  79319. }
  79320. /**
  79321. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  79322. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  79323. */
  79324. export class KeyboardInfoPre extends KeyboardInfo {
  79325. /**
  79326. * Defines the type of event (KeyboardEventTypes)
  79327. */
  79328. type: number;
  79329. /**
  79330. * Defines the related dom event
  79331. */
  79332. event: KeyboardEvent;
  79333. /**
  79334. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  79335. */
  79336. skipOnPointerObservable: boolean;
  79337. /**
  79338. * Instantiates a new keyboard pre info.
  79339. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  79340. * @param type Defines the type of event (KeyboardEventTypes)
  79341. * @param event Defines the related dom event
  79342. */
  79343. constructor(
  79344. /**
  79345. * Defines the type of event (KeyboardEventTypes)
  79346. */
  79347. type: number,
  79348. /**
  79349. * Defines the related dom event
  79350. */
  79351. event: KeyboardEvent);
  79352. }
  79353. }
  79354. declare module BABYLON {
  79355. /**
  79356. * Manage the keyboard inputs to control the movement of a free camera.
  79357. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79358. */
  79359. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  79360. /**
  79361. * Defines the camera the input is attached to.
  79362. */
  79363. camera: FreeCamera;
  79364. /**
  79365. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  79366. */
  79367. keysUp: number[];
  79368. /**
  79369. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  79370. */
  79371. keysDown: number[];
  79372. /**
  79373. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  79374. */
  79375. keysLeft: number[];
  79376. /**
  79377. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  79378. */
  79379. keysRight: number[];
  79380. private _keys;
  79381. private _onCanvasBlurObserver;
  79382. private _onKeyboardObserver;
  79383. private _engine;
  79384. private _scene;
  79385. /**
  79386. * Attach the input controls to a specific dom element to get the input from.
  79387. * @param element Defines the element the controls should be listened from
  79388. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79389. */
  79390. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79391. /**
  79392. * Detach the current controls from the specified dom element.
  79393. * @param element Defines the element to stop listening the inputs from
  79394. */
  79395. detachControl(element: Nullable<HTMLElement>): void;
  79396. /**
  79397. * Update the current camera state depending on the inputs that have been used this frame.
  79398. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79399. */
  79400. checkInputs(): void;
  79401. /**
  79402. * Gets the class name of the current intput.
  79403. * @returns the class name
  79404. */
  79405. getClassName(): string;
  79406. /** @hidden */
  79407. _onLostFocus(): void;
  79408. /**
  79409. * Get the friendly name associated with the input class.
  79410. * @returns the input friendly name
  79411. */
  79412. getSimpleName(): string;
  79413. }
  79414. }
  79415. declare module BABYLON {
  79416. /**
  79417. * Interface describing all the common properties and methods a shadow light needs to implement.
  79418. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  79419. * as well as binding the different shadow properties to the effects.
  79420. */
  79421. export interface IShadowLight extends Light {
  79422. /**
  79423. * The light id in the scene (used in scene.findLighById for instance)
  79424. */
  79425. id: string;
  79426. /**
  79427. * The position the shdow will be casted from.
  79428. */
  79429. position: Vector3;
  79430. /**
  79431. * In 2d mode (needCube being false), the direction used to cast the shadow.
  79432. */
  79433. direction: Vector3;
  79434. /**
  79435. * The transformed position. Position of the light in world space taking parenting in account.
  79436. */
  79437. transformedPosition: Vector3;
  79438. /**
  79439. * The transformed direction. Direction of the light in world space taking parenting in account.
  79440. */
  79441. transformedDirection: Vector3;
  79442. /**
  79443. * The friendly name of the light in the scene.
  79444. */
  79445. name: string;
  79446. /**
  79447. * Defines the shadow projection clipping minimum z value.
  79448. */
  79449. shadowMinZ: number;
  79450. /**
  79451. * Defines the shadow projection clipping maximum z value.
  79452. */
  79453. shadowMaxZ: number;
  79454. /**
  79455. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  79456. * @returns true if the information has been computed, false if it does not need to (no parenting)
  79457. */
  79458. computeTransformedInformation(): boolean;
  79459. /**
  79460. * Gets the scene the light belongs to.
  79461. * @returns The scene
  79462. */
  79463. getScene(): Scene;
  79464. /**
  79465. * Callback defining a custom Projection Matrix Builder.
  79466. * This can be used to override the default projection matrix computation.
  79467. */
  79468. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  79469. /**
  79470. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  79471. * @param matrix The materix to updated with the projection information
  79472. * @param viewMatrix The transform matrix of the light
  79473. * @param renderList The list of mesh to render in the map
  79474. * @returns The current light
  79475. */
  79476. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  79477. /**
  79478. * Gets the current depth scale used in ESM.
  79479. * @returns The scale
  79480. */
  79481. getDepthScale(): number;
  79482. /**
  79483. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  79484. * @returns true if a cube texture needs to be use
  79485. */
  79486. needCube(): boolean;
  79487. /**
  79488. * Detects if the projection matrix requires to be recomputed this frame.
  79489. * @returns true if it requires to be recomputed otherwise, false.
  79490. */
  79491. needProjectionMatrixCompute(): boolean;
  79492. /**
  79493. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  79494. */
  79495. forceProjectionMatrixCompute(): void;
  79496. /**
  79497. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  79498. * @param faceIndex The index of the face we are computed the direction to generate shadow
  79499. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  79500. */
  79501. getShadowDirection(faceIndex?: number): Vector3;
  79502. /**
  79503. * Gets the minZ used for shadow according to both the scene and the light.
  79504. * @param activeCamera The camera we are returning the min for
  79505. * @returns the depth min z
  79506. */
  79507. getDepthMinZ(activeCamera: Camera): number;
  79508. /**
  79509. * Gets the maxZ used for shadow according to both the scene and the light.
  79510. * @param activeCamera The camera we are returning the max for
  79511. * @returns the depth max z
  79512. */
  79513. getDepthMaxZ(activeCamera: Camera): number;
  79514. }
  79515. /**
  79516. * Base implementation IShadowLight
  79517. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  79518. */
  79519. export abstract class ShadowLight extends Light implements IShadowLight {
  79520. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  79521. protected _position: Vector3;
  79522. protected _setPosition(value: Vector3): void;
  79523. /**
  79524. * Sets the position the shadow will be casted from. Also use as the light position for both
  79525. * point and spot lights.
  79526. */
  79527. get position(): Vector3;
  79528. /**
  79529. * Sets the position the shadow will be casted from. Also use as the light position for both
  79530. * point and spot lights.
  79531. */
  79532. set position(value: Vector3);
  79533. protected _direction: Vector3;
  79534. protected _setDirection(value: Vector3): void;
  79535. /**
  79536. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  79537. * Also use as the light direction on spot and directional lights.
  79538. */
  79539. get direction(): Vector3;
  79540. /**
  79541. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  79542. * Also use as the light direction on spot and directional lights.
  79543. */
  79544. set direction(value: Vector3);
  79545. private _shadowMinZ;
  79546. /**
  79547. * Gets the shadow projection clipping minimum z value.
  79548. */
  79549. get shadowMinZ(): number;
  79550. /**
  79551. * Sets the shadow projection clipping minimum z value.
  79552. */
  79553. set shadowMinZ(value: number);
  79554. private _shadowMaxZ;
  79555. /**
  79556. * Sets the shadow projection clipping maximum z value.
  79557. */
  79558. get shadowMaxZ(): number;
  79559. /**
  79560. * Gets the shadow projection clipping maximum z value.
  79561. */
  79562. set shadowMaxZ(value: number);
  79563. /**
  79564. * Callback defining a custom Projection Matrix Builder.
  79565. * This can be used to override the default projection matrix computation.
  79566. */
  79567. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  79568. /**
  79569. * The transformed position. Position of the light in world space taking parenting in account.
  79570. */
  79571. transformedPosition: Vector3;
  79572. /**
  79573. * The transformed direction. Direction of the light in world space taking parenting in account.
  79574. */
  79575. transformedDirection: Vector3;
  79576. private _needProjectionMatrixCompute;
  79577. /**
  79578. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  79579. * @returns true if the information has been computed, false if it does not need to (no parenting)
  79580. */
  79581. computeTransformedInformation(): boolean;
  79582. /**
  79583. * Return the depth scale used for the shadow map.
  79584. * @returns the depth scale.
  79585. */
  79586. getDepthScale(): number;
  79587. /**
  79588. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  79589. * @param faceIndex The index of the face we are computed the direction to generate shadow
  79590. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  79591. */
  79592. getShadowDirection(faceIndex?: number): Vector3;
  79593. /**
  79594. * Returns the ShadowLight absolute position in the World.
  79595. * @returns the position vector in world space
  79596. */
  79597. getAbsolutePosition(): Vector3;
  79598. /**
  79599. * Sets the ShadowLight direction toward the passed target.
  79600. * @param target The point to target in local space
  79601. * @returns the updated ShadowLight direction
  79602. */
  79603. setDirectionToTarget(target: Vector3): Vector3;
  79604. /**
  79605. * Returns the light rotation in euler definition.
  79606. * @returns the x y z rotation in local space.
  79607. */
  79608. getRotation(): Vector3;
  79609. /**
  79610. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  79611. * @returns true if a cube texture needs to be use
  79612. */
  79613. needCube(): boolean;
  79614. /**
  79615. * Detects if the projection matrix requires to be recomputed this frame.
  79616. * @returns true if it requires to be recomputed otherwise, false.
  79617. */
  79618. needProjectionMatrixCompute(): boolean;
  79619. /**
  79620. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  79621. */
  79622. forceProjectionMatrixCompute(): void;
  79623. /** @hidden */
  79624. _initCache(): void;
  79625. /** @hidden */
  79626. _isSynchronized(): boolean;
  79627. /**
  79628. * Computes the world matrix of the node
  79629. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79630. * @returns the world matrix
  79631. */
  79632. computeWorldMatrix(force?: boolean): Matrix;
  79633. /**
  79634. * Gets the minZ used for shadow according to both the scene and the light.
  79635. * @param activeCamera The camera we are returning the min for
  79636. * @returns the depth min z
  79637. */
  79638. getDepthMinZ(activeCamera: Camera): number;
  79639. /**
  79640. * Gets the maxZ used for shadow according to both the scene and the light.
  79641. * @param activeCamera The camera we are returning the max for
  79642. * @returns the depth max z
  79643. */
  79644. getDepthMaxZ(activeCamera: Camera): number;
  79645. /**
  79646. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  79647. * @param matrix The materix to updated with the projection information
  79648. * @param viewMatrix The transform matrix of the light
  79649. * @param renderList The list of mesh to render in the map
  79650. * @returns The current light
  79651. */
  79652. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  79653. }
  79654. }
  79655. declare module BABYLON {
  79656. /**
  79657. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  79658. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  79659. */
  79660. export class EffectFallbacks implements IEffectFallbacks {
  79661. private _defines;
  79662. private _currentRank;
  79663. private _maxRank;
  79664. private _mesh;
  79665. /**
  79666. * Removes the fallback from the bound mesh.
  79667. */
  79668. unBindMesh(): void;
  79669. /**
  79670. * Adds a fallback on the specified property.
  79671. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  79672. * @param define The name of the define in the shader
  79673. */
  79674. addFallback(rank: number, define: string): void;
  79675. /**
  79676. * Sets the mesh to use CPU skinning when needing to fallback.
  79677. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  79678. * @param mesh The mesh to use the fallbacks.
  79679. */
  79680. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  79681. /**
  79682. * Checks to see if more fallbacks are still availible.
  79683. */
  79684. get hasMoreFallbacks(): boolean;
  79685. /**
  79686. * Removes the defines that should be removed when falling back.
  79687. * @param currentDefines defines the current define statements for the shader.
  79688. * @param effect defines the current effect we try to compile
  79689. * @returns The resulting defines with defines of the current rank removed.
  79690. */
  79691. reduce(currentDefines: string, effect: Effect): string;
  79692. }
  79693. }
  79694. declare module BABYLON {
  79695. /**
  79696. * "Static Class" containing the most commonly used helper while dealing with material for
  79697. * rendering purpose.
  79698. *
  79699. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  79700. *
  79701. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  79702. */
  79703. export class MaterialHelper {
  79704. /**
  79705. * Bind the current view position to an effect.
  79706. * @param effect The effect to be bound
  79707. * @param scene The scene the eyes position is used from
  79708. */
  79709. static BindEyePosition(effect: Effect, scene: Scene): void;
  79710. /**
  79711. * Helps preparing the defines values about the UVs in used in the effect.
  79712. * UVs are shared as much as we can accross channels in the shaders.
  79713. * @param texture The texture we are preparing the UVs for
  79714. * @param defines The defines to update
  79715. * @param key The channel key "diffuse", "specular"... used in the shader
  79716. */
  79717. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  79718. /**
  79719. * Binds a texture matrix value to its corrsponding uniform
  79720. * @param texture The texture to bind the matrix for
  79721. * @param uniformBuffer The uniform buffer receivin the data
  79722. * @param key The channel key "diffuse", "specular"... used in the shader
  79723. */
  79724. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  79725. /**
  79726. * Gets the current status of the fog (should it be enabled?)
  79727. * @param mesh defines the mesh to evaluate for fog support
  79728. * @param scene defines the hosting scene
  79729. * @returns true if fog must be enabled
  79730. */
  79731. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  79732. /**
  79733. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  79734. * @param mesh defines the current mesh
  79735. * @param scene defines the current scene
  79736. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  79737. * @param pointsCloud defines if point cloud rendering has to be turned on
  79738. * @param fogEnabled defines if fog has to be turned on
  79739. * @param alphaTest defines if alpha testing has to be turned on
  79740. * @param defines defines the current list of defines
  79741. */
  79742. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  79743. /**
  79744. * Helper used to prepare the list of defines associated with frame values for shader compilation
  79745. * @param scene defines the current scene
  79746. * @param engine defines the current engine
  79747. * @param defines specifies the list of active defines
  79748. * @param useInstances defines if instances have to be turned on
  79749. * @param useClipPlane defines if clip plane have to be turned on
  79750. */
  79751. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  79752. /**
  79753. * Prepares the defines for bones
  79754. * @param mesh The mesh containing the geometry data we will draw
  79755. * @param defines The defines to update
  79756. */
  79757. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  79758. /**
  79759. * Prepares the defines for morph targets
  79760. * @param mesh The mesh containing the geometry data we will draw
  79761. * @param defines The defines to update
  79762. */
  79763. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  79764. /**
  79765. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  79766. * @param mesh The mesh containing the geometry data we will draw
  79767. * @param defines The defines to update
  79768. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  79769. * @param useBones Precise whether bones should be used or not (override mesh info)
  79770. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  79771. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  79772. * @returns false if defines are considered not dirty and have not been checked
  79773. */
  79774. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  79775. /**
  79776. * Prepares the defines related to multiview
  79777. * @param scene The scene we are intending to draw
  79778. * @param defines The defines to update
  79779. */
  79780. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  79781. /**
  79782. * Prepares the defines related to the light information passed in parameter
  79783. * @param scene The scene we are intending to draw
  79784. * @param mesh The mesh the effect is compiling for
  79785. * @param light The light the effect is compiling for
  79786. * @param lightIndex The index of the light
  79787. * @param defines The defines to update
  79788. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  79789. * @param state Defines the current state regarding what is needed (normals, etc...)
  79790. */
  79791. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  79792. needNormals: boolean;
  79793. needRebuild: boolean;
  79794. shadowEnabled: boolean;
  79795. specularEnabled: boolean;
  79796. lightmapMode: boolean;
  79797. }): void;
  79798. /**
  79799. * Prepares the defines related to the light information passed in parameter
  79800. * @param scene The scene we are intending to draw
  79801. * @param mesh The mesh the effect is compiling for
  79802. * @param defines The defines to update
  79803. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  79804. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  79805. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  79806. * @returns true if normals will be required for the rest of the effect
  79807. */
  79808. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  79809. /**
  79810. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  79811. * @param lightIndex defines the light index
  79812. * @param uniformsList The uniform list
  79813. * @param samplersList The sampler list
  79814. * @param projectedLightTexture defines if projected texture must be used
  79815. * @param uniformBuffersList defines an optional list of uniform buffers
  79816. */
  79817. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  79818. /**
  79819. * Prepares the uniforms and samplers list to be used in the effect
  79820. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  79821. * @param samplersList The sampler list
  79822. * @param defines The defines helping in the list generation
  79823. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  79824. */
  79825. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  79826. /**
  79827. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  79828. * @param defines The defines to update while falling back
  79829. * @param fallbacks The authorized effect fallbacks
  79830. * @param maxSimultaneousLights The maximum number of lights allowed
  79831. * @param rank the current rank of the Effect
  79832. * @returns The newly affected rank
  79833. */
  79834. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  79835. private static _TmpMorphInfluencers;
  79836. /**
  79837. * Prepares the list of attributes required for morph targets according to the effect defines.
  79838. * @param attribs The current list of supported attribs
  79839. * @param mesh The mesh to prepare the morph targets attributes for
  79840. * @param influencers The number of influencers
  79841. */
  79842. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  79843. /**
  79844. * Prepares the list of attributes required for morph targets according to the effect defines.
  79845. * @param attribs The current list of supported attribs
  79846. * @param mesh The mesh to prepare the morph targets attributes for
  79847. * @param defines The current Defines of the effect
  79848. */
  79849. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  79850. /**
  79851. * Prepares the list of attributes required for bones according to the effect defines.
  79852. * @param attribs The current list of supported attribs
  79853. * @param mesh The mesh to prepare the bones attributes for
  79854. * @param defines The current Defines of the effect
  79855. * @param fallbacks The current efffect fallback strategy
  79856. */
  79857. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  79858. /**
  79859. * Check and prepare the list of attributes required for instances according to the effect defines.
  79860. * @param attribs The current list of supported attribs
  79861. * @param defines The current MaterialDefines of the effect
  79862. */
  79863. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  79864. /**
  79865. * Add the list of attributes required for instances to the attribs array.
  79866. * @param attribs The current list of supported attribs
  79867. */
  79868. static PushAttributesForInstances(attribs: string[]): void;
  79869. /**
  79870. * Binds the light information to the effect.
  79871. * @param light The light containing the generator
  79872. * @param effect The effect we are binding the data to
  79873. * @param lightIndex The light index in the effect used to render
  79874. */
  79875. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  79876. /**
  79877. * Binds the lights information from the scene to the effect for the given mesh.
  79878. * @param light Light to bind
  79879. * @param lightIndex Light index
  79880. * @param scene The scene where the light belongs to
  79881. * @param effect The effect we are binding the data to
  79882. * @param useSpecular Defines if specular is supported
  79883. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  79884. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  79885. */
  79886. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  79887. /**
  79888. * Binds the lights information from the scene to the effect for the given mesh.
  79889. * @param scene The scene the lights belongs to
  79890. * @param mesh The mesh we are binding the information to render
  79891. * @param effect The effect we are binding the data to
  79892. * @param defines The generated defines for the effect
  79893. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  79894. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  79895. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  79896. */
  79897. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  79898. private static _tempFogColor;
  79899. /**
  79900. * Binds the fog information from the scene to the effect for the given mesh.
  79901. * @param scene The scene the lights belongs to
  79902. * @param mesh The mesh we are binding the information to render
  79903. * @param effect The effect we are binding the data to
  79904. * @param linearSpace Defines if the fog effect is applied in linear space
  79905. */
  79906. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  79907. /**
  79908. * Binds the bones information from the mesh to the effect.
  79909. * @param mesh The mesh we are binding the information to render
  79910. * @param effect The effect we are binding the data to
  79911. */
  79912. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  79913. /**
  79914. * Binds the morph targets information from the mesh to the effect.
  79915. * @param abstractMesh The mesh we are binding the information to render
  79916. * @param effect The effect we are binding the data to
  79917. */
  79918. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  79919. /**
  79920. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  79921. * @param defines The generated defines used in the effect
  79922. * @param effect The effect we are binding the data to
  79923. * @param scene The scene we are willing to render with logarithmic scale for
  79924. */
  79925. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  79926. /**
  79927. * Binds the clip plane information from the scene to the effect.
  79928. * @param scene The scene the clip plane information are extracted from
  79929. * @param effect The effect we are binding the data to
  79930. */
  79931. static BindClipPlane(effect: Effect, scene: Scene): void;
  79932. }
  79933. }
  79934. declare module BABYLON {
  79935. /** @hidden */
  79936. export var packingFunctions: {
  79937. name: string;
  79938. shader: string;
  79939. };
  79940. }
  79941. declare module BABYLON {
  79942. /** @hidden */
  79943. export var shadowMapPixelShader: {
  79944. name: string;
  79945. shader: string;
  79946. };
  79947. }
  79948. declare module BABYLON {
  79949. /** @hidden */
  79950. export var bonesDeclaration: {
  79951. name: string;
  79952. shader: string;
  79953. };
  79954. }
  79955. declare module BABYLON {
  79956. /** @hidden */
  79957. export var morphTargetsVertexGlobalDeclaration: {
  79958. name: string;
  79959. shader: string;
  79960. };
  79961. }
  79962. declare module BABYLON {
  79963. /** @hidden */
  79964. export var morphTargetsVertexDeclaration: {
  79965. name: string;
  79966. shader: string;
  79967. };
  79968. }
  79969. declare module BABYLON {
  79970. /** @hidden */
  79971. export var instancesDeclaration: {
  79972. name: string;
  79973. shader: string;
  79974. };
  79975. }
  79976. declare module BABYLON {
  79977. /** @hidden */
  79978. export var helperFunctions: {
  79979. name: string;
  79980. shader: string;
  79981. };
  79982. }
  79983. declare module BABYLON {
  79984. /** @hidden */
  79985. export var morphTargetsVertex: {
  79986. name: string;
  79987. shader: string;
  79988. };
  79989. }
  79990. declare module BABYLON {
  79991. /** @hidden */
  79992. export var instancesVertex: {
  79993. name: string;
  79994. shader: string;
  79995. };
  79996. }
  79997. declare module BABYLON {
  79998. /** @hidden */
  79999. export var bonesVertex: {
  80000. name: string;
  80001. shader: string;
  80002. };
  80003. }
  80004. declare module BABYLON {
  80005. /** @hidden */
  80006. export var shadowMapVertexShader: {
  80007. name: string;
  80008. shader: string;
  80009. };
  80010. }
  80011. declare module BABYLON {
  80012. /** @hidden */
  80013. export var depthBoxBlurPixelShader: {
  80014. name: string;
  80015. shader: string;
  80016. };
  80017. }
  80018. declare module BABYLON {
  80019. /**
  80020. * Defines the options associated with the creation of a custom shader for a shadow generator.
  80021. */
  80022. export interface ICustomShaderOptions {
  80023. /**
  80024. * Gets or sets the custom shader name to use
  80025. */
  80026. shaderName: string;
  80027. /**
  80028. * The list of attribute names used in the shader
  80029. */
  80030. attributes?: string[];
  80031. /**
  80032. * The list of unifrom names used in the shader
  80033. */
  80034. uniforms?: string[];
  80035. /**
  80036. * The list of sampler names used in the shader
  80037. */
  80038. samplers?: string[];
  80039. /**
  80040. * The list of defines used in the shader
  80041. */
  80042. defines?: string[];
  80043. }
  80044. /**
  80045. * Interface to implement to create a shadow generator compatible with BJS.
  80046. */
  80047. export interface IShadowGenerator {
  80048. /**
  80049. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  80050. * @returns The render target texture if present otherwise, null
  80051. */
  80052. getShadowMap(): Nullable<RenderTargetTexture>;
  80053. /**
  80054. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  80055. * @returns The render target texture if the shadow map is present otherwise, null
  80056. */
  80057. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  80058. /**
  80059. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  80060. * @param subMesh The submesh we want to render in the shadow map
  80061. * @param useInstances Defines wether will draw in the map using instances
  80062. * @returns true if ready otherwise, false
  80063. */
  80064. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  80065. /**
  80066. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  80067. * @param defines Defines of the material we want to update
  80068. * @param lightIndex Index of the light in the enabled light list of the material
  80069. */
  80070. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  80071. /**
  80072. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  80073. * defined in the generator but impacting the effect).
  80074. * It implies the unifroms available on the materials are the standard BJS ones.
  80075. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  80076. * @param effect The effect we are binfing the information for
  80077. */
  80078. bindShadowLight(lightIndex: string, effect: Effect): void;
  80079. /**
  80080. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  80081. * (eq to shadow prjection matrix * light transform matrix)
  80082. * @returns The transform matrix used to create the shadow map
  80083. */
  80084. getTransformMatrix(): Matrix;
  80085. /**
  80086. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  80087. * Cube and 2D textures for instance.
  80088. */
  80089. recreateShadowMap(): void;
  80090. /**
  80091. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80092. * @param onCompiled Callback triggered at the and of the effects compilation
  80093. * @param options Sets of optional options forcing the compilation with different modes
  80094. */
  80095. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  80096. useInstances: boolean;
  80097. }>): void;
  80098. /**
  80099. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80100. * @param options Sets of optional options forcing the compilation with different modes
  80101. * @returns A promise that resolves when the compilation completes
  80102. */
  80103. forceCompilationAsync(options?: Partial<{
  80104. useInstances: boolean;
  80105. }>): Promise<void>;
  80106. /**
  80107. * Serializes the shadow generator setup to a json object.
  80108. * @returns The serialized JSON object
  80109. */
  80110. serialize(): any;
  80111. /**
  80112. * Disposes the Shadow map and related Textures and effects.
  80113. */
  80114. dispose(): void;
  80115. }
  80116. /**
  80117. * Default implementation IShadowGenerator.
  80118. * This is the main object responsible of generating shadows in the framework.
  80119. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  80120. */
  80121. export class ShadowGenerator implements IShadowGenerator {
  80122. /**
  80123. * Shadow generator mode None: no filtering applied.
  80124. */
  80125. static readonly FILTER_NONE: number;
  80126. /**
  80127. * Shadow generator mode ESM: Exponential Shadow Mapping.
  80128. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80129. */
  80130. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  80131. /**
  80132. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  80133. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  80134. */
  80135. static readonly FILTER_POISSONSAMPLING: number;
  80136. /**
  80137. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  80138. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80139. */
  80140. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  80141. /**
  80142. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  80143. * edge artifacts on steep falloff.
  80144. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80145. */
  80146. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  80147. /**
  80148. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  80149. * edge artifacts on steep falloff.
  80150. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80151. */
  80152. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  80153. /**
  80154. * Shadow generator mode PCF: Percentage Closer Filtering
  80155. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  80156. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  80157. */
  80158. static readonly FILTER_PCF: number;
  80159. /**
  80160. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  80161. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  80162. * Contact Hardening
  80163. */
  80164. static readonly FILTER_PCSS: number;
  80165. /**
  80166. * Reserved for PCF and PCSS
  80167. * Highest Quality.
  80168. *
  80169. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  80170. *
  80171. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  80172. */
  80173. static readonly QUALITY_HIGH: number;
  80174. /**
  80175. * Reserved for PCF and PCSS
  80176. * Good tradeoff for quality/perf cross devices
  80177. *
  80178. * Execute PCF on a 3*3 kernel.
  80179. *
  80180. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  80181. */
  80182. static readonly QUALITY_MEDIUM: number;
  80183. /**
  80184. * Reserved for PCF and PCSS
  80185. * The lowest quality but the fastest.
  80186. *
  80187. * Execute PCF on a 1*1 kernel.
  80188. *
  80189. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  80190. */
  80191. static readonly QUALITY_LOW: number;
  80192. /** Gets or sets the custom shader name to use */
  80193. customShaderOptions: ICustomShaderOptions;
  80194. /**
  80195. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  80196. */
  80197. onBeforeShadowMapRenderObservable: Observable<Effect>;
  80198. /**
  80199. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  80200. */
  80201. onAfterShadowMapRenderObservable: Observable<Effect>;
  80202. /**
  80203. * Observable triggered before a mesh is rendered in the shadow map.
  80204. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  80205. */
  80206. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  80207. /**
  80208. * Observable triggered after a mesh is rendered in the shadow map.
  80209. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  80210. */
  80211. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  80212. private _bias;
  80213. /**
  80214. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  80215. */
  80216. get bias(): number;
  80217. /**
  80218. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  80219. */
  80220. set bias(bias: number);
  80221. private _normalBias;
  80222. /**
  80223. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  80224. */
  80225. get normalBias(): number;
  80226. /**
  80227. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  80228. */
  80229. set normalBias(normalBias: number);
  80230. private _blurBoxOffset;
  80231. /**
  80232. * Gets the blur box offset: offset applied during the blur pass.
  80233. * Only useful if useKernelBlur = false
  80234. */
  80235. get blurBoxOffset(): number;
  80236. /**
  80237. * Sets the blur box offset: offset applied during the blur pass.
  80238. * Only useful if useKernelBlur = false
  80239. */
  80240. set blurBoxOffset(value: number);
  80241. private _blurScale;
  80242. /**
  80243. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  80244. * 2 means half of the size.
  80245. */
  80246. get blurScale(): number;
  80247. /**
  80248. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  80249. * 2 means half of the size.
  80250. */
  80251. set blurScale(value: number);
  80252. private _blurKernel;
  80253. /**
  80254. * Gets the blur kernel: kernel size of the blur pass.
  80255. * Only useful if useKernelBlur = true
  80256. */
  80257. get blurKernel(): number;
  80258. /**
  80259. * Sets the blur kernel: kernel size of the blur pass.
  80260. * Only useful if useKernelBlur = true
  80261. */
  80262. set blurKernel(value: number);
  80263. private _useKernelBlur;
  80264. /**
  80265. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  80266. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  80267. */
  80268. get useKernelBlur(): boolean;
  80269. /**
  80270. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  80271. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  80272. */
  80273. set useKernelBlur(value: boolean);
  80274. private _depthScale;
  80275. /**
  80276. * Gets the depth scale used in ESM mode.
  80277. */
  80278. get depthScale(): number;
  80279. /**
  80280. * Sets the depth scale used in ESM mode.
  80281. * This can override the scale stored on the light.
  80282. */
  80283. set depthScale(value: number);
  80284. private _filter;
  80285. /**
  80286. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  80287. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  80288. */
  80289. get filter(): number;
  80290. /**
  80291. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  80292. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  80293. */
  80294. set filter(value: number);
  80295. /**
  80296. * Gets if the current filter is set to Poisson Sampling.
  80297. */
  80298. get usePoissonSampling(): boolean;
  80299. /**
  80300. * Sets the current filter to Poisson Sampling.
  80301. */
  80302. set usePoissonSampling(value: boolean);
  80303. /**
  80304. * Gets if the current filter is set to ESM.
  80305. */
  80306. get useExponentialShadowMap(): boolean;
  80307. /**
  80308. * Sets the current filter is to ESM.
  80309. */
  80310. set useExponentialShadowMap(value: boolean);
  80311. /**
  80312. * Gets if the current filter is set to filtered ESM.
  80313. */
  80314. get useBlurExponentialShadowMap(): boolean;
  80315. /**
  80316. * Gets if the current filter is set to filtered ESM.
  80317. */
  80318. set useBlurExponentialShadowMap(value: boolean);
  80319. /**
  80320. * Gets if the current filter is set to "close ESM" (using the inverse of the
  80321. * exponential to prevent steep falloff artifacts).
  80322. */
  80323. get useCloseExponentialShadowMap(): boolean;
  80324. /**
  80325. * Sets the current filter to "close ESM" (using the inverse of the
  80326. * exponential to prevent steep falloff artifacts).
  80327. */
  80328. set useCloseExponentialShadowMap(value: boolean);
  80329. /**
  80330. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  80331. * exponential to prevent steep falloff artifacts).
  80332. */
  80333. get useBlurCloseExponentialShadowMap(): boolean;
  80334. /**
  80335. * Sets the current filter to filtered "close ESM" (using the inverse of the
  80336. * exponential to prevent steep falloff artifacts).
  80337. */
  80338. set useBlurCloseExponentialShadowMap(value: boolean);
  80339. /**
  80340. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  80341. */
  80342. get usePercentageCloserFiltering(): boolean;
  80343. /**
  80344. * Sets the current filter to "PCF" (percentage closer filtering).
  80345. */
  80346. set usePercentageCloserFiltering(value: boolean);
  80347. private _filteringQuality;
  80348. /**
  80349. * Gets the PCF or PCSS Quality.
  80350. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  80351. */
  80352. get filteringQuality(): number;
  80353. /**
  80354. * Sets the PCF or PCSS Quality.
  80355. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  80356. */
  80357. set filteringQuality(filteringQuality: number);
  80358. /**
  80359. * Gets if the current filter is set to "PCSS" (contact hardening).
  80360. */
  80361. get useContactHardeningShadow(): boolean;
  80362. /**
  80363. * Sets the current filter to "PCSS" (contact hardening).
  80364. */
  80365. set useContactHardeningShadow(value: boolean);
  80366. private _contactHardeningLightSizeUVRatio;
  80367. /**
  80368. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  80369. * Using a ratio helps keeping shape stability independently of the map size.
  80370. *
  80371. * It does not account for the light projection as it was having too much
  80372. * instability during the light setup or during light position changes.
  80373. *
  80374. * Only valid if useContactHardeningShadow is true.
  80375. */
  80376. get contactHardeningLightSizeUVRatio(): number;
  80377. /**
  80378. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  80379. * Using a ratio helps keeping shape stability independently of the map size.
  80380. *
  80381. * It does not account for the light projection as it was having too much
  80382. * instability during the light setup or during light position changes.
  80383. *
  80384. * Only valid if useContactHardeningShadow is true.
  80385. */
  80386. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  80387. private _darkness;
  80388. /** Gets or sets the actual darkness of a shadow */
  80389. get darkness(): number;
  80390. set darkness(value: number);
  80391. /**
  80392. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  80393. * 0 means strongest and 1 would means no shadow.
  80394. * @returns the darkness.
  80395. */
  80396. getDarkness(): number;
  80397. /**
  80398. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  80399. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  80400. * @returns the shadow generator allowing fluent coding.
  80401. */
  80402. setDarkness(darkness: number): ShadowGenerator;
  80403. private _transparencyShadow;
  80404. /** Gets or sets the ability to have transparent shadow */
  80405. get transparencyShadow(): boolean;
  80406. set transparencyShadow(value: boolean);
  80407. /**
  80408. * Sets the ability to have transparent shadow (boolean).
  80409. * @param transparent True if transparent else False
  80410. * @returns the shadow generator allowing fluent coding
  80411. */
  80412. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  80413. private _shadowMap;
  80414. private _shadowMap2;
  80415. /**
  80416. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  80417. * @returns The render target texture if present otherwise, null
  80418. */
  80419. getShadowMap(): Nullable<RenderTargetTexture>;
  80420. /**
  80421. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  80422. * @returns The render target texture if the shadow map is present otherwise, null
  80423. */
  80424. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  80425. /**
  80426. * Gets the class name of that object
  80427. * @returns "ShadowGenerator"
  80428. */
  80429. getClassName(): string;
  80430. /**
  80431. * Helper function to add a mesh and its descendants to the list of shadow casters.
  80432. * @param mesh Mesh to add
  80433. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  80434. * @returns the Shadow Generator itself
  80435. */
  80436. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  80437. /**
  80438. * Helper function to remove a mesh and its descendants from the list of shadow casters
  80439. * @param mesh Mesh to remove
  80440. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  80441. * @returns the Shadow Generator itself
  80442. */
  80443. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  80444. /**
  80445. * Controls the extent to which the shadows fade out at the edge of the frustum
  80446. * Used only by directionals and spots
  80447. */
  80448. frustumEdgeFalloff: number;
  80449. private _light;
  80450. /**
  80451. * Returns the associated light object.
  80452. * @returns the light generating the shadow
  80453. */
  80454. getLight(): IShadowLight;
  80455. /**
  80456. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  80457. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  80458. * It might on the other hand introduce peter panning.
  80459. */
  80460. forceBackFacesOnly: boolean;
  80461. private _scene;
  80462. private _lightDirection;
  80463. private _effect;
  80464. private _viewMatrix;
  80465. private _projectionMatrix;
  80466. private _transformMatrix;
  80467. private _cachedPosition;
  80468. private _cachedDirection;
  80469. private _cachedDefines;
  80470. private _currentRenderID;
  80471. private _boxBlurPostprocess;
  80472. private _kernelBlurXPostprocess;
  80473. private _kernelBlurYPostprocess;
  80474. private _blurPostProcesses;
  80475. private _mapSize;
  80476. private _currentFaceIndex;
  80477. private _currentFaceIndexCache;
  80478. private _textureType;
  80479. private _defaultTextureMatrix;
  80480. private _storedUniqueId;
  80481. /** @hidden */
  80482. static _SceneComponentInitialization: (scene: Scene) => void;
  80483. /**
  80484. * Creates a ShadowGenerator object.
  80485. * A ShadowGenerator is the required tool to use the shadows.
  80486. * Each light casting shadows needs to use its own ShadowGenerator.
  80487. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  80488. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  80489. * @param light The light object generating the shadows.
  80490. * @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.
  80491. */
  80492. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  80493. private _initializeGenerator;
  80494. private _initializeShadowMap;
  80495. private _initializeBlurRTTAndPostProcesses;
  80496. private _renderForShadowMap;
  80497. private _renderSubMeshForShadowMap;
  80498. private _applyFilterValues;
  80499. /**
  80500. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80501. * @param onCompiled Callback triggered at the and of the effects compilation
  80502. * @param options Sets of optional options forcing the compilation with different modes
  80503. */
  80504. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  80505. useInstances: boolean;
  80506. }>): void;
  80507. /**
  80508. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80509. * @param options Sets of optional options forcing the compilation with different modes
  80510. * @returns A promise that resolves when the compilation completes
  80511. */
  80512. forceCompilationAsync(options?: Partial<{
  80513. useInstances: boolean;
  80514. }>): Promise<void>;
  80515. /**
  80516. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  80517. * @param subMesh The submesh we want to render in the shadow map
  80518. * @param useInstances Defines wether will draw in the map using instances
  80519. * @returns true if ready otherwise, false
  80520. */
  80521. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  80522. /**
  80523. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  80524. * @param defines Defines of the material we want to update
  80525. * @param lightIndex Index of the light in the enabled light list of the material
  80526. */
  80527. prepareDefines(defines: any, lightIndex: number): void;
  80528. /**
  80529. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  80530. * defined in the generator but impacting the effect).
  80531. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  80532. * @param effect The effect we are binfing the information for
  80533. */
  80534. bindShadowLight(lightIndex: string, effect: Effect): void;
  80535. /**
  80536. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  80537. * (eq to shadow prjection matrix * light transform matrix)
  80538. * @returns The transform matrix used to create the shadow map
  80539. */
  80540. getTransformMatrix(): Matrix;
  80541. /**
  80542. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  80543. * Cube and 2D textures for instance.
  80544. */
  80545. recreateShadowMap(): void;
  80546. private _disposeBlurPostProcesses;
  80547. private _disposeRTTandPostProcesses;
  80548. /**
  80549. * Disposes the ShadowGenerator.
  80550. * Returns nothing.
  80551. */
  80552. dispose(): void;
  80553. /**
  80554. * Serializes the shadow generator setup to a json object.
  80555. * @returns The serialized JSON object
  80556. */
  80557. serialize(): any;
  80558. /**
  80559. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  80560. * @param parsedShadowGenerator The JSON object to parse
  80561. * @param scene The scene to create the shadow map for
  80562. * @returns The parsed shadow generator
  80563. */
  80564. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  80565. }
  80566. }
  80567. declare module BABYLON {
  80568. /**
  80569. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  80570. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  80571. * 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.
  80572. */
  80573. export abstract class Light extends Node {
  80574. /**
  80575. * Falloff Default: light is falling off following the material specification:
  80576. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  80577. */
  80578. static readonly FALLOFF_DEFAULT: number;
  80579. /**
  80580. * Falloff Physical: light is falling off following the inverse squared distance law.
  80581. */
  80582. static readonly FALLOFF_PHYSICAL: number;
  80583. /**
  80584. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  80585. * to enhance interoperability with other engines.
  80586. */
  80587. static readonly FALLOFF_GLTF: number;
  80588. /**
  80589. * Falloff Standard: light is falling off like in the standard material
  80590. * to enhance interoperability with other materials.
  80591. */
  80592. static readonly FALLOFF_STANDARD: number;
  80593. /**
  80594. * If every light affecting the material is in this lightmapMode,
  80595. * material.lightmapTexture adds or multiplies
  80596. * (depends on material.useLightmapAsShadowmap)
  80597. * after every other light calculations.
  80598. */
  80599. static readonly LIGHTMAP_DEFAULT: number;
  80600. /**
  80601. * material.lightmapTexture as only diffuse lighting from this light
  80602. * adds only specular lighting from this light
  80603. * adds dynamic shadows
  80604. */
  80605. static readonly LIGHTMAP_SPECULAR: number;
  80606. /**
  80607. * material.lightmapTexture as only lighting
  80608. * no light calculation from this light
  80609. * only adds dynamic shadows from this light
  80610. */
  80611. static readonly LIGHTMAP_SHADOWSONLY: number;
  80612. /**
  80613. * Each light type uses the default quantity according to its type:
  80614. * point/spot lights use luminous intensity
  80615. * directional lights use illuminance
  80616. */
  80617. static readonly INTENSITYMODE_AUTOMATIC: number;
  80618. /**
  80619. * lumen (lm)
  80620. */
  80621. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  80622. /**
  80623. * candela (lm/sr)
  80624. */
  80625. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  80626. /**
  80627. * lux (lm/m^2)
  80628. */
  80629. static readonly INTENSITYMODE_ILLUMINANCE: number;
  80630. /**
  80631. * nit (cd/m^2)
  80632. */
  80633. static readonly INTENSITYMODE_LUMINANCE: number;
  80634. /**
  80635. * Light type const id of the point light.
  80636. */
  80637. static readonly LIGHTTYPEID_POINTLIGHT: number;
  80638. /**
  80639. * Light type const id of the directional light.
  80640. */
  80641. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  80642. /**
  80643. * Light type const id of the spot light.
  80644. */
  80645. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  80646. /**
  80647. * Light type const id of the hemispheric light.
  80648. */
  80649. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  80650. /**
  80651. * Diffuse gives the basic color to an object.
  80652. */
  80653. diffuse: Color3;
  80654. /**
  80655. * Specular produces a highlight color on an object.
  80656. * Note: This is note affecting PBR materials.
  80657. */
  80658. specular: Color3;
  80659. /**
  80660. * Defines the falloff type for this light. This lets overrriding how punctual light are
  80661. * falling off base on range or angle.
  80662. * This can be set to any values in Light.FALLOFF_x.
  80663. *
  80664. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  80665. * other types of materials.
  80666. */
  80667. falloffType: number;
  80668. /**
  80669. * Strength of the light.
  80670. * Note: By default it is define in the framework own unit.
  80671. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  80672. */
  80673. intensity: number;
  80674. private _range;
  80675. protected _inverseSquaredRange: number;
  80676. /**
  80677. * Defines how far from the source the light is impacting in scene units.
  80678. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  80679. */
  80680. get range(): number;
  80681. /**
  80682. * Defines how far from the source the light is impacting in scene units.
  80683. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  80684. */
  80685. set range(value: number);
  80686. /**
  80687. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  80688. * of light.
  80689. */
  80690. private _photometricScale;
  80691. private _intensityMode;
  80692. /**
  80693. * Gets the photometric scale used to interpret the intensity.
  80694. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  80695. */
  80696. get intensityMode(): number;
  80697. /**
  80698. * Sets the photometric scale used to interpret the intensity.
  80699. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  80700. */
  80701. set intensityMode(value: number);
  80702. private _radius;
  80703. /**
  80704. * Gets the light radius used by PBR Materials to simulate soft area lights.
  80705. */
  80706. get radius(): number;
  80707. /**
  80708. * sets the light radius used by PBR Materials to simulate soft area lights.
  80709. */
  80710. set radius(value: number);
  80711. private _renderPriority;
  80712. /**
  80713. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  80714. * exceeding the number allowed of the materials.
  80715. */
  80716. renderPriority: number;
  80717. private _shadowEnabled;
  80718. /**
  80719. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  80720. * the current shadow generator.
  80721. */
  80722. get shadowEnabled(): boolean;
  80723. /**
  80724. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  80725. * the current shadow generator.
  80726. */
  80727. set shadowEnabled(value: boolean);
  80728. private _includedOnlyMeshes;
  80729. /**
  80730. * Gets the only meshes impacted by this light.
  80731. */
  80732. get includedOnlyMeshes(): AbstractMesh[];
  80733. /**
  80734. * Sets the only meshes impacted by this light.
  80735. */
  80736. set includedOnlyMeshes(value: AbstractMesh[]);
  80737. private _excludedMeshes;
  80738. /**
  80739. * Gets the meshes not impacted by this light.
  80740. */
  80741. get excludedMeshes(): AbstractMesh[];
  80742. /**
  80743. * Sets the meshes not impacted by this light.
  80744. */
  80745. set excludedMeshes(value: AbstractMesh[]);
  80746. private _excludeWithLayerMask;
  80747. /**
  80748. * Gets the layer id use to find what meshes are not impacted by the light.
  80749. * Inactive if 0
  80750. */
  80751. get excludeWithLayerMask(): number;
  80752. /**
  80753. * Sets the layer id use to find what meshes are not impacted by the light.
  80754. * Inactive if 0
  80755. */
  80756. set excludeWithLayerMask(value: number);
  80757. private _includeOnlyWithLayerMask;
  80758. /**
  80759. * Gets the layer id use to find what meshes are impacted by the light.
  80760. * Inactive if 0
  80761. */
  80762. get includeOnlyWithLayerMask(): number;
  80763. /**
  80764. * Sets the layer id use to find what meshes are impacted by the light.
  80765. * Inactive if 0
  80766. */
  80767. set includeOnlyWithLayerMask(value: number);
  80768. private _lightmapMode;
  80769. /**
  80770. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  80771. */
  80772. get lightmapMode(): number;
  80773. /**
  80774. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  80775. */
  80776. set lightmapMode(value: number);
  80777. /**
  80778. * Shadow generator associted to the light.
  80779. * @hidden Internal use only.
  80780. */
  80781. _shadowGenerator: Nullable<IShadowGenerator>;
  80782. /**
  80783. * @hidden Internal use only.
  80784. */
  80785. _excludedMeshesIds: string[];
  80786. /**
  80787. * @hidden Internal use only.
  80788. */
  80789. _includedOnlyMeshesIds: string[];
  80790. /**
  80791. * The current light unifom buffer.
  80792. * @hidden Internal use only.
  80793. */
  80794. _uniformBuffer: UniformBuffer;
  80795. /** @hidden */
  80796. _renderId: number;
  80797. /**
  80798. * Creates a Light object in the scene.
  80799. * Documentation : https://doc.babylonjs.com/babylon101/lights
  80800. * @param name The firendly name of the light
  80801. * @param scene The scene the light belongs too
  80802. */
  80803. constructor(name: string, scene: Scene);
  80804. protected abstract _buildUniformLayout(): void;
  80805. /**
  80806. * Sets the passed Effect "effect" with the Light information.
  80807. * @param effect The effect to update
  80808. * @param lightIndex The index of the light in the effect to update
  80809. * @returns The light
  80810. */
  80811. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  80812. /**
  80813. * Sets the passed Effect "effect" with the Light textures.
  80814. * @param effect The effect to update
  80815. * @param lightIndex The index of the light in the effect to update
  80816. * @returns The light
  80817. */
  80818. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  80819. /**
  80820. * Binds the lights information from the scene to the effect for the given mesh.
  80821. * @param lightIndex Light index
  80822. * @param scene The scene where the light belongs to
  80823. * @param effect The effect we are binding the data to
  80824. * @param useSpecular Defines if specular is supported
  80825. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  80826. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  80827. */
  80828. bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  80829. /**
  80830. * Sets the passed Effect "effect" with the Light information.
  80831. * @param effect The effect to update
  80832. * @param lightDataUniformName The uniform used to store light data (position or direction)
  80833. * @returns The light
  80834. */
  80835. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  80836. /**
  80837. * Returns the string "Light".
  80838. * @returns the class name
  80839. */
  80840. getClassName(): string;
  80841. /** @hidden */
  80842. readonly _isLight: boolean;
  80843. /**
  80844. * Converts the light information to a readable string for debug purpose.
  80845. * @param fullDetails Supports for multiple levels of logging within scene loading
  80846. * @returns the human readable light info
  80847. */
  80848. toString(fullDetails?: boolean): string;
  80849. /** @hidden */
  80850. protected _syncParentEnabledState(): void;
  80851. /**
  80852. * Set the enabled state of this node.
  80853. * @param value - the new enabled state
  80854. */
  80855. setEnabled(value: boolean): void;
  80856. /**
  80857. * Returns the Light associated shadow generator if any.
  80858. * @return the associated shadow generator.
  80859. */
  80860. getShadowGenerator(): Nullable<IShadowGenerator>;
  80861. /**
  80862. * Returns a Vector3, the absolute light position in the World.
  80863. * @returns the world space position of the light
  80864. */
  80865. getAbsolutePosition(): Vector3;
  80866. /**
  80867. * Specifies if the light will affect the passed mesh.
  80868. * @param mesh The mesh to test against the light
  80869. * @return true the mesh is affected otherwise, false.
  80870. */
  80871. canAffectMesh(mesh: AbstractMesh): boolean;
  80872. /**
  80873. * Sort function to order lights for rendering.
  80874. * @param a First Light object to compare to second.
  80875. * @param b Second Light object to compare first.
  80876. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  80877. */
  80878. static CompareLightsPriority(a: Light, b: Light): number;
  80879. /**
  80880. * Releases resources associated with this node.
  80881. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80882. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80883. */
  80884. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80885. /**
  80886. * Returns the light type ID (integer).
  80887. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  80888. */
  80889. getTypeID(): number;
  80890. /**
  80891. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  80892. * @returns the scaled intensity in intensity mode unit
  80893. */
  80894. getScaledIntensity(): number;
  80895. /**
  80896. * Returns a new Light object, named "name", from the current one.
  80897. * @param name The name of the cloned light
  80898. * @returns the new created light
  80899. */
  80900. clone(name: string): Nullable<Light>;
  80901. /**
  80902. * Serializes the current light into a Serialization object.
  80903. * @returns the serialized object.
  80904. */
  80905. serialize(): any;
  80906. /**
  80907. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  80908. * This new light is named "name" and added to the passed scene.
  80909. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  80910. * @param name The friendly name of the light
  80911. * @param scene The scene the new light will belong to
  80912. * @returns the constructor function
  80913. */
  80914. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  80915. /**
  80916. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  80917. * @param parsedLight The JSON representation of the light
  80918. * @param scene The scene to create the parsed light in
  80919. * @returns the created light after parsing
  80920. */
  80921. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  80922. private _hookArrayForExcluded;
  80923. private _hookArrayForIncludedOnly;
  80924. private _resyncMeshes;
  80925. /**
  80926. * Forces the meshes to update their light related information in their rendering used effects
  80927. * @hidden Internal Use Only
  80928. */
  80929. _markMeshesAsLightDirty(): void;
  80930. /**
  80931. * Recomputes the cached photometric scale if needed.
  80932. */
  80933. private _computePhotometricScale;
  80934. /**
  80935. * Returns the Photometric Scale according to the light type and intensity mode.
  80936. */
  80937. private _getPhotometricScale;
  80938. /**
  80939. * Reorder the light in the scene according to their defined priority.
  80940. * @hidden Internal Use Only
  80941. */
  80942. _reorderLightsInScene(): void;
  80943. /**
  80944. * Prepares the list of defines specific to the light type.
  80945. * @param defines the list of defines
  80946. * @param lightIndex defines the index of the light for the effect
  80947. */
  80948. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  80949. }
  80950. }
  80951. declare module BABYLON {
  80952. /**
  80953. * Interface used to define Action
  80954. */
  80955. export interface IAction {
  80956. /**
  80957. * Trigger for the action
  80958. */
  80959. trigger: number;
  80960. /** Options of the trigger */
  80961. triggerOptions: any;
  80962. /**
  80963. * Gets the trigger parameters
  80964. * @returns the trigger parameters
  80965. */
  80966. getTriggerParameter(): any;
  80967. /**
  80968. * Internal only - executes current action event
  80969. * @hidden
  80970. */
  80971. _executeCurrent(evt?: ActionEvent): void;
  80972. /**
  80973. * Serialize placeholder for child classes
  80974. * @param parent of child
  80975. * @returns the serialized object
  80976. */
  80977. serialize(parent: any): any;
  80978. /**
  80979. * Internal only
  80980. * @hidden
  80981. */
  80982. _prepare(): void;
  80983. /**
  80984. * Internal only - manager for action
  80985. * @hidden
  80986. */
  80987. _actionManager: AbstractActionManager;
  80988. /**
  80989. * Adds action to chain of actions, may be a DoNothingAction
  80990. * @param action defines the next action to execute
  80991. * @returns The action passed in
  80992. * @see https://www.babylonjs-playground.com/#1T30HR#0
  80993. */
  80994. then(action: IAction): IAction;
  80995. }
  80996. /**
  80997. * The action to be carried out following a trigger
  80998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  80999. */
  81000. export class Action implements IAction {
  81001. /** the trigger, with or without parameters, for the action */
  81002. triggerOptions: any;
  81003. /**
  81004. * Trigger for the action
  81005. */
  81006. trigger: number;
  81007. /**
  81008. * Internal only - manager for action
  81009. * @hidden
  81010. */
  81011. _actionManager: ActionManager;
  81012. private _nextActiveAction;
  81013. private _child;
  81014. private _condition?;
  81015. private _triggerParameter;
  81016. /**
  81017. * An event triggered prior to action being executed.
  81018. */
  81019. onBeforeExecuteObservable: Observable<Action>;
  81020. /**
  81021. * Creates a new Action
  81022. * @param triggerOptions the trigger, with or without parameters, for the action
  81023. * @param condition an optional determinant of action
  81024. */
  81025. constructor(
  81026. /** the trigger, with or without parameters, for the action */
  81027. triggerOptions: any, condition?: Condition);
  81028. /**
  81029. * Internal only
  81030. * @hidden
  81031. */
  81032. _prepare(): void;
  81033. /**
  81034. * Gets the trigger parameters
  81035. * @returns the trigger parameters
  81036. */
  81037. getTriggerParameter(): any;
  81038. /**
  81039. * Internal only - executes current action event
  81040. * @hidden
  81041. */
  81042. _executeCurrent(evt?: ActionEvent): void;
  81043. /**
  81044. * Execute placeholder for child classes
  81045. * @param evt optional action event
  81046. */
  81047. execute(evt?: ActionEvent): void;
  81048. /**
  81049. * Skips to next active action
  81050. */
  81051. skipToNextActiveAction(): void;
  81052. /**
  81053. * Adds action to chain of actions, may be a DoNothingAction
  81054. * @param action defines the next action to execute
  81055. * @returns The action passed in
  81056. * @see https://www.babylonjs-playground.com/#1T30HR#0
  81057. */
  81058. then(action: Action): Action;
  81059. /**
  81060. * Internal only
  81061. * @hidden
  81062. */
  81063. _getProperty(propertyPath: string): string;
  81064. /**
  81065. * Internal only
  81066. * @hidden
  81067. */
  81068. _getEffectiveTarget(target: any, propertyPath: string): any;
  81069. /**
  81070. * Serialize placeholder for child classes
  81071. * @param parent of child
  81072. * @returns the serialized object
  81073. */
  81074. serialize(parent: any): any;
  81075. /**
  81076. * Internal only called by serialize
  81077. * @hidden
  81078. */
  81079. protected _serialize(serializedAction: any, parent?: any): any;
  81080. /**
  81081. * Internal only
  81082. * @hidden
  81083. */
  81084. static _SerializeValueAsString: (value: any) => string;
  81085. /**
  81086. * Internal only
  81087. * @hidden
  81088. */
  81089. static _GetTargetProperty: (target: Node | Scene) => {
  81090. name: string;
  81091. targetType: string;
  81092. value: string;
  81093. };
  81094. }
  81095. }
  81096. declare module BABYLON {
  81097. /**
  81098. * A Condition applied to an Action
  81099. */
  81100. export class Condition {
  81101. /**
  81102. * Internal only - manager for action
  81103. * @hidden
  81104. */
  81105. _actionManager: ActionManager;
  81106. /**
  81107. * Internal only
  81108. * @hidden
  81109. */
  81110. _evaluationId: number;
  81111. /**
  81112. * Internal only
  81113. * @hidden
  81114. */
  81115. _currentResult: boolean;
  81116. /**
  81117. * Creates a new Condition
  81118. * @param actionManager the manager of the action the condition is applied to
  81119. */
  81120. constructor(actionManager: ActionManager);
  81121. /**
  81122. * Check if the current condition is valid
  81123. * @returns a boolean
  81124. */
  81125. isValid(): boolean;
  81126. /**
  81127. * Internal only
  81128. * @hidden
  81129. */
  81130. _getProperty(propertyPath: string): string;
  81131. /**
  81132. * Internal only
  81133. * @hidden
  81134. */
  81135. _getEffectiveTarget(target: any, propertyPath: string): any;
  81136. /**
  81137. * Serialize placeholder for child classes
  81138. * @returns the serialized object
  81139. */
  81140. serialize(): any;
  81141. /**
  81142. * Internal only
  81143. * @hidden
  81144. */
  81145. protected _serialize(serializedCondition: any): any;
  81146. }
  81147. /**
  81148. * Defines specific conditional operators as extensions of Condition
  81149. */
  81150. export class ValueCondition extends Condition {
  81151. /** path to specify the property of the target the conditional operator uses */
  81152. propertyPath: string;
  81153. /** the value compared by the conditional operator against the current value of the property */
  81154. value: any;
  81155. /** the conditional operator, default ValueCondition.IsEqual */
  81156. operator: number;
  81157. /**
  81158. * Internal only
  81159. * @hidden
  81160. */
  81161. private static _IsEqual;
  81162. /**
  81163. * Internal only
  81164. * @hidden
  81165. */
  81166. private static _IsDifferent;
  81167. /**
  81168. * Internal only
  81169. * @hidden
  81170. */
  81171. private static _IsGreater;
  81172. /**
  81173. * Internal only
  81174. * @hidden
  81175. */
  81176. private static _IsLesser;
  81177. /**
  81178. * returns the number for IsEqual
  81179. */
  81180. static get IsEqual(): number;
  81181. /**
  81182. * Returns the number for IsDifferent
  81183. */
  81184. static get IsDifferent(): number;
  81185. /**
  81186. * Returns the number for IsGreater
  81187. */
  81188. static get IsGreater(): number;
  81189. /**
  81190. * Returns the number for IsLesser
  81191. */
  81192. static get IsLesser(): number;
  81193. /**
  81194. * Internal only The action manager for the condition
  81195. * @hidden
  81196. */
  81197. _actionManager: ActionManager;
  81198. /**
  81199. * Internal only
  81200. * @hidden
  81201. */
  81202. private _target;
  81203. /**
  81204. * Internal only
  81205. * @hidden
  81206. */
  81207. private _effectiveTarget;
  81208. /**
  81209. * Internal only
  81210. * @hidden
  81211. */
  81212. private _property;
  81213. /**
  81214. * Creates a new ValueCondition
  81215. * @param actionManager manager for the action the condition applies to
  81216. * @param target for the action
  81217. * @param propertyPath path to specify the property of the target the conditional operator uses
  81218. * @param value the value compared by the conditional operator against the current value of the property
  81219. * @param operator the conditional operator, default ValueCondition.IsEqual
  81220. */
  81221. constructor(actionManager: ActionManager, target: any,
  81222. /** path to specify the property of the target the conditional operator uses */
  81223. propertyPath: string,
  81224. /** the value compared by the conditional operator against the current value of the property */
  81225. value: any,
  81226. /** the conditional operator, default ValueCondition.IsEqual */
  81227. operator?: number);
  81228. /**
  81229. * Compares the given value with the property value for the specified conditional operator
  81230. * @returns the result of the comparison
  81231. */
  81232. isValid(): boolean;
  81233. /**
  81234. * Serialize the ValueCondition into a JSON compatible object
  81235. * @returns serialization object
  81236. */
  81237. serialize(): any;
  81238. /**
  81239. * Gets the name of the conditional operator for the ValueCondition
  81240. * @param operator the conditional operator
  81241. * @returns the name
  81242. */
  81243. static GetOperatorName(operator: number): string;
  81244. }
  81245. /**
  81246. * Defines a predicate condition as an extension of Condition
  81247. */
  81248. export class PredicateCondition extends Condition {
  81249. /** defines the predicate function used to validate the condition */
  81250. predicate: () => boolean;
  81251. /**
  81252. * Internal only - manager for action
  81253. * @hidden
  81254. */
  81255. _actionManager: ActionManager;
  81256. /**
  81257. * Creates a new PredicateCondition
  81258. * @param actionManager manager for the action the condition applies to
  81259. * @param predicate defines the predicate function used to validate the condition
  81260. */
  81261. constructor(actionManager: ActionManager,
  81262. /** defines the predicate function used to validate the condition */
  81263. predicate: () => boolean);
  81264. /**
  81265. * @returns the validity of the predicate condition
  81266. */
  81267. isValid(): boolean;
  81268. }
  81269. /**
  81270. * Defines a state condition as an extension of Condition
  81271. */
  81272. export class StateCondition extends Condition {
  81273. /** Value to compare with target state */
  81274. value: string;
  81275. /**
  81276. * Internal only - manager for action
  81277. * @hidden
  81278. */
  81279. _actionManager: ActionManager;
  81280. /**
  81281. * Internal only
  81282. * @hidden
  81283. */
  81284. private _target;
  81285. /**
  81286. * Creates a new StateCondition
  81287. * @param actionManager manager for the action the condition applies to
  81288. * @param target of the condition
  81289. * @param value to compare with target state
  81290. */
  81291. constructor(actionManager: ActionManager, target: any,
  81292. /** Value to compare with target state */
  81293. value: string);
  81294. /**
  81295. * Gets a boolean indicating if the current condition is met
  81296. * @returns the validity of the state
  81297. */
  81298. isValid(): boolean;
  81299. /**
  81300. * Serialize the StateCondition into a JSON compatible object
  81301. * @returns serialization object
  81302. */
  81303. serialize(): any;
  81304. }
  81305. }
  81306. declare module BABYLON {
  81307. /**
  81308. * This defines an action responsible to toggle a boolean once triggered.
  81309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81310. */
  81311. export class SwitchBooleanAction extends Action {
  81312. /**
  81313. * The path to the boolean property in the target object
  81314. */
  81315. propertyPath: string;
  81316. private _target;
  81317. private _effectiveTarget;
  81318. private _property;
  81319. /**
  81320. * Instantiate the action
  81321. * @param triggerOptions defines the trigger options
  81322. * @param target defines the object containing the boolean
  81323. * @param propertyPath defines the path to the boolean property in the target object
  81324. * @param condition defines the trigger related conditions
  81325. */
  81326. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  81327. /** @hidden */
  81328. _prepare(): void;
  81329. /**
  81330. * Execute the action toggle the boolean value.
  81331. */
  81332. execute(): void;
  81333. /**
  81334. * Serializes the actions and its related information.
  81335. * @param parent defines the object to serialize in
  81336. * @returns the serialized object
  81337. */
  81338. serialize(parent: any): any;
  81339. }
  81340. /**
  81341. * This defines an action responsible to set a the state field of the target
  81342. * to a desired value once triggered.
  81343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81344. */
  81345. export class SetStateAction extends Action {
  81346. /**
  81347. * The value to store in the state field.
  81348. */
  81349. value: string;
  81350. private _target;
  81351. /**
  81352. * Instantiate the action
  81353. * @param triggerOptions defines the trigger options
  81354. * @param target defines the object containing the state property
  81355. * @param value defines the value to store in the state field
  81356. * @param condition defines the trigger related conditions
  81357. */
  81358. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  81359. /**
  81360. * Execute the action and store the value on the target state property.
  81361. */
  81362. execute(): void;
  81363. /**
  81364. * Serializes the actions and its related information.
  81365. * @param parent defines the object to serialize in
  81366. * @returns the serialized object
  81367. */
  81368. serialize(parent: any): any;
  81369. }
  81370. /**
  81371. * This defines an action responsible to set a property of the target
  81372. * to a desired value once triggered.
  81373. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81374. */
  81375. export class SetValueAction extends Action {
  81376. /**
  81377. * The path of the property to set in the target.
  81378. */
  81379. propertyPath: string;
  81380. /**
  81381. * The value to set in the property
  81382. */
  81383. value: any;
  81384. private _target;
  81385. private _effectiveTarget;
  81386. private _property;
  81387. /**
  81388. * Instantiate the action
  81389. * @param triggerOptions defines the trigger options
  81390. * @param target defines the object containing the property
  81391. * @param propertyPath defines the path of the property to set in the target
  81392. * @param value defines the value to set in the property
  81393. * @param condition defines the trigger related conditions
  81394. */
  81395. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  81396. /** @hidden */
  81397. _prepare(): void;
  81398. /**
  81399. * Execute the action and set the targetted property to the desired value.
  81400. */
  81401. execute(): void;
  81402. /**
  81403. * Serializes the actions and its related information.
  81404. * @param parent defines the object to serialize in
  81405. * @returns the serialized object
  81406. */
  81407. serialize(parent: any): any;
  81408. }
  81409. /**
  81410. * This defines an action responsible to increment the target value
  81411. * to a desired value once triggered.
  81412. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81413. */
  81414. export class IncrementValueAction extends Action {
  81415. /**
  81416. * The path of the property to increment in the target.
  81417. */
  81418. propertyPath: string;
  81419. /**
  81420. * The value we should increment the property by.
  81421. */
  81422. value: any;
  81423. private _target;
  81424. private _effectiveTarget;
  81425. private _property;
  81426. /**
  81427. * Instantiate the action
  81428. * @param triggerOptions defines the trigger options
  81429. * @param target defines the object containing the property
  81430. * @param propertyPath defines the path of the property to increment in the target
  81431. * @param value defines the value value we should increment the property by
  81432. * @param condition defines the trigger related conditions
  81433. */
  81434. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  81435. /** @hidden */
  81436. _prepare(): void;
  81437. /**
  81438. * Execute the action and increment the target of the value amount.
  81439. */
  81440. execute(): void;
  81441. /**
  81442. * Serializes the actions and its related information.
  81443. * @param parent defines the object to serialize in
  81444. * @returns the serialized object
  81445. */
  81446. serialize(parent: any): any;
  81447. }
  81448. /**
  81449. * This defines an action responsible to start an animation once triggered.
  81450. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81451. */
  81452. export class PlayAnimationAction extends Action {
  81453. /**
  81454. * Where the animation should start (animation frame)
  81455. */
  81456. from: number;
  81457. /**
  81458. * Where the animation should stop (animation frame)
  81459. */
  81460. to: number;
  81461. /**
  81462. * Define if the animation should loop or stop after the first play.
  81463. */
  81464. loop?: boolean;
  81465. private _target;
  81466. /**
  81467. * Instantiate the action
  81468. * @param triggerOptions defines the trigger options
  81469. * @param target defines the target animation or animation name
  81470. * @param from defines from where the animation should start (animation frame)
  81471. * @param end defines where the animation should stop (animation frame)
  81472. * @param loop defines if the animation should loop or stop after the first play
  81473. * @param condition defines the trigger related conditions
  81474. */
  81475. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  81476. /** @hidden */
  81477. _prepare(): void;
  81478. /**
  81479. * Execute the action and play the animation.
  81480. */
  81481. execute(): void;
  81482. /**
  81483. * Serializes the actions and its related information.
  81484. * @param parent defines the object to serialize in
  81485. * @returns the serialized object
  81486. */
  81487. serialize(parent: any): any;
  81488. }
  81489. /**
  81490. * This defines an action responsible to stop an animation once triggered.
  81491. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81492. */
  81493. export class StopAnimationAction extends Action {
  81494. private _target;
  81495. /**
  81496. * Instantiate the action
  81497. * @param triggerOptions defines the trigger options
  81498. * @param target defines the target animation or animation name
  81499. * @param condition defines the trigger related conditions
  81500. */
  81501. constructor(triggerOptions: any, target: any, condition?: Condition);
  81502. /** @hidden */
  81503. _prepare(): void;
  81504. /**
  81505. * Execute the action and stop the animation.
  81506. */
  81507. execute(): void;
  81508. /**
  81509. * Serializes the actions and its related information.
  81510. * @param parent defines the object to serialize in
  81511. * @returns the serialized object
  81512. */
  81513. serialize(parent: any): any;
  81514. }
  81515. /**
  81516. * This defines an action responsible that does nothing once triggered.
  81517. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81518. */
  81519. export class DoNothingAction extends Action {
  81520. /**
  81521. * Instantiate the action
  81522. * @param triggerOptions defines the trigger options
  81523. * @param condition defines the trigger related conditions
  81524. */
  81525. constructor(triggerOptions?: any, condition?: Condition);
  81526. /**
  81527. * Execute the action and do nothing.
  81528. */
  81529. execute(): void;
  81530. /**
  81531. * Serializes the actions and its related information.
  81532. * @param parent defines the object to serialize in
  81533. * @returns the serialized object
  81534. */
  81535. serialize(parent: any): any;
  81536. }
  81537. /**
  81538. * This defines an action responsible to trigger several actions once triggered.
  81539. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81540. */
  81541. export class CombineAction extends Action {
  81542. /**
  81543. * The list of aggregated animations to run.
  81544. */
  81545. children: Action[];
  81546. /**
  81547. * Instantiate the action
  81548. * @param triggerOptions defines the trigger options
  81549. * @param children defines the list of aggregated animations to run
  81550. * @param condition defines the trigger related conditions
  81551. */
  81552. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  81553. /** @hidden */
  81554. _prepare(): void;
  81555. /**
  81556. * Execute the action and executes all the aggregated actions.
  81557. */
  81558. execute(evt: ActionEvent): void;
  81559. /**
  81560. * Serializes the actions and its related information.
  81561. * @param parent defines the object to serialize in
  81562. * @returns the serialized object
  81563. */
  81564. serialize(parent: any): any;
  81565. }
  81566. /**
  81567. * This defines an action responsible to run code (external event) once triggered.
  81568. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81569. */
  81570. export class ExecuteCodeAction extends Action {
  81571. /**
  81572. * The callback function to run.
  81573. */
  81574. func: (evt: ActionEvent) => void;
  81575. /**
  81576. * Instantiate the action
  81577. * @param triggerOptions defines the trigger options
  81578. * @param func defines the callback function to run
  81579. * @param condition defines the trigger related conditions
  81580. */
  81581. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  81582. /**
  81583. * Execute the action and run the attached code.
  81584. */
  81585. execute(evt: ActionEvent): void;
  81586. }
  81587. /**
  81588. * This defines an action responsible to set the parent property of the target once triggered.
  81589. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81590. */
  81591. export class SetParentAction extends Action {
  81592. private _parent;
  81593. private _target;
  81594. /**
  81595. * Instantiate the action
  81596. * @param triggerOptions defines the trigger options
  81597. * @param target defines the target containing the parent property
  81598. * @param parent defines from where the animation should start (animation frame)
  81599. * @param condition defines the trigger related conditions
  81600. */
  81601. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  81602. /** @hidden */
  81603. _prepare(): void;
  81604. /**
  81605. * Execute the action and set the parent property.
  81606. */
  81607. execute(): void;
  81608. /**
  81609. * Serializes the actions and its related information.
  81610. * @param parent defines the object to serialize in
  81611. * @returns the serialized object
  81612. */
  81613. serialize(parent: any): any;
  81614. }
  81615. }
  81616. declare module BABYLON {
  81617. /**
  81618. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  81619. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  81620. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81621. */
  81622. export class ActionManager extends AbstractActionManager {
  81623. /**
  81624. * Nothing
  81625. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81626. */
  81627. static readonly NothingTrigger: number;
  81628. /**
  81629. * On pick
  81630. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81631. */
  81632. static readonly OnPickTrigger: number;
  81633. /**
  81634. * On left pick
  81635. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81636. */
  81637. static readonly OnLeftPickTrigger: number;
  81638. /**
  81639. * On right pick
  81640. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81641. */
  81642. static readonly OnRightPickTrigger: number;
  81643. /**
  81644. * On center pick
  81645. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81646. */
  81647. static readonly OnCenterPickTrigger: number;
  81648. /**
  81649. * On pick down
  81650. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81651. */
  81652. static readonly OnPickDownTrigger: number;
  81653. /**
  81654. * On double pick
  81655. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81656. */
  81657. static readonly OnDoublePickTrigger: number;
  81658. /**
  81659. * On pick up
  81660. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81661. */
  81662. static readonly OnPickUpTrigger: number;
  81663. /**
  81664. * On pick out.
  81665. * This trigger will only be raised if you also declared a OnPickDown
  81666. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81667. */
  81668. static readonly OnPickOutTrigger: number;
  81669. /**
  81670. * On long press
  81671. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81672. */
  81673. static readonly OnLongPressTrigger: number;
  81674. /**
  81675. * On pointer over
  81676. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81677. */
  81678. static readonly OnPointerOverTrigger: number;
  81679. /**
  81680. * On pointer out
  81681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81682. */
  81683. static readonly OnPointerOutTrigger: number;
  81684. /**
  81685. * On every frame
  81686. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81687. */
  81688. static readonly OnEveryFrameTrigger: number;
  81689. /**
  81690. * On intersection enter
  81691. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81692. */
  81693. static readonly OnIntersectionEnterTrigger: number;
  81694. /**
  81695. * On intersection exit
  81696. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81697. */
  81698. static readonly OnIntersectionExitTrigger: number;
  81699. /**
  81700. * On key down
  81701. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81702. */
  81703. static readonly OnKeyDownTrigger: number;
  81704. /**
  81705. * On key up
  81706. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81707. */
  81708. static readonly OnKeyUpTrigger: number;
  81709. private _scene;
  81710. /**
  81711. * Creates a new action manager
  81712. * @param scene defines the hosting scene
  81713. */
  81714. constructor(scene: Scene);
  81715. /**
  81716. * Releases all associated resources
  81717. */
  81718. dispose(): void;
  81719. /**
  81720. * Gets hosting scene
  81721. * @returns the hosting scene
  81722. */
  81723. getScene(): Scene;
  81724. /**
  81725. * Does this action manager handles actions of any of the given triggers
  81726. * @param triggers defines the triggers to be tested
  81727. * @return a boolean indicating whether one (or more) of the triggers is handled
  81728. */
  81729. hasSpecificTriggers(triggers: number[]): boolean;
  81730. /**
  81731. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  81732. * speed.
  81733. * @param triggerA defines the trigger to be tested
  81734. * @param triggerB defines the trigger to be tested
  81735. * @return a boolean indicating whether one (or more) of the triggers is handled
  81736. */
  81737. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  81738. /**
  81739. * Does this action manager handles actions of a given trigger
  81740. * @param trigger defines the trigger to be tested
  81741. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  81742. * @return whether the trigger is handled
  81743. */
  81744. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  81745. /**
  81746. * Does this action manager has pointer triggers
  81747. */
  81748. get hasPointerTriggers(): boolean;
  81749. /**
  81750. * Does this action manager has pick triggers
  81751. */
  81752. get hasPickTriggers(): boolean;
  81753. /**
  81754. * Registers an action to this action manager
  81755. * @param action defines the action to be registered
  81756. * @return the action amended (prepared) after registration
  81757. */
  81758. registerAction(action: IAction): Nullable<IAction>;
  81759. /**
  81760. * Unregisters an action to this action manager
  81761. * @param action defines the action to be unregistered
  81762. * @return a boolean indicating whether the action has been unregistered
  81763. */
  81764. unregisterAction(action: IAction): Boolean;
  81765. /**
  81766. * Process a specific trigger
  81767. * @param trigger defines the trigger to process
  81768. * @param evt defines the event details to be processed
  81769. */
  81770. processTrigger(trigger: number, evt?: IActionEvent): void;
  81771. /** @hidden */
  81772. _getEffectiveTarget(target: any, propertyPath: string): any;
  81773. /** @hidden */
  81774. _getProperty(propertyPath: string): string;
  81775. /**
  81776. * Serialize this manager to a JSON object
  81777. * @param name defines the property name to store this manager
  81778. * @returns a JSON representation of this manager
  81779. */
  81780. serialize(name: string): any;
  81781. /**
  81782. * Creates a new ActionManager from a JSON data
  81783. * @param parsedActions defines the JSON data to read from
  81784. * @param object defines the hosting mesh
  81785. * @param scene defines the hosting scene
  81786. */
  81787. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  81788. /**
  81789. * Get a trigger name by index
  81790. * @param trigger defines the trigger index
  81791. * @returns a trigger name
  81792. */
  81793. static GetTriggerName(trigger: number): string;
  81794. }
  81795. }
  81796. declare module BABYLON {
  81797. /**
  81798. * Class representing a ray with position and direction
  81799. */
  81800. export class Ray {
  81801. /** origin point */
  81802. origin: Vector3;
  81803. /** direction */
  81804. direction: Vector3;
  81805. /** length of the ray */
  81806. length: number;
  81807. private static readonly TmpVector3;
  81808. private _tmpRay;
  81809. /**
  81810. * Creates a new ray
  81811. * @param origin origin point
  81812. * @param direction direction
  81813. * @param length length of the ray
  81814. */
  81815. constructor(
  81816. /** origin point */
  81817. origin: Vector3,
  81818. /** direction */
  81819. direction: Vector3,
  81820. /** length of the ray */
  81821. length?: number);
  81822. /**
  81823. * Checks if the ray intersects a box
  81824. * @param minimum bound of the box
  81825. * @param maximum bound of the box
  81826. * @param intersectionTreshold extra extend to be added to the box in all direction
  81827. * @returns if the box was hit
  81828. */
  81829. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  81830. /**
  81831. * Checks if the ray intersects a box
  81832. * @param box the bounding box to check
  81833. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  81834. * @returns if the box was hit
  81835. */
  81836. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  81837. /**
  81838. * If the ray hits a sphere
  81839. * @param sphere the bounding sphere to check
  81840. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  81841. * @returns true if it hits the sphere
  81842. */
  81843. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  81844. /**
  81845. * If the ray hits a triange
  81846. * @param vertex0 triangle vertex
  81847. * @param vertex1 triangle vertex
  81848. * @param vertex2 triangle vertex
  81849. * @returns intersection information if hit
  81850. */
  81851. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  81852. /**
  81853. * Checks if ray intersects a plane
  81854. * @param plane the plane to check
  81855. * @returns the distance away it was hit
  81856. */
  81857. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  81858. /**
  81859. * Calculate the intercept of a ray on a given axis
  81860. * @param axis to check 'x' | 'y' | 'z'
  81861. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  81862. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  81863. */
  81864. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  81865. /**
  81866. * Checks if ray intersects a mesh
  81867. * @param mesh the mesh to check
  81868. * @param fastCheck if only the bounding box should checked
  81869. * @returns picking info of the intersecton
  81870. */
  81871. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  81872. /**
  81873. * Checks if ray intersects a mesh
  81874. * @param meshes the meshes to check
  81875. * @param fastCheck if only the bounding box should checked
  81876. * @param results array to store result in
  81877. * @returns Array of picking infos
  81878. */
  81879. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  81880. private _comparePickingInfo;
  81881. private static smallnum;
  81882. private static rayl;
  81883. /**
  81884. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  81885. * @param sega the first point of the segment to test the intersection against
  81886. * @param segb the second point of the segment to test the intersection against
  81887. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  81888. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  81889. */
  81890. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  81891. /**
  81892. * Update the ray from viewport position
  81893. * @param x position
  81894. * @param y y position
  81895. * @param viewportWidth viewport width
  81896. * @param viewportHeight viewport height
  81897. * @param world world matrix
  81898. * @param view view matrix
  81899. * @param projection projection matrix
  81900. * @returns this ray updated
  81901. */
  81902. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  81903. /**
  81904. * Creates a ray with origin and direction of 0,0,0
  81905. * @returns the new ray
  81906. */
  81907. static Zero(): Ray;
  81908. /**
  81909. * Creates a new ray from screen space and viewport
  81910. * @param x position
  81911. * @param y y position
  81912. * @param viewportWidth viewport width
  81913. * @param viewportHeight viewport height
  81914. * @param world world matrix
  81915. * @param view view matrix
  81916. * @param projection projection matrix
  81917. * @returns new ray
  81918. */
  81919. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  81920. /**
  81921. * 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
  81922. * transformed to the given world matrix.
  81923. * @param origin The origin point
  81924. * @param end The end point
  81925. * @param world a matrix to transform the ray to. Default is the identity matrix.
  81926. * @returns the new ray
  81927. */
  81928. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  81929. /**
  81930. * Transforms a ray by a matrix
  81931. * @param ray ray to transform
  81932. * @param matrix matrix to apply
  81933. * @returns the resulting new ray
  81934. */
  81935. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  81936. /**
  81937. * Transforms a ray by a matrix
  81938. * @param ray ray to transform
  81939. * @param matrix matrix to apply
  81940. * @param result ray to store result in
  81941. */
  81942. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  81943. /**
  81944. * Unproject a ray from screen space to object space
  81945. * @param sourceX defines the screen space x coordinate to use
  81946. * @param sourceY defines the screen space y coordinate to use
  81947. * @param viewportWidth defines the current width of the viewport
  81948. * @param viewportHeight defines the current height of the viewport
  81949. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81950. * @param view defines the view matrix to use
  81951. * @param projection defines the projection matrix to use
  81952. */
  81953. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  81954. }
  81955. /**
  81956. * Type used to define predicate used to select faces when a mesh intersection is detected
  81957. */
  81958. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  81959. interface Scene {
  81960. /** @hidden */
  81961. _tempPickingRay: Nullable<Ray>;
  81962. /** @hidden */
  81963. _cachedRayForTransform: Ray;
  81964. /** @hidden */
  81965. _pickWithRayInverseMatrix: Matrix;
  81966. /** @hidden */
  81967. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  81968. /** @hidden */
  81969. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  81970. }
  81971. }
  81972. declare module BABYLON {
  81973. /**
  81974. * Groups all the scene component constants in one place to ease maintenance.
  81975. * @hidden
  81976. */
  81977. export class SceneComponentConstants {
  81978. static readonly NAME_EFFECTLAYER: string;
  81979. static readonly NAME_LAYER: string;
  81980. static readonly NAME_LENSFLARESYSTEM: string;
  81981. static readonly NAME_BOUNDINGBOXRENDERER: string;
  81982. static readonly NAME_PARTICLESYSTEM: string;
  81983. static readonly NAME_GAMEPAD: string;
  81984. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  81985. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  81986. static readonly NAME_DEPTHRENDERER: string;
  81987. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  81988. static readonly NAME_SPRITE: string;
  81989. static readonly NAME_OUTLINERENDERER: string;
  81990. static readonly NAME_PROCEDURALTEXTURE: string;
  81991. static readonly NAME_SHADOWGENERATOR: string;
  81992. static readonly NAME_OCTREE: string;
  81993. static readonly NAME_PHYSICSENGINE: string;
  81994. static readonly NAME_AUDIO: string;
  81995. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  81996. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  81997. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  81998. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  81999. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  82000. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  82001. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  82002. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  82003. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  82004. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  82005. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  82006. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  82007. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  82008. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  82009. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  82010. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  82011. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  82012. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  82013. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  82014. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  82015. static readonly STEP_AFTERRENDER_AUDIO: number;
  82016. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  82017. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  82018. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  82019. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  82020. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  82021. static readonly STEP_POINTERMOVE_SPRITE: number;
  82022. static readonly STEP_POINTERDOWN_SPRITE: number;
  82023. static readonly STEP_POINTERUP_SPRITE: number;
  82024. }
  82025. /**
  82026. * This represents a scene component.
  82027. *
  82028. * This is used to decouple the dependency the scene is having on the different workloads like
  82029. * layers, post processes...
  82030. */
  82031. export interface ISceneComponent {
  82032. /**
  82033. * The name of the component. Each component must have a unique name.
  82034. */
  82035. name: string;
  82036. /**
  82037. * The scene the component belongs to.
  82038. */
  82039. scene: Scene;
  82040. /**
  82041. * Register the component to one instance of a scene.
  82042. */
  82043. register(): void;
  82044. /**
  82045. * Rebuilds the elements related to this component in case of
  82046. * context lost for instance.
  82047. */
  82048. rebuild(): void;
  82049. /**
  82050. * Disposes the component and the associated ressources.
  82051. */
  82052. dispose(): void;
  82053. }
  82054. /**
  82055. * This represents a SERIALIZABLE scene component.
  82056. *
  82057. * This extends Scene Component to add Serialization methods on top.
  82058. */
  82059. export interface ISceneSerializableComponent extends ISceneComponent {
  82060. /**
  82061. * Adds all the elements from the container to the scene
  82062. * @param container the container holding the elements
  82063. */
  82064. addFromContainer(container: AbstractScene): void;
  82065. /**
  82066. * Removes all the elements in the container from the scene
  82067. * @param container contains the elements to remove
  82068. * @param dispose if the removed element should be disposed (default: false)
  82069. */
  82070. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  82071. /**
  82072. * Serializes the component data to the specified json object
  82073. * @param serializationObject The object to serialize to
  82074. */
  82075. serialize(serializationObject: any): void;
  82076. }
  82077. /**
  82078. * Strong typing of a Mesh related stage step action
  82079. */
  82080. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  82081. /**
  82082. * Strong typing of a Evaluate Sub Mesh related stage step action
  82083. */
  82084. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  82085. /**
  82086. * Strong typing of a Active Mesh related stage step action
  82087. */
  82088. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  82089. /**
  82090. * Strong typing of a Camera related stage step action
  82091. */
  82092. export type CameraStageAction = (camera: Camera) => void;
  82093. /**
  82094. * Strong typing of a Camera Frame buffer related stage step action
  82095. */
  82096. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  82097. /**
  82098. * Strong typing of a Render Target related stage step action
  82099. */
  82100. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  82101. /**
  82102. * Strong typing of a RenderingGroup related stage step action
  82103. */
  82104. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  82105. /**
  82106. * Strong typing of a Mesh Render related stage step action
  82107. */
  82108. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  82109. /**
  82110. * Strong typing of a simple stage step action
  82111. */
  82112. export type SimpleStageAction = () => void;
  82113. /**
  82114. * Strong typing of a render target action.
  82115. */
  82116. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  82117. /**
  82118. * Strong typing of a pointer move action.
  82119. */
  82120. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  82121. /**
  82122. * Strong typing of a pointer up/down action.
  82123. */
  82124. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  82125. /**
  82126. * Representation of a stage in the scene (Basically a list of ordered steps)
  82127. * @hidden
  82128. */
  82129. export class Stage<T extends Function> extends Array<{
  82130. index: number;
  82131. component: ISceneComponent;
  82132. action: T;
  82133. }> {
  82134. /**
  82135. * Hide ctor from the rest of the world.
  82136. * @param items The items to add.
  82137. */
  82138. private constructor();
  82139. /**
  82140. * Creates a new Stage.
  82141. * @returns A new instance of a Stage
  82142. */
  82143. static Create<T extends Function>(): Stage<T>;
  82144. /**
  82145. * Registers a step in an ordered way in the targeted stage.
  82146. * @param index Defines the position to register the step in
  82147. * @param component Defines the component attached to the step
  82148. * @param action Defines the action to launch during the step
  82149. */
  82150. registerStep(index: number, component: ISceneComponent, action: T): void;
  82151. /**
  82152. * Clears all the steps from the stage.
  82153. */
  82154. clear(): void;
  82155. }
  82156. }
  82157. declare module BABYLON {
  82158. interface Scene {
  82159. /** @hidden */
  82160. _pointerOverSprite: Nullable<Sprite>;
  82161. /** @hidden */
  82162. _pickedDownSprite: Nullable<Sprite>;
  82163. /** @hidden */
  82164. _tempSpritePickingRay: Nullable<Ray>;
  82165. /**
  82166. * All of the sprite managers added to this scene
  82167. * @see http://doc.babylonjs.com/babylon101/sprites
  82168. */
  82169. spriteManagers: Array<ISpriteManager>;
  82170. /**
  82171. * An event triggered when sprites rendering is about to start
  82172. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  82173. */
  82174. onBeforeSpritesRenderingObservable: Observable<Scene>;
  82175. /**
  82176. * An event triggered when sprites rendering is done
  82177. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  82178. */
  82179. onAfterSpritesRenderingObservable: Observable<Scene>;
  82180. /** @hidden */
  82181. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82182. /** Launch a ray to try to pick a sprite in the scene
  82183. * @param x position on screen
  82184. * @param y position on screen
  82185. * @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
  82186. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  82187. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  82188. * @returns a PickingInfo
  82189. */
  82190. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82191. /** Use the given ray to pick a sprite in the scene
  82192. * @param ray The ray (in world space) to use to pick meshes
  82193. * @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
  82194. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  82195. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  82196. * @returns a PickingInfo
  82197. */
  82198. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82199. /** @hidden */
  82200. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82201. /** Launch a ray to try to pick sprites in the scene
  82202. * @param x position on screen
  82203. * @param y position on screen
  82204. * @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
  82205. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  82206. * @returns a PickingInfo array
  82207. */
  82208. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82209. /** Use the given ray to pick sprites in the scene
  82210. * @param ray The ray (in world space) to use to pick meshes
  82211. * @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
  82212. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  82213. * @returns a PickingInfo array
  82214. */
  82215. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82216. /**
  82217. * Force the sprite under the pointer
  82218. * @param sprite defines the sprite to use
  82219. */
  82220. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  82221. /**
  82222. * Gets the sprite under the pointer
  82223. * @returns a Sprite or null if no sprite is under the pointer
  82224. */
  82225. getPointerOverSprite(): Nullable<Sprite>;
  82226. }
  82227. /**
  82228. * Defines the sprite scene component responsible to manage sprites
  82229. * in a given scene.
  82230. */
  82231. export class SpriteSceneComponent implements ISceneComponent {
  82232. /**
  82233. * The component name helpfull to identify the component in the list of scene components.
  82234. */
  82235. readonly name: string;
  82236. /**
  82237. * The scene the component belongs to.
  82238. */
  82239. scene: Scene;
  82240. /** @hidden */
  82241. private _spritePredicate;
  82242. /**
  82243. * Creates a new instance of the component for the given scene
  82244. * @param scene Defines the scene to register the component in
  82245. */
  82246. constructor(scene: Scene);
  82247. /**
  82248. * Registers the component in a given scene
  82249. */
  82250. register(): void;
  82251. /**
  82252. * Rebuilds the elements related to this component in case of
  82253. * context lost for instance.
  82254. */
  82255. rebuild(): void;
  82256. /**
  82257. * Disposes the component and the associated ressources.
  82258. */
  82259. dispose(): void;
  82260. private _pickSpriteButKeepRay;
  82261. private _pointerMove;
  82262. private _pointerDown;
  82263. private _pointerUp;
  82264. }
  82265. }
  82266. declare module BABYLON {
  82267. /** @hidden */
  82268. export var fogFragmentDeclaration: {
  82269. name: string;
  82270. shader: string;
  82271. };
  82272. }
  82273. declare module BABYLON {
  82274. /** @hidden */
  82275. export var fogFragment: {
  82276. name: string;
  82277. shader: string;
  82278. };
  82279. }
  82280. declare module BABYLON {
  82281. /** @hidden */
  82282. export var spritesPixelShader: {
  82283. name: string;
  82284. shader: string;
  82285. };
  82286. }
  82287. declare module BABYLON {
  82288. /** @hidden */
  82289. export var fogVertexDeclaration: {
  82290. name: string;
  82291. shader: string;
  82292. };
  82293. }
  82294. declare module BABYLON {
  82295. /** @hidden */
  82296. export var spritesVertexShader: {
  82297. name: string;
  82298. shader: string;
  82299. };
  82300. }
  82301. declare module BABYLON {
  82302. /**
  82303. * Defines the minimum interface to fullfil in order to be a sprite manager.
  82304. */
  82305. export interface ISpriteManager extends IDisposable {
  82306. /**
  82307. * Restricts the camera to viewing objects with the same layerMask.
  82308. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  82309. */
  82310. layerMask: number;
  82311. /**
  82312. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  82313. */
  82314. isPickable: boolean;
  82315. /**
  82316. * Specifies the rendering group id for this mesh (0 by default)
  82317. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  82318. */
  82319. renderingGroupId: number;
  82320. /**
  82321. * Defines the list of sprites managed by the manager.
  82322. */
  82323. sprites: Array<Sprite>;
  82324. /**
  82325. * Tests the intersection of a sprite with a specific ray.
  82326. * @param ray The ray we are sending to test the collision
  82327. * @param camera The camera space we are sending rays in
  82328. * @param predicate A predicate allowing excluding sprites from the list of object to test
  82329. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  82330. * @returns picking info or null.
  82331. */
  82332. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  82333. /**
  82334. * Intersects the sprites with a ray
  82335. * @param ray defines the ray to intersect with
  82336. * @param camera defines the current active camera
  82337. * @param predicate defines a predicate used to select candidate sprites
  82338. * @returns null if no hit or a PickingInfo array
  82339. */
  82340. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  82341. /**
  82342. * Renders the list of sprites on screen.
  82343. */
  82344. render(): void;
  82345. }
  82346. /**
  82347. * Class used to manage multiple sprites on the same spritesheet
  82348. * @see http://doc.babylonjs.com/babylon101/sprites
  82349. */
  82350. export class SpriteManager implements ISpriteManager {
  82351. /** defines the manager's name */
  82352. name: string;
  82353. /** Gets the list of sprites */
  82354. sprites: Sprite[];
  82355. /** Gets or sets the rendering group id (0 by default) */
  82356. renderingGroupId: number;
  82357. /** Gets or sets camera layer mask */
  82358. layerMask: number;
  82359. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  82360. fogEnabled: boolean;
  82361. /** Gets or sets a boolean indicating if the sprites are pickable */
  82362. isPickable: boolean;
  82363. /** Defines the default width of a cell in the spritesheet */
  82364. cellWidth: number;
  82365. /** Defines the default height of a cell in the spritesheet */
  82366. cellHeight: number;
  82367. /** Associative array from JSON sprite data file */
  82368. private _cellData;
  82369. /** Array of sprite names from JSON sprite data file */
  82370. private _spriteMap;
  82371. /** True when packed cell data from JSON file is ready*/
  82372. private _packedAndReady;
  82373. /**
  82374. * An event triggered when the manager is disposed.
  82375. */
  82376. onDisposeObservable: Observable<SpriteManager>;
  82377. private _onDisposeObserver;
  82378. /**
  82379. * Callback called when the manager is disposed
  82380. */
  82381. set onDispose(callback: () => void);
  82382. private _capacity;
  82383. private _fromPacked;
  82384. private _spriteTexture;
  82385. private _epsilon;
  82386. private _scene;
  82387. private _vertexData;
  82388. private _buffer;
  82389. private _vertexBuffers;
  82390. private _indexBuffer;
  82391. private _effectBase;
  82392. private _effectFog;
  82393. /**
  82394. * Gets or sets the spritesheet texture
  82395. */
  82396. get texture(): Texture;
  82397. set texture(value: Texture);
  82398. /**
  82399. * Creates a new sprite manager
  82400. * @param name defines the manager's name
  82401. * @param imgUrl defines the sprite sheet url
  82402. * @param capacity defines the maximum allowed number of sprites
  82403. * @param cellSize defines the size of a sprite cell
  82404. * @param scene defines the hosting scene
  82405. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  82406. * @param samplingMode defines the smapling mode to use with spritesheet
  82407. * @param fromPacked set to false; do not alter
  82408. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  82409. */
  82410. constructor(
  82411. /** defines the manager's name */
  82412. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  82413. private _makePacked;
  82414. private _appendSpriteVertex;
  82415. /**
  82416. * Intersects the sprites with a ray
  82417. * @param ray defines the ray to intersect with
  82418. * @param camera defines the current active camera
  82419. * @param predicate defines a predicate used to select candidate sprites
  82420. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  82421. * @returns null if no hit or a PickingInfo
  82422. */
  82423. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  82424. /**
  82425. * Intersects the sprites with a ray
  82426. * @param ray defines the ray to intersect with
  82427. * @param camera defines the current active camera
  82428. * @param predicate defines a predicate used to select candidate sprites
  82429. * @returns null if no hit or a PickingInfo array
  82430. */
  82431. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  82432. /**
  82433. * Render all child sprites
  82434. */
  82435. render(): void;
  82436. /**
  82437. * Release associated resources
  82438. */
  82439. dispose(): void;
  82440. }
  82441. }
  82442. declare module BABYLON {
  82443. /**
  82444. * Class used to represent a sprite
  82445. * @see http://doc.babylonjs.com/babylon101/sprites
  82446. */
  82447. export class Sprite {
  82448. /** defines the name */
  82449. name: string;
  82450. /** Gets or sets the current world position */
  82451. position: Vector3;
  82452. /** Gets or sets the main color */
  82453. color: Color4;
  82454. /** Gets or sets the width */
  82455. width: number;
  82456. /** Gets or sets the height */
  82457. height: number;
  82458. /** Gets or sets rotation angle */
  82459. angle: number;
  82460. /** Gets or sets the cell index in the sprite sheet */
  82461. cellIndex: number;
  82462. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  82463. cellRef: string;
  82464. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  82465. invertU: number;
  82466. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  82467. invertV: number;
  82468. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  82469. disposeWhenFinishedAnimating: boolean;
  82470. /** Gets the list of attached animations */
  82471. animations: Animation[];
  82472. /** Gets or sets a boolean indicating if the sprite can be picked */
  82473. isPickable: boolean;
  82474. /**
  82475. * Gets or sets the associated action manager
  82476. */
  82477. actionManager: Nullable<ActionManager>;
  82478. private _animationStarted;
  82479. private _loopAnimation;
  82480. private _fromIndex;
  82481. private _toIndex;
  82482. private _delay;
  82483. private _direction;
  82484. private _manager;
  82485. private _time;
  82486. private _onAnimationEnd;
  82487. /**
  82488. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  82489. */
  82490. isVisible: boolean;
  82491. /**
  82492. * Gets or sets the sprite size
  82493. */
  82494. get size(): number;
  82495. set size(value: number);
  82496. /**
  82497. * Creates a new Sprite
  82498. * @param name defines the name
  82499. * @param manager defines the manager
  82500. */
  82501. constructor(
  82502. /** defines the name */
  82503. name: string, manager: ISpriteManager);
  82504. /**
  82505. * Starts an animation
  82506. * @param from defines the initial key
  82507. * @param to defines the end key
  82508. * @param loop defines if the animation must loop
  82509. * @param delay defines the start delay (in ms)
  82510. * @param onAnimationEnd defines a callback to call when animation ends
  82511. */
  82512. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  82513. /** Stops current animation (if any) */
  82514. stopAnimation(): void;
  82515. /** @hidden */
  82516. _animate(deltaTime: number): void;
  82517. /** Release associated resources */
  82518. dispose(): void;
  82519. }
  82520. }
  82521. declare module BABYLON {
  82522. /**
  82523. * Information about the result of picking within a scene
  82524. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  82525. */
  82526. export class PickingInfo {
  82527. /** @hidden */
  82528. _pickingUnavailable: boolean;
  82529. /**
  82530. * If the pick collided with an object
  82531. */
  82532. hit: boolean;
  82533. /**
  82534. * Distance away where the pick collided
  82535. */
  82536. distance: number;
  82537. /**
  82538. * The location of pick collision
  82539. */
  82540. pickedPoint: Nullable<Vector3>;
  82541. /**
  82542. * The mesh corresponding the the pick collision
  82543. */
  82544. pickedMesh: Nullable<AbstractMesh>;
  82545. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  82546. bu: number;
  82547. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  82548. bv: number;
  82549. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  82550. faceId: number;
  82551. /** Id of the the submesh that was picked */
  82552. subMeshId: number;
  82553. /** If a sprite was picked, this will be the sprite the pick collided with */
  82554. pickedSprite: Nullable<Sprite>;
  82555. /**
  82556. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  82557. */
  82558. originMesh: Nullable<AbstractMesh>;
  82559. /**
  82560. * The ray that was used to perform the picking.
  82561. */
  82562. ray: Nullable<Ray>;
  82563. /**
  82564. * Gets the normal correspodning to the face the pick collided with
  82565. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  82566. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  82567. * @returns The normal correspodning to the face the pick collided with
  82568. */
  82569. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  82570. /**
  82571. * Gets the texture coordinates of where the pick occured
  82572. * @returns the vector containing the coordnates of the texture
  82573. */
  82574. getTextureCoordinates(): Nullable<Vector2>;
  82575. }
  82576. }
  82577. declare module BABYLON {
  82578. /**
  82579. * Gather the list of pointer event types as constants.
  82580. */
  82581. export class PointerEventTypes {
  82582. /**
  82583. * 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.
  82584. */
  82585. static readonly POINTERDOWN: number;
  82586. /**
  82587. * The pointerup event is fired when a pointer is no longer active.
  82588. */
  82589. static readonly POINTERUP: number;
  82590. /**
  82591. * The pointermove event is fired when a pointer changes coordinates.
  82592. */
  82593. static readonly POINTERMOVE: number;
  82594. /**
  82595. * The pointerwheel event is fired when a mouse wheel has been rotated.
  82596. */
  82597. static readonly POINTERWHEEL: number;
  82598. /**
  82599. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  82600. */
  82601. static readonly POINTERPICK: number;
  82602. /**
  82603. * The pointertap event is fired when a the object has been touched and released without drag.
  82604. */
  82605. static readonly POINTERTAP: number;
  82606. /**
  82607. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  82608. */
  82609. static readonly POINTERDOUBLETAP: number;
  82610. }
  82611. /**
  82612. * Base class of pointer info types.
  82613. */
  82614. export class PointerInfoBase {
  82615. /**
  82616. * Defines the type of event (PointerEventTypes)
  82617. */
  82618. type: number;
  82619. /**
  82620. * Defines the related dom event
  82621. */
  82622. event: PointerEvent | MouseWheelEvent;
  82623. /**
  82624. * Instantiates the base class of pointers info.
  82625. * @param type Defines the type of event (PointerEventTypes)
  82626. * @param event Defines the related dom event
  82627. */
  82628. constructor(
  82629. /**
  82630. * Defines the type of event (PointerEventTypes)
  82631. */
  82632. type: number,
  82633. /**
  82634. * Defines the related dom event
  82635. */
  82636. event: PointerEvent | MouseWheelEvent);
  82637. }
  82638. /**
  82639. * This class is used to store pointer related info for the onPrePointerObservable event.
  82640. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  82641. */
  82642. export class PointerInfoPre extends PointerInfoBase {
  82643. /**
  82644. * Ray from a pointer if availible (eg. 6dof controller)
  82645. */
  82646. ray: Nullable<Ray>;
  82647. /**
  82648. * Defines the local position of the pointer on the canvas.
  82649. */
  82650. localPosition: Vector2;
  82651. /**
  82652. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  82653. */
  82654. skipOnPointerObservable: boolean;
  82655. /**
  82656. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  82657. * @param type Defines the type of event (PointerEventTypes)
  82658. * @param event Defines the related dom event
  82659. * @param localX Defines the local x coordinates of the pointer when the event occured
  82660. * @param localY Defines the local y coordinates of the pointer when the event occured
  82661. */
  82662. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  82663. }
  82664. /**
  82665. * This type contains all the data related to a pointer event in Babylon.js.
  82666. * 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.
  82667. */
  82668. export class PointerInfo extends PointerInfoBase {
  82669. /**
  82670. * Defines the picking info associated to the info (if any)\
  82671. */
  82672. pickInfo: Nullable<PickingInfo>;
  82673. /**
  82674. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  82675. * @param type Defines the type of event (PointerEventTypes)
  82676. * @param event Defines the related dom event
  82677. * @param pickInfo Defines the picking info associated to the info (if any)\
  82678. */
  82679. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  82680. /**
  82681. * Defines the picking info associated to the info (if any)\
  82682. */
  82683. pickInfo: Nullable<PickingInfo>);
  82684. }
  82685. /**
  82686. * Data relating to a touch event on the screen.
  82687. */
  82688. export interface PointerTouch {
  82689. /**
  82690. * X coordinate of touch.
  82691. */
  82692. x: number;
  82693. /**
  82694. * Y coordinate of touch.
  82695. */
  82696. y: number;
  82697. /**
  82698. * Id of touch. Unique for each finger.
  82699. */
  82700. pointerId: number;
  82701. /**
  82702. * Event type passed from DOM.
  82703. */
  82704. type: any;
  82705. }
  82706. }
  82707. declare module BABYLON {
  82708. /**
  82709. * Manage the mouse inputs to control the movement of a free camera.
  82710. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82711. */
  82712. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  82713. /**
  82714. * Define if touch is enabled in the mouse input
  82715. */
  82716. touchEnabled: boolean;
  82717. /**
  82718. * Defines the camera the input is attached to.
  82719. */
  82720. camera: FreeCamera;
  82721. /**
  82722. * Defines the buttons associated with the input to handle camera move.
  82723. */
  82724. buttons: number[];
  82725. /**
  82726. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  82727. */
  82728. angularSensibility: number;
  82729. private _pointerInput;
  82730. private _onMouseMove;
  82731. private _observer;
  82732. private previousPosition;
  82733. /**
  82734. * Observable for when a pointer move event occurs containing the move offset
  82735. */
  82736. onPointerMovedObservable: Observable<{
  82737. offsetX: number;
  82738. offsetY: number;
  82739. }>;
  82740. /**
  82741. * @hidden
  82742. * If the camera should be rotated automatically based on pointer movement
  82743. */
  82744. _allowCameraRotation: boolean;
  82745. /**
  82746. * Manage the mouse inputs to control the movement of a free camera.
  82747. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82748. * @param touchEnabled Defines if touch is enabled or not
  82749. */
  82750. constructor(
  82751. /**
  82752. * Define if touch is enabled in the mouse input
  82753. */
  82754. touchEnabled?: boolean);
  82755. /**
  82756. * Attach the input controls to a specific dom element to get the input from.
  82757. * @param element Defines the element the controls should be listened from
  82758. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82759. */
  82760. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82761. /**
  82762. * Called on JS contextmenu event.
  82763. * Override this method to provide functionality.
  82764. */
  82765. protected onContextMenu(evt: PointerEvent): void;
  82766. /**
  82767. * Detach the current controls from the specified dom element.
  82768. * @param element Defines the element to stop listening the inputs from
  82769. */
  82770. detachControl(element: Nullable<HTMLElement>): void;
  82771. /**
  82772. * Gets the class name of the current intput.
  82773. * @returns the class name
  82774. */
  82775. getClassName(): string;
  82776. /**
  82777. * Get the friendly name associated with the input class.
  82778. * @returns the input friendly name
  82779. */
  82780. getSimpleName(): string;
  82781. }
  82782. }
  82783. declare module BABYLON {
  82784. /**
  82785. * Manage the touch inputs to control the movement of a free camera.
  82786. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82787. */
  82788. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  82789. /**
  82790. * Defines the camera the input is attached to.
  82791. */
  82792. camera: FreeCamera;
  82793. /**
  82794. * Defines the touch sensibility for rotation.
  82795. * The higher the faster.
  82796. */
  82797. touchAngularSensibility: number;
  82798. /**
  82799. * Defines the touch sensibility for move.
  82800. * The higher the faster.
  82801. */
  82802. touchMoveSensibility: number;
  82803. private _offsetX;
  82804. private _offsetY;
  82805. private _pointerPressed;
  82806. private _pointerInput;
  82807. private _observer;
  82808. private _onLostFocus;
  82809. /**
  82810. * Attach the input controls to a specific dom element to get the input from.
  82811. * @param element Defines the element the controls should be listened from
  82812. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82813. */
  82814. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82815. /**
  82816. * Detach the current controls from the specified dom element.
  82817. * @param element Defines the element to stop listening the inputs from
  82818. */
  82819. detachControl(element: Nullable<HTMLElement>): void;
  82820. /**
  82821. * Update the current camera state depending on the inputs that have been used this frame.
  82822. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82823. */
  82824. checkInputs(): void;
  82825. /**
  82826. * Gets the class name of the current intput.
  82827. * @returns the class name
  82828. */
  82829. getClassName(): string;
  82830. /**
  82831. * Get the friendly name associated with the input class.
  82832. * @returns the input friendly name
  82833. */
  82834. getSimpleName(): string;
  82835. }
  82836. }
  82837. declare module BABYLON {
  82838. /**
  82839. * Default Inputs manager for the FreeCamera.
  82840. * It groups all the default supported inputs for ease of use.
  82841. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82842. */
  82843. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  82844. /**
  82845. * @hidden
  82846. */
  82847. _mouseInput: Nullable<FreeCameraMouseInput>;
  82848. /**
  82849. * Instantiates a new FreeCameraInputsManager.
  82850. * @param camera Defines the camera the inputs belong to
  82851. */
  82852. constructor(camera: FreeCamera);
  82853. /**
  82854. * Add keyboard input support to the input manager.
  82855. * @returns the current input manager
  82856. */
  82857. addKeyboard(): FreeCameraInputsManager;
  82858. /**
  82859. * Add mouse input support to the input manager.
  82860. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  82861. * @returns the current input manager
  82862. */
  82863. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  82864. /**
  82865. * Removes the mouse input support from the manager
  82866. * @returns the current input manager
  82867. */
  82868. removeMouse(): FreeCameraInputsManager;
  82869. /**
  82870. * Add touch input support to the input manager.
  82871. * @returns the current input manager
  82872. */
  82873. addTouch(): FreeCameraInputsManager;
  82874. /**
  82875. * Remove all attached input methods from a camera
  82876. */
  82877. clear(): void;
  82878. }
  82879. }
  82880. declare module BABYLON {
  82881. /**
  82882. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  82883. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  82884. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  82885. */
  82886. export class FreeCamera extends TargetCamera {
  82887. /**
  82888. * Define the collision ellipsoid of the camera.
  82889. * This is helpful to simulate a camera body like the player body around the camera
  82890. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  82891. */
  82892. ellipsoid: Vector3;
  82893. /**
  82894. * Define an offset for the position of the ellipsoid around the camera.
  82895. * This can be helpful to determine the center of the body near the gravity center of the body
  82896. * instead of its head.
  82897. */
  82898. ellipsoidOffset: Vector3;
  82899. /**
  82900. * Enable or disable collisions of the camera with the rest of the scene objects.
  82901. */
  82902. checkCollisions: boolean;
  82903. /**
  82904. * Enable or disable gravity on the camera.
  82905. */
  82906. applyGravity: boolean;
  82907. /**
  82908. * Define the input manager associated to the camera.
  82909. */
  82910. inputs: FreeCameraInputsManager;
  82911. /**
  82912. * Gets the input sensibility for a mouse input. (default is 2000.0)
  82913. * Higher values reduce sensitivity.
  82914. */
  82915. get angularSensibility(): number;
  82916. /**
  82917. * Sets the input sensibility for a mouse input. (default is 2000.0)
  82918. * Higher values reduce sensitivity.
  82919. */
  82920. set angularSensibility(value: number);
  82921. /**
  82922. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  82923. */
  82924. get keysUp(): number[];
  82925. set keysUp(value: number[]);
  82926. /**
  82927. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  82928. */
  82929. get keysDown(): number[];
  82930. set keysDown(value: number[]);
  82931. /**
  82932. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  82933. */
  82934. get keysLeft(): number[];
  82935. set keysLeft(value: number[]);
  82936. /**
  82937. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  82938. */
  82939. get keysRight(): number[];
  82940. set keysRight(value: number[]);
  82941. /**
  82942. * Event raised when the camera collide with a mesh in the scene.
  82943. */
  82944. onCollide: (collidedMesh: AbstractMesh) => void;
  82945. private _collider;
  82946. private _needMoveForGravity;
  82947. private _oldPosition;
  82948. private _diffPosition;
  82949. private _newPosition;
  82950. /** @hidden */
  82951. _localDirection: Vector3;
  82952. /** @hidden */
  82953. _transformedDirection: Vector3;
  82954. /**
  82955. * Instantiates a Free Camera.
  82956. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  82957. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  82958. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  82959. * @param name Define the name of the camera in the scene
  82960. * @param position Define the start position of the camera in the scene
  82961. * @param scene Define the scene the camera belongs to
  82962. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  82963. */
  82964. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  82965. /**
  82966. * Attached controls to the current camera.
  82967. * @param element Defines the element the controls should be listened from
  82968. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82969. */
  82970. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82971. /**
  82972. * Detach the current controls from the camera.
  82973. * The camera will stop reacting to inputs.
  82974. * @param element Defines the element to stop listening the inputs from
  82975. */
  82976. detachControl(element: HTMLElement): void;
  82977. private _collisionMask;
  82978. /**
  82979. * Define a collision mask to limit the list of object the camera can collide with
  82980. */
  82981. get collisionMask(): number;
  82982. set collisionMask(mask: number);
  82983. /** @hidden */
  82984. _collideWithWorld(displacement: Vector3): void;
  82985. private _onCollisionPositionChange;
  82986. /** @hidden */
  82987. _checkInputs(): void;
  82988. /** @hidden */
  82989. _decideIfNeedsToMove(): boolean;
  82990. /** @hidden */
  82991. _updatePosition(): void;
  82992. /**
  82993. * Destroy the camera and release the current resources hold by it.
  82994. */
  82995. dispose(): void;
  82996. /**
  82997. * Gets the current object class name.
  82998. * @return the class name
  82999. */
  83000. getClassName(): string;
  83001. }
  83002. }
  83003. declare module BABYLON {
  83004. /**
  83005. * Represents a gamepad control stick position
  83006. */
  83007. export class StickValues {
  83008. /**
  83009. * The x component of the control stick
  83010. */
  83011. x: number;
  83012. /**
  83013. * The y component of the control stick
  83014. */
  83015. y: number;
  83016. /**
  83017. * Initializes the gamepad x and y control stick values
  83018. * @param x The x component of the gamepad control stick value
  83019. * @param y The y component of the gamepad control stick value
  83020. */
  83021. constructor(
  83022. /**
  83023. * The x component of the control stick
  83024. */
  83025. x: number,
  83026. /**
  83027. * The y component of the control stick
  83028. */
  83029. y: number);
  83030. }
  83031. /**
  83032. * An interface which manages callbacks for gamepad button changes
  83033. */
  83034. export interface GamepadButtonChanges {
  83035. /**
  83036. * Called when a gamepad has been changed
  83037. */
  83038. changed: boolean;
  83039. /**
  83040. * Called when a gamepad press event has been triggered
  83041. */
  83042. pressChanged: boolean;
  83043. /**
  83044. * Called when a touch event has been triggered
  83045. */
  83046. touchChanged: boolean;
  83047. /**
  83048. * Called when a value has changed
  83049. */
  83050. valueChanged: boolean;
  83051. }
  83052. /**
  83053. * Represents a gamepad
  83054. */
  83055. export class Gamepad {
  83056. /**
  83057. * The id of the gamepad
  83058. */
  83059. id: string;
  83060. /**
  83061. * The index of the gamepad
  83062. */
  83063. index: number;
  83064. /**
  83065. * The browser gamepad
  83066. */
  83067. browserGamepad: any;
  83068. /**
  83069. * Specifies what type of gamepad this represents
  83070. */
  83071. type: number;
  83072. private _leftStick;
  83073. private _rightStick;
  83074. /** @hidden */
  83075. _isConnected: boolean;
  83076. private _leftStickAxisX;
  83077. private _leftStickAxisY;
  83078. private _rightStickAxisX;
  83079. private _rightStickAxisY;
  83080. /**
  83081. * Triggered when the left control stick has been changed
  83082. */
  83083. private _onleftstickchanged;
  83084. /**
  83085. * Triggered when the right control stick has been changed
  83086. */
  83087. private _onrightstickchanged;
  83088. /**
  83089. * Represents a gamepad controller
  83090. */
  83091. static GAMEPAD: number;
  83092. /**
  83093. * Represents a generic controller
  83094. */
  83095. static GENERIC: number;
  83096. /**
  83097. * Represents an XBox controller
  83098. */
  83099. static XBOX: number;
  83100. /**
  83101. * Represents a pose-enabled controller
  83102. */
  83103. static POSE_ENABLED: number;
  83104. /**
  83105. * Represents an Dual Shock controller
  83106. */
  83107. static DUALSHOCK: number;
  83108. /**
  83109. * Specifies whether the left control stick should be Y-inverted
  83110. */
  83111. protected _invertLeftStickY: boolean;
  83112. /**
  83113. * Specifies if the gamepad has been connected
  83114. */
  83115. get isConnected(): boolean;
  83116. /**
  83117. * Initializes the gamepad
  83118. * @param id The id of the gamepad
  83119. * @param index The index of the gamepad
  83120. * @param browserGamepad The browser gamepad
  83121. * @param leftStickX The x component of the left joystick
  83122. * @param leftStickY The y component of the left joystick
  83123. * @param rightStickX The x component of the right joystick
  83124. * @param rightStickY The y component of the right joystick
  83125. */
  83126. constructor(
  83127. /**
  83128. * The id of the gamepad
  83129. */
  83130. id: string,
  83131. /**
  83132. * The index of the gamepad
  83133. */
  83134. index: number,
  83135. /**
  83136. * The browser gamepad
  83137. */
  83138. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  83139. /**
  83140. * Callback triggered when the left joystick has changed
  83141. * @param callback
  83142. */
  83143. onleftstickchanged(callback: (values: StickValues) => void): void;
  83144. /**
  83145. * Callback triggered when the right joystick has changed
  83146. * @param callback
  83147. */
  83148. onrightstickchanged(callback: (values: StickValues) => void): void;
  83149. /**
  83150. * Gets the left joystick
  83151. */
  83152. get leftStick(): StickValues;
  83153. /**
  83154. * Sets the left joystick values
  83155. */
  83156. set leftStick(newValues: StickValues);
  83157. /**
  83158. * Gets the right joystick
  83159. */
  83160. get rightStick(): StickValues;
  83161. /**
  83162. * Sets the right joystick value
  83163. */
  83164. set rightStick(newValues: StickValues);
  83165. /**
  83166. * Updates the gamepad joystick positions
  83167. */
  83168. update(): void;
  83169. /**
  83170. * Disposes the gamepad
  83171. */
  83172. dispose(): void;
  83173. }
  83174. /**
  83175. * Represents a generic gamepad
  83176. */
  83177. export class GenericPad extends Gamepad {
  83178. private _buttons;
  83179. private _onbuttondown;
  83180. private _onbuttonup;
  83181. /**
  83182. * Observable triggered when a button has been pressed
  83183. */
  83184. onButtonDownObservable: Observable<number>;
  83185. /**
  83186. * Observable triggered when a button has been released
  83187. */
  83188. onButtonUpObservable: Observable<number>;
  83189. /**
  83190. * Callback triggered when a button has been pressed
  83191. * @param callback Called when a button has been pressed
  83192. */
  83193. onbuttondown(callback: (buttonPressed: number) => void): void;
  83194. /**
  83195. * Callback triggered when a button has been released
  83196. * @param callback Called when a button has been released
  83197. */
  83198. onbuttonup(callback: (buttonReleased: number) => void): void;
  83199. /**
  83200. * Initializes the generic gamepad
  83201. * @param id The id of the generic gamepad
  83202. * @param index The index of the generic gamepad
  83203. * @param browserGamepad The browser gamepad
  83204. */
  83205. constructor(id: string, index: number, browserGamepad: any);
  83206. private _setButtonValue;
  83207. /**
  83208. * Updates the generic gamepad
  83209. */
  83210. update(): void;
  83211. /**
  83212. * Disposes the generic gamepad
  83213. */
  83214. dispose(): void;
  83215. }
  83216. }
  83217. declare module BABYLON {
  83218. interface Engine {
  83219. /**
  83220. * Creates a raw texture
  83221. * @param data defines the data to store in the texture
  83222. * @param width defines the width of the texture
  83223. * @param height defines the height of the texture
  83224. * @param format defines the format of the data
  83225. * @param generateMipMaps defines if the engine should generate the mip levels
  83226. * @param invertY defines if data must be stored with Y axis inverted
  83227. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83228. * @param compression defines the compression used (null by default)
  83229. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83230. * @returns the raw texture inside an InternalTexture
  83231. */
  83232. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  83233. /**
  83234. * Update a raw texture
  83235. * @param texture defines the texture to update
  83236. * @param data defines the data to store in the texture
  83237. * @param format defines the format of the data
  83238. * @param invertY defines if data must be stored with Y axis inverted
  83239. */
  83240. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83241. /**
  83242. * Update a raw texture
  83243. * @param texture defines the texture to update
  83244. * @param data defines the data to store in the texture
  83245. * @param format defines the format of the data
  83246. * @param invertY defines if data must be stored with Y axis inverted
  83247. * @param compression defines the compression used (null by default)
  83248. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83249. */
  83250. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  83251. /**
  83252. * Creates a new raw cube texture
  83253. * @param data defines the array of data to use to create each face
  83254. * @param size defines the size of the textures
  83255. * @param format defines the format of the data
  83256. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83257. * @param generateMipMaps defines if the engine should generate the mip levels
  83258. * @param invertY defines if data must be stored with Y axis inverted
  83259. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83260. * @param compression defines the compression used (null by default)
  83261. * @returns the cube texture as an InternalTexture
  83262. */
  83263. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  83264. /**
  83265. * Update a raw cube texture
  83266. * @param texture defines the texture to udpdate
  83267. * @param data defines the data to store
  83268. * @param format defines the data format
  83269. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83270. * @param invertY defines if data must be stored with Y axis inverted
  83271. */
  83272. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  83273. /**
  83274. * Update a raw cube texture
  83275. * @param texture defines the texture to udpdate
  83276. * @param data defines the data to store
  83277. * @param format defines the data format
  83278. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83279. * @param invertY defines if data must be stored with Y axis inverted
  83280. * @param compression defines the compression used (null by default)
  83281. */
  83282. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  83283. /**
  83284. * Update a raw cube texture
  83285. * @param texture defines the texture to udpdate
  83286. * @param data defines the data to store
  83287. * @param format defines the data format
  83288. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83289. * @param invertY defines if data must be stored with Y axis inverted
  83290. * @param compression defines the compression used (null by default)
  83291. * @param level defines which level of the texture to update
  83292. */
  83293. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  83294. /**
  83295. * Creates a new raw cube texture from a specified url
  83296. * @param url defines the url where the data is located
  83297. * @param scene defines the current scene
  83298. * @param size defines the size of the textures
  83299. * @param format defines the format of the data
  83300. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83301. * @param noMipmap defines if the engine should avoid generating the mip levels
  83302. * @param callback defines a callback used to extract texture data from loaded data
  83303. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83304. * @param onLoad defines a callback called when texture is loaded
  83305. * @param onError defines a callback called if there is an error
  83306. * @returns the cube texture as an InternalTexture
  83307. */
  83308. 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;
  83309. /**
  83310. * Creates a new raw cube texture from a specified url
  83311. * @param url defines the url where the data is located
  83312. * @param scene defines the current scene
  83313. * @param size defines the size of the textures
  83314. * @param format defines the format of the data
  83315. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83316. * @param noMipmap defines if the engine should avoid generating the mip levels
  83317. * @param callback defines a callback used to extract texture data from loaded data
  83318. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83319. * @param onLoad defines a callback called when texture is loaded
  83320. * @param onError defines a callback called if there is an error
  83321. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83322. * @param invertY defines if data must be stored with Y axis inverted
  83323. * @returns the cube texture as an InternalTexture
  83324. */
  83325. 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;
  83326. /**
  83327. * Creates a new raw 3D texture
  83328. * @param data defines the data used to create the texture
  83329. * @param width defines the width of the texture
  83330. * @param height defines the height of the texture
  83331. * @param depth defines the depth of the texture
  83332. * @param format defines the format of the texture
  83333. * @param generateMipMaps defines if the engine must generate mip levels
  83334. * @param invertY defines if data must be stored with Y axis inverted
  83335. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83336. * @param compression defines the compressed used (can be null)
  83337. * @param textureType defines the compressed used (can be null)
  83338. * @returns a new raw 3D texture (stored in an InternalTexture)
  83339. */
  83340. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83341. /**
  83342. * Update a raw 3D texture
  83343. * @param texture defines the texture to update
  83344. * @param data defines the data to store
  83345. * @param format defines the data format
  83346. * @param invertY defines if data must be stored with Y axis inverted
  83347. */
  83348. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83349. /**
  83350. * Update a raw 3D texture
  83351. * @param texture defines the texture to update
  83352. * @param data defines the data to store
  83353. * @param format defines the data format
  83354. * @param invertY defines if data must be stored with Y axis inverted
  83355. * @param compression defines the used compression (can be null)
  83356. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83357. */
  83358. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83359. /**
  83360. * Creates a new raw 2D array texture
  83361. * @param data defines the data used to create the texture
  83362. * @param width defines the width of the texture
  83363. * @param height defines the height of the texture
  83364. * @param depth defines the number of layers of the texture
  83365. * @param format defines the format of the texture
  83366. * @param generateMipMaps defines if the engine must generate mip levels
  83367. * @param invertY defines if data must be stored with Y axis inverted
  83368. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83369. * @param compression defines the compressed used (can be null)
  83370. * @param textureType defines the compressed used (can be null)
  83371. * @returns a new raw 2D array texture (stored in an InternalTexture)
  83372. */
  83373. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83374. /**
  83375. * Update a raw 2D array texture
  83376. * @param texture defines the texture to update
  83377. * @param data defines the data to store
  83378. * @param format defines the data format
  83379. * @param invertY defines if data must be stored with Y axis inverted
  83380. */
  83381. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83382. /**
  83383. * Update a raw 2D array texture
  83384. * @param texture defines the texture to update
  83385. * @param data defines the data to store
  83386. * @param format defines the data format
  83387. * @param invertY defines if data must be stored with Y axis inverted
  83388. * @param compression defines the used compression (can be null)
  83389. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83390. */
  83391. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83392. }
  83393. }
  83394. declare module BABYLON {
  83395. /**
  83396. * Raw texture can help creating a texture directly from an array of data.
  83397. * This can be super useful if you either get the data from an uncompressed source or
  83398. * if you wish to create your texture pixel by pixel.
  83399. */
  83400. export class RawTexture extends Texture {
  83401. /**
  83402. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83403. */
  83404. format: number;
  83405. private _engine;
  83406. /**
  83407. * Instantiates a new RawTexture.
  83408. * Raw texture can help creating a texture directly from an array of data.
  83409. * This can be super useful if you either get the data from an uncompressed source or
  83410. * if you wish to create your texture pixel by pixel.
  83411. * @param data define the array of data to use to create the texture
  83412. * @param width define the width of the texture
  83413. * @param height define the height of the texture
  83414. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83415. * @param scene define the scene the texture belongs to
  83416. * @param generateMipMaps define whether mip maps should be generated or not
  83417. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83418. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83419. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83420. */
  83421. constructor(data: ArrayBufferView, width: number, height: number,
  83422. /**
  83423. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83424. */
  83425. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  83426. /**
  83427. * Updates the texture underlying data.
  83428. * @param data Define the new data of the texture
  83429. */
  83430. update(data: ArrayBufferView): void;
  83431. /**
  83432. * Creates a luminance texture from some data.
  83433. * @param data Define the texture data
  83434. * @param width Define the width of the texture
  83435. * @param height Define the height of the texture
  83436. * @param scene Define the scene the texture belongs to
  83437. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83438. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83439. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83440. * @returns the luminance texture
  83441. */
  83442. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83443. /**
  83444. * Creates a luminance alpha texture from some data.
  83445. * @param data Define the texture data
  83446. * @param width Define the width of the texture
  83447. * @param height Define the height of the texture
  83448. * @param scene Define the scene the texture belongs to
  83449. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83450. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83451. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83452. * @returns the luminance alpha texture
  83453. */
  83454. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83455. /**
  83456. * Creates an alpha texture from some data.
  83457. * @param data Define the texture data
  83458. * @param width Define the width of the texture
  83459. * @param height Define the height of the texture
  83460. * @param scene Define the scene the texture belongs to
  83461. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83462. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83463. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83464. * @returns the alpha texture
  83465. */
  83466. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83467. /**
  83468. * Creates a RGB texture from some data.
  83469. * @param data Define the texture data
  83470. * @param width Define the width of the texture
  83471. * @param height Define the height of the texture
  83472. * @param scene Define the scene the texture belongs to
  83473. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83474. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83475. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83476. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83477. * @returns the RGB alpha texture
  83478. */
  83479. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83480. /**
  83481. * Creates a RGBA texture from some data.
  83482. * @param data Define the texture data
  83483. * @param width Define the width of the texture
  83484. * @param height Define the height of the texture
  83485. * @param scene Define the scene the texture belongs to
  83486. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83487. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83488. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83489. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83490. * @returns the RGBA texture
  83491. */
  83492. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83493. /**
  83494. * Creates a R texture from some data.
  83495. * @param data Define the texture data
  83496. * @param width Define the width of the texture
  83497. * @param height Define the height of the texture
  83498. * @param scene Define the scene the texture belongs to
  83499. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83500. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83501. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83502. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83503. * @returns the R texture
  83504. */
  83505. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83506. }
  83507. }
  83508. declare module BABYLON {
  83509. /**
  83510. * Interface for the size containing width and height
  83511. */
  83512. export interface ISize {
  83513. /**
  83514. * Width
  83515. */
  83516. width: number;
  83517. /**
  83518. * Heighht
  83519. */
  83520. height: number;
  83521. }
  83522. /**
  83523. * Size containing widht and height
  83524. */
  83525. export class Size implements ISize {
  83526. /**
  83527. * Width
  83528. */
  83529. width: number;
  83530. /**
  83531. * Height
  83532. */
  83533. height: number;
  83534. /**
  83535. * Creates a Size object from the given width and height (floats).
  83536. * @param width width of the new size
  83537. * @param height height of the new size
  83538. */
  83539. constructor(width: number, height: number);
  83540. /**
  83541. * Returns a string with the Size width and height
  83542. * @returns a string with the Size width and height
  83543. */
  83544. toString(): string;
  83545. /**
  83546. * "Size"
  83547. * @returns the string "Size"
  83548. */
  83549. getClassName(): string;
  83550. /**
  83551. * Returns the Size hash code.
  83552. * @returns a hash code for a unique width and height
  83553. */
  83554. getHashCode(): number;
  83555. /**
  83556. * Updates the current size from the given one.
  83557. * @param src the given size
  83558. */
  83559. copyFrom(src: Size): void;
  83560. /**
  83561. * Updates in place the current Size from the given floats.
  83562. * @param width width of the new size
  83563. * @param height height of the new size
  83564. * @returns the updated Size.
  83565. */
  83566. copyFromFloats(width: number, height: number): Size;
  83567. /**
  83568. * Updates in place the current Size from the given floats.
  83569. * @param width width to set
  83570. * @param height height to set
  83571. * @returns the updated Size.
  83572. */
  83573. set(width: number, height: number): Size;
  83574. /**
  83575. * Multiplies the width and height by numbers
  83576. * @param w factor to multiple the width by
  83577. * @param h factor to multiple the height by
  83578. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83579. */
  83580. multiplyByFloats(w: number, h: number): Size;
  83581. /**
  83582. * Clones the size
  83583. * @returns a new Size copied from the given one.
  83584. */
  83585. clone(): Size;
  83586. /**
  83587. * True if the current Size and the given one width and height are strictly equal.
  83588. * @param other the other size to compare against
  83589. * @returns True if the current Size and the given one width and height are strictly equal.
  83590. */
  83591. equals(other: Size): boolean;
  83592. /**
  83593. * The surface of the Size : width * height (float).
  83594. */
  83595. get surface(): number;
  83596. /**
  83597. * Create a new size of zero
  83598. * @returns a new Size set to (0.0, 0.0)
  83599. */
  83600. static Zero(): Size;
  83601. /**
  83602. * Sums the width and height of two sizes
  83603. * @param otherSize size to add to this size
  83604. * @returns a new Size set as the addition result of the current Size and the given one.
  83605. */
  83606. add(otherSize: Size): Size;
  83607. /**
  83608. * Subtracts the width and height of two
  83609. * @param otherSize size to subtract to this size
  83610. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83611. */
  83612. subtract(otherSize: Size): Size;
  83613. /**
  83614. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83615. * @param start starting size to lerp between
  83616. * @param end end size to lerp between
  83617. * @param amount amount to lerp between the start and end values
  83618. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83619. */
  83620. static Lerp(start: Size, end: Size, amount: number): Size;
  83621. }
  83622. }
  83623. declare module BABYLON {
  83624. /**
  83625. * Defines a runtime animation
  83626. */
  83627. export class RuntimeAnimation {
  83628. private _events;
  83629. /**
  83630. * The current frame of the runtime animation
  83631. */
  83632. private _currentFrame;
  83633. /**
  83634. * The animation used by the runtime animation
  83635. */
  83636. private _animation;
  83637. /**
  83638. * The target of the runtime animation
  83639. */
  83640. private _target;
  83641. /**
  83642. * The initiating animatable
  83643. */
  83644. private _host;
  83645. /**
  83646. * The original value of the runtime animation
  83647. */
  83648. private _originalValue;
  83649. /**
  83650. * The original blend value of the runtime animation
  83651. */
  83652. private _originalBlendValue;
  83653. /**
  83654. * The offsets cache of the runtime animation
  83655. */
  83656. private _offsetsCache;
  83657. /**
  83658. * The high limits cache of the runtime animation
  83659. */
  83660. private _highLimitsCache;
  83661. /**
  83662. * Specifies if the runtime animation has been stopped
  83663. */
  83664. private _stopped;
  83665. /**
  83666. * The blending factor of the runtime animation
  83667. */
  83668. private _blendingFactor;
  83669. /**
  83670. * The BabylonJS scene
  83671. */
  83672. private _scene;
  83673. /**
  83674. * The current value of the runtime animation
  83675. */
  83676. private _currentValue;
  83677. /** @hidden */
  83678. _animationState: _IAnimationState;
  83679. /**
  83680. * The active target of the runtime animation
  83681. */
  83682. private _activeTargets;
  83683. private _currentActiveTarget;
  83684. private _directTarget;
  83685. /**
  83686. * The target path of the runtime animation
  83687. */
  83688. private _targetPath;
  83689. /**
  83690. * The weight of the runtime animation
  83691. */
  83692. private _weight;
  83693. /**
  83694. * The ratio offset of the runtime animation
  83695. */
  83696. private _ratioOffset;
  83697. /**
  83698. * The previous delay of the runtime animation
  83699. */
  83700. private _previousDelay;
  83701. /**
  83702. * The previous ratio of the runtime animation
  83703. */
  83704. private _previousRatio;
  83705. private _enableBlending;
  83706. private _keys;
  83707. private _minFrame;
  83708. private _maxFrame;
  83709. private _minValue;
  83710. private _maxValue;
  83711. private _targetIsArray;
  83712. /**
  83713. * Gets the current frame of the runtime animation
  83714. */
  83715. get currentFrame(): number;
  83716. /**
  83717. * Gets the weight of the runtime animation
  83718. */
  83719. get weight(): number;
  83720. /**
  83721. * Gets the current value of the runtime animation
  83722. */
  83723. get currentValue(): any;
  83724. /**
  83725. * Gets the target path of the runtime animation
  83726. */
  83727. get targetPath(): string;
  83728. /**
  83729. * Gets the actual target of the runtime animation
  83730. */
  83731. get target(): any;
  83732. /** @hidden */
  83733. _onLoop: () => void;
  83734. /**
  83735. * Create a new RuntimeAnimation object
  83736. * @param target defines the target of the animation
  83737. * @param animation defines the source animation object
  83738. * @param scene defines the hosting scene
  83739. * @param host defines the initiating Animatable
  83740. */
  83741. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  83742. private _preparePath;
  83743. /**
  83744. * Gets the animation from the runtime animation
  83745. */
  83746. get animation(): Animation;
  83747. /**
  83748. * Resets the runtime animation to the beginning
  83749. * @param restoreOriginal defines whether to restore the target property to the original value
  83750. */
  83751. reset(restoreOriginal?: boolean): void;
  83752. /**
  83753. * Specifies if the runtime animation is stopped
  83754. * @returns Boolean specifying if the runtime animation is stopped
  83755. */
  83756. isStopped(): boolean;
  83757. /**
  83758. * Disposes of the runtime animation
  83759. */
  83760. dispose(): void;
  83761. /**
  83762. * Apply the interpolated value to the target
  83763. * @param currentValue defines the value computed by the animation
  83764. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  83765. */
  83766. setValue(currentValue: any, weight: number): void;
  83767. private _getOriginalValues;
  83768. private _setValue;
  83769. /**
  83770. * Gets the loop pmode of the runtime animation
  83771. * @returns Loop Mode
  83772. */
  83773. private _getCorrectLoopMode;
  83774. /**
  83775. * Move the current animation to a given frame
  83776. * @param frame defines the frame to move to
  83777. */
  83778. goToFrame(frame: number): void;
  83779. /**
  83780. * @hidden Internal use only
  83781. */
  83782. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  83783. /**
  83784. * Execute the current animation
  83785. * @param delay defines the delay to add to the current frame
  83786. * @param from defines the lower bound of the animation range
  83787. * @param to defines the upper bound of the animation range
  83788. * @param loop defines if the current animation must loop
  83789. * @param speedRatio defines the current speed ratio
  83790. * @param weight defines the weight of the animation (default is -1 so no weight)
  83791. * @param onLoop optional callback called when animation loops
  83792. * @returns a boolean indicating if the animation is running
  83793. */
  83794. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  83795. }
  83796. }
  83797. declare module BABYLON {
  83798. /**
  83799. * Class used to store an actual running animation
  83800. */
  83801. export class Animatable {
  83802. /** defines the target object */
  83803. target: any;
  83804. /** defines the starting frame number (default is 0) */
  83805. fromFrame: number;
  83806. /** defines the ending frame number (default is 100) */
  83807. toFrame: number;
  83808. /** defines if the animation must loop (default is false) */
  83809. loopAnimation: boolean;
  83810. /** defines a callback to call when animation ends if it is not looping */
  83811. onAnimationEnd?: (() => void) | null | undefined;
  83812. /** defines a callback to call when animation loops */
  83813. onAnimationLoop?: (() => void) | null | undefined;
  83814. private _localDelayOffset;
  83815. private _pausedDelay;
  83816. private _runtimeAnimations;
  83817. private _paused;
  83818. private _scene;
  83819. private _speedRatio;
  83820. private _weight;
  83821. private _syncRoot;
  83822. /**
  83823. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  83824. * This will only apply for non looping animation (default is true)
  83825. */
  83826. disposeOnEnd: boolean;
  83827. /**
  83828. * Gets a boolean indicating if the animation has started
  83829. */
  83830. animationStarted: boolean;
  83831. /**
  83832. * Observer raised when the animation ends
  83833. */
  83834. onAnimationEndObservable: Observable<Animatable>;
  83835. /**
  83836. * Observer raised when the animation loops
  83837. */
  83838. onAnimationLoopObservable: Observable<Animatable>;
  83839. /**
  83840. * Gets the root Animatable used to synchronize and normalize animations
  83841. */
  83842. get syncRoot(): Nullable<Animatable>;
  83843. /**
  83844. * Gets the current frame of the first RuntimeAnimation
  83845. * Used to synchronize Animatables
  83846. */
  83847. get masterFrame(): number;
  83848. /**
  83849. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  83850. */
  83851. get weight(): number;
  83852. set weight(value: number);
  83853. /**
  83854. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  83855. */
  83856. get speedRatio(): number;
  83857. set speedRatio(value: number);
  83858. /**
  83859. * Creates a new Animatable
  83860. * @param scene defines the hosting scene
  83861. * @param target defines the target object
  83862. * @param fromFrame defines the starting frame number (default is 0)
  83863. * @param toFrame defines the ending frame number (default is 100)
  83864. * @param loopAnimation defines if the animation must loop (default is false)
  83865. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  83866. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  83867. * @param animations defines a group of animation to add to the new Animatable
  83868. * @param onAnimationLoop defines a callback to call when animation loops
  83869. */
  83870. constructor(scene: Scene,
  83871. /** defines the target object */
  83872. target: any,
  83873. /** defines the starting frame number (default is 0) */
  83874. fromFrame?: number,
  83875. /** defines the ending frame number (default is 100) */
  83876. toFrame?: number,
  83877. /** defines if the animation must loop (default is false) */
  83878. loopAnimation?: boolean, speedRatio?: number,
  83879. /** defines a callback to call when animation ends if it is not looping */
  83880. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  83881. /** defines a callback to call when animation loops */
  83882. onAnimationLoop?: (() => void) | null | undefined);
  83883. /**
  83884. * Synchronize and normalize current Animatable with a source Animatable
  83885. * This is useful when using animation weights and when animations are not of the same length
  83886. * @param root defines the root Animatable to synchronize with
  83887. * @returns the current Animatable
  83888. */
  83889. syncWith(root: Animatable): Animatable;
  83890. /**
  83891. * Gets the list of runtime animations
  83892. * @returns an array of RuntimeAnimation
  83893. */
  83894. getAnimations(): RuntimeAnimation[];
  83895. /**
  83896. * Adds more animations to the current animatable
  83897. * @param target defines the target of the animations
  83898. * @param animations defines the new animations to add
  83899. */
  83900. appendAnimations(target: any, animations: Animation[]): void;
  83901. /**
  83902. * Gets the source animation for a specific property
  83903. * @param property defines the propertyu to look for
  83904. * @returns null or the source animation for the given property
  83905. */
  83906. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  83907. /**
  83908. * Gets the runtime animation for a specific property
  83909. * @param property defines the propertyu to look for
  83910. * @returns null or the runtime animation for the given property
  83911. */
  83912. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  83913. /**
  83914. * Resets the animatable to its original state
  83915. */
  83916. reset(): void;
  83917. /**
  83918. * Allows the animatable to blend with current running animations
  83919. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  83920. * @param blendingSpeed defines the blending speed to use
  83921. */
  83922. enableBlending(blendingSpeed: number): void;
  83923. /**
  83924. * Disable animation blending
  83925. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  83926. */
  83927. disableBlending(): void;
  83928. /**
  83929. * Jump directly to a given frame
  83930. * @param frame defines the frame to jump to
  83931. */
  83932. goToFrame(frame: number): void;
  83933. /**
  83934. * Pause the animation
  83935. */
  83936. pause(): void;
  83937. /**
  83938. * Restart the animation
  83939. */
  83940. restart(): void;
  83941. private _raiseOnAnimationEnd;
  83942. /**
  83943. * Stop and delete the current animation
  83944. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  83945. * @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)
  83946. */
  83947. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  83948. /**
  83949. * Wait asynchronously for the animation to end
  83950. * @returns a promise which will be fullfilled when the animation ends
  83951. */
  83952. waitAsync(): Promise<Animatable>;
  83953. /** @hidden */
  83954. _animate(delay: number): boolean;
  83955. }
  83956. interface Scene {
  83957. /** @hidden */
  83958. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  83959. /** @hidden */
  83960. _processLateAnimationBindingsForMatrices(holder: {
  83961. totalWeight: number;
  83962. animations: RuntimeAnimation[];
  83963. originalValue: Matrix;
  83964. }): any;
  83965. /** @hidden */
  83966. _processLateAnimationBindingsForQuaternions(holder: {
  83967. totalWeight: number;
  83968. animations: RuntimeAnimation[];
  83969. originalValue: Quaternion;
  83970. }, refQuaternion: Quaternion): Quaternion;
  83971. /** @hidden */
  83972. _processLateAnimationBindings(): void;
  83973. /**
  83974. * Will start the animation sequence of a given target
  83975. * @param target defines the target
  83976. * @param from defines from which frame should animation start
  83977. * @param to defines until which frame should animation run.
  83978. * @param weight defines the weight to apply to the animation (1.0 by default)
  83979. * @param loop defines if the animation loops
  83980. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  83981. * @param onAnimationEnd defines the function to be executed when the animation ends
  83982. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  83983. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  83984. * @param onAnimationLoop defines the callback to call when an animation loops
  83985. * @returns the animatable object created for this animation
  83986. */
  83987. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  83988. /**
  83989. * Will start the animation sequence of a given target
  83990. * @param target defines the target
  83991. * @param from defines from which frame should animation start
  83992. * @param to defines until which frame should animation run.
  83993. * @param loop defines if the animation loops
  83994. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  83995. * @param onAnimationEnd defines the function to be executed when the animation ends
  83996. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  83997. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  83998. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  83999. * @param onAnimationLoop defines the callback to call when an animation loops
  84000. * @returns the animatable object created for this animation
  84001. */
  84002. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  84003. /**
  84004. * Will start the animation sequence of a given target and its hierarchy
  84005. * @param target defines the target
  84006. * @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.
  84007. * @param from defines from which frame should animation start
  84008. * @param to defines until which frame should animation run.
  84009. * @param loop defines if the animation loops
  84010. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  84011. * @param onAnimationEnd defines the function to be executed when the animation ends
  84012. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  84013. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  84014. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  84015. * @param onAnimationLoop defines the callback to call when an animation loops
  84016. * @returns the list of created animatables
  84017. */
  84018. 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[];
  84019. /**
  84020. * Begin a new animation on a given node
  84021. * @param target defines the target where the animation will take place
  84022. * @param animations defines the list of animations to start
  84023. * @param from defines the initial value
  84024. * @param to defines the final value
  84025. * @param loop defines if you want animation to loop (off by default)
  84026. * @param speedRatio defines the speed ratio to apply to all animations
  84027. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  84028. * @param onAnimationLoop defines the callback to call when an animation loops
  84029. * @returns the list of created animatables
  84030. */
  84031. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  84032. /**
  84033. * Begin a new animation on a given node and its hierarchy
  84034. * @param target defines the root node where the animation will take place
  84035. * @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.
  84036. * @param animations defines the list of animations to start
  84037. * @param from defines the initial value
  84038. * @param to defines the final value
  84039. * @param loop defines if you want animation to loop (off by default)
  84040. * @param speedRatio defines the speed ratio to apply to all animations
  84041. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  84042. * @param onAnimationLoop defines the callback to call when an animation loops
  84043. * @returns the list of animatables created for all nodes
  84044. */
  84045. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  84046. /**
  84047. * Gets the animatable associated with a specific target
  84048. * @param target defines the target of the animatable
  84049. * @returns the required animatable if found
  84050. */
  84051. getAnimatableByTarget(target: any): Nullable<Animatable>;
  84052. /**
  84053. * Gets all animatables associated with a given target
  84054. * @param target defines the target to look animatables for
  84055. * @returns an array of Animatables
  84056. */
  84057. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  84058. /**
  84059. * Stops and removes all animations that have been applied to the scene
  84060. */
  84061. stopAllAnimations(): void;
  84062. /**
  84063. * Gets the current delta time used by animation engine
  84064. */
  84065. deltaTime: number;
  84066. }
  84067. interface Bone {
  84068. /**
  84069. * Copy an animation range from another bone
  84070. * @param source defines the source bone
  84071. * @param rangeName defines the range name to copy
  84072. * @param frameOffset defines the frame offset
  84073. * @param rescaleAsRequired defines if rescaling must be applied if required
  84074. * @param skelDimensionsRatio defines the scaling ratio
  84075. * @returns true if operation was successful
  84076. */
  84077. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  84078. }
  84079. }
  84080. declare module BABYLON {
  84081. /**
  84082. * Class used to override all child animations of a given target
  84083. */
  84084. export class AnimationPropertiesOverride {
  84085. /**
  84086. * Gets or sets a value indicating if animation blending must be used
  84087. */
  84088. enableBlending: boolean;
  84089. /**
  84090. * Gets or sets the blending speed to use when enableBlending is true
  84091. */
  84092. blendingSpeed: number;
  84093. /**
  84094. * Gets or sets the default loop mode to use
  84095. */
  84096. loopMode: number;
  84097. }
  84098. }
  84099. declare module BABYLON {
  84100. /**
  84101. * Class used to handle skinning animations
  84102. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84103. */
  84104. export class Skeleton implements IAnimatable {
  84105. /** defines the skeleton name */
  84106. name: string;
  84107. /** defines the skeleton Id */
  84108. id: string;
  84109. /**
  84110. * Defines the list of child bones
  84111. */
  84112. bones: Bone[];
  84113. /**
  84114. * Defines an estimate of the dimension of the skeleton at rest
  84115. */
  84116. dimensionsAtRest: Vector3;
  84117. /**
  84118. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  84119. */
  84120. needInitialSkinMatrix: boolean;
  84121. /**
  84122. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  84123. */
  84124. overrideMesh: Nullable<AbstractMesh>;
  84125. /**
  84126. * Gets the list of animations attached to this skeleton
  84127. */
  84128. animations: Array<Animation>;
  84129. private _scene;
  84130. private _isDirty;
  84131. private _transformMatrices;
  84132. private _transformMatrixTexture;
  84133. private _meshesWithPoseMatrix;
  84134. private _animatables;
  84135. private _identity;
  84136. private _synchronizedWithMesh;
  84137. private _ranges;
  84138. private _lastAbsoluteTransformsUpdateId;
  84139. private _canUseTextureForBones;
  84140. private _uniqueId;
  84141. /** @hidden */
  84142. _numBonesWithLinkedTransformNode: number;
  84143. /** @hidden */
  84144. _hasWaitingData: Nullable<boolean>;
  84145. /**
  84146. * Specifies if the skeleton should be serialized
  84147. */
  84148. doNotSerialize: boolean;
  84149. private _useTextureToStoreBoneMatrices;
  84150. /**
  84151. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  84152. * Please note that this option is not available if the hardware does not support it
  84153. */
  84154. get useTextureToStoreBoneMatrices(): boolean;
  84155. set useTextureToStoreBoneMatrices(value: boolean);
  84156. private _animationPropertiesOverride;
  84157. /**
  84158. * Gets or sets the animation properties override
  84159. */
  84160. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  84161. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  84162. /**
  84163. * List of inspectable custom properties (used by the Inspector)
  84164. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84165. */
  84166. inspectableCustomProperties: IInspectable[];
  84167. /**
  84168. * An observable triggered before computing the skeleton's matrices
  84169. */
  84170. onBeforeComputeObservable: Observable<Skeleton>;
  84171. /**
  84172. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  84173. */
  84174. get isUsingTextureForMatrices(): boolean;
  84175. /**
  84176. * Gets the unique ID of this skeleton
  84177. */
  84178. get uniqueId(): number;
  84179. /**
  84180. * Creates a new skeleton
  84181. * @param name defines the skeleton name
  84182. * @param id defines the skeleton Id
  84183. * @param scene defines the hosting scene
  84184. */
  84185. constructor(
  84186. /** defines the skeleton name */
  84187. name: string,
  84188. /** defines the skeleton Id */
  84189. id: string, scene: Scene);
  84190. /**
  84191. * Gets the current object class name.
  84192. * @return the class name
  84193. */
  84194. getClassName(): string;
  84195. /**
  84196. * Returns an array containing the root bones
  84197. * @returns an array containing the root bones
  84198. */
  84199. getChildren(): Array<Bone>;
  84200. /**
  84201. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  84202. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  84203. * @returns a Float32Array containing matrices data
  84204. */
  84205. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  84206. /**
  84207. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  84208. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  84209. * @returns a raw texture containing the data
  84210. */
  84211. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  84212. /**
  84213. * Gets the current hosting scene
  84214. * @returns a scene object
  84215. */
  84216. getScene(): Scene;
  84217. /**
  84218. * Gets a string representing the current skeleton data
  84219. * @param fullDetails defines a boolean indicating if we want a verbose version
  84220. * @returns a string representing the current skeleton data
  84221. */
  84222. toString(fullDetails?: boolean): string;
  84223. /**
  84224. * Get bone's index searching by name
  84225. * @param name defines bone's name to search for
  84226. * @return the indice of the bone. Returns -1 if not found
  84227. */
  84228. getBoneIndexByName(name: string): number;
  84229. /**
  84230. * Creater a new animation range
  84231. * @param name defines the name of the range
  84232. * @param from defines the start key
  84233. * @param to defines the end key
  84234. */
  84235. createAnimationRange(name: string, from: number, to: number): void;
  84236. /**
  84237. * Delete a specific animation range
  84238. * @param name defines the name of the range
  84239. * @param deleteFrames defines if frames must be removed as well
  84240. */
  84241. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  84242. /**
  84243. * Gets a specific animation range
  84244. * @param name defines the name of the range to look for
  84245. * @returns the requested animation range or null if not found
  84246. */
  84247. getAnimationRange(name: string): Nullable<AnimationRange>;
  84248. /**
  84249. * Gets the list of all animation ranges defined on this skeleton
  84250. * @returns an array
  84251. */
  84252. getAnimationRanges(): Nullable<AnimationRange>[];
  84253. /**
  84254. * Copy animation range from a source skeleton.
  84255. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  84256. * @param source defines the source skeleton
  84257. * @param name defines the name of the range to copy
  84258. * @param rescaleAsRequired defines if rescaling must be applied if required
  84259. * @returns true if operation was successful
  84260. */
  84261. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  84262. /**
  84263. * Forces the skeleton to go to rest pose
  84264. */
  84265. returnToRest(): void;
  84266. private _getHighestAnimationFrame;
  84267. /**
  84268. * Begin a specific animation range
  84269. * @param name defines the name of the range to start
  84270. * @param loop defines if looping must be turned on (false by default)
  84271. * @param speedRatio defines the speed ratio to apply (1 by default)
  84272. * @param onAnimationEnd defines a callback which will be called when animation will end
  84273. * @returns a new animatable
  84274. */
  84275. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  84276. /** @hidden */
  84277. _markAsDirty(): void;
  84278. /** @hidden */
  84279. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  84280. /** @hidden */
  84281. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  84282. private _computeTransformMatrices;
  84283. /**
  84284. * Build all resources required to render a skeleton
  84285. */
  84286. prepare(): void;
  84287. /**
  84288. * Gets the list of animatables currently running for this skeleton
  84289. * @returns an array of animatables
  84290. */
  84291. getAnimatables(): IAnimatable[];
  84292. /**
  84293. * Clone the current skeleton
  84294. * @param name defines the name of the new skeleton
  84295. * @param id defines the id of the new skeleton
  84296. * @returns the new skeleton
  84297. */
  84298. clone(name: string, id?: string): Skeleton;
  84299. /**
  84300. * Enable animation blending for this skeleton
  84301. * @param blendingSpeed defines the blending speed to apply
  84302. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  84303. */
  84304. enableBlending(blendingSpeed?: number): void;
  84305. /**
  84306. * Releases all resources associated with the current skeleton
  84307. */
  84308. dispose(): void;
  84309. /**
  84310. * Serialize the skeleton in a JSON object
  84311. * @returns a JSON object
  84312. */
  84313. serialize(): any;
  84314. /**
  84315. * Creates a new skeleton from serialized data
  84316. * @param parsedSkeleton defines the serialized data
  84317. * @param scene defines the hosting scene
  84318. * @returns a new skeleton
  84319. */
  84320. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  84321. /**
  84322. * Compute all node absolute transforms
  84323. * @param forceUpdate defines if computation must be done even if cache is up to date
  84324. */
  84325. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  84326. /**
  84327. * Gets the root pose matrix
  84328. * @returns a matrix
  84329. */
  84330. getPoseMatrix(): Nullable<Matrix>;
  84331. /**
  84332. * Sorts bones per internal index
  84333. */
  84334. sortBones(): void;
  84335. private _sortBones;
  84336. }
  84337. }
  84338. declare module BABYLON {
  84339. /**
  84340. * Class used to store bone information
  84341. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84342. */
  84343. export class Bone extends Node {
  84344. /**
  84345. * defines the bone name
  84346. */
  84347. name: string;
  84348. private static _tmpVecs;
  84349. private static _tmpQuat;
  84350. private static _tmpMats;
  84351. /**
  84352. * Gets the list of child bones
  84353. */
  84354. children: Bone[];
  84355. /** Gets the animations associated with this bone */
  84356. animations: Animation[];
  84357. /**
  84358. * Gets or sets bone length
  84359. */
  84360. length: number;
  84361. /**
  84362. * @hidden Internal only
  84363. * Set this value to map this bone to a different index in the transform matrices
  84364. * Set this value to -1 to exclude the bone from the transform matrices
  84365. */
  84366. _index: Nullable<number>;
  84367. private _skeleton;
  84368. private _localMatrix;
  84369. private _restPose;
  84370. private _baseMatrix;
  84371. private _absoluteTransform;
  84372. private _invertedAbsoluteTransform;
  84373. private _parent;
  84374. private _scalingDeterminant;
  84375. private _worldTransform;
  84376. private _localScaling;
  84377. private _localRotation;
  84378. private _localPosition;
  84379. private _needToDecompose;
  84380. private _needToCompose;
  84381. /** @hidden */
  84382. _linkedTransformNode: Nullable<TransformNode>;
  84383. /** @hidden */
  84384. _waitingTransformNodeId: Nullable<string>;
  84385. /** @hidden */
  84386. get _matrix(): Matrix;
  84387. /** @hidden */
  84388. set _matrix(value: Matrix);
  84389. /**
  84390. * Create a new bone
  84391. * @param name defines the bone name
  84392. * @param skeleton defines the parent skeleton
  84393. * @param parentBone defines the parent (can be null if the bone is the root)
  84394. * @param localMatrix defines the local matrix
  84395. * @param restPose defines the rest pose matrix
  84396. * @param baseMatrix defines the base matrix
  84397. * @param index defines index of the bone in the hiearchy
  84398. */
  84399. constructor(
  84400. /**
  84401. * defines the bone name
  84402. */
  84403. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  84404. /**
  84405. * Gets the current object class name.
  84406. * @return the class name
  84407. */
  84408. getClassName(): string;
  84409. /**
  84410. * Gets the parent skeleton
  84411. * @returns a skeleton
  84412. */
  84413. getSkeleton(): Skeleton;
  84414. /**
  84415. * Gets parent bone
  84416. * @returns a bone or null if the bone is the root of the bone hierarchy
  84417. */
  84418. getParent(): Nullable<Bone>;
  84419. /**
  84420. * Returns an array containing the root bones
  84421. * @returns an array containing the root bones
  84422. */
  84423. getChildren(): Array<Bone>;
  84424. /**
  84425. * Gets the node index in matrix array generated for rendering
  84426. * @returns the node index
  84427. */
  84428. getIndex(): number;
  84429. /**
  84430. * Sets the parent bone
  84431. * @param parent defines the parent (can be null if the bone is the root)
  84432. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  84433. */
  84434. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  84435. /**
  84436. * Gets the local matrix
  84437. * @returns a matrix
  84438. */
  84439. getLocalMatrix(): Matrix;
  84440. /**
  84441. * Gets the base matrix (initial matrix which remains unchanged)
  84442. * @returns a matrix
  84443. */
  84444. getBaseMatrix(): Matrix;
  84445. /**
  84446. * Gets the rest pose matrix
  84447. * @returns a matrix
  84448. */
  84449. getRestPose(): Matrix;
  84450. /**
  84451. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  84452. */
  84453. getWorldMatrix(): Matrix;
  84454. /**
  84455. * Sets the local matrix to rest pose matrix
  84456. */
  84457. returnToRest(): void;
  84458. /**
  84459. * Gets the inverse of the absolute transform matrix.
  84460. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  84461. * @returns a matrix
  84462. */
  84463. getInvertedAbsoluteTransform(): Matrix;
  84464. /**
  84465. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  84466. * @returns a matrix
  84467. */
  84468. getAbsoluteTransform(): Matrix;
  84469. /**
  84470. * Links with the given transform node.
  84471. * The local matrix of this bone is copied from the transform node every frame.
  84472. * @param transformNode defines the transform node to link to
  84473. */
  84474. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  84475. /**
  84476. * Gets the node used to drive the bone's transformation
  84477. * @returns a transform node or null
  84478. */
  84479. getTransformNode(): Nullable<TransformNode>;
  84480. /** Gets or sets current position (in local space) */
  84481. get position(): Vector3;
  84482. set position(newPosition: Vector3);
  84483. /** Gets or sets current rotation (in local space) */
  84484. get rotation(): Vector3;
  84485. set rotation(newRotation: Vector3);
  84486. /** Gets or sets current rotation quaternion (in local space) */
  84487. get rotationQuaternion(): Quaternion;
  84488. set rotationQuaternion(newRotation: Quaternion);
  84489. /** Gets or sets current scaling (in local space) */
  84490. get scaling(): Vector3;
  84491. set scaling(newScaling: Vector3);
  84492. /**
  84493. * Gets the animation properties override
  84494. */
  84495. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  84496. private _decompose;
  84497. private _compose;
  84498. /**
  84499. * Update the base and local matrices
  84500. * @param matrix defines the new base or local matrix
  84501. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  84502. * @param updateLocalMatrix defines if the local matrix should be updated
  84503. */
  84504. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  84505. /** @hidden */
  84506. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  84507. /**
  84508. * Flag the bone as dirty (Forcing it to update everything)
  84509. */
  84510. markAsDirty(): void;
  84511. /** @hidden */
  84512. _markAsDirtyAndCompose(): void;
  84513. private _markAsDirtyAndDecompose;
  84514. /**
  84515. * Translate the bone in local or world space
  84516. * @param vec The amount to translate the bone
  84517. * @param space The space that the translation is in
  84518. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84519. */
  84520. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  84521. /**
  84522. * Set the postion of the bone in local or world space
  84523. * @param position The position to set the bone
  84524. * @param space The space that the position is in
  84525. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84526. */
  84527. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  84528. /**
  84529. * Set the absolute position of the bone (world space)
  84530. * @param position The position to set the bone
  84531. * @param mesh The mesh that this bone is attached to
  84532. */
  84533. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  84534. /**
  84535. * Scale the bone on the x, y and z axes (in local space)
  84536. * @param x The amount to scale the bone on the x axis
  84537. * @param y The amount to scale the bone on the y axis
  84538. * @param z The amount to scale the bone on the z axis
  84539. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  84540. */
  84541. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  84542. /**
  84543. * Set the bone scaling in local space
  84544. * @param scale defines the scaling vector
  84545. */
  84546. setScale(scale: Vector3): void;
  84547. /**
  84548. * Gets the current scaling in local space
  84549. * @returns the current scaling vector
  84550. */
  84551. getScale(): Vector3;
  84552. /**
  84553. * Gets the current scaling in local space and stores it in a target vector
  84554. * @param result defines the target vector
  84555. */
  84556. getScaleToRef(result: Vector3): void;
  84557. /**
  84558. * Set the yaw, pitch, and roll of the bone in local or world space
  84559. * @param yaw The rotation of the bone on the y axis
  84560. * @param pitch The rotation of the bone on the x axis
  84561. * @param roll The rotation of the bone on the z axis
  84562. * @param space The space that the axes of rotation are in
  84563. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84564. */
  84565. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  84566. /**
  84567. * Add a rotation to the bone on an axis in local or world space
  84568. * @param axis The axis to rotate the bone on
  84569. * @param amount The amount to rotate the bone
  84570. * @param space The space that the axis is in
  84571. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84572. */
  84573. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  84574. /**
  84575. * Set the rotation of the bone to a particular axis angle in local or world space
  84576. * @param axis The axis to rotate the bone on
  84577. * @param angle The angle that the bone should be rotated to
  84578. * @param space The space that the axis is in
  84579. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84580. */
  84581. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  84582. /**
  84583. * Set the euler rotation of the bone in local of world space
  84584. * @param rotation The euler rotation that the bone should be set to
  84585. * @param space The space that the rotation is in
  84586. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84587. */
  84588. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  84589. /**
  84590. * Set the quaternion rotation of the bone in local of world space
  84591. * @param quat The quaternion rotation that the bone should be set to
  84592. * @param space The space that the rotation is in
  84593. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84594. */
  84595. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  84596. /**
  84597. * Set the rotation matrix of the bone in local of world space
  84598. * @param rotMat The rotation matrix that the bone should be set to
  84599. * @param space The space that the rotation is in
  84600. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84601. */
  84602. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  84603. private _rotateWithMatrix;
  84604. private _getNegativeRotationToRef;
  84605. /**
  84606. * Get the position of the bone in local or world space
  84607. * @param space The space that the returned position is in
  84608. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84609. * @returns The position of the bone
  84610. */
  84611. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  84612. /**
  84613. * Copy the position of the bone to a vector3 in local or world space
  84614. * @param space The space that the returned position is in
  84615. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84616. * @param result The vector3 to copy the position to
  84617. */
  84618. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  84619. /**
  84620. * Get the absolute position of the bone (world space)
  84621. * @param mesh The mesh that this bone is attached to
  84622. * @returns The absolute position of the bone
  84623. */
  84624. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  84625. /**
  84626. * Copy the absolute position of the bone (world space) to the result param
  84627. * @param mesh The mesh that this bone is attached to
  84628. * @param result The vector3 to copy the absolute position to
  84629. */
  84630. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  84631. /**
  84632. * Compute the absolute transforms of this bone and its children
  84633. */
  84634. computeAbsoluteTransforms(): void;
  84635. /**
  84636. * Get the world direction from an axis that is in the local space of the bone
  84637. * @param localAxis The local direction that is used to compute the world direction
  84638. * @param mesh The mesh that this bone is attached to
  84639. * @returns The world direction
  84640. */
  84641. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  84642. /**
  84643. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  84644. * @param localAxis The local direction that is used to compute the world direction
  84645. * @param mesh The mesh that this bone is attached to
  84646. * @param result The vector3 that the world direction will be copied to
  84647. */
  84648. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  84649. /**
  84650. * Get the euler rotation of the bone in local or world space
  84651. * @param space The space that the rotation should be in
  84652. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84653. * @returns The euler rotation
  84654. */
  84655. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  84656. /**
  84657. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  84658. * @param space The space that the rotation should be in
  84659. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84660. * @param result The vector3 that the rotation should be copied to
  84661. */
  84662. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  84663. /**
  84664. * Get the quaternion rotation of the bone in either local or world space
  84665. * @param space The space that the rotation should be in
  84666. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84667. * @returns The quaternion rotation
  84668. */
  84669. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  84670. /**
  84671. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  84672. * @param space The space that the rotation should be in
  84673. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84674. * @param result The quaternion that the rotation should be copied to
  84675. */
  84676. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  84677. /**
  84678. * Get the rotation matrix of the bone in local or world space
  84679. * @param space The space that the rotation should be in
  84680. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84681. * @returns The rotation matrix
  84682. */
  84683. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  84684. /**
  84685. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  84686. * @param space The space that the rotation should be in
  84687. * @param mesh The mesh that this bone is attached to. This is only used in world space
  84688. * @param result The quaternion that the rotation should be copied to
  84689. */
  84690. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  84691. /**
  84692. * Get the world position of a point that is in the local space of the bone
  84693. * @param position The local position
  84694. * @param mesh The mesh that this bone is attached to
  84695. * @returns The world position
  84696. */
  84697. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  84698. /**
  84699. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  84700. * @param position The local position
  84701. * @param mesh The mesh that this bone is attached to
  84702. * @param result The vector3 that the world position should be copied to
  84703. */
  84704. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  84705. /**
  84706. * Get the local position of a point that is in world space
  84707. * @param position The world position
  84708. * @param mesh The mesh that this bone is attached to
  84709. * @returns The local position
  84710. */
  84711. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  84712. /**
  84713. * Get the local position of a point that is in world space and copy it to the result param
  84714. * @param position The world position
  84715. * @param mesh The mesh that this bone is attached to
  84716. * @param result The vector3 that the local position should be copied to
  84717. */
  84718. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  84719. }
  84720. }
  84721. declare module BABYLON {
  84722. /**
  84723. * 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.
  84724. * @see https://doc.babylonjs.com/how_to/transformnode
  84725. */
  84726. export class TransformNode extends Node {
  84727. /**
  84728. * Object will not rotate to face the camera
  84729. */
  84730. static BILLBOARDMODE_NONE: number;
  84731. /**
  84732. * Object will rotate to face the camera but only on the x axis
  84733. */
  84734. static BILLBOARDMODE_X: number;
  84735. /**
  84736. * Object will rotate to face the camera but only on the y axis
  84737. */
  84738. static BILLBOARDMODE_Y: number;
  84739. /**
  84740. * Object will rotate to face the camera but only on the z axis
  84741. */
  84742. static BILLBOARDMODE_Z: number;
  84743. /**
  84744. * Object will rotate to face the camera
  84745. */
  84746. static BILLBOARDMODE_ALL: number;
  84747. /**
  84748. * Object will rotate to face the camera's position instead of orientation
  84749. */
  84750. static BILLBOARDMODE_USE_POSITION: number;
  84751. private _forward;
  84752. private _forwardInverted;
  84753. private _up;
  84754. private _right;
  84755. private _rightInverted;
  84756. private _position;
  84757. private _rotation;
  84758. private _rotationQuaternion;
  84759. protected _scaling: Vector3;
  84760. protected _isDirty: boolean;
  84761. private _transformToBoneReferal;
  84762. private _isAbsoluteSynced;
  84763. private _billboardMode;
  84764. /**
  84765. * Gets or sets the billboard mode. Default is 0.
  84766. *
  84767. * | Value | Type | Description |
  84768. * | --- | --- | --- |
  84769. * | 0 | BILLBOARDMODE_NONE | |
  84770. * | 1 | BILLBOARDMODE_X | |
  84771. * | 2 | BILLBOARDMODE_Y | |
  84772. * | 4 | BILLBOARDMODE_Z | |
  84773. * | 7 | BILLBOARDMODE_ALL | |
  84774. *
  84775. */
  84776. get billboardMode(): number;
  84777. set billboardMode(value: number);
  84778. private _preserveParentRotationForBillboard;
  84779. /**
  84780. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  84781. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  84782. */
  84783. get preserveParentRotationForBillboard(): boolean;
  84784. set preserveParentRotationForBillboard(value: boolean);
  84785. /**
  84786. * 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
  84787. */
  84788. scalingDeterminant: number;
  84789. private _infiniteDistance;
  84790. /**
  84791. * Gets or sets the distance of the object to max, often used by skybox
  84792. */
  84793. get infiniteDistance(): boolean;
  84794. set infiniteDistance(value: boolean);
  84795. /**
  84796. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  84797. * By default the system will update normals to compensate
  84798. */
  84799. ignoreNonUniformScaling: boolean;
  84800. /**
  84801. * 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
  84802. */
  84803. reIntegrateRotationIntoRotationQuaternion: boolean;
  84804. /** @hidden */
  84805. _poseMatrix: Nullable<Matrix>;
  84806. /** @hidden */
  84807. _localMatrix: Matrix;
  84808. private _usePivotMatrix;
  84809. private _absolutePosition;
  84810. private _absoluteScaling;
  84811. private _absoluteRotationQuaternion;
  84812. private _pivotMatrix;
  84813. private _pivotMatrixInverse;
  84814. protected _postMultiplyPivotMatrix: boolean;
  84815. protected _isWorldMatrixFrozen: boolean;
  84816. /** @hidden */
  84817. _indexInSceneTransformNodesArray: number;
  84818. /**
  84819. * An event triggered after the world matrix is updated
  84820. */
  84821. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  84822. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  84823. /**
  84824. * Gets a string identifying the name of the class
  84825. * @returns "TransformNode" string
  84826. */
  84827. getClassName(): string;
  84828. /**
  84829. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  84830. */
  84831. get position(): Vector3;
  84832. set position(newPosition: Vector3);
  84833. /**
  84834. * 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)).
  84835. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  84836. */
  84837. get rotation(): Vector3;
  84838. set rotation(newRotation: Vector3);
  84839. /**
  84840. * 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)).
  84841. */
  84842. get scaling(): Vector3;
  84843. set scaling(newScaling: Vector3);
  84844. /**
  84845. * 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).
  84846. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  84847. */
  84848. get rotationQuaternion(): Nullable<Quaternion>;
  84849. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  84850. /**
  84851. * The forward direction of that transform in world space.
  84852. */
  84853. get forward(): Vector3;
  84854. /**
  84855. * The up direction of that transform in world space.
  84856. */
  84857. get up(): Vector3;
  84858. /**
  84859. * The right direction of that transform in world space.
  84860. */
  84861. get right(): Vector3;
  84862. /**
  84863. * Copies the parameter passed Matrix into the mesh Pose matrix.
  84864. * @param matrix the matrix to copy the pose from
  84865. * @returns this TransformNode.
  84866. */
  84867. updatePoseMatrix(matrix: Matrix): TransformNode;
  84868. /**
  84869. * Returns the mesh Pose matrix.
  84870. * @returns the pose matrix
  84871. */
  84872. getPoseMatrix(): Matrix;
  84873. /** @hidden */
  84874. _isSynchronized(): boolean;
  84875. /** @hidden */
  84876. _initCache(): void;
  84877. /**
  84878. * Flag the transform node as dirty (Forcing it to update everything)
  84879. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  84880. * @returns this transform node
  84881. */
  84882. markAsDirty(property: string): TransformNode;
  84883. /**
  84884. * Returns the current mesh absolute position.
  84885. * Returns a Vector3.
  84886. */
  84887. get absolutePosition(): Vector3;
  84888. /**
  84889. * Returns the current mesh absolute scaling.
  84890. * Returns a Vector3.
  84891. */
  84892. get absoluteScaling(): Vector3;
  84893. /**
  84894. * Returns the current mesh absolute rotation.
  84895. * Returns a Quaternion.
  84896. */
  84897. get absoluteRotationQuaternion(): Quaternion;
  84898. /**
  84899. * Sets a new matrix to apply before all other transformation
  84900. * @param matrix defines the transform matrix
  84901. * @returns the current TransformNode
  84902. */
  84903. setPreTransformMatrix(matrix: Matrix): TransformNode;
  84904. /**
  84905. * Sets a new pivot matrix to the current node
  84906. * @param matrix defines the new pivot matrix to use
  84907. * @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
  84908. * @returns the current TransformNode
  84909. */
  84910. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  84911. /**
  84912. * Returns the mesh pivot matrix.
  84913. * Default : Identity.
  84914. * @returns the matrix
  84915. */
  84916. getPivotMatrix(): Matrix;
  84917. /**
  84918. * Instantiate (when possible) or clone that node with its hierarchy
  84919. * @param newParent defines the new parent to use for the instance (or clone)
  84920. * @param options defines options to configure how copy is done
  84921. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  84922. * @returns an instance (or a clone) of the current node with its hiearchy
  84923. */
  84924. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  84925. doNotInstantiate: boolean;
  84926. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  84927. /**
  84928. * Prevents the World matrix to be computed any longer
  84929. * @param newWorldMatrix defines an optional matrix to use as world matrix
  84930. * @returns the TransformNode.
  84931. */
  84932. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  84933. /**
  84934. * Allows back the World matrix computation.
  84935. * @returns the TransformNode.
  84936. */
  84937. unfreezeWorldMatrix(): this;
  84938. /**
  84939. * True if the World matrix has been frozen.
  84940. */
  84941. get isWorldMatrixFrozen(): boolean;
  84942. /**
  84943. * Retuns the mesh absolute position in the World.
  84944. * @returns a Vector3.
  84945. */
  84946. getAbsolutePosition(): Vector3;
  84947. /**
  84948. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  84949. * @param absolutePosition the absolute position to set
  84950. * @returns the TransformNode.
  84951. */
  84952. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  84953. /**
  84954. * Sets the mesh position in its local space.
  84955. * @param vector3 the position to set in localspace
  84956. * @returns the TransformNode.
  84957. */
  84958. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  84959. /**
  84960. * Returns the mesh position in the local space from the current World matrix values.
  84961. * @returns a new Vector3.
  84962. */
  84963. getPositionExpressedInLocalSpace(): Vector3;
  84964. /**
  84965. * Translates the mesh along the passed Vector3 in its local space.
  84966. * @param vector3 the distance to translate in localspace
  84967. * @returns the TransformNode.
  84968. */
  84969. locallyTranslate(vector3: Vector3): TransformNode;
  84970. private static _lookAtVectorCache;
  84971. /**
  84972. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  84973. * @param targetPoint the position (must be in same space as current mesh) to look at
  84974. * @param yawCor optional yaw (y-axis) correction in radians
  84975. * @param pitchCor optional pitch (x-axis) correction in radians
  84976. * @param rollCor optional roll (z-axis) correction in radians
  84977. * @param space the choosen space of the target
  84978. * @returns the TransformNode.
  84979. */
  84980. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  84981. /**
  84982. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  84983. * This Vector3 is expressed in the World space.
  84984. * @param localAxis axis to rotate
  84985. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  84986. */
  84987. getDirection(localAxis: Vector3): Vector3;
  84988. /**
  84989. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  84990. * localAxis is expressed in the mesh local space.
  84991. * result is computed in the Wordl space from the mesh World matrix.
  84992. * @param localAxis axis to rotate
  84993. * @param result the resulting transformnode
  84994. * @returns this TransformNode.
  84995. */
  84996. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  84997. /**
  84998. * Sets this transform node rotation to the given local axis.
  84999. * @param localAxis the axis in local space
  85000. * @param yawCor optional yaw (y-axis) correction in radians
  85001. * @param pitchCor optional pitch (x-axis) correction in radians
  85002. * @param rollCor optional roll (z-axis) correction in radians
  85003. * @returns this TransformNode
  85004. */
  85005. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  85006. /**
  85007. * Sets a new pivot point to the current node
  85008. * @param point defines the new pivot point to use
  85009. * @param space defines if the point is in world or local space (local by default)
  85010. * @returns the current TransformNode
  85011. */
  85012. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  85013. /**
  85014. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  85015. * @returns the pivot point
  85016. */
  85017. getPivotPoint(): Vector3;
  85018. /**
  85019. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  85020. * @param result the vector3 to store the result
  85021. * @returns this TransformNode.
  85022. */
  85023. getPivotPointToRef(result: Vector3): TransformNode;
  85024. /**
  85025. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  85026. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  85027. */
  85028. getAbsolutePivotPoint(): Vector3;
  85029. /**
  85030. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  85031. * @param result vector3 to store the result
  85032. * @returns this TransformNode.
  85033. */
  85034. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  85035. /**
  85036. * Defines the passed node as the parent of the current node.
  85037. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  85038. * @see https://doc.babylonjs.com/how_to/parenting
  85039. * @param node the node ot set as the parent
  85040. * @returns this TransformNode.
  85041. */
  85042. setParent(node: Nullable<Node>): TransformNode;
  85043. private _nonUniformScaling;
  85044. /**
  85045. * True if the scaling property of this object is non uniform eg. (1,2,1)
  85046. */
  85047. get nonUniformScaling(): boolean;
  85048. /** @hidden */
  85049. _updateNonUniformScalingState(value: boolean): boolean;
  85050. /**
  85051. * Attach the current TransformNode to another TransformNode associated with a bone
  85052. * @param bone Bone affecting the TransformNode
  85053. * @param affectedTransformNode TransformNode associated with the bone
  85054. * @returns this object
  85055. */
  85056. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  85057. /**
  85058. * Detach the transform node if its associated with a bone
  85059. * @returns this object
  85060. */
  85061. detachFromBone(): TransformNode;
  85062. private static _rotationAxisCache;
  85063. /**
  85064. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  85065. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  85066. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  85067. * The passed axis is also normalized.
  85068. * @param axis the axis to rotate around
  85069. * @param amount the amount to rotate in radians
  85070. * @param space Space to rotate in (Default: local)
  85071. * @returns the TransformNode.
  85072. */
  85073. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  85074. /**
  85075. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  85076. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  85077. * The passed axis is also normalized. .
  85078. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  85079. * @param point the point to rotate around
  85080. * @param axis the axis to rotate around
  85081. * @param amount the amount to rotate in radians
  85082. * @returns the TransformNode
  85083. */
  85084. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  85085. /**
  85086. * Translates the mesh along the axis vector for the passed distance in the given space.
  85087. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  85088. * @param axis the axis to translate in
  85089. * @param distance the distance to translate
  85090. * @param space Space to rotate in (Default: local)
  85091. * @returns the TransformNode.
  85092. */
  85093. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  85094. /**
  85095. * Adds a rotation step to the mesh current rotation.
  85096. * x, y, z are Euler angles expressed in radians.
  85097. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  85098. * This means this rotation is made in the mesh local space only.
  85099. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  85100. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  85101. * ```javascript
  85102. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  85103. * ```
  85104. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  85105. * 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.
  85106. * @param x Rotation to add
  85107. * @param y Rotation to add
  85108. * @param z Rotation to add
  85109. * @returns the TransformNode.
  85110. */
  85111. addRotation(x: number, y: number, z: number): TransformNode;
  85112. /**
  85113. * @hidden
  85114. */
  85115. protected _getEffectiveParent(): Nullable<Node>;
  85116. /**
  85117. * Computes the world matrix of the node
  85118. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85119. * @returns the world matrix
  85120. */
  85121. computeWorldMatrix(force?: boolean): Matrix;
  85122. protected _afterComputeWorldMatrix(): void;
  85123. /**
  85124. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  85125. * @param func callback function to add
  85126. *
  85127. * @returns the TransformNode.
  85128. */
  85129. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  85130. /**
  85131. * Removes a registered callback function.
  85132. * @param func callback function to remove
  85133. * @returns the TransformNode.
  85134. */
  85135. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  85136. /**
  85137. * Gets the position of the current mesh in camera space
  85138. * @param camera defines the camera to use
  85139. * @returns a position
  85140. */
  85141. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  85142. /**
  85143. * Returns the distance from the mesh to the active camera
  85144. * @param camera defines the camera to use
  85145. * @returns the distance
  85146. */
  85147. getDistanceToCamera(camera?: Nullable<Camera>): number;
  85148. /**
  85149. * Clone the current transform node
  85150. * @param name Name of the new clone
  85151. * @param newParent New parent for the clone
  85152. * @param doNotCloneChildren Do not clone children hierarchy
  85153. * @returns the new transform node
  85154. */
  85155. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  85156. /**
  85157. * Serializes the objects information.
  85158. * @param currentSerializationObject defines the object to serialize in
  85159. * @returns the serialized object
  85160. */
  85161. serialize(currentSerializationObject?: any): any;
  85162. /**
  85163. * Returns a new TransformNode object parsed from the source provided.
  85164. * @param parsedTransformNode is the source.
  85165. * @param scene the scne the object belongs to
  85166. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  85167. * @returns a new TransformNode object parsed from the source provided.
  85168. */
  85169. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  85170. /**
  85171. * Get all child-transformNodes of this node
  85172. * @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
  85173. * @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
  85174. * @returns an array of TransformNode
  85175. */
  85176. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  85177. /**
  85178. * Releases resources associated with this transform node.
  85179. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  85180. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  85181. */
  85182. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85183. /**
  85184. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  85185. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  85186. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  85187. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  85188. * @returns the current mesh
  85189. */
  85190. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  85191. private _syncAbsoluteScalingAndRotation;
  85192. }
  85193. }
  85194. declare module BABYLON {
  85195. /**
  85196. * Defines the types of pose enabled controllers that are supported
  85197. */
  85198. export enum PoseEnabledControllerType {
  85199. /**
  85200. * HTC Vive
  85201. */
  85202. VIVE = 0,
  85203. /**
  85204. * Oculus Rift
  85205. */
  85206. OCULUS = 1,
  85207. /**
  85208. * Windows mixed reality
  85209. */
  85210. WINDOWS = 2,
  85211. /**
  85212. * Samsung gear VR
  85213. */
  85214. GEAR_VR = 3,
  85215. /**
  85216. * Google Daydream
  85217. */
  85218. DAYDREAM = 4,
  85219. /**
  85220. * Generic
  85221. */
  85222. GENERIC = 5
  85223. }
  85224. /**
  85225. * Defines the MutableGamepadButton interface for the state of a gamepad button
  85226. */
  85227. export interface MutableGamepadButton {
  85228. /**
  85229. * Value of the button/trigger
  85230. */
  85231. value: number;
  85232. /**
  85233. * If the button/trigger is currently touched
  85234. */
  85235. touched: boolean;
  85236. /**
  85237. * If the button/trigger is currently pressed
  85238. */
  85239. pressed: boolean;
  85240. }
  85241. /**
  85242. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  85243. * @hidden
  85244. */
  85245. export interface ExtendedGamepadButton extends GamepadButton {
  85246. /**
  85247. * If the button/trigger is currently pressed
  85248. */
  85249. readonly pressed: boolean;
  85250. /**
  85251. * If the button/trigger is currently touched
  85252. */
  85253. readonly touched: boolean;
  85254. /**
  85255. * Value of the button/trigger
  85256. */
  85257. readonly value: number;
  85258. }
  85259. /** @hidden */
  85260. export interface _GamePadFactory {
  85261. /**
  85262. * Returns wether or not the current gamepad can be created for this type of controller.
  85263. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  85264. * @returns true if it can be created, otherwise false
  85265. */
  85266. canCreate(gamepadInfo: any): boolean;
  85267. /**
  85268. * Creates a new instance of the Gamepad.
  85269. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  85270. * @returns the new gamepad instance
  85271. */
  85272. create(gamepadInfo: any): Gamepad;
  85273. }
  85274. /**
  85275. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  85276. */
  85277. export class PoseEnabledControllerHelper {
  85278. /** @hidden */
  85279. static _ControllerFactories: _GamePadFactory[];
  85280. /** @hidden */
  85281. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  85282. /**
  85283. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  85284. * @param vrGamepad the gamepad to initialized
  85285. * @returns a vr controller of the type the gamepad identified as
  85286. */
  85287. static InitiateController(vrGamepad: any): Gamepad;
  85288. }
  85289. /**
  85290. * Defines the PoseEnabledController object that contains state of a vr capable controller
  85291. */
  85292. export class PoseEnabledController extends Gamepad implements PoseControlled {
  85293. /**
  85294. * If the controller is used in a webXR session
  85295. */
  85296. isXR: boolean;
  85297. private _deviceRoomPosition;
  85298. private _deviceRoomRotationQuaternion;
  85299. /**
  85300. * The device position in babylon space
  85301. */
  85302. devicePosition: Vector3;
  85303. /**
  85304. * The device rotation in babylon space
  85305. */
  85306. deviceRotationQuaternion: Quaternion;
  85307. /**
  85308. * The scale factor of the device in babylon space
  85309. */
  85310. deviceScaleFactor: number;
  85311. /**
  85312. * (Likely devicePosition should be used instead) The device position in its room space
  85313. */
  85314. position: Vector3;
  85315. /**
  85316. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  85317. */
  85318. rotationQuaternion: Quaternion;
  85319. /**
  85320. * The type of controller (Eg. Windows mixed reality)
  85321. */
  85322. controllerType: PoseEnabledControllerType;
  85323. protected _calculatedPosition: Vector3;
  85324. private _calculatedRotation;
  85325. /**
  85326. * The raw pose from the device
  85327. */
  85328. rawPose: DevicePose;
  85329. private _trackPosition;
  85330. private _maxRotationDistFromHeadset;
  85331. private _draggedRoomRotation;
  85332. /**
  85333. * @hidden
  85334. */
  85335. _disableTrackPosition(fixedPosition: Vector3): void;
  85336. /**
  85337. * Internal, the mesh attached to the controller
  85338. * @hidden
  85339. */
  85340. _mesh: Nullable<AbstractMesh>;
  85341. private _poseControlledCamera;
  85342. private _leftHandSystemQuaternion;
  85343. /**
  85344. * Internal, matrix used to convert room space to babylon space
  85345. * @hidden
  85346. */
  85347. _deviceToWorld: Matrix;
  85348. /**
  85349. * Node to be used when casting a ray from the controller
  85350. * @hidden
  85351. */
  85352. _pointingPoseNode: Nullable<TransformNode>;
  85353. /**
  85354. * Name of the child mesh that can be used to cast a ray from the controller
  85355. */
  85356. static readonly POINTING_POSE: string;
  85357. /**
  85358. * Creates a new PoseEnabledController from a gamepad
  85359. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  85360. */
  85361. constructor(browserGamepad: any);
  85362. private _workingMatrix;
  85363. /**
  85364. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  85365. */
  85366. update(): void;
  85367. /**
  85368. * Updates only the pose device and mesh without doing any button event checking
  85369. */
  85370. protected _updatePoseAndMesh(): void;
  85371. /**
  85372. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  85373. * @param poseData raw pose fromthe device
  85374. */
  85375. updateFromDevice(poseData: DevicePose): void;
  85376. /**
  85377. * @hidden
  85378. */
  85379. _meshAttachedObservable: Observable<AbstractMesh>;
  85380. /**
  85381. * Attaches a mesh to the controller
  85382. * @param mesh the mesh to be attached
  85383. */
  85384. attachToMesh(mesh: AbstractMesh): void;
  85385. /**
  85386. * Attaches the controllers mesh to a camera
  85387. * @param camera the camera the mesh should be attached to
  85388. */
  85389. attachToPoseControlledCamera(camera: TargetCamera): void;
  85390. /**
  85391. * Disposes of the controller
  85392. */
  85393. dispose(): void;
  85394. /**
  85395. * The mesh that is attached to the controller
  85396. */
  85397. get mesh(): Nullable<AbstractMesh>;
  85398. /**
  85399. * Gets the ray of the controller in the direction the controller is pointing
  85400. * @param length the length the resulting ray should be
  85401. * @returns a ray in the direction the controller is pointing
  85402. */
  85403. getForwardRay(length?: number): Ray;
  85404. }
  85405. }
  85406. declare module BABYLON {
  85407. /**
  85408. * Defines the WebVRController object that represents controllers tracked in 3D space
  85409. */
  85410. export abstract class WebVRController extends PoseEnabledController {
  85411. /**
  85412. * Internal, the default controller model for the controller
  85413. */
  85414. protected _defaultModel: Nullable<AbstractMesh>;
  85415. /**
  85416. * Fired when the trigger state has changed
  85417. */
  85418. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  85419. /**
  85420. * Fired when the main button state has changed
  85421. */
  85422. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  85423. /**
  85424. * Fired when the secondary button state has changed
  85425. */
  85426. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  85427. /**
  85428. * Fired when the pad state has changed
  85429. */
  85430. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  85431. /**
  85432. * Fired when controllers stick values have changed
  85433. */
  85434. onPadValuesChangedObservable: Observable<StickValues>;
  85435. /**
  85436. * Array of button availible on the controller
  85437. */
  85438. protected _buttons: Array<MutableGamepadButton>;
  85439. private _onButtonStateChange;
  85440. /**
  85441. * Fired when a controller button's state has changed
  85442. * @param callback the callback containing the button that was modified
  85443. */
  85444. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  85445. /**
  85446. * X and Y axis corresponding to the controllers joystick
  85447. */
  85448. pad: StickValues;
  85449. /**
  85450. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  85451. */
  85452. hand: string;
  85453. /**
  85454. * The default controller model for the controller
  85455. */
  85456. get defaultModel(): Nullable<AbstractMesh>;
  85457. /**
  85458. * Creates a new WebVRController from a gamepad
  85459. * @param vrGamepad the gamepad that the WebVRController should be created from
  85460. */
  85461. constructor(vrGamepad: any);
  85462. /**
  85463. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  85464. */
  85465. update(): void;
  85466. /**
  85467. * Function to be called when a button is modified
  85468. */
  85469. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  85470. /**
  85471. * Loads a mesh and attaches it to the controller
  85472. * @param scene the scene the mesh should be added to
  85473. * @param meshLoaded callback for when the mesh has been loaded
  85474. */
  85475. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  85476. private _setButtonValue;
  85477. private _changes;
  85478. private _checkChanges;
  85479. /**
  85480. * Disposes of th webVRCOntroller
  85481. */
  85482. dispose(): void;
  85483. }
  85484. }
  85485. declare module BABYLON {
  85486. /**
  85487. * The HemisphericLight simulates the ambient environment light,
  85488. * so the passed direction is the light reflection direction, not the incoming direction.
  85489. */
  85490. export class HemisphericLight extends Light {
  85491. /**
  85492. * The groundColor is the light in the opposite direction to the one specified during creation.
  85493. * 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.
  85494. */
  85495. groundColor: Color3;
  85496. /**
  85497. * The light reflection direction, not the incoming direction.
  85498. */
  85499. direction: Vector3;
  85500. /**
  85501. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  85502. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  85503. * The HemisphericLight can't cast shadows.
  85504. * Documentation : https://doc.babylonjs.com/babylon101/lights
  85505. * @param name The friendly name of the light
  85506. * @param direction The direction of the light reflection
  85507. * @param scene The scene the light belongs to
  85508. */
  85509. constructor(name: string, direction: Vector3, scene: Scene);
  85510. protected _buildUniformLayout(): void;
  85511. /**
  85512. * Returns the string "HemisphericLight".
  85513. * @return The class name
  85514. */
  85515. getClassName(): string;
  85516. /**
  85517. * Sets the HemisphericLight direction towards the passed target (Vector3).
  85518. * Returns the updated direction.
  85519. * @param target The target the direction should point to
  85520. * @return The computed direction
  85521. */
  85522. setDirectionToTarget(target: Vector3): Vector3;
  85523. /**
  85524. * Returns the shadow generator associated to the light.
  85525. * @returns Always null for hemispheric lights because it does not support shadows.
  85526. */
  85527. getShadowGenerator(): Nullable<IShadowGenerator>;
  85528. /**
  85529. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  85530. * @param effect The effect to update
  85531. * @param lightIndex The index of the light in the effect to update
  85532. * @returns The hemispheric light
  85533. */
  85534. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  85535. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  85536. /**
  85537. * Computes the world matrix of the node
  85538. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85539. * @param useWasUpdatedFlag defines a reserved property
  85540. * @returns the world matrix
  85541. */
  85542. computeWorldMatrix(): Matrix;
  85543. /**
  85544. * Returns the integer 3.
  85545. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  85546. */
  85547. getTypeID(): number;
  85548. /**
  85549. * Prepares the list of defines specific to the light type.
  85550. * @param defines the list of defines
  85551. * @param lightIndex defines the index of the light for the effect
  85552. */
  85553. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  85554. }
  85555. }
  85556. declare module BABYLON {
  85557. /** @hidden */
  85558. export var vrMultiviewToSingleviewPixelShader: {
  85559. name: string;
  85560. shader: string;
  85561. };
  85562. }
  85563. declare module BABYLON {
  85564. /**
  85565. * Renders to multiple views with a single draw call
  85566. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  85567. */
  85568. export class MultiviewRenderTarget extends RenderTargetTexture {
  85569. /**
  85570. * Creates a multiview render target
  85571. * @param scene scene used with the render target
  85572. * @param size the size of the render target (used for each view)
  85573. */
  85574. constructor(scene: Scene, size?: number | {
  85575. width: number;
  85576. height: number;
  85577. } | {
  85578. ratio: number;
  85579. });
  85580. /**
  85581. * @hidden
  85582. * @param faceIndex the face index, if its a cube texture
  85583. */
  85584. _bindFrameBuffer(faceIndex?: number): void;
  85585. /**
  85586. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  85587. * @returns the view count
  85588. */
  85589. getViewCount(): number;
  85590. }
  85591. }
  85592. declare module BABYLON {
  85593. /**
  85594. * Represents a camera frustum
  85595. */
  85596. export class Frustum {
  85597. /**
  85598. * Gets the planes representing the frustum
  85599. * @param transform matrix to be applied to the returned planes
  85600. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  85601. */
  85602. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  85603. /**
  85604. * Gets the near frustum plane transformed by the transform matrix
  85605. * @param transform transformation matrix to be applied to the resulting frustum plane
  85606. * @param frustumPlane the resuling frustum plane
  85607. */
  85608. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85609. /**
  85610. * Gets the far frustum plane transformed by the transform matrix
  85611. * @param transform transformation matrix to be applied to the resulting frustum plane
  85612. * @param frustumPlane the resuling frustum plane
  85613. */
  85614. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85615. /**
  85616. * Gets the left frustum plane transformed by the transform matrix
  85617. * @param transform transformation matrix to be applied to the resulting frustum plane
  85618. * @param frustumPlane the resuling frustum plane
  85619. */
  85620. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85621. /**
  85622. * Gets the right frustum plane transformed by the transform matrix
  85623. * @param transform transformation matrix to be applied to the resulting frustum plane
  85624. * @param frustumPlane the resuling frustum plane
  85625. */
  85626. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85627. /**
  85628. * Gets the top frustum plane transformed by the transform matrix
  85629. * @param transform transformation matrix to be applied to the resulting frustum plane
  85630. * @param frustumPlane the resuling frustum plane
  85631. */
  85632. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85633. /**
  85634. * Gets the bottom frustum plane transformed by the transform matrix
  85635. * @param transform transformation matrix to be applied to the resulting frustum plane
  85636. * @param frustumPlane the resuling frustum plane
  85637. */
  85638. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  85639. /**
  85640. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  85641. * @param transform transformation matrix to be applied to the resulting frustum planes
  85642. * @param frustumPlanes the resuling frustum planes
  85643. */
  85644. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  85645. }
  85646. }
  85647. declare module BABYLON {
  85648. interface Engine {
  85649. /**
  85650. * Creates a new multiview render target
  85651. * @param width defines the width of the texture
  85652. * @param height defines the height of the texture
  85653. * @returns the created multiview texture
  85654. */
  85655. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  85656. /**
  85657. * Binds a multiview framebuffer to be drawn to
  85658. * @param multiviewTexture texture to bind
  85659. */
  85660. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  85661. }
  85662. interface Camera {
  85663. /**
  85664. * @hidden
  85665. * 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)
  85666. */
  85667. _useMultiviewToSingleView: boolean;
  85668. /**
  85669. * @hidden
  85670. * 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)
  85671. */
  85672. _multiviewTexture: Nullable<RenderTargetTexture>;
  85673. /**
  85674. * @hidden
  85675. * ensures the multiview texture of the camera exists and has the specified width/height
  85676. * @param width height to set on the multiview texture
  85677. * @param height width to set on the multiview texture
  85678. */
  85679. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  85680. }
  85681. interface Scene {
  85682. /** @hidden */
  85683. _transformMatrixR: Matrix;
  85684. /** @hidden */
  85685. _multiviewSceneUbo: Nullable<UniformBuffer>;
  85686. /** @hidden */
  85687. _createMultiviewUbo(): void;
  85688. /** @hidden */
  85689. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  85690. /** @hidden */
  85691. _renderMultiviewToSingleView(camera: Camera): void;
  85692. }
  85693. }
  85694. declare module BABYLON {
  85695. /**
  85696. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  85697. * This will not be used for webXR as it supports displaying texture arrays directly
  85698. */
  85699. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  85700. /**
  85701. * Initializes a VRMultiviewToSingleview
  85702. * @param name name of the post process
  85703. * @param camera camera to be applied to
  85704. * @param scaleFactor scaling factor to the size of the output texture
  85705. */
  85706. constructor(name: string, camera: Camera, scaleFactor: number);
  85707. }
  85708. }
  85709. declare module BABYLON {
  85710. /**
  85711. * Interface used to define additional presentation attributes
  85712. */
  85713. export interface IVRPresentationAttributes {
  85714. /**
  85715. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  85716. */
  85717. highRefreshRate: boolean;
  85718. /**
  85719. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  85720. */
  85721. foveationLevel: number;
  85722. }
  85723. interface Engine {
  85724. /** @hidden */
  85725. _vrDisplay: any;
  85726. /** @hidden */
  85727. _vrSupported: boolean;
  85728. /** @hidden */
  85729. _oldSize: Size;
  85730. /** @hidden */
  85731. _oldHardwareScaleFactor: number;
  85732. /** @hidden */
  85733. _vrExclusivePointerMode: boolean;
  85734. /** @hidden */
  85735. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  85736. /** @hidden */
  85737. _onVRDisplayPointerRestricted: () => void;
  85738. /** @hidden */
  85739. _onVRDisplayPointerUnrestricted: () => void;
  85740. /** @hidden */
  85741. _onVrDisplayConnect: Nullable<(display: any) => void>;
  85742. /** @hidden */
  85743. _onVrDisplayDisconnect: Nullable<() => void>;
  85744. /** @hidden */
  85745. _onVrDisplayPresentChange: Nullable<() => void>;
  85746. /**
  85747. * Observable signaled when VR display mode changes
  85748. */
  85749. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  85750. /**
  85751. * Observable signaled when VR request present is complete
  85752. */
  85753. onVRRequestPresentComplete: Observable<boolean>;
  85754. /**
  85755. * Observable signaled when VR request present starts
  85756. */
  85757. onVRRequestPresentStart: Observable<Engine>;
  85758. /**
  85759. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  85760. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  85761. */
  85762. isInVRExclusivePointerMode: boolean;
  85763. /**
  85764. * Gets a boolean indicating if a webVR device was detected
  85765. * @returns true if a webVR device was detected
  85766. */
  85767. isVRDevicePresent(): boolean;
  85768. /**
  85769. * Gets the current webVR device
  85770. * @returns the current webVR device (or null)
  85771. */
  85772. getVRDevice(): any;
  85773. /**
  85774. * Initializes a webVR display and starts listening to display change events
  85775. * The onVRDisplayChangedObservable will be notified upon these changes
  85776. * @returns A promise containing a VRDisplay and if vr is supported
  85777. */
  85778. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  85779. /** @hidden */
  85780. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  85781. /**
  85782. * Gets or sets the presentation attributes used to configure VR rendering
  85783. */
  85784. vrPresentationAttributes?: IVRPresentationAttributes;
  85785. /**
  85786. * Call this function to switch to webVR mode
  85787. * Will do nothing if webVR is not supported or if there is no webVR device
  85788. * @param options the webvr options provided to the camera. mainly used for multiview
  85789. * @see http://doc.babylonjs.com/how_to/webvr_camera
  85790. */
  85791. enableVR(options: WebVROptions): void;
  85792. /** @hidden */
  85793. _onVRFullScreenTriggered(): void;
  85794. }
  85795. }
  85796. declare module BABYLON {
  85797. /**
  85798. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  85799. * IMPORTANT!! The data is right-hand data.
  85800. * @export
  85801. * @interface DevicePose
  85802. */
  85803. export interface DevicePose {
  85804. /**
  85805. * The position of the device, values in array are [x,y,z].
  85806. */
  85807. readonly position: Nullable<Float32Array>;
  85808. /**
  85809. * The linearVelocity of the device, values in array are [x,y,z].
  85810. */
  85811. readonly linearVelocity: Nullable<Float32Array>;
  85812. /**
  85813. * The linearAcceleration of the device, values in array are [x,y,z].
  85814. */
  85815. readonly linearAcceleration: Nullable<Float32Array>;
  85816. /**
  85817. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  85818. */
  85819. readonly orientation: Nullable<Float32Array>;
  85820. /**
  85821. * The angularVelocity of the device, values in array are [x,y,z].
  85822. */
  85823. readonly angularVelocity: Nullable<Float32Array>;
  85824. /**
  85825. * The angularAcceleration of the device, values in array are [x,y,z].
  85826. */
  85827. readonly angularAcceleration: Nullable<Float32Array>;
  85828. }
  85829. /**
  85830. * Interface representing a pose controlled object in Babylon.
  85831. * A pose controlled object has both regular pose values as well as pose values
  85832. * from an external device such as a VR head mounted display
  85833. */
  85834. export interface PoseControlled {
  85835. /**
  85836. * The position of the object in babylon space.
  85837. */
  85838. position: Vector3;
  85839. /**
  85840. * The rotation quaternion of the object in babylon space.
  85841. */
  85842. rotationQuaternion: Quaternion;
  85843. /**
  85844. * The position of the device in babylon space.
  85845. */
  85846. devicePosition?: Vector3;
  85847. /**
  85848. * The rotation quaternion of the device in babylon space.
  85849. */
  85850. deviceRotationQuaternion: Quaternion;
  85851. /**
  85852. * The raw pose coming from the device.
  85853. */
  85854. rawPose: Nullable<DevicePose>;
  85855. /**
  85856. * The scale of the device to be used when translating from device space to babylon space.
  85857. */
  85858. deviceScaleFactor: number;
  85859. /**
  85860. * Updates the poseControlled values based on the input device pose.
  85861. * @param poseData the pose data to update the object with
  85862. */
  85863. updateFromDevice(poseData: DevicePose): void;
  85864. }
  85865. /**
  85866. * Set of options to customize the webVRCamera
  85867. */
  85868. export interface WebVROptions {
  85869. /**
  85870. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  85871. */
  85872. trackPosition?: boolean;
  85873. /**
  85874. * Sets the scale of the vrDevice in babylon space. (default: 1)
  85875. */
  85876. positionScale?: number;
  85877. /**
  85878. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  85879. */
  85880. displayName?: string;
  85881. /**
  85882. * Should the native controller meshes be initialized. (default: true)
  85883. */
  85884. controllerMeshes?: boolean;
  85885. /**
  85886. * Creating a default HemiLight only on controllers. (default: true)
  85887. */
  85888. defaultLightingOnControllers?: boolean;
  85889. /**
  85890. * If you don't want to use the default VR button of the helper. (default: false)
  85891. */
  85892. useCustomVRButton?: boolean;
  85893. /**
  85894. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  85895. */
  85896. customVRButton?: HTMLButtonElement;
  85897. /**
  85898. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  85899. */
  85900. rayLength?: number;
  85901. /**
  85902. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  85903. */
  85904. defaultHeight?: number;
  85905. /**
  85906. * If multiview should be used if availible (default: false)
  85907. */
  85908. useMultiview?: boolean;
  85909. }
  85910. /**
  85911. * This represents a WebVR camera.
  85912. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  85913. * @example http://doc.babylonjs.com/how_to/webvr_camera
  85914. */
  85915. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  85916. private webVROptions;
  85917. /**
  85918. * @hidden
  85919. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  85920. */
  85921. _vrDevice: any;
  85922. /**
  85923. * The rawPose of the vrDevice.
  85924. */
  85925. rawPose: Nullable<DevicePose>;
  85926. private _onVREnabled;
  85927. private _specsVersion;
  85928. private _attached;
  85929. private _frameData;
  85930. protected _descendants: Array<Node>;
  85931. private _deviceRoomPosition;
  85932. /** @hidden */
  85933. _deviceRoomRotationQuaternion: Quaternion;
  85934. private _standingMatrix;
  85935. /**
  85936. * Represents device position in babylon space.
  85937. */
  85938. devicePosition: Vector3;
  85939. /**
  85940. * Represents device rotation in babylon space.
  85941. */
  85942. deviceRotationQuaternion: Quaternion;
  85943. /**
  85944. * The scale of the device to be used when translating from device space to babylon space.
  85945. */
  85946. deviceScaleFactor: number;
  85947. private _deviceToWorld;
  85948. private _worldToDevice;
  85949. /**
  85950. * References to the webVR controllers for the vrDevice.
  85951. */
  85952. controllers: Array<WebVRController>;
  85953. /**
  85954. * Emits an event when a controller is attached.
  85955. */
  85956. onControllersAttachedObservable: Observable<WebVRController[]>;
  85957. /**
  85958. * Emits an event when a controller's mesh has been loaded;
  85959. */
  85960. onControllerMeshLoadedObservable: Observable<WebVRController>;
  85961. /**
  85962. * Emits an event when the HMD's pose has been updated.
  85963. */
  85964. onPoseUpdatedFromDeviceObservable: Observable<any>;
  85965. private _poseSet;
  85966. /**
  85967. * If the rig cameras be used as parent instead of this camera.
  85968. */
  85969. rigParenting: boolean;
  85970. private _lightOnControllers;
  85971. private _defaultHeight?;
  85972. /**
  85973. * Instantiates a WebVRFreeCamera.
  85974. * @param name The name of the WebVRFreeCamera
  85975. * @param position The starting anchor position for the camera
  85976. * @param scene The scene the camera belongs to
  85977. * @param webVROptions a set of customizable options for the webVRCamera
  85978. */
  85979. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  85980. /**
  85981. * Gets the device distance from the ground in meters.
  85982. * @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.
  85983. */
  85984. deviceDistanceToRoomGround(): number;
  85985. /**
  85986. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  85987. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  85988. */
  85989. useStandingMatrix(callback?: (bool: boolean) => void): void;
  85990. /**
  85991. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  85992. * @returns A promise with a boolean set to if the standing matrix is supported.
  85993. */
  85994. useStandingMatrixAsync(): Promise<boolean>;
  85995. /**
  85996. * Disposes the camera
  85997. */
  85998. dispose(): void;
  85999. /**
  86000. * Gets a vrController by name.
  86001. * @param name The name of the controller to retreive
  86002. * @returns the controller matching the name specified or null if not found
  86003. */
  86004. getControllerByName(name: string): Nullable<WebVRController>;
  86005. private _leftController;
  86006. /**
  86007. * The controller corresponding to the users left hand.
  86008. */
  86009. get leftController(): Nullable<WebVRController>;
  86010. private _rightController;
  86011. /**
  86012. * The controller corresponding to the users right hand.
  86013. */
  86014. get rightController(): Nullable<WebVRController>;
  86015. /**
  86016. * Casts a ray forward from the vrCamera's gaze.
  86017. * @param length Length of the ray (default: 100)
  86018. * @returns the ray corresponding to the gaze
  86019. */
  86020. getForwardRay(length?: number): Ray;
  86021. /**
  86022. * @hidden
  86023. * Updates the camera based on device's frame data
  86024. */
  86025. _checkInputs(): void;
  86026. /**
  86027. * Updates the poseControlled values based on the input device pose.
  86028. * @param poseData Pose coming from the device
  86029. */
  86030. updateFromDevice(poseData: DevicePose): void;
  86031. private _htmlElementAttached;
  86032. private _detachIfAttached;
  86033. /**
  86034. * WebVR's attach control will start broadcasting frames to the device.
  86035. * Note that in certain browsers (chrome for example) this function must be called
  86036. * within a user-interaction callback. Example:
  86037. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  86038. *
  86039. * @param element html element to attach the vrDevice to
  86040. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  86041. */
  86042. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  86043. /**
  86044. * Detaches the camera from the html element and disables VR
  86045. *
  86046. * @param element html element to detach from
  86047. */
  86048. detachControl(element: HTMLElement): void;
  86049. /**
  86050. * @returns the name of this class
  86051. */
  86052. getClassName(): string;
  86053. /**
  86054. * Calls resetPose on the vrDisplay
  86055. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  86056. */
  86057. resetToCurrentRotation(): void;
  86058. /**
  86059. * @hidden
  86060. * Updates the rig cameras (left and right eye)
  86061. */
  86062. _updateRigCameras(): void;
  86063. private _workingVector;
  86064. private _oneVector;
  86065. private _workingMatrix;
  86066. private updateCacheCalled;
  86067. private _correctPositionIfNotTrackPosition;
  86068. /**
  86069. * @hidden
  86070. * Updates the cached values of the camera
  86071. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  86072. */
  86073. _updateCache(ignoreParentClass?: boolean): void;
  86074. /**
  86075. * @hidden
  86076. * Get current device position in babylon world
  86077. */
  86078. _computeDevicePosition(): void;
  86079. /**
  86080. * Updates the current device position and rotation in the babylon world
  86081. */
  86082. update(): void;
  86083. /**
  86084. * @hidden
  86085. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  86086. * @returns an identity matrix
  86087. */
  86088. _getViewMatrix(): Matrix;
  86089. private _tmpMatrix;
  86090. /**
  86091. * This function is called by the two RIG cameras.
  86092. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  86093. * @hidden
  86094. */
  86095. _getWebVRViewMatrix(): Matrix;
  86096. /** @hidden */
  86097. _getWebVRProjectionMatrix(): Matrix;
  86098. private _onGamepadConnectedObserver;
  86099. private _onGamepadDisconnectedObserver;
  86100. private _updateCacheWhenTrackingDisabledObserver;
  86101. /**
  86102. * Initializes the controllers and their meshes
  86103. */
  86104. initControllers(): void;
  86105. }
  86106. }
  86107. declare module BABYLON {
  86108. /**
  86109. * Size options for a post process
  86110. */
  86111. export type PostProcessOptions = {
  86112. width: number;
  86113. height: number;
  86114. };
  86115. /**
  86116. * PostProcess can be used to apply a shader to a texture after it has been rendered
  86117. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  86118. */
  86119. export class PostProcess {
  86120. /** Name of the PostProcess. */
  86121. name: string;
  86122. /**
  86123. * Gets or sets the unique id of the post process
  86124. */
  86125. uniqueId: number;
  86126. /**
  86127. * Width of the texture to apply the post process on
  86128. */
  86129. width: number;
  86130. /**
  86131. * Height of the texture to apply the post process on
  86132. */
  86133. height: number;
  86134. /**
  86135. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  86136. * @hidden
  86137. */
  86138. _outputTexture: Nullable<InternalTexture>;
  86139. /**
  86140. * Sampling mode used by the shader
  86141. * See https://doc.babylonjs.com/classes/3.1/texture
  86142. */
  86143. renderTargetSamplingMode: number;
  86144. /**
  86145. * Clear color to use when screen clearing
  86146. */
  86147. clearColor: Color4;
  86148. /**
  86149. * If the buffer needs to be cleared before applying the post process. (default: true)
  86150. * Should be set to false if shader will overwrite all previous pixels.
  86151. */
  86152. autoClear: boolean;
  86153. /**
  86154. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  86155. */
  86156. alphaMode: number;
  86157. /**
  86158. * Sets the setAlphaBlendConstants of the babylon engine
  86159. */
  86160. alphaConstants: Color4;
  86161. /**
  86162. * Animations to be used for the post processing
  86163. */
  86164. animations: Animation[];
  86165. /**
  86166. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  86167. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  86168. */
  86169. enablePixelPerfectMode: boolean;
  86170. /**
  86171. * Force the postprocess to be applied without taking in account viewport
  86172. */
  86173. forceFullscreenViewport: boolean;
  86174. /**
  86175. * List of inspectable custom properties (used by the Inspector)
  86176. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86177. */
  86178. inspectableCustomProperties: IInspectable[];
  86179. /**
  86180. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  86181. *
  86182. * | Value | Type | Description |
  86183. * | ----- | ----------------------------------- | ----------- |
  86184. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  86185. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  86186. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  86187. *
  86188. */
  86189. scaleMode: number;
  86190. /**
  86191. * Force textures to be a power of two (default: false)
  86192. */
  86193. alwaysForcePOT: boolean;
  86194. private _samples;
  86195. /**
  86196. * Number of sample textures (default: 1)
  86197. */
  86198. get samples(): number;
  86199. set samples(n: number);
  86200. /**
  86201. * Modify the scale of the post process to be the same as the viewport (default: false)
  86202. */
  86203. adaptScaleToCurrentViewport: boolean;
  86204. private _camera;
  86205. private _scene;
  86206. private _engine;
  86207. private _options;
  86208. private _reusable;
  86209. private _textureType;
  86210. /**
  86211. * Smart array of input and output textures for the post process.
  86212. * @hidden
  86213. */
  86214. _textures: SmartArray<InternalTexture>;
  86215. /**
  86216. * The index in _textures that corresponds to the output texture.
  86217. * @hidden
  86218. */
  86219. _currentRenderTextureInd: number;
  86220. private _effect;
  86221. private _samplers;
  86222. private _fragmentUrl;
  86223. private _vertexUrl;
  86224. private _parameters;
  86225. private _scaleRatio;
  86226. protected _indexParameters: any;
  86227. private _shareOutputWithPostProcess;
  86228. private _texelSize;
  86229. private _forcedOutputTexture;
  86230. /**
  86231. * Returns the fragment url or shader name used in the post process.
  86232. * @returns the fragment url or name in the shader store.
  86233. */
  86234. getEffectName(): string;
  86235. /**
  86236. * An event triggered when the postprocess is activated.
  86237. */
  86238. onActivateObservable: Observable<Camera>;
  86239. private _onActivateObserver;
  86240. /**
  86241. * A function that is added to the onActivateObservable
  86242. */
  86243. set onActivate(callback: Nullable<(camera: Camera) => void>);
  86244. /**
  86245. * An event triggered when the postprocess changes its size.
  86246. */
  86247. onSizeChangedObservable: Observable<PostProcess>;
  86248. private _onSizeChangedObserver;
  86249. /**
  86250. * A function that is added to the onSizeChangedObservable
  86251. */
  86252. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  86253. /**
  86254. * An event triggered when the postprocess applies its effect.
  86255. */
  86256. onApplyObservable: Observable<Effect>;
  86257. private _onApplyObserver;
  86258. /**
  86259. * A function that is added to the onApplyObservable
  86260. */
  86261. set onApply(callback: (effect: Effect) => void);
  86262. /**
  86263. * An event triggered before rendering the postprocess
  86264. */
  86265. onBeforeRenderObservable: Observable<Effect>;
  86266. private _onBeforeRenderObserver;
  86267. /**
  86268. * A function that is added to the onBeforeRenderObservable
  86269. */
  86270. set onBeforeRender(callback: (effect: Effect) => void);
  86271. /**
  86272. * An event triggered after rendering the postprocess
  86273. */
  86274. onAfterRenderObservable: Observable<Effect>;
  86275. private _onAfterRenderObserver;
  86276. /**
  86277. * A function that is added to the onAfterRenderObservable
  86278. */
  86279. set onAfterRender(callback: (efect: Effect) => void);
  86280. /**
  86281. * 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
  86282. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  86283. */
  86284. get inputTexture(): InternalTexture;
  86285. set inputTexture(value: InternalTexture);
  86286. /**
  86287. * Gets the camera which post process is applied to.
  86288. * @returns The camera the post process is applied to.
  86289. */
  86290. getCamera(): Camera;
  86291. /**
  86292. * Gets the texel size of the postprocess.
  86293. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  86294. */
  86295. get texelSize(): Vector2;
  86296. /**
  86297. * Creates a new instance PostProcess
  86298. * @param name The name of the PostProcess.
  86299. * @param fragmentUrl The url of the fragment shader to be used.
  86300. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  86301. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  86302. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  86303. * @param camera The camera to apply the render pass to.
  86304. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  86305. * @param engine The engine which the post process will be applied. (default: current engine)
  86306. * @param reusable If the post process can be reused on the same frame. (default: false)
  86307. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  86308. * @param textureType Type of textures used when performing the post process. (default: 0)
  86309. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  86310. * @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
  86311. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  86312. */
  86313. constructor(
  86314. /** Name of the PostProcess. */
  86315. 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);
  86316. /**
  86317. * Gets a string idenfifying the name of the class
  86318. * @returns "PostProcess" string
  86319. */
  86320. getClassName(): string;
  86321. /**
  86322. * Gets the engine which this post process belongs to.
  86323. * @returns The engine the post process was enabled with.
  86324. */
  86325. getEngine(): Engine;
  86326. /**
  86327. * The effect that is created when initializing the post process.
  86328. * @returns The created effect corresponding the the postprocess.
  86329. */
  86330. getEffect(): Effect;
  86331. /**
  86332. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  86333. * @param postProcess The post process to share the output with.
  86334. * @returns This post process.
  86335. */
  86336. shareOutputWith(postProcess: PostProcess): PostProcess;
  86337. /**
  86338. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  86339. * This should be called if the post process that shares output with this post process is disabled/disposed.
  86340. */
  86341. useOwnOutput(): void;
  86342. /**
  86343. * Updates the effect with the current post process compile time values and recompiles the shader.
  86344. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  86345. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  86346. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  86347. * @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
  86348. * @param onCompiled Called when the shader has been compiled.
  86349. * @param onError Called if there is an error when compiling a shader.
  86350. */
  86351. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  86352. /**
  86353. * The post process is reusable if it can be used multiple times within one frame.
  86354. * @returns If the post process is reusable
  86355. */
  86356. isReusable(): boolean;
  86357. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  86358. markTextureDirty(): void;
  86359. /**
  86360. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  86361. * 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.
  86362. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  86363. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  86364. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  86365. * @returns The target texture that was bound to be written to.
  86366. */
  86367. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  86368. /**
  86369. * If the post process is supported.
  86370. */
  86371. get isSupported(): boolean;
  86372. /**
  86373. * The aspect ratio of the output texture.
  86374. */
  86375. get aspectRatio(): number;
  86376. /**
  86377. * Get a value indicating if the post-process is ready to be used
  86378. * @returns true if the post-process is ready (shader is compiled)
  86379. */
  86380. isReady(): boolean;
  86381. /**
  86382. * Binds all textures and uniforms to the shader, this will be run on every pass.
  86383. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  86384. */
  86385. apply(): Nullable<Effect>;
  86386. private _disposeTextures;
  86387. /**
  86388. * Disposes the post process.
  86389. * @param camera The camera to dispose the post process on.
  86390. */
  86391. dispose(camera?: Camera): void;
  86392. }
  86393. }
  86394. declare module BABYLON {
  86395. /** @hidden */
  86396. export var kernelBlurVaryingDeclaration: {
  86397. name: string;
  86398. shader: string;
  86399. };
  86400. }
  86401. declare module BABYLON {
  86402. /** @hidden */
  86403. export var kernelBlurFragment: {
  86404. name: string;
  86405. shader: string;
  86406. };
  86407. }
  86408. declare module BABYLON {
  86409. /** @hidden */
  86410. export var kernelBlurFragment2: {
  86411. name: string;
  86412. shader: string;
  86413. };
  86414. }
  86415. declare module BABYLON {
  86416. /** @hidden */
  86417. export var kernelBlurPixelShader: {
  86418. name: string;
  86419. shader: string;
  86420. };
  86421. }
  86422. declare module BABYLON {
  86423. /** @hidden */
  86424. export var kernelBlurVertex: {
  86425. name: string;
  86426. shader: string;
  86427. };
  86428. }
  86429. declare module BABYLON {
  86430. /** @hidden */
  86431. export var kernelBlurVertexShader: {
  86432. name: string;
  86433. shader: string;
  86434. };
  86435. }
  86436. declare module BABYLON {
  86437. /**
  86438. * The Blur Post Process which blurs an image based on a kernel and direction.
  86439. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  86440. */
  86441. export class BlurPostProcess extends PostProcess {
  86442. /** The direction in which to blur the image. */
  86443. direction: Vector2;
  86444. private blockCompilation;
  86445. protected _kernel: number;
  86446. protected _idealKernel: number;
  86447. protected _packedFloat: boolean;
  86448. private _staticDefines;
  86449. /**
  86450. * Sets the length in pixels of the blur sample region
  86451. */
  86452. set kernel(v: number);
  86453. /**
  86454. * Gets the length in pixels of the blur sample region
  86455. */
  86456. get kernel(): number;
  86457. /**
  86458. * Sets wether or not the blur needs to unpack/repack floats
  86459. */
  86460. set packedFloat(v: boolean);
  86461. /**
  86462. * Gets wether or not the blur is unpacking/repacking floats
  86463. */
  86464. get packedFloat(): boolean;
  86465. /**
  86466. * Creates a new instance BlurPostProcess
  86467. * @param name The name of the effect.
  86468. * @param direction The direction in which to blur the image.
  86469. * @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.
  86470. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  86471. * @param camera The camera to apply the render pass to.
  86472. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  86473. * @param engine The engine which the post process will be applied. (default: current engine)
  86474. * @param reusable If the post process can be reused on the same frame. (default: false)
  86475. * @param textureType Type of textures used when performing the post process. (default: 0)
  86476. * @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)
  86477. */
  86478. constructor(name: string,
  86479. /** The direction in which to blur the image. */
  86480. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  86481. /**
  86482. * Updates the effect with the current post process compile time values and recompiles the shader.
  86483. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  86484. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  86485. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  86486. * @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
  86487. * @param onCompiled Called when the shader has been compiled.
  86488. * @param onError Called if there is an error when compiling a shader.
  86489. */
  86490. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  86491. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  86492. /**
  86493. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  86494. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  86495. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  86496. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  86497. * The gaps between physical kernels are compensated for in the weighting of the samples
  86498. * @param idealKernel Ideal blur kernel.
  86499. * @return Nearest best kernel.
  86500. */
  86501. protected _nearestBestKernel(idealKernel: number): number;
  86502. /**
  86503. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  86504. * @param x The point on the Gaussian distribution to sample.
  86505. * @return the value of the Gaussian function at x.
  86506. */
  86507. protected _gaussianWeight(x: number): number;
  86508. /**
  86509. * Generates a string that can be used as a floating point number in GLSL.
  86510. * @param x Value to print.
  86511. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  86512. * @return GLSL float string.
  86513. */
  86514. protected _glslFloat(x: number, decimalFigures?: number): string;
  86515. }
  86516. }
  86517. declare module BABYLON {
  86518. /**
  86519. * Mirror texture can be used to simulate the view from a mirror in a scene.
  86520. * It will dynamically be rendered every frame to adapt to the camera point of view.
  86521. * You can then easily use it as a reflectionTexture on a flat surface.
  86522. * In case the surface is not a plane, please consider relying on reflection probes.
  86523. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  86524. */
  86525. export class MirrorTexture extends RenderTargetTexture {
  86526. private scene;
  86527. /**
  86528. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  86529. * 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.
  86530. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  86531. */
  86532. mirrorPlane: Plane;
  86533. /**
  86534. * Define the blur ratio used to blur the reflection if needed.
  86535. */
  86536. set blurRatio(value: number);
  86537. get blurRatio(): number;
  86538. /**
  86539. * Define the adaptive blur kernel used to blur the reflection if needed.
  86540. * This will autocompute the closest best match for the `blurKernel`
  86541. */
  86542. set adaptiveBlurKernel(value: number);
  86543. /**
  86544. * Define the blur kernel used to blur the reflection if needed.
  86545. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  86546. */
  86547. set blurKernel(value: number);
  86548. /**
  86549. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  86550. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  86551. */
  86552. set blurKernelX(value: number);
  86553. get blurKernelX(): number;
  86554. /**
  86555. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  86556. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  86557. */
  86558. set blurKernelY(value: number);
  86559. get blurKernelY(): number;
  86560. private _autoComputeBlurKernel;
  86561. protected _onRatioRescale(): void;
  86562. private _updateGammaSpace;
  86563. private _imageProcessingConfigChangeObserver;
  86564. private _transformMatrix;
  86565. private _mirrorMatrix;
  86566. private _savedViewMatrix;
  86567. private _blurX;
  86568. private _blurY;
  86569. private _adaptiveBlurKernel;
  86570. private _blurKernelX;
  86571. private _blurKernelY;
  86572. private _blurRatio;
  86573. /**
  86574. * Instantiates a Mirror Texture.
  86575. * Mirror texture can be used to simulate the view from a mirror in a scene.
  86576. * It will dynamically be rendered every frame to adapt to the camera point of view.
  86577. * You can then easily use it as a reflectionTexture on a flat surface.
  86578. * In case the surface is not a plane, please consider relying on reflection probes.
  86579. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  86580. * @param name
  86581. * @param size
  86582. * @param scene
  86583. * @param generateMipMaps
  86584. * @param type
  86585. * @param samplingMode
  86586. * @param generateDepthBuffer
  86587. */
  86588. constructor(name: string, size: number | {
  86589. width: number;
  86590. height: number;
  86591. } | {
  86592. ratio: number;
  86593. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  86594. private _preparePostProcesses;
  86595. /**
  86596. * Clone the mirror texture.
  86597. * @returns the cloned texture
  86598. */
  86599. clone(): MirrorTexture;
  86600. /**
  86601. * Serialize the texture to a JSON representation you could use in Parse later on
  86602. * @returns the serialized JSON representation
  86603. */
  86604. serialize(): any;
  86605. /**
  86606. * Dispose the texture and release its associated resources.
  86607. */
  86608. dispose(): void;
  86609. }
  86610. }
  86611. declare module BABYLON {
  86612. /**
  86613. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  86614. * @see http://doc.babylonjs.com/babylon101/materials#texture
  86615. */
  86616. export class Texture extends BaseTexture {
  86617. /**
  86618. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  86619. */
  86620. static SerializeBuffers: boolean;
  86621. /** @hidden */
  86622. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  86623. /** @hidden */
  86624. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  86625. /** @hidden */
  86626. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  86627. /** nearest is mag = nearest and min = nearest and mip = linear */
  86628. static readonly NEAREST_SAMPLINGMODE: number;
  86629. /** nearest is mag = nearest and min = nearest and mip = linear */
  86630. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  86631. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86632. static readonly BILINEAR_SAMPLINGMODE: number;
  86633. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86634. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  86635. /** Trilinear is mag = linear and min = linear and mip = linear */
  86636. static readonly TRILINEAR_SAMPLINGMODE: number;
  86637. /** Trilinear is mag = linear and min = linear and mip = linear */
  86638. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  86639. /** mag = nearest and min = nearest and mip = nearest */
  86640. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  86641. /** mag = nearest and min = linear and mip = nearest */
  86642. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  86643. /** mag = nearest and min = linear and mip = linear */
  86644. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  86645. /** mag = nearest and min = linear and mip = none */
  86646. static readonly NEAREST_LINEAR: number;
  86647. /** mag = nearest and min = nearest and mip = none */
  86648. static readonly NEAREST_NEAREST: number;
  86649. /** mag = linear and min = nearest and mip = nearest */
  86650. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  86651. /** mag = linear and min = nearest and mip = linear */
  86652. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  86653. /** mag = linear and min = linear and mip = none */
  86654. static readonly LINEAR_LINEAR: number;
  86655. /** mag = linear and min = nearest and mip = none */
  86656. static readonly LINEAR_NEAREST: number;
  86657. /** Explicit coordinates mode */
  86658. static readonly EXPLICIT_MODE: number;
  86659. /** Spherical coordinates mode */
  86660. static readonly SPHERICAL_MODE: number;
  86661. /** Planar coordinates mode */
  86662. static readonly PLANAR_MODE: number;
  86663. /** Cubic coordinates mode */
  86664. static readonly CUBIC_MODE: number;
  86665. /** Projection coordinates mode */
  86666. static readonly PROJECTION_MODE: number;
  86667. /** Inverse Cubic coordinates mode */
  86668. static readonly SKYBOX_MODE: number;
  86669. /** Inverse Cubic coordinates mode */
  86670. static readonly INVCUBIC_MODE: number;
  86671. /** Equirectangular coordinates mode */
  86672. static readonly EQUIRECTANGULAR_MODE: number;
  86673. /** Equirectangular Fixed coordinates mode */
  86674. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  86675. /** Equirectangular Fixed Mirrored coordinates mode */
  86676. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  86677. /** Texture is not repeating outside of 0..1 UVs */
  86678. static readonly CLAMP_ADDRESSMODE: number;
  86679. /** Texture is repeating outside of 0..1 UVs */
  86680. static readonly WRAP_ADDRESSMODE: number;
  86681. /** Texture is repeating and mirrored */
  86682. static readonly MIRROR_ADDRESSMODE: number;
  86683. /**
  86684. * 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
  86685. */
  86686. static UseSerializedUrlIfAny: boolean;
  86687. /**
  86688. * Define the url of the texture.
  86689. */
  86690. url: Nullable<string>;
  86691. /**
  86692. * Define an offset on the texture to offset the u coordinates of the UVs
  86693. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  86694. */
  86695. uOffset: number;
  86696. /**
  86697. * Define an offset on the texture to offset the v coordinates of the UVs
  86698. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  86699. */
  86700. vOffset: number;
  86701. /**
  86702. * Define an offset on the texture to scale the u coordinates of the UVs
  86703. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  86704. */
  86705. uScale: number;
  86706. /**
  86707. * Define an offset on the texture to scale the v coordinates of the UVs
  86708. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  86709. */
  86710. vScale: number;
  86711. /**
  86712. * Define an offset on the texture to rotate around the u coordinates of the UVs
  86713. * @see http://doc.babylonjs.com/how_to/more_materials
  86714. */
  86715. uAng: number;
  86716. /**
  86717. * Define an offset on the texture to rotate around the v coordinates of the UVs
  86718. * @see http://doc.babylonjs.com/how_to/more_materials
  86719. */
  86720. vAng: number;
  86721. /**
  86722. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  86723. * @see http://doc.babylonjs.com/how_to/more_materials
  86724. */
  86725. wAng: number;
  86726. /**
  86727. * Defines the center of rotation (U)
  86728. */
  86729. uRotationCenter: number;
  86730. /**
  86731. * Defines the center of rotation (V)
  86732. */
  86733. vRotationCenter: number;
  86734. /**
  86735. * Defines the center of rotation (W)
  86736. */
  86737. wRotationCenter: number;
  86738. /**
  86739. * Are mip maps generated for this texture or not.
  86740. */
  86741. get noMipmap(): boolean;
  86742. /**
  86743. * List of inspectable custom properties (used by the Inspector)
  86744. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86745. */
  86746. inspectableCustomProperties: Nullable<IInspectable[]>;
  86747. private _noMipmap;
  86748. /** @hidden */
  86749. _invertY: boolean;
  86750. private _rowGenerationMatrix;
  86751. private _cachedTextureMatrix;
  86752. private _projectionModeMatrix;
  86753. private _t0;
  86754. private _t1;
  86755. private _t2;
  86756. private _cachedUOffset;
  86757. private _cachedVOffset;
  86758. private _cachedUScale;
  86759. private _cachedVScale;
  86760. private _cachedUAng;
  86761. private _cachedVAng;
  86762. private _cachedWAng;
  86763. private _cachedProjectionMatrixId;
  86764. private _cachedCoordinatesMode;
  86765. /** @hidden */
  86766. protected _initialSamplingMode: number;
  86767. /** @hidden */
  86768. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  86769. private _deleteBuffer;
  86770. protected _format: Nullable<number>;
  86771. private _delayedOnLoad;
  86772. private _delayedOnError;
  86773. private _mimeType?;
  86774. /**
  86775. * Observable triggered once the texture has been loaded.
  86776. */
  86777. onLoadObservable: Observable<Texture>;
  86778. protected _isBlocking: boolean;
  86779. /**
  86780. * Is the texture preventing material to render while loading.
  86781. * If false, a default texture will be used instead of the loading one during the preparation step.
  86782. */
  86783. set isBlocking(value: boolean);
  86784. get isBlocking(): boolean;
  86785. /**
  86786. * Get the current sampling mode associated with the texture.
  86787. */
  86788. get samplingMode(): number;
  86789. /**
  86790. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  86791. */
  86792. get invertY(): boolean;
  86793. /**
  86794. * Instantiates a new texture.
  86795. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  86796. * @see http://doc.babylonjs.com/babylon101/materials#texture
  86797. * @param url defines the url of the picture to load as a texture
  86798. * @param scene defines the scene or engine the texture will belong to
  86799. * @param noMipmap defines if the texture will require mip maps or not
  86800. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  86801. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  86802. * @param onLoad defines a callback triggered when the texture has been loaded
  86803. * @param onError defines a callback triggered when an error occurred during the loading session
  86804. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  86805. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  86806. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  86807. * @param mimeType defines an optional mime type information
  86808. */
  86809. 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 | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  86810. /**
  86811. * Update the url (and optional buffer) of this texture if url was null during construction.
  86812. * @param url the url of the texture
  86813. * @param buffer the buffer of the texture (defaults to null)
  86814. * @param onLoad callback called when the texture is loaded (defaults to null)
  86815. */
  86816. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  86817. /**
  86818. * Finish the loading sequence of a texture flagged as delayed load.
  86819. * @hidden
  86820. */
  86821. delayLoad(): void;
  86822. private _prepareRowForTextureGeneration;
  86823. /**
  86824. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  86825. * @returns the transform matrix of the texture.
  86826. */
  86827. getTextureMatrix(uBase?: number): Matrix;
  86828. /**
  86829. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  86830. * @returns The reflection texture transform
  86831. */
  86832. getReflectionTextureMatrix(): Matrix;
  86833. /**
  86834. * Clones the texture.
  86835. * @returns the cloned texture
  86836. */
  86837. clone(): Texture;
  86838. /**
  86839. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  86840. * @returns The JSON representation of the texture
  86841. */
  86842. serialize(): any;
  86843. /**
  86844. * Get the current class name of the texture useful for serialization or dynamic coding.
  86845. * @returns "Texture"
  86846. */
  86847. getClassName(): string;
  86848. /**
  86849. * Dispose the texture and release its associated resources.
  86850. */
  86851. dispose(): void;
  86852. /**
  86853. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  86854. * @param parsedTexture Define the JSON representation of the texture
  86855. * @param scene Define the scene the parsed texture should be instantiated in
  86856. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  86857. * @returns The parsed texture if successful
  86858. */
  86859. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  86860. /**
  86861. * Creates a texture from its base 64 representation.
  86862. * @param data Define the base64 payload without the data: prefix
  86863. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  86864. * @param scene Define the scene the texture should belong to
  86865. * @param noMipmap Forces the texture to not create mip map information if true
  86866. * @param invertY define if the texture needs to be inverted on the y axis during loading
  86867. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  86868. * @param onLoad define a callback triggered when the texture has been loaded
  86869. * @param onError define a callback triggered when an error occurred during the loading session
  86870. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  86871. * @returns the created texture
  86872. */
  86873. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  86874. /**
  86875. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  86876. * @param data Define the base64 payload without the data: prefix
  86877. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  86878. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  86879. * @param scene Define the scene the texture should belong to
  86880. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  86881. * @param noMipmap Forces the texture to not create mip map information if true
  86882. * @param invertY define if the texture needs to be inverted on the y axis during loading
  86883. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  86884. * @param onLoad define a callback triggered when the texture has been loaded
  86885. * @param onError define a callback triggered when an error occurred during the loading session
  86886. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  86887. * @returns the created texture
  86888. */
  86889. 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;
  86890. }
  86891. }
  86892. declare module BABYLON {
  86893. /**
  86894. * PostProcessManager is used to manage one or more post processes or post process pipelines
  86895. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  86896. */
  86897. export class PostProcessManager {
  86898. private _scene;
  86899. private _indexBuffer;
  86900. private _vertexBuffers;
  86901. /**
  86902. * Creates a new instance PostProcess
  86903. * @param scene The scene that the post process is associated with.
  86904. */
  86905. constructor(scene: Scene);
  86906. private _prepareBuffers;
  86907. private _buildIndexBuffer;
  86908. /**
  86909. * Rebuilds the vertex buffers of the manager.
  86910. * @hidden
  86911. */
  86912. _rebuild(): void;
  86913. /**
  86914. * Prepares a frame to be run through a post process.
  86915. * @param sourceTexture The input texture to the post procesess. (default: null)
  86916. * @param postProcesses An array of post processes to be run. (default: null)
  86917. * @returns True if the post processes were able to be run.
  86918. * @hidden
  86919. */
  86920. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  86921. /**
  86922. * Manually render a set of post processes to a texture.
  86923. * @param postProcesses An array of post processes to be run.
  86924. * @param targetTexture The target texture to render to.
  86925. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  86926. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  86927. * @param lodLevel defines which lod of the texture to render to
  86928. */
  86929. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  86930. /**
  86931. * Finalize the result of the output of the postprocesses.
  86932. * @param doNotPresent If true the result will not be displayed to the screen.
  86933. * @param targetTexture The target texture to render to.
  86934. * @param faceIndex The index of the face to bind the target texture to.
  86935. * @param postProcesses The array of post processes to render.
  86936. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  86937. * @hidden
  86938. */
  86939. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  86940. /**
  86941. * Disposes of the post process manager.
  86942. */
  86943. dispose(): void;
  86944. }
  86945. }
  86946. declare module BABYLON {
  86947. /** Interface used by value gradients (color, factor, ...) */
  86948. export interface IValueGradient {
  86949. /**
  86950. * Gets or sets the gradient value (between 0 and 1)
  86951. */
  86952. gradient: number;
  86953. }
  86954. /** Class used to store color4 gradient */
  86955. export class ColorGradient implements IValueGradient {
  86956. /**
  86957. * Gets or sets the gradient value (between 0 and 1)
  86958. */
  86959. gradient: number;
  86960. /**
  86961. * Gets or sets first associated color
  86962. */
  86963. color1: Color4;
  86964. /**
  86965. * Gets or sets second associated color
  86966. */
  86967. color2?: Color4;
  86968. /**
  86969. * Will get a color picked randomly between color1 and color2.
  86970. * If color2 is undefined then color1 will be used
  86971. * @param result defines the target Color4 to store the result in
  86972. */
  86973. getColorToRef(result: Color4): void;
  86974. }
  86975. /** Class used to store color 3 gradient */
  86976. export class Color3Gradient implements IValueGradient {
  86977. /**
  86978. * Gets or sets the gradient value (between 0 and 1)
  86979. */
  86980. gradient: number;
  86981. /**
  86982. * Gets or sets the associated color
  86983. */
  86984. color: Color3;
  86985. }
  86986. /** Class used to store factor gradient */
  86987. export class FactorGradient implements IValueGradient {
  86988. /**
  86989. * Gets or sets the gradient value (between 0 and 1)
  86990. */
  86991. gradient: number;
  86992. /**
  86993. * Gets or sets first associated factor
  86994. */
  86995. factor1: number;
  86996. /**
  86997. * Gets or sets second associated factor
  86998. */
  86999. factor2?: number;
  87000. /**
  87001. * Will get a number picked randomly between factor1 and factor2.
  87002. * If factor2 is undefined then factor1 will be used
  87003. * @returns the picked number
  87004. */
  87005. getFactor(): number;
  87006. }
  87007. /**
  87008. * Helper used to simplify some generic gradient tasks
  87009. */
  87010. export class GradientHelper {
  87011. /**
  87012. * Gets the current gradient from an array of IValueGradient
  87013. * @param ratio defines the current ratio to get
  87014. * @param gradients defines the array of IValueGradient
  87015. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  87016. */
  87017. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  87018. }
  87019. }
  87020. declare module BABYLON {
  87021. interface ThinEngine {
  87022. /**
  87023. * Creates a dynamic texture
  87024. * @param width defines the width of the texture
  87025. * @param height defines the height of the texture
  87026. * @param generateMipMaps defines if the engine should generate the mip levels
  87027. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  87028. * @returns the dynamic texture inside an InternalTexture
  87029. */
  87030. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  87031. /**
  87032. * Update the content of a dynamic texture
  87033. * @param texture defines the texture to update
  87034. * @param canvas defines the canvas containing the source
  87035. * @param invertY defines if data must be stored with Y axis inverted
  87036. * @param premulAlpha defines if alpha is stored as premultiplied
  87037. * @param format defines the format of the data
  87038. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  87039. */
  87040. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  87041. }
  87042. }
  87043. declare module BABYLON {
  87044. /**
  87045. * Helper class used to generate a canvas to manipulate images
  87046. */
  87047. export class CanvasGenerator {
  87048. /**
  87049. * Create a new canvas (or offscreen canvas depending on the context)
  87050. * @param width defines the expected width
  87051. * @param height defines the expected height
  87052. * @return a new canvas or offscreen canvas
  87053. */
  87054. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  87055. }
  87056. }
  87057. declare module BABYLON {
  87058. /**
  87059. * A class extending Texture allowing drawing on a texture
  87060. * @see http://doc.babylonjs.com/how_to/dynamictexture
  87061. */
  87062. export class DynamicTexture extends Texture {
  87063. private _generateMipMaps;
  87064. private _canvas;
  87065. private _context;
  87066. private _engine;
  87067. /**
  87068. * Creates a DynamicTexture
  87069. * @param name defines the name of the texture
  87070. * @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
  87071. * @param scene defines the scene where you want the texture
  87072. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  87073. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  87074. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  87075. */
  87076. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  87077. /**
  87078. * Get the current class name of the texture useful for serialization or dynamic coding.
  87079. * @returns "DynamicTexture"
  87080. */
  87081. getClassName(): string;
  87082. /**
  87083. * Gets the current state of canRescale
  87084. */
  87085. get canRescale(): boolean;
  87086. private _recreate;
  87087. /**
  87088. * Scales the texture
  87089. * @param ratio the scale factor to apply to both width and height
  87090. */
  87091. scale(ratio: number): void;
  87092. /**
  87093. * Resizes the texture
  87094. * @param width the new width
  87095. * @param height the new height
  87096. */
  87097. scaleTo(width: number, height: number): void;
  87098. /**
  87099. * Gets the context of the canvas used by the texture
  87100. * @returns the canvas context of the dynamic texture
  87101. */
  87102. getContext(): CanvasRenderingContext2D;
  87103. /**
  87104. * Clears the texture
  87105. */
  87106. clear(): void;
  87107. /**
  87108. * Updates the texture
  87109. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  87110. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  87111. */
  87112. update(invertY?: boolean, premulAlpha?: boolean): void;
  87113. /**
  87114. * Draws text onto the texture
  87115. * @param text defines the text to be drawn
  87116. * @param x defines the placement of the text from the left
  87117. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  87118. * @param font defines the font to be used with font-style, font-size, font-name
  87119. * @param color defines the color used for the text
  87120. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  87121. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  87122. * @param update defines whether texture is immediately update (default is true)
  87123. */
  87124. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  87125. /**
  87126. * Clones the texture
  87127. * @returns the clone of the texture.
  87128. */
  87129. clone(): DynamicTexture;
  87130. /**
  87131. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  87132. * @returns a serialized dynamic texture object
  87133. */
  87134. serialize(): any;
  87135. /** @hidden */
  87136. _rebuild(): void;
  87137. }
  87138. }
  87139. declare module BABYLON {
  87140. interface AbstractScene {
  87141. /**
  87142. * The list of procedural textures added to the scene
  87143. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  87144. */
  87145. proceduralTextures: Array<ProceduralTexture>;
  87146. }
  87147. /**
  87148. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  87149. * in a given scene.
  87150. */
  87151. export class ProceduralTextureSceneComponent implements ISceneComponent {
  87152. /**
  87153. * The component name helpfull to identify the component in the list of scene components.
  87154. */
  87155. readonly name: string;
  87156. /**
  87157. * The scene the component belongs to.
  87158. */
  87159. scene: Scene;
  87160. /**
  87161. * Creates a new instance of the component for the given scene
  87162. * @param scene Defines the scene to register the component in
  87163. */
  87164. constructor(scene: Scene);
  87165. /**
  87166. * Registers the component in a given scene
  87167. */
  87168. register(): void;
  87169. /**
  87170. * Rebuilds the elements related to this component in case of
  87171. * context lost for instance.
  87172. */
  87173. rebuild(): void;
  87174. /**
  87175. * Disposes the component and the associated ressources.
  87176. */
  87177. dispose(): void;
  87178. private _beforeClear;
  87179. }
  87180. }
  87181. declare module BABYLON {
  87182. interface ThinEngine {
  87183. /**
  87184. * Creates a new render target cube texture
  87185. * @param size defines the size of the texture
  87186. * @param options defines the options used to create the texture
  87187. * @returns a new render target cube texture stored in an InternalTexture
  87188. */
  87189. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  87190. }
  87191. }
  87192. declare module BABYLON {
  87193. /** @hidden */
  87194. export var proceduralVertexShader: {
  87195. name: string;
  87196. shader: string;
  87197. };
  87198. }
  87199. declare module BABYLON {
  87200. /**
  87201. * 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.
  87202. * This is the base class of any Procedural texture and contains most of the shareable code.
  87203. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  87204. */
  87205. export class ProceduralTexture extends Texture {
  87206. isCube: boolean;
  87207. /**
  87208. * Define if the texture is enabled or not (disabled texture will not render)
  87209. */
  87210. isEnabled: boolean;
  87211. /**
  87212. * Define if the texture must be cleared before rendering (default is true)
  87213. */
  87214. autoClear: boolean;
  87215. /**
  87216. * Callback called when the texture is generated
  87217. */
  87218. onGenerated: () => void;
  87219. /**
  87220. * Event raised when the texture is generated
  87221. */
  87222. onGeneratedObservable: Observable<ProceduralTexture>;
  87223. /** @hidden */
  87224. _generateMipMaps: boolean;
  87225. /** @hidden **/
  87226. _effect: Effect;
  87227. /** @hidden */
  87228. _textures: {
  87229. [key: string]: Texture;
  87230. };
  87231. private _size;
  87232. private _currentRefreshId;
  87233. private _frameId;
  87234. private _refreshRate;
  87235. private _vertexBuffers;
  87236. private _indexBuffer;
  87237. private _uniforms;
  87238. private _samplers;
  87239. private _fragment;
  87240. private _floats;
  87241. private _ints;
  87242. private _floatsArrays;
  87243. private _colors3;
  87244. private _colors4;
  87245. private _vectors2;
  87246. private _vectors3;
  87247. private _matrices;
  87248. private _fallbackTexture;
  87249. private _fallbackTextureUsed;
  87250. private _engine;
  87251. private _cachedDefines;
  87252. private _contentUpdateId;
  87253. private _contentData;
  87254. /**
  87255. * Instantiates a new procedural texture.
  87256. * 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.
  87257. * This is the base class of any Procedural texture and contains most of the shareable code.
  87258. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  87259. * @param name Define the name of the texture
  87260. * @param size Define the size of the texture to create
  87261. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  87262. * @param scene Define the scene the texture belongs to
  87263. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  87264. * @param generateMipMaps Define if the texture should creates mip maps or not
  87265. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  87266. */
  87267. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  87268. /**
  87269. * The effect that is created when initializing the post process.
  87270. * @returns The created effect corresponding the the postprocess.
  87271. */
  87272. getEffect(): Effect;
  87273. /**
  87274. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  87275. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  87276. */
  87277. getContent(): Nullable<ArrayBufferView>;
  87278. private _createIndexBuffer;
  87279. /** @hidden */
  87280. _rebuild(): void;
  87281. /**
  87282. * Resets the texture in order to recreate its associated resources.
  87283. * This can be called in case of context loss
  87284. */
  87285. reset(): void;
  87286. protected _getDefines(): string;
  87287. /**
  87288. * Is the texture ready to be used ? (rendered at least once)
  87289. * @returns true if ready, otherwise, false.
  87290. */
  87291. isReady(): boolean;
  87292. /**
  87293. * Resets the refresh counter of the texture and start bak from scratch.
  87294. * Could be useful to regenerate the texture if it is setup to render only once.
  87295. */
  87296. resetRefreshCounter(): void;
  87297. /**
  87298. * Set the fragment shader to use in order to render the texture.
  87299. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  87300. */
  87301. setFragment(fragment: any): void;
  87302. /**
  87303. * Define the refresh rate of the texture or the rendering frequency.
  87304. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  87305. */
  87306. get refreshRate(): number;
  87307. set refreshRate(value: number);
  87308. /** @hidden */
  87309. _shouldRender(): boolean;
  87310. /**
  87311. * Get the size the texture is rendering at.
  87312. * @returns the size (texture is always squared)
  87313. */
  87314. getRenderSize(): number;
  87315. /**
  87316. * Resize the texture to new value.
  87317. * @param size Define the new size the texture should have
  87318. * @param generateMipMaps Define whether the new texture should create mip maps
  87319. */
  87320. resize(size: number, generateMipMaps: boolean): void;
  87321. private _checkUniform;
  87322. /**
  87323. * Set a texture in the shader program used to render.
  87324. * @param name Define the name of the uniform samplers as defined in the shader
  87325. * @param texture Define the texture to bind to this sampler
  87326. * @return the texture itself allowing "fluent" like uniform updates
  87327. */
  87328. setTexture(name: string, texture: Texture): ProceduralTexture;
  87329. /**
  87330. * Set a float in the shader.
  87331. * @param name Define the name of the uniform as defined in the shader
  87332. * @param value Define the value to give to the uniform
  87333. * @return the texture itself allowing "fluent" like uniform updates
  87334. */
  87335. setFloat(name: string, value: number): ProceduralTexture;
  87336. /**
  87337. * Set a int in the shader.
  87338. * @param name Define the name of the uniform as defined in the shader
  87339. * @param value Define the value to give to the uniform
  87340. * @return the texture itself allowing "fluent" like uniform updates
  87341. */
  87342. setInt(name: string, value: number): ProceduralTexture;
  87343. /**
  87344. * Set an array of floats in the shader.
  87345. * @param name Define the name of the uniform as defined in the shader
  87346. * @param value Define the value to give to the uniform
  87347. * @return the texture itself allowing "fluent" like uniform updates
  87348. */
  87349. setFloats(name: string, value: number[]): ProceduralTexture;
  87350. /**
  87351. * Set a vec3 in the shader from a Color3.
  87352. * @param name Define the name of the uniform as defined in the shader
  87353. * @param value Define the value to give to the uniform
  87354. * @return the texture itself allowing "fluent" like uniform updates
  87355. */
  87356. setColor3(name: string, value: Color3): ProceduralTexture;
  87357. /**
  87358. * Set a vec4 in the shader from a Color4.
  87359. * @param name Define the name of the uniform as defined in the shader
  87360. * @param value Define the value to give to the uniform
  87361. * @return the texture itself allowing "fluent" like uniform updates
  87362. */
  87363. setColor4(name: string, value: Color4): ProceduralTexture;
  87364. /**
  87365. * Set a vec2 in the shader from a Vector2.
  87366. * @param name Define the name of the uniform as defined in the shader
  87367. * @param value Define the value to give to the uniform
  87368. * @return the texture itself allowing "fluent" like uniform updates
  87369. */
  87370. setVector2(name: string, value: Vector2): ProceduralTexture;
  87371. /**
  87372. * Set a vec3 in the shader from a Vector3.
  87373. * @param name Define the name of the uniform as defined in the shader
  87374. * @param value Define the value to give to the uniform
  87375. * @return the texture itself allowing "fluent" like uniform updates
  87376. */
  87377. setVector3(name: string, value: Vector3): ProceduralTexture;
  87378. /**
  87379. * Set a mat4 in the shader from a MAtrix.
  87380. * @param name Define the name of the uniform as defined in the shader
  87381. * @param value Define the value to give to the uniform
  87382. * @return the texture itself allowing "fluent" like uniform updates
  87383. */
  87384. setMatrix(name: string, value: Matrix): ProceduralTexture;
  87385. /**
  87386. * Render the texture to its associated render target.
  87387. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  87388. */
  87389. render(useCameraPostProcess?: boolean): void;
  87390. /**
  87391. * Clone the texture.
  87392. * @returns the cloned texture
  87393. */
  87394. clone(): ProceduralTexture;
  87395. /**
  87396. * Dispose the texture and release its asoociated resources.
  87397. */
  87398. dispose(): void;
  87399. }
  87400. }
  87401. declare module BABYLON {
  87402. /**
  87403. * This represents the base class for particle system in Babylon.
  87404. * 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.
  87405. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  87406. * @example https://doc.babylonjs.com/babylon101/particles
  87407. */
  87408. export class BaseParticleSystem {
  87409. /**
  87410. * Source color is added to the destination color without alpha affecting the result
  87411. */
  87412. static BLENDMODE_ONEONE: number;
  87413. /**
  87414. * Blend current color and particle color using particle’s alpha
  87415. */
  87416. static BLENDMODE_STANDARD: number;
  87417. /**
  87418. * Add current color and particle color multiplied by particle’s alpha
  87419. */
  87420. static BLENDMODE_ADD: number;
  87421. /**
  87422. * Multiply current color with particle color
  87423. */
  87424. static BLENDMODE_MULTIPLY: number;
  87425. /**
  87426. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  87427. */
  87428. static BLENDMODE_MULTIPLYADD: number;
  87429. /**
  87430. * List of animations used by the particle system.
  87431. */
  87432. animations: Animation[];
  87433. /**
  87434. * The id of the Particle system.
  87435. */
  87436. id: string;
  87437. /**
  87438. * The friendly name of the Particle system.
  87439. */
  87440. name: string;
  87441. /**
  87442. * The rendering group used by the Particle system to chose when to render.
  87443. */
  87444. renderingGroupId: number;
  87445. /**
  87446. * The emitter represents the Mesh or position we are attaching the particle system to.
  87447. */
  87448. emitter: Nullable<AbstractMesh | Vector3>;
  87449. /**
  87450. * The maximum number of particles to emit per frame
  87451. */
  87452. emitRate: number;
  87453. /**
  87454. * If you want to launch only a few particles at once, that can be done, as well.
  87455. */
  87456. manualEmitCount: number;
  87457. /**
  87458. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  87459. */
  87460. updateSpeed: number;
  87461. /**
  87462. * The amount of time the particle system is running (depends of the overall update speed).
  87463. */
  87464. targetStopDuration: number;
  87465. /**
  87466. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  87467. */
  87468. disposeOnStop: boolean;
  87469. /**
  87470. * Minimum power of emitting particles.
  87471. */
  87472. minEmitPower: number;
  87473. /**
  87474. * Maximum power of emitting particles.
  87475. */
  87476. maxEmitPower: number;
  87477. /**
  87478. * Minimum life time of emitting particles.
  87479. */
  87480. minLifeTime: number;
  87481. /**
  87482. * Maximum life time of emitting particles.
  87483. */
  87484. maxLifeTime: number;
  87485. /**
  87486. * Minimum Size of emitting particles.
  87487. */
  87488. minSize: number;
  87489. /**
  87490. * Maximum Size of emitting particles.
  87491. */
  87492. maxSize: number;
  87493. /**
  87494. * Minimum scale of emitting particles on X axis.
  87495. */
  87496. minScaleX: number;
  87497. /**
  87498. * Maximum scale of emitting particles on X axis.
  87499. */
  87500. maxScaleX: number;
  87501. /**
  87502. * Minimum scale of emitting particles on Y axis.
  87503. */
  87504. minScaleY: number;
  87505. /**
  87506. * Maximum scale of emitting particles on Y axis.
  87507. */
  87508. maxScaleY: number;
  87509. /**
  87510. * Gets or sets the minimal initial rotation in radians.
  87511. */
  87512. minInitialRotation: number;
  87513. /**
  87514. * Gets or sets the maximal initial rotation in radians.
  87515. */
  87516. maxInitialRotation: number;
  87517. /**
  87518. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  87519. */
  87520. minAngularSpeed: number;
  87521. /**
  87522. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  87523. */
  87524. maxAngularSpeed: number;
  87525. /**
  87526. * The texture used to render each particle. (this can be a spritesheet)
  87527. */
  87528. particleTexture: Nullable<Texture>;
  87529. /**
  87530. * The layer mask we are rendering the particles through.
  87531. */
  87532. layerMask: number;
  87533. /**
  87534. * This can help using your own shader to render the particle system.
  87535. * The according effect will be created
  87536. */
  87537. customShader: any;
  87538. /**
  87539. * By default particle system starts as soon as they are created. This prevents the
  87540. * automatic start to happen and let you decide when to start emitting particles.
  87541. */
  87542. preventAutoStart: boolean;
  87543. private _noiseTexture;
  87544. /**
  87545. * Gets or sets a texture used to add random noise to particle positions
  87546. */
  87547. get noiseTexture(): Nullable<ProceduralTexture>;
  87548. set noiseTexture(value: Nullable<ProceduralTexture>);
  87549. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  87550. noiseStrength: Vector3;
  87551. /**
  87552. * Callback triggered when the particle animation is ending.
  87553. */
  87554. onAnimationEnd: Nullable<() => void>;
  87555. /**
  87556. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  87557. */
  87558. blendMode: number;
  87559. /**
  87560. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  87561. * to override the particles.
  87562. */
  87563. forceDepthWrite: boolean;
  87564. /** 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 */
  87565. preWarmCycles: number;
  87566. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  87567. preWarmStepOffset: number;
  87568. /**
  87569. * 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)
  87570. */
  87571. spriteCellChangeSpeed: number;
  87572. /**
  87573. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  87574. */
  87575. startSpriteCellID: number;
  87576. /**
  87577. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  87578. */
  87579. endSpriteCellID: number;
  87580. /**
  87581. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  87582. */
  87583. spriteCellWidth: number;
  87584. /**
  87585. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  87586. */
  87587. spriteCellHeight: number;
  87588. /**
  87589. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  87590. */
  87591. spriteRandomStartCell: boolean;
  87592. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  87593. translationPivot: Vector2;
  87594. /** @hidden */
  87595. protected _isAnimationSheetEnabled: boolean;
  87596. /**
  87597. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  87598. */
  87599. beginAnimationOnStart: boolean;
  87600. /**
  87601. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  87602. */
  87603. beginAnimationFrom: number;
  87604. /**
  87605. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  87606. */
  87607. beginAnimationTo: number;
  87608. /**
  87609. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  87610. */
  87611. beginAnimationLoop: boolean;
  87612. /**
  87613. * Gets or sets a world offset applied to all particles
  87614. */
  87615. worldOffset: Vector3;
  87616. /**
  87617. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  87618. */
  87619. get isAnimationSheetEnabled(): boolean;
  87620. set isAnimationSheetEnabled(value: boolean);
  87621. /**
  87622. * Get hosting scene
  87623. * @returns the scene
  87624. */
  87625. getScene(): Scene;
  87626. /**
  87627. * You can use gravity if you want to give an orientation to your particles.
  87628. */
  87629. gravity: Vector3;
  87630. protected _colorGradients: Nullable<Array<ColorGradient>>;
  87631. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  87632. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  87633. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  87634. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  87635. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  87636. protected _dragGradients: Nullable<Array<FactorGradient>>;
  87637. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  87638. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  87639. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  87640. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  87641. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  87642. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  87643. /**
  87644. * Defines the delay in milliseconds before starting the system (0 by default)
  87645. */
  87646. startDelay: number;
  87647. /**
  87648. * Gets the current list of drag gradients.
  87649. * You must use addDragGradient and removeDragGradient to udpate this list
  87650. * @returns the list of drag gradients
  87651. */
  87652. getDragGradients(): Nullable<Array<FactorGradient>>;
  87653. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  87654. limitVelocityDamping: number;
  87655. /**
  87656. * Gets the current list of limit velocity gradients.
  87657. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  87658. * @returns the list of limit velocity gradients
  87659. */
  87660. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  87661. /**
  87662. * Gets the current list of color gradients.
  87663. * You must use addColorGradient and removeColorGradient to udpate this list
  87664. * @returns the list of color gradients
  87665. */
  87666. getColorGradients(): Nullable<Array<ColorGradient>>;
  87667. /**
  87668. * Gets the current list of size gradients.
  87669. * You must use addSizeGradient and removeSizeGradient to udpate this list
  87670. * @returns the list of size gradients
  87671. */
  87672. getSizeGradients(): Nullable<Array<FactorGradient>>;
  87673. /**
  87674. * Gets the current list of color remap gradients.
  87675. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87676. * @returns the list of color remap gradients
  87677. */
  87678. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87679. /**
  87680. * Gets the current list of alpha remap gradients.
  87681. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87682. * @returns the list of alpha remap gradients
  87683. */
  87684. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87685. /**
  87686. * Gets the current list of life time gradients.
  87687. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87688. * @returns the list of life time gradients
  87689. */
  87690. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87691. /**
  87692. * Gets the current list of angular speed gradients.
  87693. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  87694. * @returns the list of angular speed gradients
  87695. */
  87696. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  87697. /**
  87698. * Gets the current list of velocity gradients.
  87699. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  87700. * @returns the list of velocity gradients
  87701. */
  87702. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  87703. /**
  87704. * Gets the current list of start size gradients.
  87705. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  87706. * @returns the list of start size gradients
  87707. */
  87708. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  87709. /**
  87710. * Gets the current list of emit rate gradients.
  87711. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  87712. * @returns the list of emit rate gradients
  87713. */
  87714. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  87715. /**
  87716. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87717. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87718. */
  87719. get direction1(): Vector3;
  87720. set direction1(value: Vector3);
  87721. /**
  87722. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87723. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87724. */
  87725. get direction2(): Vector3;
  87726. set direction2(value: Vector3);
  87727. /**
  87728. * 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.
  87729. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87730. */
  87731. get minEmitBox(): Vector3;
  87732. set minEmitBox(value: Vector3);
  87733. /**
  87734. * 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.
  87735. * This only works when particleEmitterTyps is a BoxParticleEmitter
  87736. */
  87737. get maxEmitBox(): Vector3;
  87738. set maxEmitBox(value: Vector3);
  87739. /**
  87740. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  87741. */
  87742. color1: Color4;
  87743. /**
  87744. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  87745. */
  87746. color2: Color4;
  87747. /**
  87748. * Color the particle will have at the end of its lifetime
  87749. */
  87750. colorDead: Color4;
  87751. /**
  87752. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  87753. */
  87754. textureMask: Color4;
  87755. /**
  87756. * The particle emitter type defines the emitter used by the particle system.
  87757. * It can be for example box, sphere, or cone...
  87758. */
  87759. particleEmitterType: IParticleEmitterType;
  87760. /** @hidden */
  87761. _isSubEmitter: boolean;
  87762. /**
  87763. * Gets or sets the billboard mode to use when isBillboardBased = true.
  87764. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  87765. */
  87766. billboardMode: number;
  87767. protected _isBillboardBased: boolean;
  87768. /**
  87769. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  87770. */
  87771. get isBillboardBased(): boolean;
  87772. set isBillboardBased(value: boolean);
  87773. /**
  87774. * The scene the particle system belongs to.
  87775. */
  87776. protected _scene: Scene;
  87777. /**
  87778. * Local cache of defines for image processing.
  87779. */
  87780. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  87781. /**
  87782. * Default configuration related to image processing available in the standard Material.
  87783. */
  87784. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  87785. /**
  87786. * Gets the image processing configuration used either in this material.
  87787. */
  87788. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  87789. /**
  87790. * Sets the Default image processing configuration used either in the this material.
  87791. *
  87792. * If sets to null, the scene one is in use.
  87793. */
  87794. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  87795. /**
  87796. * Attaches a new image processing configuration to the Standard Material.
  87797. * @param configuration
  87798. */
  87799. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  87800. /** @hidden */
  87801. protected _reset(): void;
  87802. /** @hidden */
  87803. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  87804. /**
  87805. * Instantiates a particle system.
  87806. * 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.
  87807. * @param name The name of the particle system
  87808. */
  87809. constructor(name: string);
  87810. /**
  87811. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87812. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87813. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87814. * @returns the emitter
  87815. */
  87816. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87817. /**
  87818. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87819. * @param radius The radius of the hemisphere to emit from
  87820. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87821. * @returns the emitter
  87822. */
  87823. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  87824. /**
  87825. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87826. * @param radius The radius of the sphere to emit from
  87827. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87828. * @returns the emitter
  87829. */
  87830. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  87831. /**
  87832. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87833. * @param radius The radius of the sphere to emit from
  87834. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87835. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87836. * @returns the emitter
  87837. */
  87838. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  87839. /**
  87840. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87841. * @param radius The radius of the emission cylinder
  87842. * @param height The height of the emission cylinder
  87843. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87844. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87845. * @returns the emitter
  87846. */
  87847. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  87848. /**
  87849. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87850. * @param radius The radius of the cylinder to emit from
  87851. * @param height The height of the emission cylinder
  87852. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87853. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87854. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87855. * @returns the emitter
  87856. */
  87857. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  87858. /**
  87859. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87860. * @param radius The radius of the cone to emit from
  87861. * @param angle The base angle of the cone
  87862. * @returns the emitter
  87863. */
  87864. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  87865. /**
  87866. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87867. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87868. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87869. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87870. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87871. * @returns the emitter
  87872. */
  87873. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87874. }
  87875. }
  87876. declare module BABYLON {
  87877. /**
  87878. * Type of sub emitter
  87879. */
  87880. export enum SubEmitterType {
  87881. /**
  87882. * Attached to the particle over it's lifetime
  87883. */
  87884. ATTACHED = 0,
  87885. /**
  87886. * Created when the particle dies
  87887. */
  87888. END = 1
  87889. }
  87890. /**
  87891. * Sub emitter class used to emit particles from an existing particle
  87892. */
  87893. export class SubEmitter {
  87894. /**
  87895. * the particle system to be used by the sub emitter
  87896. */
  87897. particleSystem: ParticleSystem;
  87898. /**
  87899. * Type of the submitter (Default: END)
  87900. */
  87901. type: SubEmitterType;
  87902. /**
  87903. * 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)
  87904. * Note: This only is supported when using an emitter of type Mesh
  87905. */
  87906. inheritDirection: boolean;
  87907. /**
  87908. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  87909. */
  87910. inheritedVelocityAmount: number;
  87911. /**
  87912. * Creates a sub emitter
  87913. * @param particleSystem the particle system to be used by the sub emitter
  87914. */
  87915. constructor(
  87916. /**
  87917. * the particle system to be used by the sub emitter
  87918. */
  87919. particleSystem: ParticleSystem);
  87920. /**
  87921. * Clones the sub emitter
  87922. * @returns the cloned sub emitter
  87923. */
  87924. clone(): SubEmitter;
  87925. /**
  87926. * Serialize current object to a JSON object
  87927. * @returns the serialized object
  87928. */
  87929. serialize(): any;
  87930. /** @hidden */
  87931. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  87932. /**
  87933. * Creates a new SubEmitter from a serialized JSON version
  87934. * @param serializationObject defines the JSON object to read from
  87935. * @param scene defines the hosting scene
  87936. * @param rootUrl defines the rootUrl for data loading
  87937. * @returns a new SubEmitter
  87938. */
  87939. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  87940. /** Release associated resources */
  87941. dispose(): void;
  87942. }
  87943. }
  87944. declare module BABYLON {
  87945. /** @hidden */
  87946. export var clipPlaneFragmentDeclaration: {
  87947. name: string;
  87948. shader: string;
  87949. };
  87950. }
  87951. declare module BABYLON {
  87952. /** @hidden */
  87953. export var imageProcessingDeclaration: {
  87954. name: string;
  87955. shader: string;
  87956. };
  87957. }
  87958. declare module BABYLON {
  87959. /** @hidden */
  87960. export var imageProcessingFunctions: {
  87961. name: string;
  87962. shader: string;
  87963. };
  87964. }
  87965. declare module BABYLON {
  87966. /** @hidden */
  87967. export var clipPlaneFragment: {
  87968. name: string;
  87969. shader: string;
  87970. };
  87971. }
  87972. declare module BABYLON {
  87973. /** @hidden */
  87974. export var particlesPixelShader: {
  87975. name: string;
  87976. shader: string;
  87977. };
  87978. }
  87979. declare module BABYLON {
  87980. /** @hidden */
  87981. export var clipPlaneVertexDeclaration: {
  87982. name: string;
  87983. shader: string;
  87984. };
  87985. }
  87986. declare module BABYLON {
  87987. /** @hidden */
  87988. export var clipPlaneVertex: {
  87989. name: string;
  87990. shader: string;
  87991. };
  87992. }
  87993. declare module BABYLON {
  87994. /** @hidden */
  87995. export var particlesVertexShader: {
  87996. name: string;
  87997. shader: string;
  87998. };
  87999. }
  88000. declare module BABYLON {
  88001. /**
  88002. * This represents a particle system in Babylon.
  88003. * 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.
  88004. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  88005. * @example https://doc.babylonjs.com/babylon101/particles
  88006. */
  88007. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  88008. /**
  88009. * Billboard mode will only apply to Y axis
  88010. */
  88011. static readonly BILLBOARDMODE_Y: number;
  88012. /**
  88013. * Billboard mode will apply to all axes
  88014. */
  88015. static readonly BILLBOARDMODE_ALL: number;
  88016. /**
  88017. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  88018. */
  88019. static readonly BILLBOARDMODE_STRETCHED: number;
  88020. /**
  88021. * This function can be defined to provide custom update for active particles.
  88022. * This function will be called instead of regular update (age, position, color, etc.).
  88023. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  88024. */
  88025. updateFunction: (particles: Particle[]) => void;
  88026. private _emitterWorldMatrix;
  88027. /**
  88028. * This function can be defined to specify initial direction for every new particle.
  88029. * It by default use the emitterType defined function
  88030. */
  88031. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  88032. /**
  88033. * This function can be defined to specify initial position for every new particle.
  88034. * It by default use the emitterType defined function
  88035. */
  88036. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  88037. /**
  88038. * @hidden
  88039. */
  88040. _inheritedVelocityOffset: Vector3;
  88041. /**
  88042. * An event triggered when the system is disposed
  88043. */
  88044. onDisposeObservable: Observable<ParticleSystem>;
  88045. private _onDisposeObserver;
  88046. /**
  88047. * Sets a callback that will be triggered when the system is disposed
  88048. */
  88049. set onDispose(callback: () => void);
  88050. private _particles;
  88051. private _epsilon;
  88052. private _capacity;
  88053. private _stockParticles;
  88054. private _newPartsExcess;
  88055. private _vertexData;
  88056. private _vertexBuffer;
  88057. private _vertexBuffers;
  88058. private _spriteBuffer;
  88059. private _indexBuffer;
  88060. private _effect;
  88061. private _customEffect;
  88062. private _cachedDefines;
  88063. private _scaledColorStep;
  88064. private _colorDiff;
  88065. private _scaledDirection;
  88066. private _scaledGravity;
  88067. private _currentRenderId;
  88068. private _alive;
  88069. private _useInstancing;
  88070. private _started;
  88071. private _stopped;
  88072. private _actualFrame;
  88073. private _scaledUpdateSpeed;
  88074. private _vertexBufferSize;
  88075. /** @hidden */
  88076. _currentEmitRateGradient: Nullable<FactorGradient>;
  88077. /** @hidden */
  88078. _currentEmitRate1: number;
  88079. /** @hidden */
  88080. _currentEmitRate2: number;
  88081. /** @hidden */
  88082. _currentStartSizeGradient: Nullable<FactorGradient>;
  88083. /** @hidden */
  88084. _currentStartSize1: number;
  88085. /** @hidden */
  88086. _currentStartSize2: number;
  88087. private readonly _rawTextureWidth;
  88088. private _rampGradientsTexture;
  88089. private _useRampGradients;
  88090. /** Gets or sets a boolean indicating that ramp gradients must be used
  88091. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  88092. */
  88093. get useRampGradients(): boolean;
  88094. set useRampGradients(value: boolean);
  88095. /**
  88096. * 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.
  88097. * 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: [])
  88098. */
  88099. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  88100. private _subEmitters;
  88101. /**
  88102. * @hidden
  88103. * If the particle systems emitter should be disposed when the particle system is disposed
  88104. */
  88105. _disposeEmitterOnDispose: boolean;
  88106. /**
  88107. * The current active Sub-systems, this property is used by the root particle system only.
  88108. */
  88109. activeSubSystems: Array<ParticleSystem>;
  88110. private _rootParticleSystem;
  88111. /**
  88112. * Gets the current list of active particles
  88113. */
  88114. get particles(): Particle[];
  88115. /**
  88116. * Returns the string "ParticleSystem"
  88117. * @returns a string containing the class name
  88118. */
  88119. getClassName(): string;
  88120. /**
  88121. * Instantiates a particle system.
  88122. * 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.
  88123. * @param name The name of the particle system
  88124. * @param capacity The max number of particles alive at the same time
  88125. * @param scene The scene the particle system belongs to
  88126. * @param customEffect a custom effect used to change the way particles are rendered by default
  88127. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  88128. * @param epsilon Offset used to render the particles
  88129. */
  88130. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  88131. private _addFactorGradient;
  88132. private _removeFactorGradient;
  88133. /**
  88134. * Adds a new life time gradient
  88135. * @param gradient defines the gradient to use (between 0 and 1)
  88136. * @param factor defines the life time factor to affect to the specified gradient
  88137. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88138. * @returns the current particle system
  88139. */
  88140. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88141. /**
  88142. * Remove a specific life time gradient
  88143. * @param gradient defines the gradient to remove
  88144. * @returns the current particle system
  88145. */
  88146. removeLifeTimeGradient(gradient: number): IParticleSystem;
  88147. /**
  88148. * Adds a new size gradient
  88149. * @param gradient defines the gradient to use (between 0 and 1)
  88150. * @param factor defines the size factor to affect to the specified gradient
  88151. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88152. * @returns the current particle system
  88153. */
  88154. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88155. /**
  88156. * Remove a specific size gradient
  88157. * @param gradient defines the gradient to remove
  88158. * @returns the current particle system
  88159. */
  88160. removeSizeGradient(gradient: number): IParticleSystem;
  88161. /**
  88162. * Adds a new color remap gradient
  88163. * @param gradient defines the gradient to use (between 0 and 1)
  88164. * @param min defines the color remap minimal range
  88165. * @param max defines the color remap maximal range
  88166. * @returns the current particle system
  88167. */
  88168. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88169. /**
  88170. * Remove a specific color remap gradient
  88171. * @param gradient defines the gradient to remove
  88172. * @returns the current particle system
  88173. */
  88174. removeColorRemapGradient(gradient: number): IParticleSystem;
  88175. /**
  88176. * Adds a new alpha remap gradient
  88177. * @param gradient defines the gradient to use (between 0 and 1)
  88178. * @param min defines the alpha remap minimal range
  88179. * @param max defines the alpha remap maximal range
  88180. * @returns the current particle system
  88181. */
  88182. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88183. /**
  88184. * Remove a specific alpha remap gradient
  88185. * @param gradient defines the gradient to remove
  88186. * @returns the current particle system
  88187. */
  88188. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  88189. /**
  88190. * Adds a new angular speed gradient
  88191. * @param gradient defines the gradient to use (between 0 and 1)
  88192. * @param factor defines the angular speed to affect to the specified gradient
  88193. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88194. * @returns the current particle system
  88195. */
  88196. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88197. /**
  88198. * Remove a specific angular speed gradient
  88199. * @param gradient defines the gradient to remove
  88200. * @returns the current particle system
  88201. */
  88202. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  88203. /**
  88204. * Adds a new velocity gradient
  88205. * @param gradient defines the gradient to use (between 0 and 1)
  88206. * @param factor defines the velocity to affect to the specified gradient
  88207. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88208. * @returns the current particle system
  88209. */
  88210. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88211. /**
  88212. * Remove a specific velocity gradient
  88213. * @param gradient defines the gradient to remove
  88214. * @returns the current particle system
  88215. */
  88216. removeVelocityGradient(gradient: number): IParticleSystem;
  88217. /**
  88218. * Adds a new limit velocity gradient
  88219. * @param gradient defines the gradient to use (between 0 and 1)
  88220. * @param factor defines the limit velocity value to affect to the specified gradient
  88221. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88222. * @returns the current particle system
  88223. */
  88224. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88225. /**
  88226. * Remove a specific limit velocity gradient
  88227. * @param gradient defines the gradient to remove
  88228. * @returns the current particle system
  88229. */
  88230. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  88231. /**
  88232. * Adds a new drag gradient
  88233. * @param gradient defines the gradient to use (between 0 and 1)
  88234. * @param factor defines the drag value to affect to the specified gradient
  88235. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88236. * @returns the current particle system
  88237. */
  88238. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88239. /**
  88240. * Remove a specific drag gradient
  88241. * @param gradient defines the gradient to remove
  88242. * @returns the current particle system
  88243. */
  88244. removeDragGradient(gradient: number): IParticleSystem;
  88245. /**
  88246. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  88247. * @param gradient defines the gradient to use (between 0 and 1)
  88248. * @param factor defines the emit rate value to affect to the specified gradient
  88249. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88250. * @returns the current particle system
  88251. */
  88252. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88253. /**
  88254. * Remove a specific emit rate gradient
  88255. * @param gradient defines the gradient to remove
  88256. * @returns the current particle system
  88257. */
  88258. removeEmitRateGradient(gradient: number): IParticleSystem;
  88259. /**
  88260. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  88261. * @param gradient defines the gradient to use (between 0 and 1)
  88262. * @param factor defines the start size value to affect to the specified gradient
  88263. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88264. * @returns the current particle system
  88265. */
  88266. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88267. /**
  88268. * Remove a specific start size gradient
  88269. * @param gradient defines the gradient to remove
  88270. * @returns the current particle system
  88271. */
  88272. removeStartSizeGradient(gradient: number): IParticleSystem;
  88273. private _createRampGradientTexture;
  88274. /**
  88275. * Gets the current list of ramp gradients.
  88276. * You must use addRampGradient and removeRampGradient to udpate this list
  88277. * @returns the list of ramp gradients
  88278. */
  88279. getRampGradients(): Nullable<Array<Color3Gradient>>;
  88280. /**
  88281. * Adds a new ramp gradient used to remap particle colors
  88282. * @param gradient defines the gradient to use (between 0 and 1)
  88283. * @param color defines the color to affect to the specified gradient
  88284. * @returns the current particle system
  88285. */
  88286. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  88287. /**
  88288. * Remove a specific ramp gradient
  88289. * @param gradient defines the gradient to remove
  88290. * @returns the current particle system
  88291. */
  88292. removeRampGradient(gradient: number): ParticleSystem;
  88293. /**
  88294. * Adds a new color gradient
  88295. * @param gradient defines the gradient to use (between 0 and 1)
  88296. * @param color1 defines the color to affect to the specified gradient
  88297. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  88298. * @returns this particle system
  88299. */
  88300. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  88301. /**
  88302. * Remove a specific color gradient
  88303. * @param gradient defines the gradient to remove
  88304. * @returns this particle system
  88305. */
  88306. removeColorGradient(gradient: number): IParticleSystem;
  88307. private _fetchR;
  88308. protected _reset(): void;
  88309. private _resetEffect;
  88310. private _createVertexBuffers;
  88311. private _createIndexBuffer;
  88312. /**
  88313. * Gets the maximum number of particles active at the same time.
  88314. * @returns The max number of active particles.
  88315. */
  88316. getCapacity(): number;
  88317. /**
  88318. * Gets whether there are still active particles in the system.
  88319. * @returns True if it is alive, otherwise false.
  88320. */
  88321. isAlive(): boolean;
  88322. /**
  88323. * Gets if the system has been started. (Note: this will still be true after stop is called)
  88324. * @returns True if it has been started, otherwise false.
  88325. */
  88326. isStarted(): boolean;
  88327. private _prepareSubEmitterInternalArray;
  88328. /**
  88329. * Starts the particle system and begins to emit
  88330. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  88331. */
  88332. start(delay?: number): void;
  88333. /**
  88334. * Stops the particle system.
  88335. * @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.
  88336. */
  88337. stop(stopSubEmitters?: boolean): void;
  88338. /**
  88339. * Remove all active particles
  88340. */
  88341. reset(): void;
  88342. /**
  88343. * @hidden (for internal use only)
  88344. */
  88345. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  88346. /**
  88347. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  88348. * Its lifetime will start back at 0.
  88349. */
  88350. recycleParticle: (particle: Particle) => void;
  88351. private _stopSubEmitters;
  88352. private _createParticle;
  88353. private _removeFromRoot;
  88354. private _emitFromParticle;
  88355. private _update;
  88356. /** @hidden */
  88357. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  88358. /** @hidden */
  88359. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  88360. /** @hidden */
  88361. private _getEffect;
  88362. /**
  88363. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  88364. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  88365. */
  88366. animate(preWarmOnly?: boolean): void;
  88367. private _appendParticleVertices;
  88368. /**
  88369. * Rebuilds the particle system.
  88370. */
  88371. rebuild(): void;
  88372. /**
  88373. * Is this system ready to be used/rendered
  88374. * @return true if the system is ready
  88375. */
  88376. isReady(): boolean;
  88377. private _render;
  88378. /**
  88379. * Renders the particle system in its current state.
  88380. * @returns the current number of particles
  88381. */
  88382. render(): number;
  88383. /**
  88384. * Disposes the particle system and free the associated resources
  88385. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  88386. */
  88387. dispose(disposeTexture?: boolean): void;
  88388. /**
  88389. * Clones the particle system.
  88390. * @param name The name of the cloned object
  88391. * @param newEmitter The new emitter to use
  88392. * @returns the cloned particle system
  88393. */
  88394. clone(name: string, newEmitter: any): ParticleSystem;
  88395. /**
  88396. * Serializes the particle system to a JSON object.
  88397. * @returns the JSON object
  88398. */
  88399. serialize(): any;
  88400. /** @hidden */
  88401. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  88402. /** @hidden */
  88403. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  88404. /**
  88405. * Parses a JSON object to create a particle system.
  88406. * @param parsedParticleSystem The JSON object to parse
  88407. * @param scene The scene to create the particle system in
  88408. * @param rootUrl The root url to use to load external dependencies like texture
  88409. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  88410. * @returns the Parsed particle system
  88411. */
  88412. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  88413. }
  88414. }
  88415. declare module BABYLON {
  88416. /**
  88417. * A particle represents one of the element emitted by a particle system.
  88418. * This is mainly define by its coordinates, direction, velocity and age.
  88419. */
  88420. export class Particle {
  88421. /**
  88422. * The particle system the particle belongs to.
  88423. */
  88424. particleSystem: ParticleSystem;
  88425. private static _Count;
  88426. /**
  88427. * Unique ID of the particle
  88428. */
  88429. id: number;
  88430. /**
  88431. * The world position of the particle in the scene.
  88432. */
  88433. position: Vector3;
  88434. /**
  88435. * The world direction of the particle in the scene.
  88436. */
  88437. direction: Vector3;
  88438. /**
  88439. * The color of the particle.
  88440. */
  88441. color: Color4;
  88442. /**
  88443. * The color change of the particle per step.
  88444. */
  88445. colorStep: Color4;
  88446. /**
  88447. * Defines how long will the life of the particle be.
  88448. */
  88449. lifeTime: number;
  88450. /**
  88451. * The current age of the particle.
  88452. */
  88453. age: number;
  88454. /**
  88455. * The current size of the particle.
  88456. */
  88457. size: number;
  88458. /**
  88459. * The current scale of the particle.
  88460. */
  88461. scale: Vector2;
  88462. /**
  88463. * The current angle of the particle.
  88464. */
  88465. angle: number;
  88466. /**
  88467. * Defines how fast is the angle changing.
  88468. */
  88469. angularSpeed: number;
  88470. /**
  88471. * Defines the cell index used by the particle to be rendered from a sprite.
  88472. */
  88473. cellIndex: number;
  88474. /**
  88475. * The information required to support color remapping
  88476. */
  88477. remapData: Vector4;
  88478. /** @hidden */
  88479. _randomCellOffset?: number;
  88480. /** @hidden */
  88481. _initialDirection: Nullable<Vector3>;
  88482. /** @hidden */
  88483. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  88484. /** @hidden */
  88485. _initialStartSpriteCellID: number;
  88486. /** @hidden */
  88487. _initialEndSpriteCellID: number;
  88488. /** @hidden */
  88489. _currentColorGradient: Nullable<ColorGradient>;
  88490. /** @hidden */
  88491. _currentColor1: Color4;
  88492. /** @hidden */
  88493. _currentColor2: Color4;
  88494. /** @hidden */
  88495. _currentSizeGradient: Nullable<FactorGradient>;
  88496. /** @hidden */
  88497. _currentSize1: number;
  88498. /** @hidden */
  88499. _currentSize2: number;
  88500. /** @hidden */
  88501. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  88502. /** @hidden */
  88503. _currentAngularSpeed1: number;
  88504. /** @hidden */
  88505. _currentAngularSpeed2: number;
  88506. /** @hidden */
  88507. _currentVelocityGradient: Nullable<FactorGradient>;
  88508. /** @hidden */
  88509. _currentVelocity1: number;
  88510. /** @hidden */
  88511. _currentVelocity2: number;
  88512. /** @hidden */
  88513. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  88514. /** @hidden */
  88515. _currentLimitVelocity1: number;
  88516. /** @hidden */
  88517. _currentLimitVelocity2: number;
  88518. /** @hidden */
  88519. _currentDragGradient: Nullable<FactorGradient>;
  88520. /** @hidden */
  88521. _currentDrag1: number;
  88522. /** @hidden */
  88523. _currentDrag2: number;
  88524. /** @hidden */
  88525. _randomNoiseCoordinates1: Vector3;
  88526. /** @hidden */
  88527. _randomNoiseCoordinates2: Vector3;
  88528. /**
  88529. * Creates a new instance Particle
  88530. * @param particleSystem the particle system the particle belongs to
  88531. */
  88532. constructor(
  88533. /**
  88534. * The particle system the particle belongs to.
  88535. */
  88536. particleSystem: ParticleSystem);
  88537. private updateCellInfoFromSystem;
  88538. /**
  88539. * Defines how the sprite cell index is updated for the particle
  88540. */
  88541. updateCellIndex(): void;
  88542. /** @hidden */
  88543. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  88544. /** @hidden */
  88545. _inheritParticleInfoToSubEmitters(): void;
  88546. /** @hidden */
  88547. _reset(): void;
  88548. /**
  88549. * Copy the properties of particle to another one.
  88550. * @param other the particle to copy the information to.
  88551. */
  88552. copyTo(other: Particle): void;
  88553. }
  88554. }
  88555. declare module BABYLON {
  88556. /**
  88557. * Particle emitter represents a volume emitting particles.
  88558. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  88559. */
  88560. export interface IParticleEmitterType {
  88561. /**
  88562. * Called by the particle System when the direction is computed for the created particle.
  88563. * @param worldMatrix is the world matrix of the particle system
  88564. * @param directionToUpdate is the direction vector to update with the result
  88565. * @param particle is the particle we are computed the direction for
  88566. */
  88567. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88568. /**
  88569. * Called by the particle System when the position is computed for the created particle.
  88570. * @param worldMatrix is the world matrix of the particle system
  88571. * @param positionToUpdate is the position vector to update with the result
  88572. * @param particle is the particle we are computed the position for
  88573. */
  88574. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88575. /**
  88576. * Clones the current emitter and returns a copy of it
  88577. * @returns the new emitter
  88578. */
  88579. clone(): IParticleEmitterType;
  88580. /**
  88581. * Called by the GPUParticleSystem to setup the update shader
  88582. * @param effect defines the update shader
  88583. */
  88584. applyToShader(effect: Effect): void;
  88585. /**
  88586. * Returns a string to use to update the GPU particles update shader
  88587. * @returns the effect defines string
  88588. */
  88589. getEffectDefines(): string;
  88590. /**
  88591. * Returns a string representing the class name
  88592. * @returns a string containing the class name
  88593. */
  88594. getClassName(): string;
  88595. /**
  88596. * Serializes the particle system to a JSON object.
  88597. * @returns the JSON object
  88598. */
  88599. serialize(): any;
  88600. /**
  88601. * Parse properties from a JSON object
  88602. * @param serializationObject defines the JSON object
  88603. */
  88604. parse(serializationObject: any): void;
  88605. }
  88606. }
  88607. declare module BABYLON {
  88608. /**
  88609. * Particle emitter emitting particles from the inside of a box.
  88610. * It emits the particles randomly between 2 given directions.
  88611. */
  88612. export class BoxParticleEmitter implements IParticleEmitterType {
  88613. /**
  88614. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88615. */
  88616. direction1: Vector3;
  88617. /**
  88618. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88619. */
  88620. direction2: Vector3;
  88621. /**
  88622. * 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.
  88623. */
  88624. minEmitBox: Vector3;
  88625. /**
  88626. * 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.
  88627. */
  88628. maxEmitBox: Vector3;
  88629. /**
  88630. * Creates a new instance BoxParticleEmitter
  88631. */
  88632. constructor();
  88633. /**
  88634. * Called by the particle System when the direction is computed for the created particle.
  88635. * @param worldMatrix is the world matrix of the particle system
  88636. * @param directionToUpdate is the direction vector to update with the result
  88637. * @param particle is the particle we are computed the direction for
  88638. */
  88639. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88640. /**
  88641. * Called by the particle System when the position is computed for the created particle.
  88642. * @param worldMatrix is the world matrix of the particle system
  88643. * @param positionToUpdate is the position vector to update with the result
  88644. * @param particle is the particle we are computed the position for
  88645. */
  88646. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88647. /**
  88648. * Clones the current emitter and returns a copy of it
  88649. * @returns the new emitter
  88650. */
  88651. clone(): BoxParticleEmitter;
  88652. /**
  88653. * Called by the GPUParticleSystem to setup the update shader
  88654. * @param effect defines the update shader
  88655. */
  88656. applyToShader(effect: Effect): void;
  88657. /**
  88658. * Returns a string to use to update the GPU particles update shader
  88659. * @returns a string containng the defines string
  88660. */
  88661. getEffectDefines(): string;
  88662. /**
  88663. * Returns the string "BoxParticleEmitter"
  88664. * @returns a string containing the class name
  88665. */
  88666. getClassName(): string;
  88667. /**
  88668. * Serializes the particle system to a JSON object.
  88669. * @returns the JSON object
  88670. */
  88671. serialize(): any;
  88672. /**
  88673. * Parse properties from a JSON object
  88674. * @param serializationObject defines the JSON object
  88675. */
  88676. parse(serializationObject: any): void;
  88677. }
  88678. }
  88679. declare module BABYLON {
  88680. /**
  88681. * Particle emitter emitting particles from the inside of a cone.
  88682. * It emits the particles alongside the cone volume from the base to the particle.
  88683. * The emission direction might be randomized.
  88684. */
  88685. export class ConeParticleEmitter implements IParticleEmitterType {
  88686. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  88687. directionRandomizer: number;
  88688. private _radius;
  88689. private _angle;
  88690. private _height;
  88691. /**
  88692. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  88693. */
  88694. radiusRange: number;
  88695. /**
  88696. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  88697. */
  88698. heightRange: number;
  88699. /**
  88700. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  88701. */
  88702. emitFromSpawnPointOnly: boolean;
  88703. /**
  88704. * Gets or sets the radius of the emission cone
  88705. */
  88706. get radius(): number;
  88707. set radius(value: number);
  88708. /**
  88709. * Gets or sets the angle of the emission cone
  88710. */
  88711. get angle(): number;
  88712. set angle(value: number);
  88713. private _buildHeight;
  88714. /**
  88715. * Creates a new instance ConeParticleEmitter
  88716. * @param radius the radius of the emission cone (1 by default)
  88717. * @param angle the cone base angle (PI by default)
  88718. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  88719. */
  88720. constructor(radius?: number, angle?: number,
  88721. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  88722. directionRandomizer?: number);
  88723. /**
  88724. * Called by the particle System when the direction is computed for the created particle.
  88725. * @param worldMatrix is the world matrix of the particle system
  88726. * @param directionToUpdate is the direction vector to update with the result
  88727. * @param particle is the particle we are computed the direction for
  88728. */
  88729. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88730. /**
  88731. * Called by the particle System when the position is computed for the created particle.
  88732. * @param worldMatrix is the world matrix of the particle system
  88733. * @param positionToUpdate is the position vector to update with the result
  88734. * @param particle is the particle we are computed the position for
  88735. */
  88736. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88737. /**
  88738. * Clones the current emitter and returns a copy of it
  88739. * @returns the new emitter
  88740. */
  88741. clone(): ConeParticleEmitter;
  88742. /**
  88743. * Called by the GPUParticleSystem to setup the update shader
  88744. * @param effect defines the update shader
  88745. */
  88746. applyToShader(effect: Effect): void;
  88747. /**
  88748. * Returns a string to use to update the GPU particles update shader
  88749. * @returns a string containng the defines string
  88750. */
  88751. getEffectDefines(): string;
  88752. /**
  88753. * Returns the string "ConeParticleEmitter"
  88754. * @returns a string containing the class name
  88755. */
  88756. getClassName(): string;
  88757. /**
  88758. * Serializes the particle system to a JSON object.
  88759. * @returns the JSON object
  88760. */
  88761. serialize(): any;
  88762. /**
  88763. * Parse properties from a JSON object
  88764. * @param serializationObject defines the JSON object
  88765. */
  88766. parse(serializationObject: any): void;
  88767. }
  88768. }
  88769. declare module BABYLON {
  88770. /**
  88771. * Particle emitter emitting particles from the inside of a cylinder.
  88772. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  88773. */
  88774. export class CylinderParticleEmitter implements IParticleEmitterType {
  88775. /**
  88776. * The radius of the emission cylinder.
  88777. */
  88778. radius: number;
  88779. /**
  88780. * The height of the emission cylinder.
  88781. */
  88782. height: number;
  88783. /**
  88784. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88785. */
  88786. radiusRange: number;
  88787. /**
  88788. * How much to randomize the particle direction [0-1].
  88789. */
  88790. directionRandomizer: number;
  88791. /**
  88792. * Creates a new instance CylinderParticleEmitter
  88793. * @param radius the radius of the emission cylinder (1 by default)
  88794. * @param height the height of the emission cylinder (1 by default)
  88795. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88796. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88797. */
  88798. constructor(
  88799. /**
  88800. * The radius of the emission cylinder.
  88801. */
  88802. radius?: number,
  88803. /**
  88804. * The height of the emission cylinder.
  88805. */
  88806. height?: number,
  88807. /**
  88808. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88809. */
  88810. radiusRange?: number,
  88811. /**
  88812. * How much to randomize the particle direction [0-1].
  88813. */
  88814. directionRandomizer?: number);
  88815. /**
  88816. * Called by the particle System when the direction is computed for the created particle.
  88817. * @param worldMatrix is the world matrix of the particle system
  88818. * @param directionToUpdate is the direction vector to update with the result
  88819. * @param particle is the particle we are computed the direction for
  88820. */
  88821. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88822. /**
  88823. * Called by the particle System when the position is computed for the created particle.
  88824. * @param worldMatrix is the world matrix of the particle system
  88825. * @param positionToUpdate is the position vector to update with the result
  88826. * @param particle is the particle we are computed the position for
  88827. */
  88828. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88829. /**
  88830. * Clones the current emitter and returns a copy of it
  88831. * @returns the new emitter
  88832. */
  88833. clone(): CylinderParticleEmitter;
  88834. /**
  88835. * Called by the GPUParticleSystem to setup the update shader
  88836. * @param effect defines the update shader
  88837. */
  88838. applyToShader(effect: Effect): void;
  88839. /**
  88840. * Returns a string to use to update the GPU particles update shader
  88841. * @returns a string containng the defines string
  88842. */
  88843. getEffectDefines(): string;
  88844. /**
  88845. * Returns the string "CylinderParticleEmitter"
  88846. * @returns a string containing the class name
  88847. */
  88848. getClassName(): string;
  88849. /**
  88850. * Serializes the particle system to a JSON object.
  88851. * @returns the JSON object
  88852. */
  88853. serialize(): any;
  88854. /**
  88855. * Parse properties from a JSON object
  88856. * @param serializationObject defines the JSON object
  88857. */
  88858. parse(serializationObject: any): void;
  88859. }
  88860. /**
  88861. * Particle emitter emitting particles from the inside of a cylinder.
  88862. * It emits the particles randomly between two vectors.
  88863. */
  88864. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  88865. /**
  88866. * The min limit of the emission direction.
  88867. */
  88868. direction1: Vector3;
  88869. /**
  88870. * The max limit of the emission direction.
  88871. */
  88872. direction2: Vector3;
  88873. /**
  88874. * Creates a new instance CylinderDirectedParticleEmitter
  88875. * @param radius the radius of the emission cylinder (1 by default)
  88876. * @param height the height of the emission cylinder (1 by default)
  88877. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88878. * @param direction1 the min limit of the emission direction (up vector by default)
  88879. * @param direction2 the max limit of the emission direction (up vector by default)
  88880. */
  88881. constructor(radius?: number, height?: number, radiusRange?: number,
  88882. /**
  88883. * The min limit of the emission direction.
  88884. */
  88885. direction1?: Vector3,
  88886. /**
  88887. * The max limit of the emission direction.
  88888. */
  88889. direction2?: Vector3);
  88890. /**
  88891. * Called by the particle System when the direction is computed for the created particle.
  88892. * @param worldMatrix is the world matrix of the particle system
  88893. * @param directionToUpdate is the direction vector to update with the result
  88894. * @param particle is the particle we are computed the direction for
  88895. */
  88896. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88897. /**
  88898. * Clones the current emitter and returns a copy of it
  88899. * @returns the new emitter
  88900. */
  88901. clone(): CylinderDirectedParticleEmitter;
  88902. /**
  88903. * Called by the GPUParticleSystem to setup the update shader
  88904. * @param effect defines the update shader
  88905. */
  88906. applyToShader(effect: Effect): void;
  88907. /**
  88908. * Returns a string to use to update the GPU particles update shader
  88909. * @returns a string containng the defines string
  88910. */
  88911. getEffectDefines(): string;
  88912. /**
  88913. * Returns the string "CylinderDirectedParticleEmitter"
  88914. * @returns a string containing the class name
  88915. */
  88916. getClassName(): string;
  88917. /**
  88918. * Serializes the particle system to a JSON object.
  88919. * @returns the JSON object
  88920. */
  88921. serialize(): any;
  88922. /**
  88923. * Parse properties from a JSON object
  88924. * @param serializationObject defines the JSON object
  88925. */
  88926. parse(serializationObject: any): void;
  88927. }
  88928. }
  88929. declare module BABYLON {
  88930. /**
  88931. * Particle emitter emitting particles from the inside of a hemisphere.
  88932. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  88933. */
  88934. export class HemisphericParticleEmitter implements IParticleEmitterType {
  88935. /**
  88936. * The radius of the emission hemisphere.
  88937. */
  88938. radius: number;
  88939. /**
  88940. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88941. */
  88942. radiusRange: number;
  88943. /**
  88944. * How much to randomize the particle direction [0-1].
  88945. */
  88946. directionRandomizer: number;
  88947. /**
  88948. * Creates a new instance HemisphericParticleEmitter
  88949. * @param radius the radius of the emission hemisphere (1 by default)
  88950. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88951. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  88952. */
  88953. constructor(
  88954. /**
  88955. * The radius of the emission hemisphere.
  88956. */
  88957. radius?: number,
  88958. /**
  88959. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  88960. */
  88961. radiusRange?: number,
  88962. /**
  88963. * How much to randomize the particle direction [0-1].
  88964. */
  88965. directionRandomizer?: number);
  88966. /**
  88967. * Called by the particle System when the direction is computed for the created particle.
  88968. * @param worldMatrix is the world matrix of the particle system
  88969. * @param directionToUpdate is the direction vector to update with the result
  88970. * @param particle is the particle we are computed the direction for
  88971. */
  88972. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  88973. /**
  88974. * Called by the particle System when the position is computed for the created particle.
  88975. * @param worldMatrix is the world matrix of the particle system
  88976. * @param positionToUpdate is the position vector to update with the result
  88977. * @param particle is the particle we are computed the position for
  88978. */
  88979. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  88980. /**
  88981. * Clones the current emitter and returns a copy of it
  88982. * @returns the new emitter
  88983. */
  88984. clone(): HemisphericParticleEmitter;
  88985. /**
  88986. * Called by the GPUParticleSystem to setup the update shader
  88987. * @param effect defines the update shader
  88988. */
  88989. applyToShader(effect: Effect): void;
  88990. /**
  88991. * Returns a string to use to update the GPU particles update shader
  88992. * @returns a string containng the defines string
  88993. */
  88994. getEffectDefines(): string;
  88995. /**
  88996. * Returns the string "HemisphericParticleEmitter"
  88997. * @returns a string containing the class name
  88998. */
  88999. getClassName(): string;
  89000. /**
  89001. * Serializes the particle system to a JSON object.
  89002. * @returns the JSON object
  89003. */
  89004. serialize(): any;
  89005. /**
  89006. * Parse properties from a JSON object
  89007. * @param serializationObject defines the JSON object
  89008. */
  89009. parse(serializationObject: any): void;
  89010. }
  89011. }
  89012. declare module BABYLON {
  89013. /**
  89014. * Particle emitter emitting particles from a point.
  89015. * It emits the particles randomly between 2 given directions.
  89016. */
  89017. export class PointParticleEmitter implements IParticleEmitterType {
  89018. /**
  89019. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89020. */
  89021. direction1: Vector3;
  89022. /**
  89023. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89024. */
  89025. direction2: Vector3;
  89026. /**
  89027. * Creates a new instance PointParticleEmitter
  89028. */
  89029. constructor();
  89030. /**
  89031. * Called by the particle System when the direction is computed for the created particle.
  89032. * @param worldMatrix is the world matrix of the particle system
  89033. * @param directionToUpdate is the direction vector to update with the result
  89034. * @param particle is the particle we are computed the direction for
  89035. */
  89036. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89037. /**
  89038. * Called by the particle System when the position is computed for the created particle.
  89039. * @param worldMatrix is the world matrix of the particle system
  89040. * @param positionToUpdate is the position vector to update with the result
  89041. * @param particle is the particle we are computed the position for
  89042. */
  89043. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89044. /**
  89045. * Clones the current emitter and returns a copy of it
  89046. * @returns the new emitter
  89047. */
  89048. clone(): PointParticleEmitter;
  89049. /**
  89050. * Called by the GPUParticleSystem to setup the update shader
  89051. * @param effect defines the update shader
  89052. */
  89053. applyToShader(effect: Effect): void;
  89054. /**
  89055. * Returns a string to use to update the GPU particles update shader
  89056. * @returns a string containng the defines string
  89057. */
  89058. getEffectDefines(): string;
  89059. /**
  89060. * Returns the string "PointParticleEmitter"
  89061. * @returns a string containing the class name
  89062. */
  89063. getClassName(): string;
  89064. /**
  89065. * Serializes the particle system to a JSON object.
  89066. * @returns the JSON object
  89067. */
  89068. serialize(): any;
  89069. /**
  89070. * Parse properties from a JSON object
  89071. * @param serializationObject defines the JSON object
  89072. */
  89073. parse(serializationObject: any): void;
  89074. }
  89075. }
  89076. declare module BABYLON {
  89077. /**
  89078. * Particle emitter emitting particles from the inside of a sphere.
  89079. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  89080. */
  89081. export class SphereParticleEmitter implements IParticleEmitterType {
  89082. /**
  89083. * The radius of the emission sphere.
  89084. */
  89085. radius: number;
  89086. /**
  89087. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89088. */
  89089. radiusRange: number;
  89090. /**
  89091. * How much to randomize the particle direction [0-1].
  89092. */
  89093. directionRandomizer: number;
  89094. /**
  89095. * Creates a new instance SphereParticleEmitter
  89096. * @param radius the radius of the emission sphere (1 by default)
  89097. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89098. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  89099. */
  89100. constructor(
  89101. /**
  89102. * The radius of the emission sphere.
  89103. */
  89104. radius?: number,
  89105. /**
  89106. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89107. */
  89108. radiusRange?: number,
  89109. /**
  89110. * How much to randomize the particle direction [0-1].
  89111. */
  89112. directionRandomizer?: number);
  89113. /**
  89114. * Called by the particle System when the direction is computed for the created particle.
  89115. * @param worldMatrix is the world matrix of the particle system
  89116. * @param directionToUpdate is the direction vector to update with the result
  89117. * @param particle is the particle we are computed the direction for
  89118. */
  89119. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89120. /**
  89121. * Called by the particle System when the position is computed for the created particle.
  89122. * @param worldMatrix is the world matrix of the particle system
  89123. * @param positionToUpdate is the position vector to update with the result
  89124. * @param particle is the particle we are computed the position for
  89125. */
  89126. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89127. /**
  89128. * Clones the current emitter and returns a copy of it
  89129. * @returns the new emitter
  89130. */
  89131. clone(): SphereParticleEmitter;
  89132. /**
  89133. * Called by the GPUParticleSystem to setup the update shader
  89134. * @param effect defines the update shader
  89135. */
  89136. applyToShader(effect: Effect): void;
  89137. /**
  89138. * Returns a string to use to update the GPU particles update shader
  89139. * @returns a string containng the defines string
  89140. */
  89141. getEffectDefines(): string;
  89142. /**
  89143. * Returns the string "SphereParticleEmitter"
  89144. * @returns a string containing the class name
  89145. */
  89146. getClassName(): string;
  89147. /**
  89148. * Serializes the particle system to a JSON object.
  89149. * @returns the JSON object
  89150. */
  89151. serialize(): any;
  89152. /**
  89153. * Parse properties from a JSON object
  89154. * @param serializationObject defines the JSON object
  89155. */
  89156. parse(serializationObject: any): void;
  89157. }
  89158. /**
  89159. * Particle emitter emitting particles from the inside of a sphere.
  89160. * It emits the particles randomly between two vectors.
  89161. */
  89162. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  89163. /**
  89164. * The min limit of the emission direction.
  89165. */
  89166. direction1: Vector3;
  89167. /**
  89168. * The max limit of the emission direction.
  89169. */
  89170. direction2: Vector3;
  89171. /**
  89172. * Creates a new instance SphereDirectedParticleEmitter
  89173. * @param radius the radius of the emission sphere (1 by default)
  89174. * @param direction1 the min limit of the emission direction (up vector by default)
  89175. * @param direction2 the max limit of the emission direction (up vector by default)
  89176. */
  89177. constructor(radius?: number,
  89178. /**
  89179. * The min limit of the emission direction.
  89180. */
  89181. direction1?: Vector3,
  89182. /**
  89183. * The max limit of the emission direction.
  89184. */
  89185. direction2?: Vector3);
  89186. /**
  89187. * Called by the particle System when the direction is computed for the created particle.
  89188. * @param worldMatrix is the world matrix of the particle system
  89189. * @param directionToUpdate is the direction vector to update with the result
  89190. * @param particle is the particle we are computed the direction for
  89191. */
  89192. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89193. /**
  89194. * Clones the current emitter and returns a copy of it
  89195. * @returns the new emitter
  89196. */
  89197. clone(): SphereDirectedParticleEmitter;
  89198. /**
  89199. * Called by the GPUParticleSystem to setup the update shader
  89200. * @param effect defines the update shader
  89201. */
  89202. applyToShader(effect: Effect): void;
  89203. /**
  89204. * Returns a string to use to update the GPU particles update shader
  89205. * @returns a string containng the defines string
  89206. */
  89207. getEffectDefines(): string;
  89208. /**
  89209. * Returns the string "SphereDirectedParticleEmitter"
  89210. * @returns a string containing the class name
  89211. */
  89212. getClassName(): string;
  89213. /**
  89214. * Serializes the particle system to a JSON object.
  89215. * @returns the JSON object
  89216. */
  89217. serialize(): any;
  89218. /**
  89219. * Parse properties from a JSON object
  89220. * @param serializationObject defines the JSON object
  89221. */
  89222. parse(serializationObject: any): void;
  89223. }
  89224. }
  89225. declare module BABYLON {
  89226. /**
  89227. * Interface representing a particle system in Babylon.js.
  89228. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  89229. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  89230. */
  89231. export interface IParticleSystem {
  89232. /**
  89233. * List of animations used by the particle system.
  89234. */
  89235. animations: Animation[];
  89236. /**
  89237. * The id of the Particle system.
  89238. */
  89239. id: string;
  89240. /**
  89241. * The name of the Particle system.
  89242. */
  89243. name: string;
  89244. /**
  89245. * The emitter represents the Mesh or position we are attaching the particle system to.
  89246. */
  89247. emitter: Nullable<AbstractMesh | Vector3>;
  89248. /**
  89249. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  89250. */
  89251. isBillboardBased: boolean;
  89252. /**
  89253. * The rendering group used by the Particle system to chose when to render.
  89254. */
  89255. renderingGroupId: number;
  89256. /**
  89257. * The layer mask we are rendering the particles through.
  89258. */
  89259. layerMask: number;
  89260. /**
  89261. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  89262. */
  89263. updateSpeed: number;
  89264. /**
  89265. * The amount of time the particle system is running (depends of the overall update speed).
  89266. */
  89267. targetStopDuration: number;
  89268. /**
  89269. * The texture used to render each particle. (this can be a spritesheet)
  89270. */
  89271. particleTexture: Nullable<Texture>;
  89272. /**
  89273. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  89274. */
  89275. blendMode: number;
  89276. /**
  89277. * Minimum life time of emitting particles.
  89278. */
  89279. minLifeTime: number;
  89280. /**
  89281. * Maximum life time of emitting particles.
  89282. */
  89283. maxLifeTime: number;
  89284. /**
  89285. * Minimum Size of emitting particles.
  89286. */
  89287. minSize: number;
  89288. /**
  89289. * Maximum Size of emitting particles.
  89290. */
  89291. maxSize: number;
  89292. /**
  89293. * Minimum scale of emitting particles on X axis.
  89294. */
  89295. minScaleX: number;
  89296. /**
  89297. * Maximum scale of emitting particles on X axis.
  89298. */
  89299. maxScaleX: number;
  89300. /**
  89301. * Minimum scale of emitting particles on Y axis.
  89302. */
  89303. minScaleY: number;
  89304. /**
  89305. * Maximum scale of emitting particles on Y axis.
  89306. */
  89307. maxScaleY: number;
  89308. /**
  89309. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  89310. */
  89311. color1: Color4;
  89312. /**
  89313. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  89314. */
  89315. color2: Color4;
  89316. /**
  89317. * Color the particle will have at the end of its lifetime.
  89318. */
  89319. colorDead: Color4;
  89320. /**
  89321. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  89322. */
  89323. emitRate: number;
  89324. /**
  89325. * You can use gravity if you want to give an orientation to your particles.
  89326. */
  89327. gravity: Vector3;
  89328. /**
  89329. * Minimum power of emitting particles.
  89330. */
  89331. minEmitPower: number;
  89332. /**
  89333. * Maximum power of emitting particles.
  89334. */
  89335. maxEmitPower: number;
  89336. /**
  89337. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  89338. */
  89339. minAngularSpeed: number;
  89340. /**
  89341. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  89342. */
  89343. maxAngularSpeed: number;
  89344. /**
  89345. * Gets or sets the minimal initial rotation in radians.
  89346. */
  89347. minInitialRotation: number;
  89348. /**
  89349. * Gets or sets the maximal initial rotation in radians.
  89350. */
  89351. maxInitialRotation: number;
  89352. /**
  89353. * The particle emitter type defines the emitter used by the particle system.
  89354. * It can be for example box, sphere, or cone...
  89355. */
  89356. particleEmitterType: Nullable<IParticleEmitterType>;
  89357. /**
  89358. * Defines the delay in milliseconds before starting the system (0 by default)
  89359. */
  89360. startDelay: number;
  89361. /**
  89362. * 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
  89363. */
  89364. preWarmCycles: number;
  89365. /**
  89366. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  89367. */
  89368. preWarmStepOffset: number;
  89369. /**
  89370. * 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)
  89371. */
  89372. spriteCellChangeSpeed: number;
  89373. /**
  89374. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  89375. */
  89376. startSpriteCellID: number;
  89377. /**
  89378. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  89379. */
  89380. endSpriteCellID: number;
  89381. /**
  89382. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  89383. */
  89384. spriteCellWidth: number;
  89385. /**
  89386. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  89387. */
  89388. spriteCellHeight: number;
  89389. /**
  89390. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  89391. */
  89392. spriteRandomStartCell: boolean;
  89393. /**
  89394. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  89395. */
  89396. isAnimationSheetEnabled: boolean;
  89397. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  89398. translationPivot: Vector2;
  89399. /**
  89400. * Gets or sets a texture used to add random noise to particle positions
  89401. */
  89402. noiseTexture: Nullable<BaseTexture>;
  89403. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  89404. noiseStrength: Vector3;
  89405. /**
  89406. * Gets or sets the billboard mode to use when isBillboardBased = true.
  89407. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  89408. */
  89409. billboardMode: number;
  89410. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  89411. limitVelocityDamping: number;
  89412. /**
  89413. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  89414. */
  89415. beginAnimationOnStart: boolean;
  89416. /**
  89417. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  89418. */
  89419. beginAnimationFrom: number;
  89420. /**
  89421. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  89422. */
  89423. beginAnimationTo: number;
  89424. /**
  89425. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  89426. */
  89427. beginAnimationLoop: boolean;
  89428. /**
  89429. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  89430. */
  89431. disposeOnStop: boolean;
  89432. /**
  89433. * Gets the maximum number of particles active at the same time.
  89434. * @returns The max number of active particles.
  89435. */
  89436. getCapacity(): number;
  89437. /**
  89438. * Gets if the system has been started. (Note: this will still be true after stop is called)
  89439. * @returns True if it has been started, otherwise false.
  89440. */
  89441. isStarted(): boolean;
  89442. /**
  89443. * Animates the particle system for this frame.
  89444. */
  89445. animate(): void;
  89446. /**
  89447. * Renders the particle system in its current state.
  89448. * @returns the current number of particles
  89449. */
  89450. render(): number;
  89451. /**
  89452. * Dispose the particle system and frees its associated resources.
  89453. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  89454. */
  89455. dispose(disposeTexture?: boolean): void;
  89456. /**
  89457. * Clones the particle system.
  89458. * @param name The name of the cloned object
  89459. * @param newEmitter The new emitter to use
  89460. * @returns the cloned particle system
  89461. */
  89462. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  89463. /**
  89464. * Serializes the particle system to a JSON object.
  89465. * @returns the JSON object
  89466. */
  89467. serialize(): any;
  89468. /**
  89469. * Rebuild the particle system
  89470. */
  89471. rebuild(): void;
  89472. /**
  89473. * Starts the particle system and begins to emit
  89474. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  89475. */
  89476. start(delay?: number): void;
  89477. /**
  89478. * Stops the particle system.
  89479. */
  89480. stop(): void;
  89481. /**
  89482. * Remove all active particles
  89483. */
  89484. reset(): void;
  89485. /**
  89486. * Is this system ready to be used/rendered
  89487. * @return true if the system is ready
  89488. */
  89489. isReady(): boolean;
  89490. /**
  89491. * Adds a new color gradient
  89492. * @param gradient defines the gradient to use (between 0 and 1)
  89493. * @param color1 defines the color to affect to the specified gradient
  89494. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  89495. * @returns the current particle system
  89496. */
  89497. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  89498. /**
  89499. * Remove a specific color gradient
  89500. * @param gradient defines the gradient to remove
  89501. * @returns the current particle system
  89502. */
  89503. removeColorGradient(gradient: number): IParticleSystem;
  89504. /**
  89505. * Adds a new size gradient
  89506. * @param gradient defines the gradient to use (between 0 and 1)
  89507. * @param factor defines the size factor to affect to the specified gradient
  89508. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89509. * @returns the current particle system
  89510. */
  89511. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89512. /**
  89513. * Remove a specific size gradient
  89514. * @param gradient defines the gradient to remove
  89515. * @returns the current particle system
  89516. */
  89517. removeSizeGradient(gradient: number): IParticleSystem;
  89518. /**
  89519. * Gets the current list of color gradients.
  89520. * You must use addColorGradient and removeColorGradient to udpate this list
  89521. * @returns the list of color gradients
  89522. */
  89523. getColorGradients(): Nullable<Array<ColorGradient>>;
  89524. /**
  89525. * Gets the current list of size gradients.
  89526. * You must use addSizeGradient and removeSizeGradient to udpate this list
  89527. * @returns the list of size gradients
  89528. */
  89529. getSizeGradients(): Nullable<Array<FactorGradient>>;
  89530. /**
  89531. * Gets the current list of angular speed gradients.
  89532. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  89533. * @returns the list of angular speed gradients
  89534. */
  89535. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  89536. /**
  89537. * Adds a new angular speed gradient
  89538. * @param gradient defines the gradient to use (between 0 and 1)
  89539. * @param factor defines the angular speed to affect to the specified gradient
  89540. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89541. * @returns the current particle system
  89542. */
  89543. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89544. /**
  89545. * Remove a specific angular speed gradient
  89546. * @param gradient defines the gradient to remove
  89547. * @returns the current particle system
  89548. */
  89549. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  89550. /**
  89551. * Gets the current list of velocity gradients.
  89552. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  89553. * @returns the list of velocity gradients
  89554. */
  89555. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  89556. /**
  89557. * Adds a new velocity gradient
  89558. * @param gradient defines the gradient to use (between 0 and 1)
  89559. * @param factor defines the velocity to affect to the specified gradient
  89560. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89561. * @returns the current particle system
  89562. */
  89563. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89564. /**
  89565. * Remove a specific velocity gradient
  89566. * @param gradient defines the gradient to remove
  89567. * @returns the current particle system
  89568. */
  89569. removeVelocityGradient(gradient: number): IParticleSystem;
  89570. /**
  89571. * Gets the current list of limit velocity gradients.
  89572. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  89573. * @returns the list of limit velocity gradients
  89574. */
  89575. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  89576. /**
  89577. * Adds a new limit velocity gradient
  89578. * @param gradient defines the gradient to use (between 0 and 1)
  89579. * @param factor defines the limit velocity to affect to the specified gradient
  89580. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89581. * @returns the current particle system
  89582. */
  89583. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89584. /**
  89585. * Remove a specific limit velocity gradient
  89586. * @param gradient defines the gradient to remove
  89587. * @returns the current particle system
  89588. */
  89589. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  89590. /**
  89591. * Adds a new drag gradient
  89592. * @param gradient defines the gradient to use (between 0 and 1)
  89593. * @param factor defines the drag to affect to the specified gradient
  89594. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89595. * @returns the current particle system
  89596. */
  89597. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89598. /**
  89599. * Remove a specific drag gradient
  89600. * @param gradient defines the gradient to remove
  89601. * @returns the current particle system
  89602. */
  89603. removeDragGradient(gradient: number): IParticleSystem;
  89604. /**
  89605. * Gets the current list of drag gradients.
  89606. * You must use addDragGradient and removeDragGradient to udpate this list
  89607. * @returns the list of drag gradients
  89608. */
  89609. getDragGradients(): Nullable<Array<FactorGradient>>;
  89610. /**
  89611. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  89612. * @param gradient defines the gradient to use (between 0 and 1)
  89613. * @param factor defines the emit rate to affect to the specified gradient
  89614. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89615. * @returns the current particle system
  89616. */
  89617. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89618. /**
  89619. * Remove a specific emit rate gradient
  89620. * @param gradient defines the gradient to remove
  89621. * @returns the current particle system
  89622. */
  89623. removeEmitRateGradient(gradient: number): IParticleSystem;
  89624. /**
  89625. * Gets the current list of emit rate gradients.
  89626. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  89627. * @returns the list of emit rate gradients
  89628. */
  89629. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  89630. /**
  89631. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  89632. * @param gradient defines the gradient to use (between 0 and 1)
  89633. * @param factor defines the start size to affect to the specified gradient
  89634. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89635. * @returns the current particle system
  89636. */
  89637. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89638. /**
  89639. * Remove a specific start size gradient
  89640. * @param gradient defines the gradient to remove
  89641. * @returns the current particle system
  89642. */
  89643. removeStartSizeGradient(gradient: number): IParticleSystem;
  89644. /**
  89645. * Gets the current list of start size gradients.
  89646. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  89647. * @returns the list of start size gradients
  89648. */
  89649. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  89650. /**
  89651. * Adds a new life time gradient
  89652. * @param gradient defines the gradient to use (between 0 and 1)
  89653. * @param factor defines the life time factor to affect to the specified gradient
  89654. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89655. * @returns the current particle system
  89656. */
  89657. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89658. /**
  89659. * Remove a specific life time gradient
  89660. * @param gradient defines the gradient to remove
  89661. * @returns the current particle system
  89662. */
  89663. removeLifeTimeGradient(gradient: number): IParticleSystem;
  89664. /**
  89665. * Gets the current list of life time gradients.
  89666. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  89667. * @returns the list of life time gradients
  89668. */
  89669. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  89670. /**
  89671. * Gets the current list of color gradients.
  89672. * You must use addColorGradient and removeColorGradient to udpate this list
  89673. * @returns the list of color gradients
  89674. */
  89675. getColorGradients(): Nullable<Array<ColorGradient>>;
  89676. /**
  89677. * Adds a new ramp gradient used to remap particle colors
  89678. * @param gradient defines the gradient to use (between 0 and 1)
  89679. * @param color defines the color to affect to the specified gradient
  89680. * @returns the current particle system
  89681. */
  89682. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  89683. /**
  89684. * Gets the current list of ramp gradients.
  89685. * You must use addRampGradient and removeRampGradient to udpate this list
  89686. * @returns the list of ramp gradients
  89687. */
  89688. getRampGradients(): Nullable<Array<Color3Gradient>>;
  89689. /** Gets or sets a boolean indicating that ramp gradients must be used
  89690. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  89691. */
  89692. useRampGradients: boolean;
  89693. /**
  89694. * Adds a new color remap gradient
  89695. * @param gradient defines the gradient to use (between 0 and 1)
  89696. * @param min defines the color remap minimal range
  89697. * @param max defines the color remap maximal range
  89698. * @returns the current particle system
  89699. */
  89700. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89701. /**
  89702. * Gets the current list of color remap gradients.
  89703. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  89704. * @returns the list of color remap gradients
  89705. */
  89706. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  89707. /**
  89708. * Adds a new alpha remap gradient
  89709. * @param gradient defines the gradient to use (between 0 and 1)
  89710. * @param min defines the alpha remap minimal range
  89711. * @param max defines the alpha remap maximal range
  89712. * @returns the current particle system
  89713. */
  89714. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  89715. /**
  89716. * Gets the current list of alpha remap gradients.
  89717. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89718. * @returns the list of alpha remap gradients
  89719. */
  89720. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89721. /**
  89722. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  89723. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89724. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89725. * @returns the emitter
  89726. */
  89727. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  89728. /**
  89729. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  89730. * @param radius The radius of the hemisphere to emit from
  89731. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89732. * @returns the emitter
  89733. */
  89734. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  89735. /**
  89736. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  89737. * @param radius The radius of the sphere to emit from
  89738. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89739. * @returns the emitter
  89740. */
  89741. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  89742. /**
  89743. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  89744. * @param radius The radius of the sphere to emit from
  89745. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  89746. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  89747. * @returns the emitter
  89748. */
  89749. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  89750. /**
  89751. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  89752. * @param radius The radius of the emission cylinder
  89753. * @param height The height of the emission cylinder
  89754. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  89755. * @param directionRandomizer How much to randomize the particle direction [0-1]
  89756. * @returns the emitter
  89757. */
  89758. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  89759. /**
  89760. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  89761. * @param radius The radius of the cylinder to emit from
  89762. * @param height The height of the emission cylinder
  89763. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89764. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  89765. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  89766. * @returns the emitter
  89767. */
  89768. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  89769. /**
  89770. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  89771. * @param radius The radius of the cone to emit from
  89772. * @param angle The base angle of the cone
  89773. * @returns the emitter
  89774. */
  89775. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  89776. /**
  89777. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  89778. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89779. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89780. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89781. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89782. * @returns the emitter
  89783. */
  89784. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  89785. /**
  89786. * Get hosting scene
  89787. * @returns the scene
  89788. */
  89789. getScene(): Scene;
  89790. }
  89791. }
  89792. declare module BABYLON {
  89793. /**
  89794. * Creates an instance based on a source mesh.
  89795. */
  89796. export class InstancedMesh extends AbstractMesh {
  89797. private _sourceMesh;
  89798. private _currentLOD;
  89799. /** @hidden */
  89800. _indexInSourceMeshInstanceArray: number;
  89801. constructor(name: string, source: Mesh);
  89802. /**
  89803. * Returns the string "InstancedMesh".
  89804. */
  89805. getClassName(): string;
  89806. /** Gets the list of lights affecting that mesh */
  89807. get lightSources(): Light[];
  89808. _resyncLightSources(): void;
  89809. _resyncLightSource(light: Light): void;
  89810. _removeLightSource(light: Light, dispose: boolean): void;
  89811. /**
  89812. * If the source mesh receives shadows
  89813. */
  89814. get receiveShadows(): boolean;
  89815. /**
  89816. * The material of the source mesh
  89817. */
  89818. get material(): Nullable<Material>;
  89819. /**
  89820. * Visibility of the source mesh
  89821. */
  89822. get visibility(): number;
  89823. /**
  89824. * Skeleton of the source mesh
  89825. */
  89826. get skeleton(): Nullable<Skeleton>;
  89827. /**
  89828. * Rendering ground id of the source mesh
  89829. */
  89830. get renderingGroupId(): number;
  89831. set renderingGroupId(value: number);
  89832. /**
  89833. * Returns the total number of vertices (integer).
  89834. */
  89835. getTotalVertices(): number;
  89836. /**
  89837. * Returns a positive integer : the total number of indices in this mesh geometry.
  89838. * @returns the numner of indices or zero if the mesh has no geometry.
  89839. */
  89840. getTotalIndices(): number;
  89841. /**
  89842. * The source mesh of the instance
  89843. */
  89844. get sourceMesh(): Mesh;
  89845. /**
  89846. * Is this node ready to be used/rendered
  89847. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89848. * @return {boolean} is it ready
  89849. */
  89850. isReady(completeCheck?: boolean): boolean;
  89851. /**
  89852. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89853. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  89854. * @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.
  89855. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  89856. */
  89857. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  89858. /**
  89859. * Sets the vertex data of the mesh geometry for the requested `kind`.
  89860. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  89861. * The `data` are either a numeric array either a Float32Array.
  89862. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  89863. * 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).
  89864. * Note that a new underlying VertexBuffer object is created each call.
  89865. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  89866. *
  89867. * Possible `kind` values :
  89868. * - VertexBuffer.PositionKind
  89869. * - VertexBuffer.UVKind
  89870. * - VertexBuffer.UV2Kind
  89871. * - VertexBuffer.UV3Kind
  89872. * - VertexBuffer.UV4Kind
  89873. * - VertexBuffer.UV5Kind
  89874. * - VertexBuffer.UV6Kind
  89875. * - VertexBuffer.ColorKind
  89876. * - VertexBuffer.MatricesIndicesKind
  89877. * - VertexBuffer.MatricesIndicesExtraKind
  89878. * - VertexBuffer.MatricesWeightsKind
  89879. * - VertexBuffer.MatricesWeightsExtraKind
  89880. *
  89881. * Returns the Mesh.
  89882. */
  89883. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89884. /**
  89885. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  89886. * If the mesh has no geometry, it is simply returned as it is.
  89887. * The `data` are either a numeric array either a Float32Array.
  89888. * No new underlying VertexBuffer object is created.
  89889. * 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.
  89890. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  89891. *
  89892. * Possible `kind` values :
  89893. * - VertexBuffer.PositionKind
  89894. * - VertexBuffer.UVKind
  89895. * - VertexBuffer.UV2Kind
  89896. * - VertexBuffer.UV3Kind
  89897. * - VertexBuffer.UV4Kind
  89898. * - VertexBuffer.UV5Kind
  89899. * - VertexBuffer.UV6Kind
  89900. * - VertexBuffer.ColorKind
  89901. * - VertexBuffer.MatricesIndicesKind
  89902. * - VertexBuffer.MatricesIndicesExtraKind
  89903. * - VertexBuffer.MatricesWeightsKind
  89904. * - VertexBuffer.MatricesWeightsExtraKind
  89905. *
  89906. * Returns the Mesh.
  89907. */
  89908. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  89909. /**
  89910. * Sets the mesh indices.
  89911. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  89912. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  89913. * This method creates a new index buffer each call.
  89914. * Returns the Mesh.
  89915. */
  89916. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  89917. /**
  89918. * Boolean : True if the mesh owns the requested kind of data.
  89919. */
  89920. isVerticesDataPresent(kind: string): boolean;
  89921. /**
  89922. * Returns an array of indices (IndicesArray).
  89923. */
  89924. getIndices(): Nullable<IndicesArray>;
  89925. get _positions(): Nullable<Vector3[]>;
  89926. /**
  89927. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89928. * This means the mesh underlying bounding box and sphere are recomputed.
  89929. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89930. * @returns the current mesh
  89931. */
  89932. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  89933. /** @hidden */
  89934. _preActivate(): InstancedMesh;
  89935. /** @hidden */
  89936. _activate(renderId: number, intermediateRendering: boolean): boolean;
  89937. /** @hidden */
  89938. _postActivate(): void;
  89939. getWorldMatrix(): Matrix;
  89940. get isAnInstance(): boolean;
  89941. /**
  89942. * Returns the current associated LOD AbstractMesh.
  89943. */
  89944. getLOD(camera: Camera): AbstractMesh;
  89945. /** @hidden */
  89946. _syncSubMeshes(): InstancedMesh;
  89947. /** @hidden */
  89948. _generatePointsArray(): boolean;
  89949. /**
  89950. * Creates a new InstancedMesh from the current mesh.
  89951. * - name (string) : the cloned mesh name
  89952. * - newParent (optional Node) : the optional Node to parent the clone to.
  89953. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  89954. *
  89955. * Returns the clone.
  89956. */
  89957. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  89958. /**
  89959. * Disposes the InstancedMesh.
  89960. * Returns nothing.
  89961. */
  89962. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89963. }
  89964. interface Mesh {
  89965. /**
  89966. * Register a custom buffer that will be instanced
  89967. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  89968. * @param kind defines the buffer kind
  89969. * @param stride defines the stride in floats
  89970. */
  89971. registerInstancedBuffer(kind: string, stride: number): void;
  89972. /** @hidden */
  89973. _userInstancedBuffersStorage: {
  89974. data: {
  89975. [key: string]: Float32Array;
  89976. };
  89977. sizes: {
  89978. [key: string]: number;
  89979. };
  89980. vertexBuffers: {
  89981. [key: string]: Nullable<VertexBuffer>;
  89982. };
  89983. strides: {
  89984. [key: string]: number;
  89985. };
  89986. };
  89987. }
  89988. interface AbstractMesh {
  89989. /**
  89990. * Object used to store instanced buffers defined by user
  89991. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  89992. */
  89993. instancedBuffers: {
  89994. [key: string]: any;
  89995. };
  89996. }
  89997. }
  89998. declare module BABYLON {
  89999. /**
  90000. * Defines the options associated with the creation of a shader material.
  90001. */
  90002. export interface IShaderMaterialOptions {
  90003. /**
  90004. * Does the material work in alpha blend mode
  90005. */
  90006. needAlphaBlending: boolean;
  90007. /**
  90008. * Does the material work in alpha test mode
  90009. */
  90010. needAlphaTesting: boolean;
  90011. /**
  90012. * The list of attribute names used in the shader
  90013. */
  90014. attributes: string[];
  90015. /**
  90016. * The list of unifrom names used in the shader
  90017. */
  90018. uniforms: string[];
  90019. /**
  90020. * The list of UBO names used in the shader
  90021. */
  90022. uniformBuffers: string[];
  90023. /**
  90024. * The list of sampler names used in the shader
  90025. */
  90026. samplers: string[];
  90027. /**
  90028. * The list of defines used in the shader
  90029. */
  90030. defines: string[];
  90031. }
  90032. /**
  90033. * 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.
  90034. *
  90035. * This returned material effects how the mesh will look based on the code in the shaders.
  90036. *
  90037. * @see http://doc.babylonjs.com/how_to/shader_material
  90038. */
  90039. export class ShaderMaterial extends Material {
  90040. private _shaderPath;
  90041. private _options;
  90042. private _textures;
  90043. private _textureArrays;
  90044. private _floats;
  90045. private _ints;
  90046. private _floatsArrays;
  90047. private _colors3;
  90048. private _colors3Arrays;
  90049. private _colors4;
  90050. private _colors4Arrays;
  90051. private _vectors2;
  90052. private _vectors3;
  90053. private _vectors4;
  90054. private _matrices;
  90055. private _matrixArrays;
  90056. private _matrices3x3;
  90057. private _matrices2x2;
  90058. private _vectors2Arrays;
  90059. private _vectors3Arrays;
  90060. private _vectors4Arrays;
  90061. private _cachedWorldViewMatrix;
  90062. private _cachedWorldViewProjectionMatrix;
  90063. private _renderId;
  90064. private _multiview;
  90065. /**
  90066. * Instantiate a new shader material.
  90067. * 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.
  90068. * This returned material effects how the mesh will look based on the code in the shaders.
  90069. * @see http://doc.babylonjs.com/how_to/shader_material
  90070. * @param name Define the name of the material in the scene
  90071. * @param scene Define the scene the material belongs to
  90072. * @param shaderPath Defines the route to the shader code in one of three ways:
  90073. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  90074. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  90075. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  90076. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  90077. * @param options Define the options used to create the shader
  90078. */
  90079. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  90080. /**
  90081. * Gets the shader path used to define the shader code
  90082. * It can be modified to trigger a new compilation
  90083. */
  90084. get shaderPath(): any;
  90085. /**
  90086. * Sets the shader path used to define the shader code
  90087. * It can be modified to trigger a new compilation
  90088. */
  90089. set shaderPath(shaderPath: any);
  90090. /**
  90091. * Gets the options used to compile the shader.
  90092. * They can be modified to trigger a new compilation
  90093. */
  90094. get options(): IShaderMaterialOptions;
  90095. /**
  90096. * Gets the current class name of the material e.g. "ShaderMaterial"
  90097. * Mainly use in serialization.
  90098. * @returns the class name
  90099. */
  90100. getClassName(): string;
  90101. /**
  90102. * Specifies if the material will require alpha blending
  90103. * @returns a boolean specifying if alpha blending is needed
  90104. */
  90105. needAlphaBlending(): boolean;
  90106. /**
  90107. * Specifies if this material should be rendered in alpha test mode
  90108. * @returns a boolean specifying if an alpha test is needed.
  90109. */
  90110. needAlphaTesting(): boolean;
  90111. private _checkUniform;
  90112. /**
  90113. * Set a texture in the shader.
  90114. * @param name Define the name of the uniform samplers as defined in the shader
  90115. * @param texture Define the texture to bind to this sampler
  90116. * @return the material itself allowing "fluent" like uniform updates
  90117. */
  90118. setTexture(name: string, texture: Texture): ShaderMaterial;
  90119. /**
  90120. * Set a texture array in the shader.
  90121. * @param name Define the name of the uniform sampler array as defined in the shader
  90122. * @param textures Define the list of textures to bind to this sampler
  90123. * @return the material itself allowing "fluent" like uniform updates
  90124. */
  90125. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  90126. /**
  90127. * Set a float in the shader.
  90128. * @param name Define the name of the uniform as defined in the shader
  90129. * @param value Define the value to give to the uniform
  90130. * @return the material itself allowing "fluent" like uniform updates
  90131. */
  90132. setFloat(name: string, value: number): ShaderMaterial;
  90133. /**
  90134. * Set a int in the shader.
  90135. * @param name Define the name of the uniform as defined in the shader
  90136. * @param value Define the value to give to the uniform
  90137. * @return the material itself allowing "fluent" like uniform updates
  90138. */
  90139. setInt(name: string, value: number): ShaderMaterial;
  90140. /**
  90141. * Set an array of floats in the shader.
  90142. * @param name Define the name of the uniform as defined in the shader
  90143. * @param value Define the value to give to the uniform
  90144. * @return the material itself allowing "fluent" like uniform updates
  90145. */
  90146. setFloats(name: string, value: number[]): ShaderMaterial;
  90147. /**
  90148. * Set a vec3 in the shader from a Color3.
  90149. * @param name Define the name of the uniform as defined in the shader
  90150. * @param value Define the value to give to the uniform
  90151. * @return the material itself allowing "fluent" like uniform updates
  90152. */
  90153. setColor3(name: string, value: Color3): ShaderMaterial;
  90154. /**
  90155. * Set a vec3 array in the shader from a Color3 array.
  90156. * @param name Define the name of the uniform as defined in the shader
  90157. * @param value Define the value to give to the uniform
  90158. * @return the material itself allowing "fluent" like uniform updates
  90159. */
  90160. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  90161. /**
  90162. * Set a vec4 in the shader from a Color4.
  90163. * @param name Define the name of the uniform as defined in the shader
  90164. * @param value Define the value to give to the uniform
  90165. * @return the material itself allowing "fluent" like uniform updates
  90166. */
  90167. setColor4(name: string, value: Color4): ShaderMaterial;
  90168. /**
  90169. * Set a vec4 array in the shader from a Color4 array.
  90170. * @param name Define the name of the uniform as defined in the shader
  90171. * @param value Define the value to give to the uniform
  90172. * @return the material itself allowing "fluent" like uniform updates
  90173. */
  90174. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  90175. /**
  90176. * Set a vec2 in the shader from a Vector2.
  90177. * @param name Define the name of the uniform as defined in the shader
  90178. * @param value Define the value to give to the uniform
  90179. * @return the material itself allowing "fluent" like uniform updates
  90180. */
  90181. setVector2(name: string, value: Vector2): ShaderMaterial;
  90182. /**
  90183. * Set a vec3 in the shader from a Vector3.
  90184. * @param name Define the name of the uniform as defined in the shader
  90185. * @param value Define the value to give to the uniform
  90186. * @return the material itself allowing "fluent" like uniform updates
  90187. */
  90188. setVector3(name: string, value: Vector3): ShaderMaterial;
  90189. /**
  90190. * Set a vec4 in the shader from a Vector4.
  90191. * @param name Define the name of the uniform as defined in the shader
  90192. * @param value Define the value to give to the uniform
  90193. * @return the material itself allowing "fluent" like uniform updates
  90194. */
  90195. setVector4(name: string, value: Vector4): ShaderMaterial;
  90196. /**
  90197. * Set a mat4 in the shader from a Matrix.
  90198. * @param name Define the name of the uniform as defined in the shader
  90199. * @param value Define the value to give to the uniform
  90200. * @return the material itself allowing "fluent" like uniform updates
  90201. */
  90202. setMatrix(name: string, value: Matrix): ShaderMaterial;
  90203. /**
  90204. * Set a float32Array in the shader from a matrix array.
  90205. * @param name Define the name of the uniform as defined in the shader
  90206. * @param value Define the value to give to the uniform
  90207. * @return the material itself allowing "fluent" like uniform updates
  90208. */
  90209. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  90210. /**
  90211. * Set a mat3 in the shader from a Float32Array.
  90212. * @param name Define the name of the uniform as defined in the shader
  90213. * @param value Define the value to give to the uniform
  90214. * @return the material itself allowing "fluent" like uniform updates
  90215. */
  90216. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  90217. /**
  90218. * Set a mat2 in the shader from a Float32Array.
  90219. * @param name Define the name of the uniform as defined in the shader
  90220. * @param value Define the value to give to the uniform
  90221. * @return the material itself allowing "fluent" like uniform updates
  90222. */
  90223. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  90224. /**
  90225. * Set a vec2 array in the shader from a number array.
  90226. * @param name Define the name of the uniform as defined in the shader
  90227. * @param value Define the value to give to the uniform
  90228. * @return the material itself allowing "fluent" like uniform updates
  90229. */
  90230. setArray2(name: string, value: number[]): ShaderMaterial;
  90231. /**
  90232. * Set a vec3 array in the shader from a number array.
  90233. * @param name Define the name of the uniform as defined in the shader
  90234. * @param value Define the value to give to the uniform
  90235. * @return the material itself allowing "fluent" like uniform updates
  90236. */
  90237. setArray3(name: string, value: number[]): ShaderMaterial;
  90238. /**
  90239. * Set a vec4 array in the shader from a number array.
  90240. * @param name Define the name of the uniform as defined in the shader
  90241. * @param value Define the value to give to the uniform
  90242. * @return the material itself allowing "fluent" like uniform updates
  90243. */
  90244. setArray4(name: string, value: number[]): ShaderMaterial;
  90245. private _checkCache;
  90246. /**
  90247. * Specifies that the submesh is ready to be used
  90248. * @param mesh defines the mesh to check
  90249. * @param subMesh defines which submesh to check
  90250. * @param useInstances specifies that instances should be used
  90251. * @returns a boolean indicating that the submesh is ready or not
  90252. */
  90253. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  90254. /**
  90255. * Checks if the material is ready to render the requested mesh
  90256. * @param mesh Define the mesh to render
  90257. * @param useInstances Define whether or not the material is used with instances
  90258. * @returns true if ready, otherwise false
  90259. */
  90260. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  90261. /**
  90262. * Binds the world matrix to the material
  90263. * @param world defines the world transformation matrix
  90264. */
  90265. bindOnlyWorldMatrix(world: Matrix): void;
  90266. /**
  90267. * Binds the material to the mesh
  90268. * @param world defines the world transformation matrix
  90269. * @param mesh defines the mesh to bind the material to
  90270. */
  90271. bind(world: Matrix, mesh?: Mesh): void;
  90272. /**
  90273. * Gets the active textures from the material
  90274. * @returns an array of textures
  90275. */
  90276. getActiveTextures(): BaseTexture[];
  90277. /**
  90278. * Specifies if the material uses a texture
  90279. * @param texture defines the texture to check against the material
  90280. * @returns a boolean specifying if the material uses the texture
  90281. */
  90282. hasTexture(texture: BaseTexture): boolean;
  90283. /**
  90284. * Makes a duplicate of the material, and gives it a new name
  90285. * @param name defines the new name for the duplicated material
  90286. * @returns the cloned material
  90287. */
  90288. clone(name: string): ShaderMaterial;
  90289. /**
  90290. * Disposes the material
  90291. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  90292. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  90293. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  90294. */
  90295. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  90296. /**
  90297. * Serializes this material in a JSON representation
  90298. * @returns the serialized material object
  90299. */
  90300. serialize(): any;
  90301. /**
  90302. * Creates a shader material from parsed shader material data
  90303. * @param source defines the JSON represnetation of the material
  90304. * @param scene defines the hosting scene
  90305. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90306. * @returns a new material
  90307. */
  90308. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  90309. }
  90310. }
  90311. declare module BABYLON {
  90312. /** @hidden */
  90313. export var colorPixelShader: {
  90314. name: string;
  90315. shader: string;
  90316. };
  90317. }
  90318. declare module BABYLON {
  90319. /** @hidden */
  90320. export var colorVertexShader: {
  90321. name: string;
  90322. shader: string;
  90323. };
  90324. }
  90325. declare module BABYLON {
  90326. /**
  90327. * Line mesh
  90328. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  90329. */
  90330. export class LinesMesh extends Mesh {
  90331. /**
  90332. * If vertex color should be applied to the mesh
  90333. */
  90334. readonly useVertexColor?: boolean | undefined;
  90335. /**
  90336. * If vertex alpha should be applied to the mesh
  90337. */
  90338. readonly useVertexAlpha?: boolean | undefined;
  90339. /**
  90340. * Color of the line (Default: White)
  90341. */
  90342. color: Color3;
  90343. /**
  90344. * Alpha of the line (Default: 1)
  90345. */
  90346. alpha: number;
  90347. /**
  90348. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  90349. * This margin is expressed in world space coordinates, so its value may vary.
  90350. * Default value is 0.1
  90351. */
  90352. intersectionThreshold: number;
  90353. private _colorShader;
  90354. private color4;
  90355. /**
  90356. * Creates a new LinesMesh
  90357. * @param name defines the name
  90358. * @param scene defines the hosting scene
  90359. * @param parent defines the parent mesh if any
  90360. * @param source defines the optional source LinesMesh used to clone data from
  90361. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  90362. * When false, achieved by calling a clone(), also passing False.
  90363. * This will make creation of children, recursive.
  90364. * @param useVertexColor defines if this LinesMesh supports vertex color
  90365. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  90366. */
  90367. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  90368. /**
  90369. * If vertex color should be applied to the mesh
  90370. */
  90371. useVertexColor?: boolean | undefined,
  90372. /**
  90373. * If vertex alpha should be applied to the mesh
  90374. */
  90375. useVertexAlpha?: boolean | undefined);
  90376. private _addClipPlaneDefine;
  90377. private _removeClipPlaneDefine;
  90378. isReady(): boolean;
  90379. /**
  90380. * Returns the string "LineMesh"
  90381. */
  90382. getClassName(): string;
  90383. /**
  90384. * @hidden
  90385. */
  90386. get material(): Material;
  90387. /**
  90388. * @hidden
  90389. */
  90390. set material(value: Material);
  90391. /**
  90392. * @hidden
  90393. */
  90394. get checkCollisions(): boolean;
  90395. /** @hidden */
  90396. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  90397. /** @hidden */
  90398. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  90399. /**
  90400. * Disposes of the line mesh
  90401. * @param doNotRecurse If children should be disposed
  90402. */
  90403. dispose(doNotRecurse?: boolean): void;
  90404. /**
  90405. * Returns a new LineMesh object cloned from the current one.
  90406. */
  90407. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  90408. /**
  90409. * Creates a new InstancedLinesMesh object from the mesh model.
  90410. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90411. * @param name defines the name of the new instance
  90412. * @returns a new InstancedLinesMesh
  90413. */
  90414. createInstance(name: string): InstancedLinesMesh;
  90415. }
  90416. /**
  90417. * Creates an instance based on a source LinesMesh
  90418. */
  90419. export class InstancedLinesMesh extends InstancedMesh {
  90420. /**
  90421. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  90422. * This margin is expressed in world space coordinates, so its value may vary.
  90423. * Initilized with the intersectionThreshold value of the source LinesMesh
  90424. */
  90425. intersectionThreshold: number;
  90426. constructor(name: string, source: LinesMesh);
  90427. /**
  90428. * Returns the string "InstancedLinesMesh".
  90429. */
  90430. getClassName(): string;
  90431. }
  90432. }
  90433. declare module BABYLON {
  90434. /** @hidden */
  90435. export var linePixelShader: {
  90436. name: string;
  90437. shader: string;
  90438. };
  90439. }
  90440. declare module BABYLON {
  90441. /** @hidden */
  90442. export var lineVertexShader: {
  90443. name: string;
  90444. shader: string;
  90445. };
  90446. }
  90447. declare module BABYLON {
  90448. interface AbstractMesh {
  90449. /**
  90450. * Gets the edgesRenderer associated with the mesh
  90451. */
  90452. edgesRenderer: Nullable<EdgesRenderer>;
  90453. }
  90454. interface LinesMesh {
  90455. /**
  90456. * Enables the edge rendering mode on the mesh.
  90457. * This mode makes the mesh edges visible
  90458. * @param epsilon defines the maximal distance between two angles to detect a face
  90459. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90460. * @returns the currentAbstractMesh
  90461. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90462. */
  90463. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  90464. }
  90465. interface InstancedLinesMesh {
  90466. /**
  90467. * Enables the edge rendering mode on the mesh.
  90468. * This mode makes the mesh edges visible
  90469. * @param epsilon defines the maximal distance between two angles to detect a face
  90470. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90471. * @returns the current InstancedLinesMesh
  90472. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90473. */
  90474. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  90475. }
  90476. /**
  90477. * Defines the minimum contract an Edges renderer should follow.
  90478. */
  90479. export interface IEdgesRenderer extends IDisposable {
  90480. /**
  90481. * Gets or sets a boolean indicating if the edgesRenderer is active
  90482. */
  90483. isEnabled: boolean;
  90484. /**
  90485. * Renders the edges of the attached mesh,
  90486. */
  90487. render(): void;
  90488. /**
  90489. * Checks wether or not the edges renderer is ready to render.
  90490. * @return true if ready, otherwise false.
  90491. */
  90492. isReady(): boolean;
  90493. }
  90494. /**
  90495. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  90496. */
  90497. export class EdgesRenderer implements IEdgesRenderer {
  90498. /**
  90499. * Define the size of the edges with an orthographic camera
  90500. */
  90501. edgesWidthScalerForOrthographic: number;
  90502. /**
  90503. * Define the size of the edges with a perspective camera
  90504. */
  90505. edgesWidthScalerForPerspective: number;
  90506. protected _source: AbstractMesh;
  90507. protected _linesPositions: number[];
  90508. protected _linesNormals: number[];
  90509. protected _linesIndices: number[];
  90510. protected _epsilon: number;
  90511. protected _indicesCount: number;
  90512. protected _lineShader: ShaderMaterial;
  90513. protected _ib: DataBuffer;
  90514. protected _buffers: {
  90515. [key: string]: Nullable<VertexBuffer>;
  90516. };
  90517. protected _checkVerticesInsteadOfIndices: boolean;
  90518. private _meshRebuildObserver;
  90519. private _meshDisposeObserver;
  90520. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  90521. isEnabled: boolean;
  90522. /**
  90523. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  90524. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  90525. * @param source Mesh used to create edges
  90526. * @param epsilon sum of angles in adjacency to check for edge
  90527. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  90528. * @param generateEdgesLines - should generate Lines or only prepare resources.
  90529. */
  90530. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  90531. protected _prepareRessources(): void;
  90532. /** @hidden */
  90533. _rebuild(): void;
  90534. /**
  90535. * Releases the required resources for the edges renderer
  90536. */
  90537. dispose(): void;
  90538. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  90539. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  90540. /**
  90541. * Checks if the pair of p0 and p1 is en edge
  90542. * @param faceIndex
  90543. * @param edge
  90544. * @param faceNormals
  90545. * @param p0
  90546. * @param p1
  90547. * @private
  90548. */
  90549. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  90550. /**
  90551. * push line into the position, normal and index buffer
  90552. * @protected
  90553. */
  90554. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  90555. /**
  90556. * Generates lines edges from adjacencjes
  90557. * @private
  90558. */
  90559. _generateEdgesLines(): void;
  90560. /**
  90561. * Checks wether or not the edges renderer is ready to render.
  90562. * @return true if ready, otherwise false.
  90563. */
  90564. isReady(): boolean;
  90565. /**
  90566. * Renders the edges of the attached mesh,
  90567. */
  90568. render(): void;
  90569. }
  90570. /**
  90571. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  90572. */
  90573. export class LineEdgesRenderer extends EdgesRenderer {
  90574. /**
  90575. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  90576. * @param source LineMesh used to generate edges
  90577. * @param epsilon not important (specified angle for edge detection)
  90578. * @param checkVerticesInsteadOfIndices not important for LineMesh
  90579. */
  90580. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  90581. /**
  90582. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  90583. */
  90584. _generateEdgesLines(): void;
  90585. }
  90586. }
  90587. declare module BABYLON {
  90588. /**
  90589. * This represents the object necessary to create a rendering group.
  90590. * This is exclusively used and created by the rendering manager.
  90591. * To modify the behavior, you use the available helpers in your scene or meshes.
  90592. * @hidden
  90593. */
  90594. export class RenderingGroup {
  90595. index: number;
  90596. private static _zeroVector;
  90597. private _scene;
  90598. private _opaqueSubMeshes;
  90599. private _transparentSubMeshes;
  90600. private _alphaTestSubMeshes;
  90601. private _depthOnlySubMeshes;
  90602. private _particleSystems;
  90603. private _spriteManagers;
  90604. private _opaqueSortCompareFn;
  90605. private _alphaTestSortCompareFn;
  90606. private _transparentSortCompareFn;
  90607. private _renderOpaque;
  90608. private _renderAlphaTest;
  90609. private _renderTransparent;
  90610. /** @hidden */
  90611. _edgesRenderers: SmartArray<IEdgesRenderer>;
  90612. onBeforeTransparentRendering: () => void;
  90613. /**
  90614. * Set the opaque sort comparison function.
  90615. * If null the sub meshes will be render in the order they were created
  90616. */
  90617. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90618. /**
  90619. * Set the alpha test sort comparison function.
  90620. * If null the sub meshes will be render in the order they were created
  90621. */
  90622. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90623. /**
  90624. * Set the transparent sort comparison function.
  90625. * If null the sub meshes will be render in the order they were created
  90626. */
  90627. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90628. /**
  90629. * Creates a new rendering group.
  90630. * @param index The rendering group index
  90631. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  90632. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  90633. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  90634. */
  90635. 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>);
  90636. /**
  90637. * Render all the sub meshes contained in the group.
  90638. * @param customRenderFunction Used to override the default render behaviour of the group.
  90639. * @returns true if rendered some submeshes.
  90640. */
  90641. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  90642. /**
  90643. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  90644. * @param subMeshes The submeshes to render
  90645. */
  90646. private renderOpaqueSorted;
  90647. /**
  90648. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  90649. * @param subMeshes The submeshes to render
  90650. */
  90651. private renderAlphaTestSorted;
  90652. /**
  90653. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  90654. * @param subMeshes The submeshes to render
  90655. */
  90656. private renderTransparentSorted;
  90657. /**
  90658. * Renders the submeshes in a specified order.
  90659. * @param subMeshes The submeshes to sort before render
  90660. * @param sortCompareFn The comparison function use to sort
  90661. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  90662. * @param transparent Specifies to activate blending if true
  90663. */
  90664. private static renderSorted;
  90665. /**
  90666. * Renders the submeshes in the order they were dispatched (no sort applied).
  90667. * @param subMeshes The submeshes to render
  90668. */
  90669. private static renderUnsorted;
  90670. /**
  90671. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90672. * are rendered back to front if in the same alpha index.
  90673. *
  90674. * @param a The first submesh
  90675. * @param b The second submesh
  90676. * @returns The result of the comparison
  90677. */
  90678. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  90679. /**
  90680. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90681. * are rendered back to front.
  90682. *
  90683. * @param a The first submesh
  90684. * @param b The second submesh
  90685. * @returns The result of the comparison
  90686. */
  90687. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  90688. /**
  90689. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90690. * are rendered front to back (prevent overdraw).
  90691. *
  90692. * @param a The first submesh
  90693. * @param b The second submesh
  90694. * @returns The result of the comparison
  90695. */
  90696. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  90697. /**
  90698. * Resets the different lists of submeshes to prepare a new frame.
  90699. */
  90700. prepare(): void;
  90701. dispose(): void;
  90702. /**
  90703. * Inserts the submesh in its correct queue depending on its material.
  90704. * @param subMesh The submesh to dispatch
  90705. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90706. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90707. */
  90708. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90709. dispatchSprites(spriteManager: ISpriteManager): void;
  90710. dispatchParticles(particleSystem: IParticleSystem): void;
  90711. private _renderParticles;
  90712. private _renderSprites;
  90713. }
  90714. }
  90715. declare module BABYLON {
  90716. /**
  90717. * Interface describing the different options available in the rendering manager
  90718. * regarding Auto Clear between groups.
  90719. */
  90720. export interface IRenderingManagerAutoClearSetup {
  90721. /**
  90722. * Defines whether or not autoclear is enable.
  90723. */
  90724. autoClear: boolean;
  90725. /**
  90726. * Defines whether or not to autoclear the depth buffer.
  90727. */
  90728. depth: boolean;
  90729. /**
  90730. * Defines whether or not to autoclear the stencil buffer.
  90731. */
  90732. stencil: boolean;
  90733. }
  90734. /**
  90735. * This class is used by the onRenderingGroupObservable
  90736. */
  90737. export class RenderingGroupInfo {
  90738. /**
  90739. * The Scene that being rendered
  90740. */
  90741. scene: Scene;
  90742. /**
  90743. * The camera currently used for the rendering pass
  90744. */
  90745. camera: Nullable<Camera>;
  90746. /**
  90747. * The ID of the renderingGroup being processed
  90748. */
  90749. renderingGroupId: number;
  90750. }
  90751. /**
  90752. * This is the manager responsible of all the rendering for meshes sprites and particles.
  90753. * It is enable to manage the different groups as well as the different necessary sort functions.
  90754. * This should not be used directly aside of the few static configurations
  90755. */
  90756. export class RenderingManager {
  90757. /**
  90758. * The max id used for rendering groups (not included)
  90759. */
  90760. static MAX_RENDERINGGROUPS: number;
  90761. /**
  90762. * The min id used for rendering groups (included)
  90763. */
  90764. static MIN_RENDERINGGROUPS: number;
  90765. /**
  90766. * Used to globally prevent autoclearing scenes.
  90767. */
  90768. static AUTOCLEAR: boolean;
  90769. /**
  90770. * @hidden
  90771. */
  90772. _useSceneAutoClearSetup: boolean;
  90773. private _scene;
  90774. private _renderingGroups;
  90775. private _depthStencilBufferAlreadyCleaned;
  90776. private _autoClearDepthStencil;
  90777. private _customOpaqueSortCompareFn;
  90778. private _customAlphaTestSortCompareFn;
  90779. private _customTransparentSortCompareFn;
  90780. private _renderingGroupInfo;
  90781. /**
  90782. * Instantiates a new rendering group for a particular scene
  90783. * @param scene Defines the scene the groups belongs to
  90784. */
  90785. constructor(scene: Scene);
  90786. private _clearDepthStencilBuffer;
  90787. /**
  90788. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  90789. * @hidden
  90790. */
  90791. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  90792. /**
  90793. * Resets the different information of the group to prepare a new frame
  90794. * @hidden
  90795. */
  90796. reset(): void;
  90797. /**
  90798. * Dispose and release the group and its associated resources.
  90799. * @hidden
  90800. */
  90801. dispose(): void;
  90802. /**
  90803. * Clear the info related to rendering groups preventing retention points during dispose.
  90804. */
  90805. freeRenderingGroups(): void;
  90806. private _prepareRenderingGroup;
  90807. /**
  90808. * Add a sprite manager to the rendering manager in order to render it this frame.
  90809. * @param spriteManager Define the sprite manager to render
  90810. */
  90811. dispatchSprites(spriteManager: ISpriteManager): void;
  90812. /**
  90813. * Add a particle system to the rendering manager in order to render it this frame.
  90814. * @param particleSystem Define the particle system to render
  90815. */
  90816. dispatchParticles(particleSystem: IParticleSystem): void;
  90817. /**
  90818. * Add a submesh to the manager in order to render it this frame
  90819. * @param subMesh The submesh to dispatch
  90820. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90821. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90822. */
  90823. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90824. /**
  90825. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90826. * This allowed control for front to back rendering or reversly depending of the special needs.
  90827. *
  90828. * @param renderingGroupId The rendering group id corresponding to its index
  90829. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90830. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90831. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90832. */
  90833. 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;
  90834. /**
  90835. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90836. *
  90837. * @param renderingGroupId The rendering group id corresponding to its index
  90838. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90839. * @param depth Automatically clears depth between groups if true and autoClear is true.
  90840. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  90841. */
  90842. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  90843. /**
  90844. * Gets the current auto clear configuration for one rendering group of the rendering
  90845. * manager.
  90846. * @param index the rendering group index to get the information for
  90847. * @returns The auto clear setup for the requested rendering group
  90848. */
  90849. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  90850. }
  90851. }
  90852. declare module BABYLON {
  90853. /**
  90854. * This Helps creating a texture that will be created from a camera in your scene.
  90855. * It is basically a dynamic texture that could be used to create special effects for instance.
  90856. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  90857. */
  90858. export class RenderTargetTexture extends Texture {
  90859. isCube: boolean;
  90860. /**
  90861. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  90862. */
  90863. static readonly REFRESHRATE_RENDER_ONCE: number;
  90864. /**
  90865. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  90866. */
  90867. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  90868. /**
  90869. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  90870. * the central point of your effect and can save a lot of performances.
  90871. */
  90872. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  90873. /**
  90874. * Use this predicate to dynamically define the list of mesh you want to render.
  90875. * If set, the renderList property will be overwritten.
  90876. */
  90877. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  90878. private _renderList;
  90879. /**
  90880. * Use this list to define the list of mesh you want to render.
  90881. */
  90882. get renderList(): Nullable<Array<AbstractMesh>>;
  90883. set renderList(value: Nullable<Array<AbstractMesh>>);
  90884. private _hookArray;
  90885. /**
  90886. * Define if particles should be rendered in your texture.
  90887. */
  90888. renderParticles: boolean;
  90889. /**
  90890. * Define if sprites should be rendered in your texture.
  90891. */
  90892. renderSprites: boolean;
  90893. /**
  90894. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  90895. */
  90896. coordinatesMode: number;
  90897. /**
  90898. * Define the camera used to render the texture.
  90899. */
  90900. activeCamera: Nullable<Camera>;
  90901. /**
  90902. * Override the render function of the texture with your own one.
  90903. */
  90904. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  90905. /**
  90906. * Define if camera post processes should be use while rendering the texture.
  90907. */
  90908. useCameraPostProcesses: boolean;
  90909. /**
  90910. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  90911. */
  90912. ignoreCameraViewport: boolean;
  90913. private _postProcessManager;
  90914. private _postProcesses;
  90915. private _resizeObserver;
  90916. /**
  90917. * An event triggered when the texture is unbind.
  90918. */
  90919. onBeforeBindObservable: Observable<RenderTargetTexture>;
  90920. /**
  90921. * An event triggered when the texture is unbind.
  90922. */
  90923. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  90924. private _onAfterUnbindObserver;
  90925. /**
  90926. * Set a after unbind callback in the texture.
  90927. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  90928. */
  90929. set onAfterUnbind(callback: () => void);
  90930. /**
  90931. * An event triggered before rendering the texture
  90932. */
  90933. onBeforeRenderObservable: Observable<number>;
  90934. private _onBeforeRenderObserver;
  90935. /**
  90936. * Set a before render callback in the texture.
  90937. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  90938. */
  90939. set onBeforeRender(callback: (faceIndex: number) => void);
  90940. /**
  90941. * An event triggered after rendering the texture
  90942. */
  90943. onAfterRenderObservable: Observable<number>;
  90944. private _onAfterRenderObserver;
  90945. /**
  90946. * Set a after render callback in the texture.
  90947. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  90948. */
  90949. set onAfterRender(callback: (faceIndex: number) => void);
  90950. /**
  90951. * An event triggered after the texture clear
  90952. */
  90953. onClearObservable: Observable<Engine>;
  90954. private _onClearObserver;
  90955. /**
  90956. * Set a clear callback in the texture.
  90957. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  90958. */
  90959. set onClear(callback: (Engine: Engine) => void);
  90960. /**
  90961. * An event triggered when the texture is resized.
  90962. */
  90963. onResizeObservable: Observable<RenderTargetTexture>;
  90964. /**
  90965. * Define the clear color of the Render Target if it should be different from the scene.
  90966. */
  90967. clearColor: Color4;
  90968. protected _size: number | {
  90969. width: number;
  90970. height: number;
  90971. };
  90972. protected _initialSizeParameter: number | {
  90973. width: number;
  90974. height: number;
  90975. } | {
  90976. ratio: number;
  90977. };
  90978. protected _sizeRatio: Nullable<number>;
  90979. /** @hidden */
  90980. _generateMipMaps: boolean;
  90981. protected _renderingManager: RenderingManager;
  90982. /** @hidden */
  90983. _waitingRenderList: string[];
  90984. protected _doNotChangeAspectRatio: boolean;
  90985. protected _currentRefreshId: number;
  90986. protected _refreshRate: number;
  90987. protected _textureMatrix: Matrix;
  90988. protected _samples: number;
  90989. protected _renderTargetOptions: RenderTargetCreationOptions;
  90990. /**
  90991. * Gets render target creation options that were used.
  90992. */
  90993. get renderTargetOptions(): RenderTargetCreationOptions;
  90994. protected _engine: Engine;
  90995. protected _onRatioRescale(): void;
  90996. /**
  90997. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  90998. * It must define where the camera used to render the texture is set
  90999. */
  91000. boundingBoxPosition: Vector3;
  91001. private _boundingBoxSize;
  91002. /**
  91003. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  91004. * When defined, the cubemap will switch to local mode
  91005. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  91006. * @example https://www.babylonjs-playground.com/#RNASML
  91007. */
  91008. set boundingBoxSize(value: Vector3);
  91009. get boundingBoxSize(): Vector3;
  91010. /**
  91011. * In case the RTT has been created with a depth texture, get the associated
  91012. * depth texture.
  91013. * Otherwise, return null.
  91014. */
  91015. depthStencilTexture: Nullable<InternalTexture>;
  91016. /**
  91017. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  91018. * or used a shadow, depth texture...
  91019. * @param name The friendly name of the texture
  91020. * @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)
  91021. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  91022. * @param generateMipMaps True if mip maps need to be generated after render.
  91023. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  91024. * @param type The type of the buffer in the RTT (int, half float, float...)
  91025. * @param isCube True if a cube texture needs to be created
  91026. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  91027. * @param generateDepthBuffer True to generate a depth buffer
  91028. * @param generateStencilBuffer True to generate a stencil buffer
  91029. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  91030. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  91031. * @param delayAllocation if the texture allocation should be delayed (default: false)
  91032. */
  91033. constructor(name: string, size: number | {
  91034. width: number;
  91035. height: number;
  91036. } | {
  91037. ratio: number;
  91038. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  91039. /**
  91040. * Creates a depth stencil texture.
  91041. * This is only available in WebGL 2 or with the depth texture extension available.
  91042. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  91043. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  91044. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  91045. */
  91046. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  91047. private _processSizeParameter;
  91048. /**
  91049. * Define the number of samples to use in case of MSAA.
  91050. * It defaults to one meaning no MSAA has been enabled.
  91051. */
  91052. get samples(): number;
  91053. set samples(value: number);
  91054. /**
  91055. * Resets the refresh counter of the texture and start bak from scratch.
  91056. * Could be useful to regenerate the texture if it is setup to render only once.
  91057. */
  91058. resetRefreshCounter(): void;
  91059. /**
  91060. * Define the refresh rate of the texture or the rendering frequency.
  91061. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  91062. */
  91063. get refreshRate(): number;
  91064. set refreshRate(value: number);
  91065. /**
  91066. * Adds a post process to the render target rendering passes.
  91067. * @param postProcess define the post process to add
  91068. */
  91069. addPostProcess(postProcess: PostProcess): void;
  91070. /**
  91071. * Clear all the post processes attached to the render target
  91072. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  91073. */
  91074. clearPostProcesses(dispose?: boolean): void;
  91075. /**
  91076. * Remove one of the post process from the list of attached post processes to the texture
  91077. * @param postProcess define the post process to remove from the list
  91078. */
  91079. removePostProcess(postProcess: PostProcess): void;
  91080. /** @hidden */
  91081. _shouldRender(): boolean;
  91082. /**
  91083. * Gets the actual render size of the texture.
  91084. * @returns the width of the render size
  91085. */
  91086. getRenderSize(): number;
  91087. /**
  91088. * Gets the actual render width of the texture.
  91089. * @returns the width of the render size
  91090. */
  91091. getRenderWidth(): number;
  91092. /**
  91093. * Gets the actual render height of the texture.
  91094. * @returns the height of the render size
  91095. */
  91096. getRenderHeight(): number;
  91097. /**
  91098. * Get if the texture can be rescaled or not.
  91099. */
  91100. get canRescale(): boolean;
  91101. /**
  91102. * Resize the texture using a ratio.
  91103. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  91104. */
  91105. scale(ratio: number): void;
  91106. /**
  91107. * Get the texture reflection matrix used to rotate/transform the reflection.
  91108. * @returns the reflection matrix
  91109. */
  91110. getReflectionTextureMatrix(): Matrix;
  91111. /**
  91112. * Resize the texture to a new desired size.
  91113. * Be carrefull as it will recreate all the data in the new texture.
  91114. * @param size Define the new size. It can be:
  91115. * - a number for squared texture,
  91116. * - an object containing { width: number, height: number }
  91117. * - or an object containing a ratio { ratio: number }
  91118. */
  91119. resize(size: number | {
  91120. width: number;
  91121. height: number;
  91122. } | {
  91123. ratio: number;
  91124. }): void;
  91125. /**
  91126. * Renders all the objects from the render list into the texture.
  91127. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  91128. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  91129. */
  91130. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  91131. private _bestReflectionRenderTargetDimension;
  91132. /**
  91133. * @hidden
  91134. * @param faceIndex face index to bind to if this is a cubetexture
  91135. */
  91136. _bindFrameBuffer(faceIndex?: number): void;
  91137. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  91138. private renderToTarget;
  91139. /**
  91140. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  91141. * This allowed control for front to back rendering or reversly depending of the special needs.
  91142. *
  91143. * @param renderingGroupId The rendering group id corresponding to its index
  91144. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  91145. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  91146. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  91147. */
  91148. 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;
  91149. /**
  91150. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  91151. *
  91152. * @param renderingGroupId The rendering group id corresponding to its index
  91153. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  91154. */
  91155. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  91156. /**
  91157. * Clones the texture.
  91158. * @returns the cloned texture
  91159. */
  91160. clone(): RenderTargetTexture;
  91161. /**
  91162. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  91163. * @returns The JSON representation of the texture
  91164. */
  91165. serialize(): any;
  91166. /**
  91167. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  91168. */
  91169. disposeFramebufferObjects(): void;
  91170. /**
  91171. * Dispose the texture and release its associated resources.
  91172. */
  91173. dispose(): void;
  91174. /** @hidden */
  91175. _rebuild(): void;
  91176. /**
  91177. * Clear the info related to rendering groups preventing retention point in material dispose.
  91178. */
  91179. freeRenderingGroups(): void;
  91180. /**
  91181. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  91182. * @returns the view count
  91183. */
  91184. getViewCount(): number;
  91185. }
  91186. }
  91187. declare module BABYLON {
  91188. /**
  91189. * Options for compiling materials.
  91190. */
  91191. export interface IMaterialCompilationOptions {
  91192. /**
  91193. * Defines whether clip planes are enabled.
  91194. */
  91195. clipPlane: boolean;
  91196. /**
  91197. * Defines whether instances are enabled.
  91198. */
  91199. useInstances: boolean;
  91200. }
  91201. /**
  91202. * Base class for the main features of a material in Babylon.js
  91203. */
  91204. export class Material implements IAnimatable {
  91205. /**
  91206. * Returns the triangle fill mode
  91207. */
  91208. static readonly TriangleFillMode: number;
  91209. /**
  91210. * Returns the wireframe mode
  91211. */
  91212. static readonly WireFrameFillMode: number;
  91213. /**
  91214. * Returns the point fill mode
  91215. */
  91216. static readonly PointFillMode: number;
  91217. /**
  91218. * Returns the point list draw mode
  91219. */
  91220. static readonly PointListDrawMode: number;
  91221. /**
  91222. * Returns the line list draw mode
  91223. */
  91224. static readonly LineListDrawMode: number;
  91225. /**
  91226. * Returns the line loop draw mode
  91227. */
  91228. static readonly LineLoopDrawMode: number;
  91229. /**
  91230. * Returns the line strip draw mode
  91231. */
  91232. static readonly LineStripDrawMode: number;
  91233. /**
  91234. * Returns the triangle strip draw mode
  91235. */
  91236. static readonly TriangleStripDrawMode: number;
  91237. /**
  91238. * Returns the triangle fan draw mode
  91239. */
  91240. static readonly TriangleFanDrawMode: number;
  91241. /**
  91242. * Stores the clock-wise side orientation
  91243. */
  91244. static readonly ClockWiseSideOrientation: number;
  91245. /**
  91246. * Stores the counter clock-wise side orientation
  91247. */
  91248. static readonly CounterClockWiseSideOrientation: number;
  91249. /**
  91250. * The dirty texture flag value
  91251. */
  91252. static readonly TextureDirtyFlag: number;
  91253. /**
  91254. * The dirty light flag value
  91255. */
  91256. static readonly LightDirtyFlag: number;
  91257. /**
  91258. * The dirty fresnel flag value
  91259. */
  91260. static readonly FresnelDirtyFlag: number;
  91261. /**
  91262. * The dirty attribute flag value
  91263. */
  91264. static readonly AttributesDirtyFlag: number;
  91265. /**
  91266. * The dirty misc flag value
  91267. */
  91268. static readonly MiscDirtyFlag: number;
  91269. /**
  91270. * The all dirty flag value
  91271. */
  91272. static readonly AllDirtyFlag: number;
  91273. /**
  91274. * The ID of the material
  91275. */
  91276. id: string;
  91277. /**
  91278. * Gets or sets the unique id of the material
  91279. */
  91280. uniqueId: number;
  91281. /**
  91282. * The name of the material
  91283. */
  91284. name: string;
  91285. /**
  91286. * Gets or sets user defined metadata
  91287. */
  91288. metadata: any;
  91289. /**
  91290. * For internal use only. Please do not use.
  91291. */
  91292. reservedDataStore: any;
  91293. /**
  91294. * Specifies if the ready state should be checked on each call
  91295. */
  91296. checkReadyOnEveryCall: boolean;
  91297. /**
  91298. * Specifies if the ready state should be checked once
  91299. */
  91300. checkReadyOnlyOnce: boolean;
  91301. /**
  91302. * The state of the material
  91303. */
  91304. state: string;
  91305. /**
  91306. * The alpha value of the material
  91307. */
  91308. protected _alpha: number;
  91309. /**
  91310. * List of inspectable custom properties (used by the Inspector)
  91311. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  91312. */
  91313. inspectableCustomProperties: IInspectable[];
  91314. /**
  91315. * Sets the alpha value of the material
  91316. */
  91317. set alpha(value: number);
  91318. /**
  91319. * Gets the alpha value of the material
  91320. */
  91321. get alpha(): number;
  91322. /**
  91323. * Specifies if back face culling is enabled
  91324. */
  91325. protected _backFaceCulling: boolean;
  91326. /**
  91327. * Sets the back-face culling state
  91328. */
  91329. set backFaceCulling(value: boolean);
  91330. /**
  91331. * Gets the back-face culling state
  91332. */
  91333. get backFaceCulling(): boolean;
  91334. /**
  91335. * Stores the value for side orientation
  91336. */
  91337. sideOrientation: number;
  91338. /**
  91339. * Callback triggered when the material is compiled
  91340. */
  91341. onCompiled: Nullable<(effect: Effect) => void>;
  91342. /**
  91343. * Callback triggered when an error occurs
  91344. */
  91345. onError: Nullable<(effect: Effect, errors: string) => void>;
  91346. /**
  91347. * Callback triggered to get the render target textures
  91348. */
  91349. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  91350. /**
  91351. * Gets a boolean indicating that current material needs to register RTT
  91352. */
  91353. get hasRenderTargetTextures(): boolean;
  91354. /**
  91355. * Specifies if the material should be serialized
  91356. */
  91357. doNotSerialize: boolean;
  91358. /**
  91359. * @hidden
  91360. */
  91361. _storeEffectOnSubMeshes: boolean;
  91362. /**
  91363. * Stores the animations for the material
  91364. */
  91365. animations: Nullable<Array<Animation>>;
  91366. /**
  91367. * An event triggered when the material is disposed
  91368. */
  91369. onDisposeObservable: Observable<Material>;
  91370. /**
  91371. * An observer which watches for dispose events
  91372. */
  91373. private _onDisposeObserver;
  91374. private _onUnBindObservable;
  91375. /**
  91376. * Called during a dispose event
  91377. */
  91378. set onDispose(callback: () => void);
  91379. private _onBindObservable;
  91380. /**
  91381. * An event triggered when the material is bound
  91382. */
  91383. get onBindObservable(): Observable<AbstractMesh>;
  91384. /**
  91385. * An observer which watches for bind events
  91386. */
  91387. private _onBindObserver;
  91388. /**
  91389. * Called during a bind event
  91390. */
  91391. set onBind(callback: (Mesh: AbstractMesh) => void);
  91392. /**
  91393. * An event triggered when the material is unbound
  91394. */
  91395. get onUnBindObservable(): Observable<Material>;
  91396. /**
  91397. * Stores the value of the alpha mode
  91398. */
  91399. private _alphaMode;
  91400. /**
  91401. * Sets the value of the alpha mode.
  91402. *
  91403. * | Value | Type | Description |
  91404. * | --- | --- | --- |
  91405. * | 0 | ALPHA_DISABLE | |
  91406. * | 1 | ALPHA_ADD | |
  91407. * | 2 | ALPHA_COMBINE | |
  91408. * | 3 | ALPHA_SUBTRACT | |
  91409. * | 4 | ALPHA_MULTIPLY | |
  91410. * | 5 | ALPHA_MAXIMIZED | |
  91411. * | 6 | ALPHA_ONEONE | |
  91412. * | 7 | ALPHA_PREMULTIPLIED | |
  91413. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  91414. * | 9 | ALPHA_INTERPOLATE | |
  91415. * | 10 | ALPHA_SCREENMODE | |
  91416. *
  91417. */
  91418. set alphaMode(value: number);
  91419. /**
  91420. * Gets the value of the alpha mode
  91421. */
  91422. get alphaMode(): number;
  91423. /**
  91424. * Stores the state of the need depth pre-pass value
  91425. */
  91426. private _needDepthPrePass;
  91427. /**
  91428. * Sets the need depth pre-pass value
  91429. */
  91430. set needDepthPrePass(value: boolean);
  91431. /**
  91432. * Gets the depth pre-pass value
  91433. */
  91434. get needDepthPrePass(): boolean;
  91435. /**
  91436. * Specifies if depth writing should be disabled
  91437. */
  91438. disableDepthWrite: boolean;
  91439. /**
  91440. * Specifies if depth writing should be forced
  91441. */
  91442. forceDepthWrite: boolean;
  91443. /**
  91444. * Specifies the depth function that should be used. 0 means the default engine function
  91445. */
  91446. depthFunction: number;
  91447. /**
  91448. * Specifies if there should be a separate pass for culling
  91449. */
  91450. separateCullingPass: boolean;
  91451. /**
  91452. * Stores the state specifing if fog should be enabled
  91453. */
  91454. private _fogEnabled;
  91455. /**
  91456. * Sets the state for enabling fog
  91457. */
  91458. set fogEnabled(value: boolean);
  91459. /**
  91460. * Gets the value of the fog enabled state
  91461. */
  91462. get fogEnabled(): boolean;
  91463. /**
  91464. * Stores the size of points
  91465. */
  91466. pointSize: number;
  91467. /**
  91468. * Stores the z offset value
  91469. */
  91470. zOffset: number;
  91471. /**
  91472. * Gets a value specifying if wireframe mode is enabled
  91473. */
  91474. get wireframe(): boolean;
  91475. /**
  91476. * Sets the state of wireframe mode
  91477. */
  91478. set wireframe(value: boolean);
  91479. /**
  91480. * Gets the value specifying if point clouds are enabled
  91481. */
  91482. get pointsCloud(): boolean;
  91483. /**
  91484. * Sets the state of point cloud mode
  91485. */
  91486. set pointsCloud(value: boolean);
  91487. /**
  91488. * Gets the material fill mode
  91489. */
  91490. get fillMode(): number;
  91491. /**
  91492. * Sets the material fill mode
  91493. */
  91494. set fillMode(value: number);
  91495. /**
  91496. * @hidden
  91497. * Stores the effects for the material
  91498. */
  91499. _effect: Nullable<Effect>;
  91500. /**
  91501. * @hidden
  91502. * Specifies if the material was previously ready
  91503. */
  91504. _wasPreviouslyReady: boolean;
  91505. /**
  91506. * Specifies if uniform buffers should be used
  91507. */
  91508. private _useUBO;
  91509. /**
  91510. * Stores a reference to the scene
  91511. */
  91512. private _scene;
  91513. /**
  91514. * Stores the fill mode state
  91515. */
  91516. private _fillMode;
  91517. /**
  91518. * Specifies if the depth write state should be cached
  91519. */
  91520. private _cachedDepthWriteState;
  91521. /**
  91522. * Specifies if the depth function state should be cached
  91523. */
  91524. private _cachedDepthFunctionState;
  91525. /**
  91526. * Stores the uniform buffer
  91527. */
  91528. protected _uniformBuffer: UniformBuffer;
  91529. /** @hidden */
  91530. _indexInSceneMaterialArray: number;
  91531. /** @hidden */
  91532. meshMap: Nullable<{
  91533. [id: string]: AbstractMesh | undefined;
  91534. }>;
  91535. /**
  91536. * Creates a material instance
  91537. * @param name defines the name of the material
  91538. * @param scene defines the scene to reference
  91539. * @param doNotAdd specifies if the material should be added to the scene
  91540. */
  91541. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  91542. /**
  91543. * Returns a string representation of the current material
  91544. * @param fullDetails defines a boolean indicating which levels of logging is desired
  91545. * @returns a string with material information
  91546. */
  91547. toString(fullDetails?: boolean): string;
  91548. /**
  91549. * Gets the class name of the material
  91550. * @returns a string with the class name of the material
  91551. */
  91552. getClassName(): string;
  91553. /**
  91554. * Specifies if updates for the material been locked
  91555. */
  91556. get isFrozen(): boolean;
  91557. /**
  91558. * Locks updates for the material
  91559. */
  91560. freeze(): void;
  91561. /**
  91562. * Unlocks updates for the material
  91563. */
  91564. unfreeze(): void;
  91565. /**
  91566. * Specifies if the material is ready to be used
  91567. * @param mesh defines the mesh to check
  91568. * @param useInstances specifies if instances should be used
  91569. * @returns a boolean indicating if the material is ready to be used
  91570. */
  91571. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  91572. /**
  91573. * Specifies that the submesh is ready to be used
  91574. * @param mesh defines the mesh to check
  91575. * @param subMesh defines which submesh to check
  91576. * @param useInstances specifies that instances should be used
  91577. * @returns a boolean indicating that the submesh is ready or not
  91578. */
  91579. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  91580. /**
  91581. * Returns the material effect
  91582. * @returns the effect associated with the material
  91583. */
  91584. getEffect(): Nullable<Effect>;
  91585. /**
  91586. * Returns the current scene
  91587. * @returns a Scene
  91588. */
  91589. getScene(): Scene;
  91590. /**
  91591. * Specifies if the material will require alpha blending
  91592. * @returns a boolean specifying if alpha blending is needed
  91593. */
  91594. needAlphaBlending(): boolean;
  91595. /**
  91596. * Specifies if the mesh will require alpha blending
  91597. * @param mesh defines the mesh to check
  91598. * @returns a boolean specifying if alpha blending is needed for the mesh
  91599. */
  91600. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  91601. /**
  91602. * Specifies if this material should be rendered in alpha test mode
  91603. * @returns a boolean specifying if an alpha test is needed.
  91604. */
  91605. needAlphaTesting(): boolean;
  91606. /**
  91607. * Gets the texture used for the alpha test
  91608. * @returns the texture to use for alpha testing
  91609. */
  91610. getAlphaTestTexture(): Nullable<BaseTexture>;
  91611. /**
  91612. * Marks the material to indicate that it needs to be re-calculated
  91613. */
  91614. markDirty(): void;
  91615. /** @hidden */
  91616. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  91617. /**
  91618. * Binds the material to the mesh
  91619. * @param world defines the world transformation matrix
  91620. * @param mesh defines the mesh to bind the material to
  91621. */
  91622. bind(world: Matrix, mesh?: Mesh): void;
  91623. /**
  91624. * Binds the submesh to the material
  91625. * @param world defines the world transformation matrix
  91626. * @param mesh defines the mesh containing the submesh
  91627. * @param subMesh defines the submesh to bind the material to
  91628. */
  91629. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  91630. /**
  91631. * Binds the world matrix to the material
  91632. * @param world defines the world transformation matrix
  91633. */
  91634. bindOnlyWorldMatrix(world: Matrix): void;
  91635. /**
  91636. * Binds the scene's uniform buffer to the effect.
  91637. * @param effect defines the effect to bind to the scene uniform buffer
  91638. * @param sceneUbo defines the uniform buffer storing scene data
  91639. */
  91640. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  91641. /**
  91642. * Binds the view matrix to the effect
  91643. * @param effect defines the effect to bind the view matrix to
  91644. */
  91645. bindView(effect: Effect): void;
  91646. /**
  91647. * Binds the view projection matrix to the effect
  91648. * @param effect defines the effect to bind the view projection matrix to
  91649. */
  91650. bindViewProjection(effect: Effect): void;
  91651. /**
  91652. * Specifies if material alpha testing should be turned on for the mesh
  91653. * @param mesh defines the mesh to check
  91654. */
  91655. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  91656. /**
  91657. * Processes to execute after binding the material to a mesh
  91658. * @param mesh defines the rendered mesh
  91659. */
  91660. protected _afterBind(mesh?: Mesh): void;
  91661. /**
  91662. * Unbinds the material from the mesh
  91663. */
  91664. unbind(): void;
  91665. /**
  91666. * Gets the active textures from the material
  91667. * @returns an array of textures
  91668. */
  91669. getActiveTextures(): BaseTexture[];
  91670. /**
  91671. * Specifies if the material uses a texture
  91672. * @param texture defines the texture to check against the material
  91673. * @returns a boolean specifying if the material uses the texture
  91674. */
  91675. hasTexture(texture: BaseTexture): boolean;
  91676. /**
  91677. * Makes a duplicate of the material, and gives it a new name
  91678. * @param name defines the new name for the duplicated material
  91679. * @returns the cloned material
  91680. */
  91681. clone(name: string): Nullable<Material>;
  91682. /**
  91683. * Gets the meshes bound to the material
  91684. * @returns an array of meshes bound to the material
  91685. */
  91686. getBindedMeshes(): AbstractMesh[];
  91687. /**
  91688. * Force shader compilation
  91689. * @param mesh defines the mesh associated with this material
  91690. * @param onCompiled defines a function to execute once the material is compiled
  91691. * @param options defines the options to configure the compilation
  91692. * @param onError defines a function to execute if the material fails compiling
  91693. */
  91694. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  91695. /**
  91696. * Force shader compilation
  91697. * @param mesh defines the mesh that will use this material
  91698. * @param options defines additional options for compiling the shaders
  91699. * @returns a promise that resolves when the compilation completes
  91700. */
  91701. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  91702. private static readonly _AllDirtyCallBack;
  91703. private static readonly _ImageProcessingDirtyCallBack;
  91704. private static readonly _TextureDirtyCallBack;
  91705. private static readonly _FresnelDirtyCallBack;
  91706. private static readonly _MiscDirtyCallBack;
  91707. private static readonly _LightsDirtyCallBack;
  91708. private static readonly _AttributeDirtyCallBack;
  91709. private static _FresnelAndMiscDirtyCallBack;
  91710. private static _TextureAndMiscDirtyCallBack;
  91711. private static readonly _DirtyCallbackArray;
  91712. private static readonly _RunDirtyCallBacks;
  91713. /**
  91714. * Marks a define in the material to indicate that it needs to be re-computed
  91715. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  91716. */
  91717. markAsDirty(flag: number): void;
  91718. /**
  91719. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  91720. * @param func defines a function which checks material defines against the submeshes
  91721. */
  91722. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  91723. /**
  91724. * Indicates that we need to re-calculated for all submeshes
  91725. */
  91726. protected _markAllSubMeshesAsAllDirty(): void;
  91727. /**
  91728. * Indicates that image processing needs to be re-calculated for all submeshes
  91729. */
  91730. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  91731. /**
  91732. * Indicates that textures need to be re-calculated for all submeshes
  91733. */
  91734. protected _markAllSubMeshesAsTexturesDirty(): void;
  91735. /**
  91736. * Indicates that fresnel needs to be re-calculated for all submeshes
  91737. */
  91738. protected _markAllSubMeshesAsFresnelDirty(): void;
  91739. /**
  91740. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  91741. */
  91742. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  91743. /**
  91744. * Indicates that lights need to be re-calculated for all submeshes
  91745. */
  91746. protected _markAllSubMeshesAsLightsDirty(): void;
  91747. /**
  91748. * Indicates that attributes need to be re-calculated for all submeshes
  91749. */
  91750. protected _markAllSubMeshesAsAttributesDirty(): void;
  91751. /**
  91752. * Indicates that misc needs to be re-calculated for all submeshes
  91753. */
  91754. protected _markAllSubMeshesAsMiscDirty(): void;
  91755. /**
  91756. * Indicates that textures and misc need to be re-calculated for all submeshes
  91757. */
  91758. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  91759. /**
  91760. * Disposes the material
  91761. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  91762. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  91763. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  91764. */
  91765. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  91766. /** @hidden */
  91767. private releaseVertexArrayObject;
  91768. /**
  91769. * Serializes this material
  91770. * @returns the serialized material object
  91771. */
  91772. serialize(): any;
  91773. /**
  91774. * Creates a material from parsed material data
  91775. * @param parsedMaterial defines parsed material data
  91776. * @param scene defines the hosting scene
  91777. * @param rootUrl defines the root URL to use to load textures
  91778. * @returns a new material
  91779. */
  91780. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  91781. }
  91782. }
  91783. declare module BABYLON {
  91784. /**
  91785. * A multi-material is used to apply different materials to different parts of the same object without the need of
  91786. * separate meshes. This can be use to improve performances.
  91787. * @see http://doc.babylonjs.com/how_to/multi_materials
  91788. */
  91789. export class MultiMaterial extends Material {
  91790. private _subMaterials;
  91791. /**
  91792. * Gets or Sets the list of Materials used within the multi material.
  91793. * They need to be ordered according to the submeshes order in the associated mesh
  91794. */
  91795. get subMaterials(): Nullable<Material>[];
  91796. set subMaterials(value: Nullable<Material>[]);
  91797. /**
  91798. * Function used to align with Node.getChildren()
  91799. * @returns the list of Materials used within the multi material
  91800. */
  91801. getChildren(): Nullable<Material>[];
  91802. /**
  91803. * Instantiates a new Multi Material
  91804. * A multi-material is used to apply different materials to different parts of the same object without the need of
  91805. * separate meshes. This can be use to improve performances.
  91806. * @see http://doc.babylonjs.com/how_to/multi_materials
  91807. * @param name Define the name in the scene
  91808. * @param scene Define the scene the material belongs to
  91809. */
  91810. constructor(name: string, scene: Scene);
  91811. private _hookArray;
  91812. /**
  91813. * Get one of the submaterial by its index in the submaterials array
  91814. * @param index The index to look the sub material at
  91815. * @returns The Material if the index has been defined
  91816. */
  91817. getSubMaterial(index: number): Nullable<Material>;
  91818. /**
  91819. * Get the list of active textures for the whole sub materials list.
  91820. * @returns All the textures that will be used during the rendering
  91821. */
  91822. getActiveTextures(): BaseTexture[];
  91823. /**
  91824. * Gets the current class name of the material e.g. "MultiMaterial"
  91825. * Mainly use in serialization.
  91826. * @returns the class name
  91827. */
  91828. getClassName(): string;
  91829. /**
  91830. * Checks if the material is ready to render the requested sub mesh
  91831. * @param mesh Define the mesh the submesh belongs to
  91832. * @param subMesh Define the sub mesh to look readyness for
  91833. * @param useInstances Define whether or not the material is used with instances
  91834. * @returns true if ready, otherwise false
  91835. */
  91836. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  91837. /**
  91838. * Clones the current material and its related sub materials
  91839. * @param name Define the name of the newly cloned material
  91840. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  91841. * @returns the cloned material
  91842. */
  91843. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  91844. /**
  91845. * Serializes the materials into a JSON representation.
  91846. * @returns the JSON representation
  91847. */
  91848. serialize(): any;
  91849. /**
  91850. * Dispose the material and release its associated resources
  91851. * @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)
  91852. * @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)
  91853. * @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)
  91854. */
  91855. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  91856. /**
  91857. * Creates a MultiMaterial from parsed MultiMaterial data.
  91858. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  91859. * @param scene defines the hosting scene
  91860. * @returns a new MultiMaterial
  91861. */
  91862. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  91863. }
  91864. }
  91865. declare module BABYLON {
  91866. /**
  91867. * Base class for submeshes
  91868. */
  91869. export class BaseSubMesh {
  91870. /** @hidden */
  91871. _materialDefines: Nullable<MaterialDefines>;
  91872. /** @hidden */
  91873. _materialEffect: Nullable<Effect>;
  91874. /**
  91875. * Gets material defines used by the effect associated to the sub mesh
  91876. */
  91877. get materialDefines(): Nullable<MaterialDefines>;
  91878. /**
  91879. * Sets material defines used by the effect associated to the sub mesh
  91880. */
  91881. set materialDefines(defines: Nullable<MaterialDefines>);
  91882. /**
  91883. * Gets associated effect
  91884. */
  91885. get effect(): Nullable<Effect>;
  91886. /**
  91887. * Sets associated effect (effect used to render this submesh)
  91888. * @param effect defines the effect to associate with
  91889. * @param defines defines the set of defines used to compile this effect
  91890. */
  91891. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  91892. }
  91893. /**
  91894. * Defines a subdivision inside a mesh
  91895. */
  91896. export class SubMesh extends BaseSubMesh implements ICullable {
  91897. /** the material index to use */
  91898. materialIndex: number;
  91899. /** vertex index start */
  91900. verticesStart: number;
  91901. /** vertices count */
  91902. verticesCount: number;
  91903. /** index start */
  91904. indexStart: number;
  91905. /** indices count */
  91906. indexCount: number;
  91907. /** @hidden */
  91908. _linesIndexCount: number;
  91909. private _mesh;
  91910. private _renderingMesh;
  91911. private _boundingInfo;
  91912. private _linesIndexBuffer;
  91913. /** @hidden */
  91914. _lastColliderWorldVertices: Nullable<Vector3[]>;
  91915. /** @hidden */
  91916. _trianglePlanes: Plane[];
  91917. /** @hidden */
  91918. _lastColliderTransformMatrix: Nullable<Matrix>;
  91919. /** @hidden */
  91920. _renderId: number;
  91921. /** @hidden */
  91922. _alphaIndex: number;
  91923. /** @hidden */
  91924. _distanceToCamera: number;
  91925. /** @hidden */
  91926. _id: number;
  91927. private _currentMaterial;
  91928. /**
  91929. * Add a new submesh to a mesh
  91930. * @param materialIndex defines the material index to use
  91931. * @param verticesStart defines vertex index start
  91932. * @param verticesCount defines vertices count
  91933. * @param indexStart defines index start
  91934. * @param indexCount defines indices count
  91935. * @param mesh defines the parent mesh
  91936. * @param renderingMesh defines an optional rendering mesh
  91937. * @param createBoundingBox defines if bounding box should be created for this submesh
  91938. * @returns the new submesh
  91939. */
  91940. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  91941. /**
  91942. * Creates a new submesh
  91943. * @param materialIndex defines the material index to use
  91944. * @param verticesStart defines vertex index start
  91945. * @param verticesCount defines vertices count
  91946. * @param indexStart defines index start
  91947. * @param indexCount defines indices count
  91948. * @param mesh defines the parent mesh
  91949. * @param renderingMesh defines an optional rendering mesh
  91950. * @param createBoundingBox defines if bounding box should be created for this submesh
  91951. */
  91952. constructor(
  91953. /** the material index to use */
  91954. materialIndex: number,
  91955. /** vertex index start */
  91956. verticesStart: number,
  91957. /** vertices count */
  91958. verticesCount: number,
  91959. /** index start */
  91960. indexStart: number,
  91961. /** indices count */
  91962. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  91963. /**
  91964. * Returns true if this submesh covers the entire parent mesh
  91965. * @ignorenaming
  91966. */
  91967. get IsGlobal(): boolean;
  91968. /**
  91969. * Returns the submesh BoudingInfo object
  91970. * @returns current bounding info (or mesh's one if the submesh is global)
  91971. */
  91972. getBoundingInfo(): BoundingInfo;
  91973. /**
  91974. * Sets the submesh BoundingInfo
  91975. * @param boundingInfo defines the new bounding info to use
  91976. * @returns the SubMesh
  91977. */
  91978. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  91979. /**
  91980. * Returns the mesh of the current submesh
  91981. * @return the parent mesh
  91982. */
  91983. getMesh(): AbstractMesh;
  91984. /**
  91985. * Returns the rendering mesh of the submesh
  91986. * @returns the rendering mesh (could be different from parent mesh)
  91987. */
  91988. getRenderingMesh(): Mesh;
  91989. /**
  91990. * Returns the submesh material
  91991. * @returns null or the current material
  91992. */
  91993. getMaterial(): Nullable<Material>;
  91994. /**
  91995. * Sets a new updated BoundingInfo object to the submesh
  91996. * @param data defines an optional position array to use to determine the bounding info
  91997. * @returns the SubMesh
  91998. */
  91999. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  92000. /** @hidden */
  92001. _checkCollision(collider: Collider): boolean;
  92002. /**
  92003. * Updates the submesh BoundingInfo
  92004. * @param world defines the world matrix to use to update the bounding info
  92005. * @returns the submesh
  92006. */
  92007. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  92008. /**
  92009. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  92010. * @param frustumPlanes defines the frustum planes
  92011. * @returns true if the submesh is intersecting with the frustum
  92012. */
  92013. isInFrustum(frustumPlanes: Plane[]): boolean;
  92014. /**
  92015. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  92016. * @param frustumPlanes defines the frustum planes
  92017. * @returns true if the submesh is inside the frustum
  92018. */
  92019. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  92020. /**
  92021. * Renders the submesh
  92022. * @param enableAlphaMode defines if alpha needs to be used
  92023. * @returns the submesh
  92024. */
  92025. render(enableAlphaMode: boolean): SubMesh;
  92026. /**
  92027. * @hidden
  92028. */
  92029. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  92030. /**
  92031. * Checks if the submesh intersects with a ray
  92032. * @param ray defines the ray to test
  92033. * @returns true is the passed ray intersects the submesh bounding box
  92034. */
  92035. canIntersects(ray: Ray): boolean;
  92036. /**
  92037. * Intersects current submesh with a ray
  92038. * @param ray defines the ray to test
  92039. * @param positions defines mesh's positions array
  92040. * @param indices defines mesh's indices array
  92041. * @param fastCheck defines if only bounding info should be used
  92042. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92043. * @returns intersection info or null if no intersection
  92044. */
  92045. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  92046. /** @hidden */
  92047. private _intersectLines;
  92048. /** @hidden */
  92049. private _intersectUnIndexedLines;
  92050. /** @hidden */
  92051. private _intersectTriangles;
  92052. /** @hidden */
  92053. private _intersectUnIndexedTriangles;
  92054. /** @hidden */
  92055. _rebuild(): void;
  92056. /**
  92057. * Creates a new submesh from the passed mesh
  92058. * @param newMesh defines the new hosting mesh
  92059. * @param newRenderingMesh defines an optional rendering mesh
  92060. * @returns the new submesh
  92061. */
  92062. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  92063. /**
  92064. * Release associated resources
  92065. */
  92066. dispose(): void;
  92067. /**
  92068. * Gets the class name
  92069. * @returns the string "SubMesh".
  92070. */
  92071. getClassName(): string;
  92072. /**
  92073. * Creates a new submesh from indices data
  92074. * @param materialIndex the index of the main mesh material
  92075. * @param startIndex the index where to start the copy in the mesh indices array
  92076. * @param indexCount the number of indices to copy then from the startIndex
  92077. * @param mesh the main mesh to create the submesh from
  92078. * @param renderingMesh the optional rendering mesh
  92079. * @returns a new submesh
  92080. */
  92081. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  92082. }
  92083. }
  92084. declare module BABYLON {
  92085. /**
  92086. * Class used to represent data loading progression
  92087. */
  92088. export class SceneLoaderFlags {
  92089. private static _ForceFullSceneLoadingForIncremental;
  92090. private static _ShowLoadingScreen;
  92091. private static _CleanBoneMatrixWeights;
  92092. private static _loggingLevel;
  92093. /**
  92094. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  92095. */
  92096. static get ForceFullSceneLoadingForIncremental(): boolean;
  92097. static set ForceFullSceneLoadingForIncremental(value: boolean);
  92098. /**
  92099. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  92100. */
  92101. static get ShowLoadingScreen(): boolean;
  92102. static set ShowLoadingScreen(value: boolean);
  92103. /**
  92104. * Defines the current logging level (while loading the scene)
  92105. * @ignorenaming
  92106. */
  92107. static get loggingLevel(): number;
  92108. static set loggingLevel(value: number);
  92109. /**
  92110. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  92111. */
  92112. static get CleanBoneMatrixWeights(): boolean;
  92113. static set CleanBoneMatrixWeights(value: boolean);
  92114. }
  92115. }
  92116. declare module BABYLON {
  92117. /**
  92118. * Class used to store geometry data (vertex buffers + index buffer)
  92119. */
  92120. export class Geometry implements IGetSetVerticesData {
  92121. /**
  92122. * Gets or sets the ID of the geometry
  92123. */
  92124. id: string;
  92125. /**
  92126. * Gets or sets the unique ID of the geometry
  92127. */
  92128. uniqueId: number;
  92129. /**
  92130. * Gets the delay loading state of the geometry (none by default which means not delayed)
  92131. */
  92132. delayLoadState: number;
  92133. /**
  92134. * Gets the file containing the data to load when running in delay load state
  92135. */
  92136. delayLoadingFile: Nullable<string>;
  92137. /**
  92138. * Callback called when the geometry is updated
  92139. */
  92140. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  92141. private _scene;
  92142. private _engine;
  92143. private _meshes;
  92144. private _totalVertices;
  92145. /** @hidden */
  92146. _indices: IndicesArray;
  92147. /** @hidden */
  92148. _vertexBuffers: {
  92149. [key: string]: VertexBuffer;
  92150. };
  92151. private _isDisposed;
  92152. private _extend;
  92153. private _boundingBias;
  92154. /** @hidden */
  92155. _delayInfo: Array<string>;
  92156. private _indexBuffer;
  92157. private _indexBufferIsUpdatable;
  92158. /** @hidden */
  92159. _boundingInfo: Nullable<BoundingInfo>;
  92160. /** @hidden */
  92161. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  92162. /** @hidden */
  92163. _softwareSkinningFrameId: number;
  92164. private _vertexArrayObjects;
  92165. private _updatable;
  92166. /** @hidden */
  92167. _positions: Nullable<Vector3[]>;
  92168. /**
  92169. * 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
  92170. */
  92171. get boundingBias(): Vector2;
  92172. /**
  92173. * 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
  92174. */
  92175. set boundingBias(value: Vector2);
  92176. /**
  92177. * Static function used to attach a new empty geometry to a mesh
  92178. * @param mesh defines the mesh to attach the geometry to
  92179. * @returns the new Geometry
  92180. */
  92181. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  92182. /**
  92183. * Creates a new geometry
  92184. * @param id defines the unique ID
  92185. * @param scene defines the hosting scene
  92186. * @param vertexData defines the VertexData used to get geometry data
  92187. * @param updatable defines if geometry must be updatable (false by default)
  92188. * @param mesh defines the mesh that will be associated with the geometry
  92189. */
  92190. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  92191. /**
  92192. * Gets the current extend of the geometry
  92193. */
  92194. get extend(): {
  92195. minimum: Vector3;
  92196. maximum: Vector3;
  92197. };
  92198. /**
  92199. * Gets the hosting scene
  92200. * @returns the hosting Scene
  92201. */
  92202. getScene(): Scene;
  92203. /**
  92204. * Gets the hosting engine
  92205. * @returns the hosting Engine
  92206. */
  92207. getEngine(): Engine;
  92208. /**
  92209. * Defines if the geometry is ready to use
  92210. * @returns true if the geometry is ready to be used
  92211. */
  92212. isReady(): boolean;
  92213. /**
  92214. * Gets a value indicating that the geometry should not be serialized
  92215. */
  92216. get doNotSerialize(): boolean;
  92217. /** @hidden */
  92218. _rebuild(): void;
  92219. /**
  92220. * Affects all geometry data in one call
  92221. * @param vertexData defines the geometry data
  92222. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  92223. */
  92224. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  92225. /**
  92226. * Set specific vertex data
  92227. * @param kind defines the data kind (Position, normal, etc...)
  92228. * @param data defines the vertex data to use
  92229. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  92230. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  92231. */
  92232. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  92233. /**
  92234. * Removes a specific vertex data
  92235. * @param kind defines the data kind (Position, normal, etc...)
  92236. */
  92237. removeVerticesData(kind: string): void;
  92238. /**
  92239. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  92240. * @param buffer defines the vertex buffer to use
  92241. * @param totalVertices defines the total number of vertices for position kind (could be null)
  92242. */
  92243. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  92244. /**
  92245. * Update a specific vertex buffer
  92246. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  92247. * It will do nothing if the buffer is not updatable
  92248. * @param kind defines the data kind (Position, normal, etc...)
  92249. * @param data defines the data to use
  92250. * @param offset defines the offset in the target buffer where to store the data
  92251. * @param useBytes set to true if the offset is in bytes
  92252. */
  92253. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  92254. /**
  92255. * Update a specific vertex buffer
  92256. * This function will create a new buffer if the current one is not updatable
  92257. * @param kind defines the data kind (Position, normal, etc...)
  92258. * @param data defines the data to use
  92259. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  92260. */
  92261. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  92262. private _updateBoundingInfo;
  92263. /** @hidden */
  92264. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  92265. /**
  92266. * Gets total number of vertices
  92267. * @returns the total number of vertices
  92268. */
  92269. getTotalVertices(): number;
  92270. /**
  92271. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  92272. * @param kind defines the data kind (Position, normal, etc...)
  92273. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  92274. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92275. * @returns a float array containing vertex data
  92276. */
  92277. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  92278. /**
  92279. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  92280. * @param kind defines the data kind (Position, normal, etc...)
  92281. * @returns true if the vertex buffer with the specified kind is updatable
  92282. */
  92283. isVertexBufferUpdatable(kind: string): boolean;
  92284. /**
  92285. * Gets a specific vertex buffer
  92286. * @param kind defines the data kind (Position, normal, etc...)
  92287. * @returns a VertexBuffer
  92288. */
  92289. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  92290. /**
  92291. * Returns all vertex buffers
  92292. * @return an object holding all vertex buffers indexed by kind
  92293. */
  92294. getVertexBuffers(): Nullable<{
  92295. [key: string]: VertexBuffer;
  92296. }>;
  92297. /**
  92298. * Gets a boolean indicating if specific vertex buffer is present
  92299. * @param kind defines the data kind (Position, normal, etc...)
  92300. * @returns true if data is present
  92301. */
  92302. isVerticesDataPresent(kind: string): boolean;
  92303. /**
  92304. * Gets a list of all attached data kinds (Position, normal, etc...)
  92305. * @returns a list of string containing all kinds
  92306. */
  92307. getVerticesDataKinds(): string[];
  92308. /**
  92309. * Update index buffer
  92310. * @param indices defines the indices to store in the index buffer
  92311. * @param offset defines the offset in the target buffer where to store the data
  92312. * @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)
  92313. */
  92314. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  92315. /**
  92316. * Creates a new index buffer
  92317. * @param indices defines the indices to store in the index buffer
  92318. * @param totalVertices defines the total number of vertices (could be null)
  92319. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  92320. */
  92321. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  92322. /**
  92323. * Return the total number of indices
  92324. * @returns the total number of indices
  92325. */
  92326. getTotalIndices(): number;
  92327. /**
  92328. * Gets the index buffer array
  92329. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  92330. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92331. * @returns the index buffer array
  92332. */
  92333. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  92334. /**
  92335. * Gets the index buffer
  92336. * @return the index buffer
  92337. */
  92338. getIndexBuffer(): Nullable<DataBuffer>;
  92339. /** @hidden */
  92340. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  92341. /**
  92342. * Release the associated resources for a specific mesh
  92343. * @param mesh defines the source mesh
  92344. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  92345. */
  92346. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  92347. /**
  92348. * Apply current geometry to a given mesh
  92349. * @param mesh defines the mesh to apply geometry to
  92350. */
  92351. applyToMesh(mesh: Mesh): void;
  92352. private _updateExtend;
  92353. private _applyToMesh;
  92354. private notifyUpdate;
  92355. /**
  92356. * Load the geometry if it was flagged as delay loaded
  92357. * @param scene defines the hosting scene
  92358. * @param onLoaded defines a callback called when the geometry is loaded
  92359. */
  92360. load(scene: Scene, onLoaded?: () => void): void;
  92361. private _queueLoad;
  92362. /**
  92363. * Invert the geometry to move from a right handed system to a left handed one.
  92364. */
  92365. toLeftHanded(): void;
  92366. /** @hidden */
  92367. _resetPointsArrayCache(): void;
  92368. /** @hidden */
  92369. _generatePointsArray(): boolean;
  92370. /**
  92371. * Gets a value indicating if the geometry is disposed
  92372. * @returns true if the geometry was disposed
  92373. */
  92374. isDisposed(): boolean;
  92375. private _disposeVertexArrayObjects;
  92376. /**
  92377. * Free all associated resources
  92378. */
  92379. dispose(): void;
  92380. /**
  92381. * Clone the current geometry into a new geometry
  92382. * @param id defines the unique ID of the new geometry
  92383. * @returns a new geometry object
  92384. */
  92385. copy(id: string): Geometry;
  92386. /**
  92387. * Serialize the current geometry info (and not the vertices data) into a JSON object
  92388. * @return a JSON representation of the current geometry data (without the vertices data)
  92389. */
  92390. serialize(): any;
  92391. private toNumberArray;
  92392. /**
  92393. * Serialize all vertices data into a JSON oject
  92394. * @returns a JSON representation of the current geometry data
  92395. */
  92396. serializeVerticeData(): any;
  92397. /**
  92398. * Extracts a clone of a mesh geometry
  92399. * @param mesh defines the source mesh
  92400. * @param id defines the unique ID of the new geometry object
  92401. * @returns the new geometry object
  92402. */
  92403. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  92404. /**
  92405. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  92406. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  92407. * Be aware Math.random() could cause collisions, but:
  92408. * "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"
  92409. * @returns a string containing a new GUID
  92410. */
  92411. static RandomId(): string;
  92412. /** @hidden */
  92413. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  92414. private static _CleanMatricesWeights;
  92415. /**
  92416. * Create a new geometry from persisted data (Using .babylon file format)
  92417. * @param parsedVertexData defines the persisted data
  92418. * @param scene defines the hosting scene
  92419. * @param rootUrl defines the root url to use to load assets (like delayed data)
  92420. * @returns the new geometry object
  92421. */
  92422. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  92423. }
  92424. }
  92425. declare module BABYLON {
  92426. /**
  92427. * Define an interface for all classes that will get and set the data on vertices
  92428. */
  92429. export interface IGetSetVerticesData {
  92430. /**
  92431. * Gets a boolean indicating if specific vertex data is present
  92432. * @param kind defines the vertex data kind to use
  92433. * @returns true is data kind is present
  92434. */
  92435. isVerticesDataPresent(kind: string): boolean;
  92436. /**
  92437. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  92438. * @param kind defines the data kind (Position, normal, etc...)
  92439. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  92440. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92441. * @returns a float array containing vertex data
  92442. */
  92443. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  92444. /**
  92445. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  92446. * @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.
  92447. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92448. * @returns the indices array or an empty array if the mesh has no geometry
  92449. */
  92450. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  92451. /**
  92452. * Set specific vertex data
  92453. * @param kind defines the data kind (Position, normal, etc...)
  92454. * @param data defines the vertex data to use
  92455. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  92456. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  92457. */
  92458. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  92459. /**
  92460. * Update a specific associated vertex buffer
  92461. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92462. * - VertexBuffer.PositionKind
  92463. * - VertexBuffer.UVKind
  92464. * - VertexBuffer.UV2Kind
  92465. * - VertexBuffer.UV3Kind
  92466. * - VertexBuffer.UV4Kind
  92467. * - VertexBuffer.UV5Kind
  92468. * - VertexBuffer.UV6Kind
  92469. * - VertexBuffer.ColorKind
  92470. * - VertexBuffer.MatricesIndicesKind
  92471. * - VertexBuffer.MatricesIndicesExtraKind
  92472. * - VertexBuffer.MatricesWeightsKind
  92473. * - VertexBuffer.MatricesWeightsExtraKind
  92474. * @param data defines the data source
  92475. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  92476. * @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)
  92477. */
  92478. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  92479. /**
  92480. * Creates a new index buffer
  92481. * @param indices defines the indices to store in the index buffer
  92482. * @param totalVertices defines the total number of vertices (could be null)
  92483. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  92484. */
  92485. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  92486. }
  92487. /**
  92488. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  92489. */
  92490. export class VertexData {
  92491. /**
  92492. * Mesh side orientation : usually the external or front surface
  92493. */
  92494. static readonly FRONTSIDE: number;
  92495. /**
  92496. * Mesh side orientation : usually the internal or back surface
  92497. */
  92498. static readonly BACKSIDE: number;
  92499. /**
  92500. * Mesh side orientation : both internal and external or front and back surfaces
  92501. */
  92502. static readonly DOUBLESIDE: number;
  92503. /**
  92504. * Mesh side orientation : by default, `FRONTSIDE`
  92505. */
  92506. static readonly DEFAULTSIDE: number;
  92507. /**
  92508. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  92509. */
  92510. positions: Nullable<FloatArray>;
  92511. /**
  92512. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  92513. */
  92514. normals: Nullable<FloatArray>;
  92515. /**
  92516. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  92517. */
  92518. tangents: Nullable<FloatArray>;
  92519. /**
  92520. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92521. */
  92522. uvs: Nullable<FloatArray>;
  92523. /**
  92524. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92525. */
  92526. uvs2: Nullable<FloatArray>;
  92527. /**
  92528. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92529. */
  92530. uvs3: Nullable<FloatArray>;
  92531. /**
  92532. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92533. */
  92534. uvs4: Nullable<FloatArray>;
  92535. /**
  92536. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92537. */
  92538. uvs5: Nullable<FloatArray>;
  92539. /**
  92540. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  92541. */
  92542. uvs6: Nullable<FloatArray>;
  92543. /**
  92544. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  92545. */
  92546. colors: Nullable<FloatArray>;
  92547. /**
  92548. * 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).
  92549. */
  92550. matricesIndices: Nullable<FloatArray>;
  92551. /**
  92552. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  92553. */
  92554. matricesWeights: Nullable<FloatArray>;
  92555. /**
  92556. * An array extending the number of possible indices
  92557. */
  92558. matricesIndicesExtra: Nullable<FloatArray>;
  92559. /**
  92560. * An array extending the number of possible weights when the number of indices is extended
  92561. */
  92562. matricesWeightsExtra: Nullable<FloatArray>;
  92563. /**
  92564. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  92565. */
  92566. indices: Nullable<IndicesArray>;
  92567. /**
  92568. * Uses the passed data array to set the set the values for the specified kind of data
  92569. * @param data a linear array of floating numbers
  92570. * @param kind the type of data that is being set, eg positions, colors etc
  92571. */
  92572. set(data: FloatArray, kind: string): void;
  92573. /**
  92574. * Associates the vertexData to the passed Mesh.
  92575. * Sets it as updatable or not (default `false`)
  92576. * @param mesh the mesh the vertexData is applied to
  92577. * @param updatable when used and having the value true allows new data to update the vertexData
  92578. * @returns the VertexData
  92579. */
  92580. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  92581. /**
  92582. * Associates the vertexData to the passed Geometry.
  92583. * Sets it as updatable or not (default `false`)
  92584. * @param geometry the geometry the vertexData is applied to
  92585. * @param updatable when used and having the value true allows new data to update the vertexData
  92586. * @returns VertexData
  92587. */
  92588. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  92589. /**
  92590. * Updates the associated mesh
  92591. * @param mesh the mesh to be updated
  92592. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  92593. * @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
  92594. * @returns VertexData
  92595. */
  92596. updateMesh(mesh: Mesh): VertexData;
  92597. /**
  92598. * Updates the associated geometry
  92599. * @param geometry the geometry to be updated
  92600. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  92601. * @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
  92602. * @returns VertexData.
  92603. */
  92604. updateGeometry(geometry: Geometry): VertexData;
  92605. private _applyTo;
  92606. private _update;
  92607. /**
  92608. * Transforms each position and each normal of the vertexData according to the passed Matrix
  92609. * @param matrix the transforming matrix
  92610. * @returns the VertexData
  92611. */
  92612. transform(matrix: Matrix): VertexData;
  92613. /**
  92614. * Merges the passed VertexData into the current one
  92615. * @param other the VertexData to be merged into the current one
  92616. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  92617. * @returns the modified VertexData
  92618. */
  92619. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  92620. private _mergeElement;
  92621. private _validate;
  92622. /**
  92623. * Serializes the VertexData
  92624. * @returns a serialized object
  92625. */
  92626. serialize(): any;
  92627. /**
  92628. * Extracts the vertexData from a mesh
  92629. * @param mesh the mesh from which to extract the VertexData
  92630. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  92631. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  92632. * @returns the object VertexData associated to the passed mesh
  92633. */
  92634. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  92635. /**
  92636. * Extracts the vertexData from the geometry
  92637. * @param geometry the geometry from which to extract the VertexData
  92638. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  92639. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  92640. * @returns the object VertexData associated to the passed mesh
  92641. */
  92642. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  92643. private static _ExtractFrom;
  92644. /**
  92645. * Creates the VertexData for a Ribbon
  92646. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  92647. * * pathArray array of paths, each of which an array of successive Vector3
  92648. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  92649. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  92650. * * 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
  92651. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92652. * * 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)
  92653. * * 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)
  92654. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  92655. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  92656. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  92657. * @returns the VertexData of the ribbon
  92658. */
  92659. static CreateRibbon(options: {
  92660. pathArray: Vector3[][];
  92661. closeArray?: boolean;
  92662. closePath?: boolean;
  92663. offset?: number;
  92664. sideOrientation?: number;
  92665. frontUVs?: Vector4;
  92666. backUVs?: Vector4;
  92667. invertUV?: boolean;
  92668. uvs?: Vector2[];
  92669. colors?: Color4[];
  92670. }): VertexData;
  92671. /**
  92672. * Creates the VertexData for a box
  92673. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92674. * * size sets the width, height and depth of the box to the value of size, optional default 1
  92675. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  92676. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  92677. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  92678. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  92679. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  92680. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92681. * * 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)
  92682. * * 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)
  92683. * @returns the VertexData of the box
  92684. */
  92685. static CreateBox(options: {
  92686. size?: number;
  92687. width?: number;
  92688. height?: number;
  92689. depth?: number;
  92690. faceUV?: Vector4[];
  92691. faceColors?: Color4[];
  92692. sideOrientation?: number;
  92693. frontUVs?: Vector4;
  92694. backUVs?: Vector4;
  92695. }): VertexData;
  92696. /**
  92697. * Creates the VertexData for a tiled box
  92698. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92699. * * faceTiles sets the pattern, tile size and number of tiles for a face
  92700. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  92701. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  92702. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92703. * @returns the VertexData of the box
  92704. */
  92705. static CreateTiledBox(options: {
  92706. pattern?: number;
  92707. width?: number;
  92708. height?: number;
  92709. depth?: number;
  92710. tileSize?: number;
  92711. tileWidth?: number;
  92712. tileHeight?: number;
  92713. alignHorizontal?: number;
  92714. alignVertical?: number;
  92715. faceUV?: Vector4[];
  92716. faceColors?: Color4[];
  92717. sideOrientation?: number;
  92718. }): VertexData;
  92719. /**
  92720. * Creates the VertexData for a tiled plane
  92721. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92722. * * pattern a limited pattern arrangement depending on the number
  92723. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  92724. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  92725. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  92726. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92727. * * 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)
  92728. * * 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)
  92729. * @returns the VertexData of the tiled plane
  92730. */
  92731. static CreateTiledPlane(options: {
  92732. pattern?: number;
  92733. tileSize?: number;
  92734. tileWidth?: number;
  92735. tileHeight?: number;
  92736. size?: number;
  92737. width?: number;
  92738. height?: number;
  92739. alignHorizontal?: number;
  92740. alignVertical?: number;
  92741. sideOrientation?: number;
  92742. frontUVs?: Vector4;
  92743. backUVs?: Vector4;
  92744. }): VertexData;
  92745. /**
  92746. * Creates the VertexData for an ellipsoid, defaults to a sphere
  92747. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92748. * * segments sets the number of horizontal strips optional, default 32
  92749. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  92750. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  92751. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  92752. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  92753. * * 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
  92754. * * 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
  92755. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92756. * * 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)
  92757. * * 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)
  92758. * @returns the VertexData of the ellipsoid
  92759. */
  92760. static CreateSphere(options: {
  92761. segments?: number;
  92762. diameter?: number;
  92763. diameterX?: number;
  92764. diameterY?: number;
  92765. diameterZ?: number;
  92766. arc?: number;
  92767. slice?: number;
  92768. sideOrientation?: number;
  92769. frontUVs?: Vector4;
  92770. backUVs?: Vector4;
  92771. }): VertexData;
  92772. /**
  92773. * Creates the VertexData for a cylinder, cone or prism
  92774. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92775. * * height sets the height (y direction) of the cylinder, optional, default 2
  92776. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  92777. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  92778. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  92779. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  92780. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  92781. * * 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
  92782. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  92783. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  92784. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  92785. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  92786. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92787. * * 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)
  92788. * * 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)
  92789. * @returns the VertexData of the cylinder, cone or prism
  92790. */
  92791. static CreateCylinder(options: {
  92792. height?: number;
  92793. diameterTop?: number;
  92794. diameterBottom?: number;
  92795. diameter?: number;
  92796. tessellation?: number;
  92797. subdivisions?: number;
  92798. arc?: number;
  92799. faceColors?: Color4[];
  92800. faceUV?: Vector4[];
  92801. hasRings?: boolean;
  92802. enclose?: boolean;
  92803. sideOrientation?: number;
  92804. frontUVs?: Vector4;
  92805. backUVs?: Vector4;
  92806. }): VertexData;
  92807. /**
  92808. * Creates the VertexData for a torus
  92809. * @param options an object used to set the following optional parameters for the box, required but can be empty
  92810. * * diameter the diameter of the torus, optional default 1
  92811. * * thickness the diameter of the tube forming the torus, optional default 0.5
  92812. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  92813. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92814. * * 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)
  92815. * * 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)
  92816. * @returns the VertexData of the torus
  92817. */
  92818. static CreateTorus(options: {
  92819. diameter?: number;
  92820. thickness?: number;
  92821. tessellation?: number;
  92822. sideOrientation?: number;
  92823. frontUVs?: Vector4;
  92824. backUVs?: Vector4;
  92825. }): VertexData;
  92826. /**
  92827. * Creates the VertexData of the LineSystem
  92828. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  92829. * - lines an array of lines, each line being an array of successive Vector3
  92830. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  92831. * @returns the VertexData of the LineSystem
  92832. */
  92833. static CreateLineSystem(options: {
  92834. lines: Vector3[][];
  92835. colors?: Nullable<Color4[][]>;
  92836. }): VertexData;
  92837. /**
  92838. * Create the VertexData for a DashedLines
  92839. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  92840. * - points an array successive Vector3
  92841. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  92842. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  92843. * - dashNb the intended total number of dashes, optional, default 200
  92844. * @returns the VertexData for the DashedLines
  92845. */
  92846. static CreateDashedLines(options: {
  92847. points: Vector3[];
  92848. dashSize?: number;
  92849. gapSize?: number;
  92850. dashNb?: number;
  92851. }): VertexData;
  92852. /**
  92853. * Creates the VertexData for a Ground
  92854. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  92855. * - width the width (x direction) of the ground, optional, default 1
  92856. * - height the height (z direction) of the ground, optional, default 1
  92857. * - subdivisions the number of subdivisions per side, optional, default 1
  92858. * @returns the VertexData of the Ground
  92859. */
  92860. static CreateGround(options: {
  92861. width?: number;
  92862. height?: number;
  92863. subdivisions?: number;
  92864. subdivisionsX?: number;
  92865. subdivisionsY?: number;
  92866. }): VertexData;
  92867. /**
  92868. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  92869. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  92870. * * xmin the ground minimum X coordinate, optional, default -1
  92871. * * zmin the ground minimum Z coordinate, optional, default -1
  92872. * * xmax the ground maximum X coordinate, optional, default 1
  92873. * * zmax the ground maximum Z coordinate, optional, default 1
  92874. * * 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}
  92875. * * 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}
  92876. * @returns the VertexData of the TiledGround
  92877. */
  92878. static CreateTiledGround(options: {
  92879. xmin: number;
  92880. zmin: number;
  92881. xmax: number;
  92882. zmax: number;
  92883. subdivisions?: {
  92884. w: number;
  92885. h: number;
  92886. };
  92887. precision?: {
  92888. w: number;
  92889. h: number;
  92890. };
  92891. }): VertexData;
  92892. /**
  92893. * Creates the VertexData of the Ground designed from a heightmap
  92894. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  92895. * * width the width (x direction) of the ground
  92896. * * height the height (z direction) of the ground
  92897. * * subdivisions the number of subdivisions per side
  92898. * * minHeight the minimum altitude on the ground, optional, default 0
  92899. * * maxHeight the maximum altitude on the ground, optional default 1
  92900. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  92901. * * buffer the array holding the image color data
  92902. * * bufferWidth the width of image
  92903. * * bufferHeight the height of image
  92904. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  92905. * @returns the VertexData of the Ground designed from a heightmap
  92906. */
  92907. static CreateGroundFromHeightMap(options: {
  92908. width: number;
  92909. height: number;
  92910. subdivisions: number;
  92911. minHeight: number;
  92912. maxHeight: number;
  92913. colorFilter: Color3;
  92914. buffer: Uint8Array;
  92915. bufferWidth: number;
  92916. bufferHeight: number;
  92917. alphaFilter: number;
  92918. }): VertexData;
  92919. /**
  92920. * Creates the VertexData for a Plane
  92921. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  92922. * * size sets the width and height of the plane to the value of size, optional default 1
  92923. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  92924. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  92925. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92926. * * 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)
  92927. * * 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)
  92928. * @returns the VertexData of the box
  92929. */
  92930. static CreatePlane(options: {
  92931. size?: number;
  92932. width?: number;
  92933. height?: number;
  92934. sideOrientation?: number;
  92935. frontUVs?: Vector4;
  92936. backUVs?: Vector4;
  92937. }): VertexData;
  92938. /**
  92939. * Creates the VertexData of the Disc or regular Polygon
  92940. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  92941. * * radius the radius of the disc, optional default 0.5
  92942. * * tessellation the number of polygon sides, optional, default 64
  92943. * * 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
  92944. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92945. * * 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)
  92946. * * 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)
  92947. * @returns the VertexData of the box
  92948. */
  92949. static CreateDisc(options: {
  92950. radius?: number;
  92951. tessellation?: number;
  92952. arc?: number;
  92953. sideOrientation?: number;
  92954. frontUVs?: Vector4;
  92955. backUVs?: Vector4;
  92956. }): VertexData;
  92957. /**
  92958. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  92959. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  92960. * @param polygon a mesh built from polygonTriangulation.build()
  92961. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92962. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  92963. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  92964. * @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)
  92965. * @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)
  92966. * @returns the VertexData of the Polygon
  92967. */
  92968. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  92969. /**
  92970. * Creates the VertexData of the IcoSphere
  92971. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  92972. * * radius the radius of the IcoSphere, optional default 1
  92973. * * radiusX allows stretching in the x direction, optional, default radius
  92974. * * radiusY allows stretching in the y direction, optional, default radius
  92975. * * radiusZ allows stretching in the z direction, optional, default radius
  92976. * * flat when true creates a flat shaded mesh, optional, default true
  92977. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  92978. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92979. * * 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)
  92980. * * 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)
  92981. * @returns the VertexData of the IcoSphere
  92982. */
  92983. static CreateIcoSphere(options: {
  92984. radius?: number;
  92985. radiusX?: number;
  92986. radiusY?: number;
  92987. radiusZ?: number;
  92988. flat?: boolean;
  92989. subdivisions?: number;
  92990. sideOrientation?: number;
  92991. frontUVs?: Vector4;
  92992. backUVs?: Vector4;
  92993. }): VertexData;
  92994. /**
  92995. * Creates the VertexData for a Polyhedron
  92996. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  92997. * * type provided types are:
  92998. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  92999. * * 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)
  93000. * * size the size of the IcoSphere, optional default 1
  93001. * * sizeX allows stretching in the x direction, optional, default size
  93002. * * sizeY allows stretching in the y direction, optional, default size
  93003. * * sizeZ allows stretching in the z direction, optional, default size
  93004. * * 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
  93005. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  93006. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  93007. * * flat when true creates a flat shaded mesh, optional, default true
  93008. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  93009. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93010. * * 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)
  93011. * * 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)
  93012. * @returns the VertexData of the Polyhedron
  93013. */
  93014. static CreatePolyhedron(options: {
  93015. type?: number;
  93016. size?: number;
  93017. sizeX?: number;
  93018. sizeY?: number;
  93019. sizeZ?: number;
  93020. custom?: any;
  93021. faceUV?: Vector4[];
  93022. faceColors?: Color4[];
  93023. flat?: boolean;
  93024. sideOrientation?: number;
  93025. frontUVs?: Vector4;
  93026. backUVs?: Vector4;
  93027. }): VertexData;
  93028. /**
  93029. * Creates the VertexData for a TorusKnot
  93030. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  93031. * * radius the radius of the torus knot, optional, default 2
  93032. * * tube the thickness of the tube, optional, default 0.5
  93033. * * radialSegments the number of sides on each tube segments, optional, default 32
  93034. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  93035. * * p the number of windings around the z axis, optional, default 2
  93036. * * q the number of windings around the x axis, optional, default 3
  93037. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93038. * * 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)
  93039. * * 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)
  93040. * @returns the VertexData of the Torus Knot
  93041. */
  93042. static CreateTorusKnot(options: {
  93043. radius?: number;
  93044. tube?: number;
  93045. radialSegments?: number;
  93046. tubularSegments?: number;
  93047. p?: number;
  93048. q?: number;
  93049. sideOrientation?: number;
  93050. frontUVs?: Vector4;
  93051. backUVs?: Vector4;
  93052. }): VertexData;
  93053. /**
  93054. * Compute normals for given positions and indices
  93055. * @param positions an array of vertex positions, [...., x, y, z, ......]
  93056. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  93057. * @param normals an array of vertex normals, [...., x, y, z, ......]
  93058. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  93059. * * facetNormals : optional array of facet normals (vector3)
  93060. * * facetPositions : optional array of facet positions (vector3)
  93061. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  93062. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  93063. * * bInfo : optional bounding info, required for facetPartitioning computation
  93064. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  93065. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  93066. * * useRightHandedSystem: optional boolean to for right handed system computation
  93067. * * depthSort : optional boolean to enable the facet depth sort computation
  93068. * * distanceTo : optional Vector3 to compute the facet depth from this location
  93069. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  93070. */
  93071. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  93072. facetNormals?: any;
  93073. facetPositions?: any;
  93074. facetPartitioning?: any;
  93075. ratio?: number;
  93076. bInfo?: any;
  93077. bbSize?: Vector3;
  93078. subDiv?: any;
  93079. useRightHandedSystem?: boolean;
  93080. depthSort?: boolean;
  93081. distanceTo?: Vector3;
  93082. depthSortedFacets?: any;
  93083. }): void;
  93084. /** @hidden */
  93085. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  93086. /**
  93087. * Applies VertexData created from the imported parameters to the geometry
  93088. * @param parsedVertexData the parsed data from an imported file
  93089. * @param geometry the geometry to apply the VertexData to
  93090. */
  93091. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  93092. }
  93093. }
  93094. declare module BABYLON {
  93095. /**
  93096. * Defines a target to use with MorphTargetManager
  93097. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  93098. */
  93099. export class MorphTarget implements IAnimatable {
  93100. /** defines the name of the target */
  93101. name: string;
  93102. /**
  93103. * Gets or sets the list of animations
  93104. */
  93105. animations: Animation[];
  93106. private _scene;
  93107. private _positions;
  93108. private _normals;
  93109. private _tangents;
  93110. private _uvs;
  93111. private _influence;
  93112. private _uniqueId;
  93113. /**
  93114. * Observable raised when the influence changes
  93115. */
  93116. onInfluenceChanged: Observable<boolean>;
  93117. /** @hidden */
  93118. _onDataLayoutChanged: Observable<void>;
  93119. /**
  93120. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  93121. */
  93122. get influence(): number;
  93123. set influence(influence: number);
  93124. /**
  93125. * Gets or sets the id of the morph Target
  93126. */
  93127. id: string;
  93128. private _animationPropertiesOverride;
  93129. /**
  93130. * Gets or sets the animation properties override
  93131. */
  93132. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  93133. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  93134. /**
  93135. * Creates a new MorphTarget
  93136. * @param name defines the name of the target
  93137. * @param influence defines the influence to use
  93138. * @param scene defines the scene the morphtarget belongs to
  93139. */
  93140. constructor(
  93141. /** defines the name of the target */
  93142. name: string, influence?: number, scene?: Nullable<Scene>);
  93143. /**
  93144. * Gets the unique ID of this manager
  93145. */
  93146. get uniqueId(): number;
  93147. /**
  93148. * Gets a boolean defining if the target contains position data
  93149. */
  93150. get hasPositions(): boolean;
  93151. /**
  93152. * Gets a boolean defining if the target contains normal data
  93153. */
  93154. get hasNormals(): boolean;
  93155. /**
  93156. * Gets a boolean defining if the target contains tangent data
  93157. */
  93158. get hasTangents(): boolean;
  93159. /**
  93160. * Gets a boolean defining if the target contains texture coordinates data
  93161. */
  93162. get hasUVs(): boolean;
  93163. /**
  93164. * Affects position data to this target
  93165. * @param data defines the position data to use
  93166. */
  93167. setPositions(data: Nullable<FloatArray>): void;
  93168. /**
  93169. * Gets the position data stored in this target
  93170. * @returns a FloatArray containing the position data (or null if not present)
  93171. */
  93172. getPositions(): Nullable<FloatArray>;
  93173. /**
  93174. * Affects normal data to this target
  93175. * @param data defines the normal data to use
  93176. */
  93177. setNormals(data: Nullable<FloatArray>): void;
  93178. /**
  93179. * Gets the normal data stored in this target
  93180. * @returns a FloatArray containing the normal data (or null if not present)
  93181. */
  93182. getNormals(): Nullable<FloatArray>;
  93183. /**
  93184. * Affects tangent data to this target
  93185. * @param data defines the tangent data to use
  93186. */
  93187. setTangents(data: Nullable<FloatArray>): void;
  93188. /**
  93189. * Gets the tangent data stored in this target
  93190. * @returns a FloatArray containing the tangent data (or null if not present)
  93191. */
  93192. getTangents(): Nullable<FloatArray>;
  93193. /**
  93194. * Affects texture coordinates data to this target
  93195. * @param data defines the texture coordinates data to use
  93196. */
  93197. setUVs(data: Nullable<FloatArray>): void;
  93198. /**
  93199. * Gets the texture coordinates data stored in this target
  93200. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  93201. */
  93202. getUVs(): Nullable<FloatArray>;
  93203. /**
  93204. * Clone the current target
  93205. * @returns a new MorphTarget
  93206. */
  93207. clone(): MorphTarget;
  93208. /**
  93209. * Serializes the current target into a Serialization object
  93210. * @returns the serialized object
  93211. */
  93212. serialize(): any;
  93213. /**
  93214. * Returns the string "MorphTarget"
  93215. * @returns "MorphTarget"
  93216. */
  93217. getClassName(): string;
  93218. /**
  93219. * Creates a new target from serialized data
  93220. * @param serializationObject defines the serialized data to use
  93221. * @returns a new MorphTarget
  93222. */
  93223. static Parse(serializationObject: any): MorphTarget;
  93224. /**
  93225. * Creates a MorphTarget from mesh data
  93226. * @param mesh defines the source mesh
  93227. * @param name defines the name to use for the new target
  93228. * @param influence defines the influence to attach to the target
  93229. * @returns a new MorphTarget
  93230. */
  93231. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  93232. }
  93233. }
  93234. declare module BABYLON {
  93235. /**
  93236. * This class is used to deform meshes using morphing between different targets
  93237. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  93238. */
  93239. export class MorphTargetManager {
  93240. private _targets;
  93241. private _targetInfluenceChangedObservers;
  93242. private _targetDataLayoutChangedObservers;
  93243. private _activeTargets;
  93244. private _scene;
  93245. private _influences;
  93246. private _supportsNormals;
  93247. private _supportsTangents;
  93248. private _supportsUVs;
  93249. private _vertexCount;
  93250. private _uniqueId;
  93251. private _tempInfluences;
  93252. /**
  93253. * Gets or sets a boolean indicating if normals must be morphed
  93254. */
  93255. enableNormalMorphing: boolean;
  93256. /**
  93257. * Gets or sets a boolean indicating if tangents must be morphed
  93258. */
  93259. enableTangentMorphing: boolean;
  93260. /**
  93261. * Gets or sets a boolean indicating if UV must be morphed
  93262. */
  93263. enableUVMorphing: boolean;
  93264. /**
  93265. * Creates a new MorphTargetManager
  93266. * @param scene defines the current scene
  93267. */
  93268. constructor(scene?: Nullable<Scene>);
  93269. /**
  93270. * Gets the unique ID of this manager
  93271. */
  93272. get uniqueId(): number;
  93273. /**
  93274. * Gets the number of vertices handled by this manager
  93275. */
  93276. get vertexCount(): number;
  93277. /**
  93278. * Gets a boolean indicating if this manager supports morphing of normals
  93279. */
  93280. get supportsNormals(): boolean;
  93281. /**
  93282. * Gets a boolean indicating if this manager supports morphing of tangents
  93283. */
  93284. get supportsTangents(): boolean;
  93285. /**
  93286. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  93287. */
  93288. get supportsUVs(): boolean;
  93289. /**
  93290. * Gets the number of targets stored in this manager
  93291. */
  93292. get numTargets(): number;
  93293. /**
  93294. * Gets the number of influencers (ie. the number of targets with influences > 0)
  93295. */
  93296. get numInfluencers(): number;
  93297. /**
  93298. * Gets the list of influences (one per target)
  93299. */
  93300. get influences(): Float32Array;
  93301. /**
  93302. * Gets the active target at specified index. An active target is a target with an influence > 0
  93303. * @param index defines the index to check
  93304. * @returns the requested target
  93305. */
  93306. getActiveTarget(index: number): MorphTarget;
  93307. /**
  93308. * Gets the target at specified index
  93309. * @param index defines the index to check
  93310. * @returns the requested target
  93311. */
  93312. getTarget(index: number): MorphTarget;
  93313. /**
  93314. * Add a new target to this manager
  93315. * @param target defines the target to add
  93316. */
  93317. addTarget(target: MorphTarget): void;
  93318. /**
  93319. * Removes a target from the manager
  93320. * @param target defines the target to remove
  93321. */
  93322. removeTarget(target: MorphTarget): void;
  93323. /**
  93324. * Clone the current manager
  93325. * @returns a new MorphTargetManager
  93326. */
  93327. clone(): MorphTargetManager;
  93328. /**
  93329. * Serializes the current manager into a Serialization object
  93330. * @returns the serialized object
  93331. */
  93332. serialize(): any;
  93333. private _syncActiveTargets;
  93334. /**
  93335. * Syncrhonize the targets with all the meshes using this morph target manager
  93336. */
  93337. synchronize(): void;
  93338. /**
  93339. * Creates a new MorphTargetManager from serialized data
  93340. * @param serializationObject defines the serialized data
  93341. * @param scene defines the hosting scene
  93342. * @returns the new MorphTargetManager
  93343. */
  93344. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  93345. }
  93346. }
  93347. declare module BABYLON {
  93348. /**
  93349. * Class used to represent a specific level of detail of a mesh
  93350. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  93351. */
  93352. export class MeshLODLevel {
  93353. /** Defines the distance where this level should start being displayed */
  93354. distance: number;
  93355. /** Defines the mesh to use to render this level */
  93356. mesh: Nullable<Mesh>;
  93357. /**
  93358. * Creates a new LOD level
  93359. * @param distance defines the distance where this level should star being displayed
  93360. * @param mesh defines the mesh to use to render this level
  93361. */
  93362. constructor(
  93363. /** Defines the distance where this level should start being displayed */
  93364. distance: number,
  93365. /** Defines the mesh to use to render this level */
  93366. mesh: Nullable<Mesh>);
  93367. }
  93368. }
  93369. declare module BABYLON {
  93370. /**
  93371. * Mesh representing the gorund
  93372. */
  93373. export class GroundMesh extends Mesh {
  93374. /** If octree should be generated */
  93375. generateOctree: boolean;
  93376. private _heightQuads;
  93377. /** @hidden */
  93378. _subdivisionsX: number;
  93379. /** @hidden */
  93380. _subdivisionsY: number;
  93381. /** @hidden */
  93382. _width: number;
  93383. /** @hidden */
  93384. _height: number;
  93385. /** @hidden */
  93386. _minX: number;
  93387. /** @hidden */
  93388. _maxX: number;
  93389. /** @hidden */
  93390. _minZ: number;
  93391. /** @hidden */
  93392. _maxZ: number;
  93393. constructor(name: string, scene: Scene);
  93394. /**
  93395. * "GroundMesh"
  93396. * @returns "GroundMesh"
  93397. */
  93398. getClassName(): string;
  93399. /**
  93400. * The minimum of x and y subdivisions
  93401. */
  93402. get subdivisions(): number;
  93403. /**
  93404. * X subdivisions
  93405. */
  93406. get subdivisionsX(): number;
  93407. /**
  93408. * Y subdivisions
  93409. */
  93410. get subdivisionsY(): number;
  93411. /**
  93412. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  93413. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  93414. * @param chunksCount the number of subdivisions for x and y
  93415. * @param octreeBlocksSize (Default: 32)
  93416. */
  93417. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  93418. /**
  93419. * Returns a height (y) value in the Worl system :
  93420. * the ground altitude at the coordinates (x, z) expressed in the World system.
  93421. * @param x x coordinate
  93422. * @param z z coordinate
  93423. * @returns the ground y position if (x, z) are outside the ground surface.
  93424. */
  93425. getHeightAtCoordinates(x: number, z: number): number;
  93426. /**
  93427. * Returns a normalized vector (Vector3) orthogonal to the ground
  93428. * at the ground coordinates (x, z) expressed in the World system.
  93429. * @param x x coordinate
  93430. * @param z z coordinate
  93431. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  93432. */
  93433. getNormalAtCoordinates(x: number, z: number): Vector3;
  93434. /**
  93435. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  93436. * at the ground coordinates (x, z) expressed in the World system.
  93437. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  93438. * @param x x coordinate
  93439. * @param z z coordinate
  93440. * @param ref vector to store the result
  93441. * @returns the GroundMesh.
  93442. */
  93443. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  93444. /**
  93445. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  93446. * if the ground has been updated.
  93447. * This can be used in the render loop.
  93448. * @returns the GroundMesh.
  93449. */
  93450. updateCoordinateHeights(): GroundMesh;
  93451. private _getFacetAt;
  93452. private _initHeightQuads;
  93453. private _computeHeightQuads;
  93454. /**
  93455. * Serializes this ground mesh
  93456. * @param serializationObject object to write serialization to
  93457. */
  93458. serialize(serializationObject: any): void;
  93459. /**
  93460. * Parses a serialized ground mesh
  93461. * @param parsedMesh the serialized mesh
  93462. * @param scene the scene to create the ground mesh in
  93463. * @returns the created ground mesh
  93464. */
  93465. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  93466. }
  93467. }
  93468. declare module BABYLON {
  93469. /**
  93470. * Interface for Physics-Joint data
  93471. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93472. */
  93473. export interface PhysicsJointData {
  93474. /**
  93475. * The main pivot of the joint
  93476. */
  93477. mainPivot?: Vector3;
  93478. /**
  93479. * The connected pivot of the joint
  93480. */
  93481. connectedPivot?: Vector3;
  93482. /**
  93483. * The main axis of the joint
  93484. */
  93485. mainAxis?: Vector3;
  93486. /**
  93487. * The connected axis of the joint
  93488. */
  93489. connectedAxis?: Vector3;
  93490. /**
  93491. * The collision of the joint
  93492. */
  93493. collision?: boolean;
  93494. /**
  93495. * Native Oimo/Cannon/Energy data
  93496. */
  93497. nativeParams?: any;
  93498. }
  93499. /**
  93500. * This is a holder class for the physics joint created by the physics plugin
  93501. * It holds a set of functions to control the underlying joint
  93502. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93503. */
  93504. export class PhysicsJoint {
  93505. /**
  93506. * The type of the physics joint
  93507. */
  93508. type: number;
  93509. /**
  93510. * The data for the physics joint
  93511. */
  93512. jointData: PhysicsJointData;
  93513. private _physicsJoint;
  93514. protected _physicsPlugin: IPhysicsEnginePlugin;
  93515. /**
  93516. * Initializes the physics joint
  93517. * @param type The type of the physics joint
  93518. * @param jointData The data for the physics joint
  93519. */
  93520. constructor(
  93521. /**
  93522. * The type of the physics joint
  93523. */
  93524. type: number,
  93525. /**
  93526. * The data for the physics joint
  93527. */
  93528. jointData: PhysicsJointData);
  93529. /**
  93530. * Gets the physics joint
  93531. */
  93532. get physicsJoint(): any;
  93533. /**
  93534. * Sets the physics joint
  93535. */
  93536. set physicsJoint(newJoint: any);
  93537. /**
  93538. * Sets the physics plugin
  93539. */
  93540. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  93541. /**
  93542. * Execute a function that is physics-plugin specific.
  93543. * @param {Function} func the function that will be executed.
  93544. * It accepts two parameters: the physics world and the physics joint
  93545. */
  93546. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  93547. /**
  93548. * Distance-Joint type
  93549. */
  93550. static DistanceJoint: number;
  93551. /**
  93552. * Hinge-Joint type
  93553. */
  93554. static HingeJoint: number;
  93555. /**
  93556. * Ball-and-Socket joint type
  93557. */
  93558. static BallAndSocketJoint: number;
  93559. /**
  93560. * Wheel-Joint type
  93561. */
  93562. static WheelJoint: number;
  93563. /**
  93564. * Slider-Joint type
  93565. */
  93566. static SliderJoint: number;
  93567. /**
  93568. * Prismatic-Joint type
  93569. */
  93570. static PrismaticJoint: number;
  93571. /**
  93572. * Universal-Joint type
  93573. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  93574. */
  93575. static UniversalJoint: number;
  93576. /**
  93577. * Hinge-Joint 2 type
  93578. */
  93579. static Hinge2Joint: number;
  93580. /**
  93581. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  93582. */
  93583. static PointToPointJoint: number;
  93584. /**
  93585. * Spring-Joint type
  93586. */
  93587. static SpringJoint: number;
  93588. /**
  93589. * Lock-Joint type
  93590. */
  93591. static LockJoint: number;
  93592. }
  93593. /**
  93594. * A class representing a physics distance joint
  93595. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93596. */
  93597. export class DistanceJoint extends PhysicsJoint {
  93598. /**
  93599. *
  93600. * @param jointData The data for the Distance-Joint
  93601. */
  93602. constructor(jointData: DistanceJointData);
  93603. /**
  93604. * Update the predefined distance.
  93605. * @param maxDistance The maximum preferred distance
  93606. * @param minDistance The minimum preferred distance
  93607. */
  93608. updateDistance(maxDistance: number, minDistance?: number): void;
  93609. }
  93610. /**
  93611. * Represents a Motor-Enabled Joint
  93612. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93613. */
  93614. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  93615. /**
  93616. * Initializes the Motor-Enabled Joint
  93617. * @param type The type of the joint
  93618. * @param jointData The physica joint data for the joint
  93619. */
  93620. constructor(type: number, jointData: PhysicsJointData);
  93621. /**
  93622. * Set the motor values.
  93623. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93624. * @param force the force to apply
  93625. * @param maxForce max force for this motor.
  93626. */
  93627. setMotor(force?: number, maxForce?: number): void;
  93628. /**
  93629. * Set the motor's limits.
  93630. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93631. * @param upperLimit The upper limit of the motor
  93632. * @param lowerLimit The lower limit of the motor
  93633. */
  93634. setLimit(upperLimit: number, lowerLimit?: number): void;
  93635. }
  93636. /**
  93637. * This class represents a single physics Hinge-Joint
  93638. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93639. */
  93640. export class HingeJoint extends MotorEnabledJoint {
  93641. /**
  93642. * Initializes the Hinge-Joint
  93643. * @param jointData The joint data for the Hinge-Joint
  93644. */
  93645. constructor(jointData: PhysicsJointData);
  93646. /**
  93647. * Set the motor values.
  93648. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93649. * @param {number} force the force to apply
  93650. * @param {number} maxForce max force for this motor.
  93651. */
  93652. setMotor(force?: number, maxForce?: number): void;
  93653. /**
  93654. * Set the motor's limits.
  93655. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93656. * @param upperLimit The upper limit of the motor
  93657. * @param lowerLimit The lower limit of the motor
  93658. */
  93659. setLimit(upperLimit: number, lowerLimit?: number): void;
  93660. }
  93661. /**
  93662. * This class represents a dual hinge physics joint (same as wheel joint)
  93663. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93664. */
  93665. export class Hinge2Joint extends MotorEnabledJoint {
  93666. /**
  93667. * Initializes the Hinge2-Joint
  93668. * @param jointData The joint data for the Hinge2-Joint
  93669. */
  93670. constructor(jointData: PhysicsJointData);
  93671. /**
  93672. * Set the motor values.
  93673. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93674. * @param {number} targetSpeed the speed the motor is to reach
  93675. * @param {number} maxForce max force for this motor.
  93676. * @param {motorIndex} the motor's index, 0 or 1.
  93677. */
  93678. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  93679. /**
  93680. * Set the motor limits.
  93681. * Attention, this function is plugin specific. Engines won't react 100% the same.
  93682. * @param {number} upperLimit the upper limit
  93683. * @param {number} lowerLimit lower limit
  93684. * @param {motorIndex} the motor's index, 0 or 1.
  93685. */
  93686. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  93687. }
  93688. /**
  93689. * Interface for a motor enabled joint
  93690. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93691. */
  93692. export interface IMotorEnabledJoint {
  93693. /**
  93694. * Physics joint
  93695. */
  93696. physicsJoint: any;
  93697. /**
  93698. * Sets the motor of the motor-enabled joint
  93699. * @param force The force of the motor
  93700. * @param maxForce The maximum force of the motor
  93701. * @param motorIndex The index of the motor
  93702. */
  93703. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  93704. /**
  93705. * Sets the limit of the motor
  93706. * @param upperLimit The upper limit of the motor
  93707. * @param lowerLimit The lower limit of the motor
  93708. * @param motorIndex The index of the motor
  93709. */
  93710. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  93711. }
  93712. /**
  93713. * Joint data for a Distance-Joint
  93714. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93715. */
  93716. export interface DistanceJointData extends PhysicsJointData {
  93717. /**
  93718. * Max distance the 2 joint objects can be apart
  93719. */
  93720. maxDistance: number;
  93721. }
  93722. /**
  93723. * Joint data from a spring joint
  93724. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93725. */
  93726. export interface SpringJointData extends PhysicsJointData {
  93727. /**
  93728. * Length of the spring
  93729. */
  93730. length: number;
  93731. /**
  93732. * Stiffness of the spring
  93733. */
  93734. stiffness: number;
  93735. /**
  93736. * Damping of the spring
  93737. */
  93738. damping: number;
  93739. /** this callback will be called when applying the force to the impostors. */
  93740. forceApplicationCallback: () => void;
  93741. }
  93742. }
  93743. declare module BABYLON {
  93744. /**
  93745. * Holds the data for the raycast result
  93746. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93747. */
  93748. export class PhysicsRaycastResult {
  93749. private _hasHit;
  93750. private _hitDistance;
  93751. private _hitNormalWorld;
  93752. private _hitPointWorld;
  93753. private _rayFromWorld;
  93754. private _rayToWorld;
  93755. /**
  93756. * Gets if there was a hit
  93757. */
  93758. get hasHit(): boolean;
  93759. /**
  93760. * Gets the distance from the hit
  93761. */
  93762. get hitDistance(): number;
  93763. /**
  93764. * Gets the hit normal/direction in the world
  93765. */
  93766. get hitNormalWorld(): Vector3;
  93767. /**
  93768. * Gets the hit point in the world
  93769. */
  93770. get hitPointWorld(): Vector3;
  93771. /**
  93772. * Gets the ray "start point" of the ray in the world
  93773. */
  93774. get rayFromWorld(): Vector3;
  93775. /**
  93776. * Gets the ray "end point" of the ray in the world
  93777. */
  93778. get rayToWorld(): Vector3;
  93779. /**
  93780. * Sets the hit data (normal & point in world space)
  93781. * @param hitNormalWorld defines the normal in world space
  93782. * @param hitPointWorld defines the point in world space
  93783. */
  93784. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  93785. /**
  93786. * Sets the distance from the start point to the hit point
  93787. * @param distance
  93788. */
  93789. setHitDistance(distance: number): void;
  93790. /**
  93791. * Calculates the distance manually
  93792. */
  93793. calculateHitDistance(): void;
  93794. /**
  93795. * Resets all the values to default
  93796. * @param from The from point on world space
  93797. * @param to The to point on world space
  93798. */
  93799. reset(from?: Vector3, to?: Vector3): void;
  93800. }
  93801. /**
  93802. * Interface for the size containing width and height
  93803. */
  93804. interface IXYZ {
  93805. /**
  93806. * X
  93807. */
  93808. x: number;
  93809. /**
  93810. * Y
  93811. */
  93812. y: number;
  93813. /**
  93814. * Z
  93815. */
  93816. z: number;
  93817. }
  93818. }
  93819. declare module BABYLON {
  93820. /**
  93821. * Interface used to describe a physics joint
  93822. */
  93823. export interface PhysicsImpostorJoint {
  93824. /** Defines the main impostor to which the joint is linked */
  93825. mainImpostor: PhysicsImpostor;
  93826. /** Defines the impostor that is connected to the main impostor using this joint */
  93827. connectedImpostor: PhysicsImpostor;
  93828. /** Defines the joint itself */
  93829. joint: PhysicsJoint;
  93830. }
  93831. /** @hidden */
  93832. export interface IPhysicsEnginePlugin {
  93833. world: any;
  93834. name: string;
  93835. setGravity(gravity: Vector3): void;
  93836. setTimeStep(timeStep: number): void;
  93837. getTimeStep(): number;
  93838. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  93839. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  93840. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  93841. generatePhysicsBody(impostor: PhysicsImpostor): void;
  93842. removePhysicsBody(impostor: PhysicsImpostor): void;
  93843. generateJoint(joint: PhysicsImpostorJoint): void;
  93844. removeJoint(joint: PhysicsImpostorJoint): void;
  93845. isSupported(): boolean;
  93846. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  93847. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  93848. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  93849. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  93850. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  93851. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  93852. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  93853. getBodyMass(impostor: PhysicsImpostor): number;
  93854. getBodyFriction(impostor: PhysicsImpostor): number;
  93855. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  93856. getBodyRestitution(impostor: PhysicsImpostor): number;
  93857. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  93858. getBodyPressure?(impostor: PhysicsImpostor): number;
  93859. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  93860. getBodyStiffness?(impostor: PhysicsImpostor): number;
  93861. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  93862. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  93863. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  93864. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  93865. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  93866. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  93867. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  93868. sleepBody(impostor: PhysicsImpostor): void;
  93869. wakeUpBody(impostor: PhysicsImpostor): void;
  93870. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  93871. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  93872. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  93873. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  93874. getRadius(impostor: PhysicsImpostor): number;
  93875. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  93876. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  93877. dispose(): void;
  93878. }
  93879. /**
  93880. * Interface used to define a physics engine
  93881. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  93882. */
  93883. export interface IPhysicsEngine {
  93884. /**
  93885. * Gets the gravity vector used by the simulation
  93886. */
  93887. gravity: Vector3;
  93888. /**
  93889. * Sets the gravity vector used by the simulation
  93890. * @param gravity defines the gravity vector to use
  93891. */
  93892. setGravity(gravity: Vector3): void;
  93893. /**
  93894. * Set the time step of the physics engine.
  93895. * Default is 1/60.
  93896. * To slow it down, enter 1/600 for example.
  93897. * To speed it up, 1/30
  93898. * @param newTimeStep the new timestep to apply to this world.
  93899. */
  93900. setTimeStep(newTimeStep: number): void;
  93901. /**
  93902. * Get the time step of the physics engine.
  93903. * @returns the current time step
  93904. */
  93905. getTimeStep(): number;
  93906. /**
  93907. * Set the sub time step of the physics engine.
  93908. * Default is 0 meaning there is no sub steps
  93909. * To increase physics resolution precision, set a small value (like 1 ms)
  93910. * @param subTimeStep defines the new sub timestep used for physics resolution.
  93911. */
  93912. setSubTimeStep(subTimeStep: number): void;
  93913. /**
  93914. * Get the sub time step of the physics engine.
  93915. * @returns the current sub time step
  93916. */
  93917. getSubTimeStep(): number;
  93918. /**
  93919. * Release all resources
  93920. */
  93921. dispose(): void;
  93922. /**
  93923. * Gets the name of the current physics plugin
  93924. * @returns the name of the plugin
  93925. */
  93926. getPhysicsPluginName(): string;
  93927. /**
  93928. * Adding a new impostor for the impostor tracking.
  93929. * This will be done by the impostor itself.
  93930. * @param impostor the impostor to add
  93931. */
  93932. addImpostor(impostor: PhysicsImpostor): void;
  93933. /**
  93934. * Remove an impostor from the engine.
  93935. * This impostor and its mesh will not longer be updated by the physics engine.
  93936. * @param impostor the impostor to remove
  93937. */
  93938. removeImpostor(impostor: PhysicsImpostor): void;
  93939. /**
  93940. * Add a joint to the physics engine
  93941. * @param mainImpostor defines the main impostor to which the joint is added.
  93942. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  93943. * @param joint defines the joint that will connect both impostors.
  93944. */
  93945. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  93946. /**
  93947. * Removes a joint from the simulation
  93948. * @param mainImpostor defines the impostor used with the joint
  93949. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  93950. * @param joint defines the joint to remove
  93951. */
  93952. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  93953. /**
  93954. * Gets the current plugin used to run the simulation
  93955. * @returns current plugin
  93956. */
  93957. getPhysicsPlugin(): IPhysicsEnginePlugin;
  93958. /**
  93959. * Gets the list of physic impostors
  93960. * @returns an array of PhysicsImpostor
  93961. */
  93962. getImpostors(): Array<PhysicsImpostor>;
  93963. /**
  93964. * Gets the impostor for a physics enabled object
  93965. * @param object defines the object impersonated by the impostor
  93966. * @returns the PhysicsImpostor or null if not found
  93967. */
  93968. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  93969. /**
  93970. * Gets the impostor for a physics body object
  93971. * @param body defines physics body used by the impostor
  93972. * @returns the PhysicsImpostor or null if not found
  93973. */
  93974. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  93975. /**
  93976. * Does a raycast in the physics world
  93977. * @param from when should the ray start?
  93978. * @param to when should the ray end?
  93979. * @returns PhysicsRaycastResult
  93980. */
  93981. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  93982. /**
  93983. * Called by the scene. No need to call it.
  93984. * @param delta defines the timespam between frames
  93985. */
  93986. _step(delta: number): void;
  93987. }
  93988. }
  93989. declare module BABYLON {
  93990. /**
  93991. * The interface for the physics imposter parameters
  93992. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  93993. */
  93994. export interface PhysicsImpostorParameters {
  93995. /**
  93996. * The mass of the physics imposter
  93997. */
  93998. mass: number;
  93999. /**
  94000. * The friction of the physics imposter
  94001. */
  94002. friction?: number;
  94003. /**
  94004. * The coefficient of restitution of the physics imposter
  94005. */
  94006. restitution?: number;
  94007. /**
  94008. * The native options of the physics imposter
  94009. */
  94010. nativeOptions?: any;
  94011. /**
  94012. * Specifies if the parent should be ignored
  94013. */
  94014. ignoreParent?: boolean;
  94015. /**
  94016. * Specifies if bi-directional transformations should be disabled
  94017. */
  94018. disableBidirectionalTransformation?: boolean;
  94019. /**
  94020. * The pressure inside the physics imposter, soft object only
  94021. */
  94022. pressure?: number;
  94023. /**
  94024. * The stiffness the physics imposter, soft object only
  94025. */
  94026. stiffness?: number;
  94027. /**
  94028. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  94029. */
  94030. velocityIterations?: number;
  94031. /**
  94032. * The number of iterations used in maintaining consistent vertex positions, soft object only
  94033. */
  94034. positionIterations?: number;
  94035. /**
  94036. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  94037. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  94038. * Add to fix multiple points
  94039. */
  94040. fixedPoints?: number;
  94041. /**
  94042. * The collision margin around a soft object
  94043. */
  94044. margin?: number;
  94045. /**
  94046. * The collision margin around a soft object
  94047. */
  94048. damping?: number;
  94049. /**
  94050. * The path for a rope based on an extrusion
  94051. */
  94052. path?: any;
  94053. /**
  94054. * The shape of an extrusion used for a rope based on an extrusion
  94055. */
  94056. shape?: any;
  94057. }
  94058. /**
  94059. * Interface for a physics-enabled object
  94060. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94061. */
  94062. export interface IPhysicsEnabledObject {
  94063. /**
  94064. * The position of the physics-enabled object
  94065. */
  94066. position: Vector3;
  94067. /**
  94068. * The rotation of the physics-enabled object
  94069. */
  94070. rotationQuaternion: Nullable<Quaternion>;
  94071. /**
  94072. * The scale of the physics-enabled object
  94073. */
  94074. scaling: Vector3;
  94075. /**
  94076. * The rotation of the physics-enabled object
  94077. */
  94078. rotation?: Vector3;
  94079. /**
  94080. * The parent of the physics-enabled object
  94081. */
  94082. parent?: any;
  94083. /**
  94084. * The bounding info of the physics-enabled object
  94085. * @returns The bounding info of the physics-enabled object
  94086. */
  94087. getBoundingInfo(): BoundingInfo;
  94088. /**
  94089. * Computes the world matrix
  94090. * @param force Specifies if the world matrix should be computed by force
  94091. * @returns A world matrix
  94092. */
  94093. computeWorldMatrix(force: boolean): Matrix;
  94094. /**
  94095. * Gets the world matrix
  94096. * @returns A world matrix
  94097. */
  94098. getWorldMatrix?(): Matrix;
  94099. /**
  94100. * Gets the child meshes
  94101. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  94102. * @returns An array of abstract meshes
  94103. */
  94104. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  94105. /**
  94106. * Gets the vertex data
  94107. * @param kind The type of vertex data
  94108. * @returns A nullable array of numbers, or a float32 array
  94109. */
  94110. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  94111. /**
  94112. * Gets the indices from the mesh
  94113. * @returns A nullable array of index arrays
  94114. */
  94115. getIndices?(): Nullable<IndicesArray>;
  94116. /**
  94117. * Gets the scene from the mesh
  94118. * @returns the indices array or null
  94119. */
  94120. getScene?(): Scene;
  94121. /**
  94122. * Gets the absolute position from the mesh
  94123. * @returns the absolute position
  94124. */
  94125. getAbsolutePosition(): Vector3;
  94126. /**
  94127. * Gets the absolute pivot point from the mesh
  94128. * @returns the absolute pivot point
  94129. */
  94130. getAbsolutePivotPoint(): Vector3;
  94131. /**
  94132. * Rotates the mesh
  94133. * @param axis The axis of rotation
  94134. * @param amount The amount of rotation
  94135. * @param space The space of the rotation
  94136. * @returns The rotation transform node
  94137. */
  94138. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  94139. /**
  94140. * Translates the mesh
  94141. * @param axis The axis of translation
  94142. * @param distance The distance of translation
  94143. * @param space The space of the translation
  94144. * @returns The transform node
  94145. */
  94146. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  94147. /**
  94148. * Sets the absolute position of the mesh
  94149. * @param absolutePosition The absolute position of the mesh
  94150. * @returns The transform node
  94151. */
  94152. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  94153. /**
  94154. * Gets the class name of the mesh
  94155. * @returns The class name
  94156. */
  94157. getClassName(): string;
  94158. }
  94159. /**
  94160. * Represents a physics imposter
  94161. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94162. */
  94163. export class PhysicsImpostor {
  94164. /**
  94165. * The physics-enabled object used as the physics imposter
  94166. */
  94167. object: IPhysicsEnabledObject;
  94168. /**
  94169. * The type of the physics imposter
  94170. */
  94171. type: number;
  94172. private _options;
  94173. private _scene?;
  94174. /**
  94175. * The default object size of the imposter
  94176. */
  94177. static DEFAULT_OBJECT_SIZE: Vector3;
  94178. /**
  94179. * The identity quaternion of the imposter
  94180. */
  94181. static IDENTITY_QUATERNION: Quaternion;
  94182. /** @hidden */
  94183. _pluginData: any;
  94184. private _physicsEngine;
  94185. private _physicsBody;
  94186. private _bodyUpdateRequired;
  94187. private _onBeforePhysicsStepCallbacks;
  94188. private _onAfterPhysicsStepCallbacks;
  94189. /** @hidden */
  94190. _onPhysicsCollideCallbacks: Array<{
  94191. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  94192. otherImpostors: Array<PhysicsImpostor>;
  94193. }>;
  94194. private _deltaPosition;
  94195. private _deltaRotation;
  94196. private _deltaRotationConjugated;
  94197. /** @hidden */
  94198. _isFromLine: boolean;
  94199. private _parent;
  94200. private _isDisposed;
  94201. private static _tmpVecs;
  94202. private static _tmpQuat;
  94203. /**
  94204. * Specifies if the physics imposter is disposed
  94205. */
  94206. get isDisposed(): boolean;
  94207. /**
  94208. * Gets the mass of the physics imposter
  94209. */
  94210. get mass(): number;
  94211. set mass(value: number);
  94212. /**
  94213. * Gets the coefficient of friction
  94214. */
  94215. get friction(): number;
  94216. /**
  94217. * Sets the coefficient of friction
  94218. */
  94219. set friction(value: number);
  94220. /**
  94221. * Gets the coefficient of restitution
  94222. */
  94223. get restitution(): number;
  94224. /**
  94225. * Sets the coefficient of restitution
  94226. */
  94227. set restitution(value: number);
  94228. /**
  94229. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  94230. */
  94231. get pressure(): number;
  94232. /**
  94233. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  94234. */
  94235. set pressure(value: number);
  94236. /**
  94237. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  94238. */
  94239. get stiffness(): number;
  94240. /**
  94241. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  94242. */
  94243. set stiffness(value: number);
  94244. /**
  94245. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  94246. */
  94247. get velocityIterations(): number;
  94248. /**
  94249. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  94250. */
  94251. set velocityIterations(value: number);
  94252. /**
  94253. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  94254. */
  94255. get positionIterations(): number;
  94256. /**
  94257. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  94258. */
  94259. set positionIterations(value: number);
  94260. /**
  94261. * The unique id of the physics imposter
  94262. * set by the physics engine when adding this impostor to the array
  94263. */
  94264. uniqueId: number;
  94265. /**
  94266. * @hidden
  94267. */
  94268. soft: boolean;
  94269. /**
  94270. * @hidden
  94271. */
  94272. segments: number;
  94273. private _joints;
  94274. /**
  94275. * Initializes the physics imposter
  94276. * @param object The physics-enabled object used as the physics imposter
  94277. * @param type The type of the physics imposter
  94278. * @param _options The options for the physics imposter
  94279. * @param _scene The Babylon scene
  94280. */
  94281. constructor(
  94282. /**
  94283. * The physics-enabled object used as the physics imposter
  94284. */
  94285. object: IPhysicsEnabledObject,
  94286. /**
  94287. * The type of the physics imposter
  94288. */
  94289. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  94290. /**
  94291. * This function will completly initialize this impostor.
  94292. * It will create a new body - but only if this mesh has no parent.
  94293. * If it has, this impostor will not be used other than to define the impostor
  94294. * of the child mesh.
  94295. * @hidden
  94296. */
  94297. _init(): void;
  94298. private _getPhysicsParent;
  94299. /**
  94300. * Should a new body be generated.
  94301. * @returns boolean specifying if body initialization is required
  94302. */
  94303. isBodyInitRequired(): boolean;
  94304. /**
  94305. * Sets the updated scaling
  94306. * @param updated Specifies if the scaling is updated
  94307. */
  94308. setScalingUpdated(): void;
  94309. /**
  94310. * Force a regeneration of this or the parent's impostor's body.
  94311. * Use under cautious - This will remove all joints already implemented.
  94312. */
  94313. forceUpdate(): void;
  94314. /**
  94315. * Gets the body that holds this impostor. Either its own, or its parent.
  94316. */
  94317. get physicsBody(): any;
  94318. /**
  94319. * Get the parent of the physics imposter
  94320. * @returns Physics imposter or null
  94321. */
  94322. get parent(): Nullable<PhysicsImpostor>;
  94323. /**
  94324. * Sets the parent of the physics imposter
  94325. */
  94326. set parent(value: Nullable<PhysicsImpostor>);
  94327. /**
  94328. * Set the physics body. Used mainly by the physics engine/plugin
  94329. */
  94330. set physicsBody(physicsBody: any);
  94331. /**
  94332. * Resets the update flags
  94333. */
  94334. resetUpdateFlags(): void;
  94335. /**
  94336. * Gets the object extend size
  94337. * @returns the object extend size
  94338. */
  94339. getObjectExtendSize(): Vector3;
  94340. /**
  94341. * Gets the object center
  94342. * @returns The object center
  94343. */
  94344. getObjectCenter(): Vector3;
  94345. /**
  94346. * Get a specific parametes from the options parameter
  94347. * @param paramName The object parameter name
  94348. * @returns The object parameter
  94349. */
  94350. getParam(paramName: string): any;
  94351. /**
  94352. * Sets a specific parameter in the options given to the physics plugin
  94353. * @param paramName The parameter name
  94354. * @param value The value of the parameter
  94355. */
  94356. setParam(paramName: string, value: number): void;
  94357. /**
  94358. * Specifically change the body's mass option. Won't recreate the physics body object
  94359. * @param mass The mass of the physics imposter
  94360. */
  94361. setMass(mass: number): void;
  94362. /**
  94363. * Gets the linear velocity
  94364. * @returns linear velocity or null
  94365. */
  94366. getLinearVelocity(): Nullable<Vector3>;
  94367. /**
  94368. * Sets the linear velocity
  94369. * @param velocity linear velocity or null
  94370. */
  94371. setLinearVelocity(velocity: Nullable<Vector3>): void;
  94372. /**
  94373. * Gets the angular velocity
  94374. * @returns angular velocity or null
  94375. */
  94376. getAngularVelocity(): Nullable<Vector3>;
  94377. /**
  94378. * Sets the angular velocity
  94379. * @param velocity The velocity or null
  94380. */
  94381. setAngularVelocity(velocity: Nullable<Vector3>): void;
  94382. /**
  94383. * Execute a function with the physics plugin native code
  94384. * Provide a function the will have two variables - the world object and the physics body object
  94385. * @param func The function to execute with the physics plugin native code
  94386. */
  94387. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  94388. /**
  94389. * Register a function that will be executed before the physics world is stepping forward
  94390. * @param func The function to execute before the physics world is stepped forward
  94391. */
  94392. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  94393. /**
  94394. * Unregister a function that will be executed before the physics world is stepping forward
  94395. * @param func The function to execute before the physics world is stepped forward
  94396. */
  94397. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  94398. /**
  94399. * Register a function that will be executed after the physics step
  94400. * @param func The function to execute after physics step
  94401. */
  94402. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  94403. /**
  94404. * Unregisters a function that will be executed after the physics step
  94405. * @param func The function to execute after physics step
  94406. */
  94407. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  94408. /**
  94409. * register a function that will be executed when this impostor collides against a different body
  94410. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  94411. * @param func Callback that is executed on collision
  94412. */
  94413. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  94414. /**
  94415. * Unregisters the physics imposter on contact
  94416. * @param collideAgainst The physics object to collide against
  94417. * @param func Callback to execute on collision
  94418. */
  94419. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  94420. private _tmpQuat;
  94421. private _tmpQuat2;
  94422. /**
  94423. * Get the parent rotation
  94424. * @returns The parent rotation
  94425. */
  94426. getParentsRotation(): Quaternion;
  94427. /**
  94428. * this function is executed by the physics engine.
  94429. */
  94430. beforeStep: () => void;
  94431. /**
  94432. * this function is executed by the physics engine
  94433. */
  94434. afterStep: () => void;
  94435. /**
  94436. * Legacy collision detection event support
  94437. */
  94438. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  94439. /**
  94440. * event and body object due to cannon's event-based architecture.
  94441. */
  94442. onCollide: (e: {
  94443. body: any;
  94444. }) => void;
  94445. /**
  94446. * Apply a force
  94447. * @param force The force to apply
  94448. * @param contactPoint The contact point for the force
  94449. * @returns The physics imposter
  94450. */
  94451. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  94452. /**
  94453. * Apply an impulse
  94454. * @param force The impulse force
  94455. * @param contactPoint The contact point for the impulse force
  94456. * @returns The physics imposter
  94457. */
  94458. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  94459. /**
  94460. * A help function to create a joint
  94461. * @param otherImpostor A physics imposter used to create a joint
  94462. * @param jointType The type of joint
  94463. * @param jointData The data for the joint
  94464. * @returns The physics imposter
  94465. */
  94466. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  94467. /**
  94468. * Add a joint to this impostor with a different impostor
  94469. * @param otherImpostor A physics imposter used to add a joint
  94470. * @param joint The joint to add
  94471. * @returns The physics imposter
  94472. */
  94473. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  94474. /**
  94475. * Add an anchor to a cloth impostor
  94476. * @param otherImpostor rigid impostor to anchor to
  94477. * @param width ratio across width from 0 to 1
  94478. * @param height ratio up height from 0 to 1
  94479. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  94480. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  94481. * @returns impostor the soft imposter
  94482. */
  94483. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  94484. /**
  94485. * Add a hook to a rope impostor
  94486. * @param otherImpostor rigid impostor to anchor to
  94487. * @param length ratio across rope from 0 to 1
  94488. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  94489. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  94490. * @returns impostor the rope imposter
  94491. */
  94492. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  94493. /**
  94494. * Will keep this body still, in a sleep mode.
  94495. * @returns the physics imposter
  94496. */
  94497. sleep(): PhysicsImpostor;
  94498. /**
  94499. * Wake the body up.
  94500. * @returns The physics imposter
  94501. */
  94502. wakeUp(): PhysicsImpostor;
  94503. /**
  94504. * Clones the physics imposter
  94505. * @param newObject The physics imposter clones to this physics-enabled object
  94506. * @returns A nullable physics imposter
  94507. */
  94508. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  94509. /**
  94510. * Disposes the physics imposter
  94511. */
  94512. dispose(): void;
  94513. /**
  94514. * Sets the delta position
  94515. * @param position The delta position amount
  94516. */
  94517. setDeltaPosition(position: Vector3): void;
  94518. /**
  94519. * Sets the delta rotation
  94520. * @param rotation The delta rotation amount
  94521. */
  94522. setDeltaRotation(rotation: Quaternion): void;
  94523. /**
  94524. * Gets the box size of the physics imposter and stores the result in the input parameter
  94525. * @param result Stores the box size
  94526. * @returns The physics imposter
  94527. */
  94528. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  94529. /**
  94530. * Gets the radius of the physics imposter
  94531. * @returns Radius of the physics imposter
  94532. */
  94533. getRadius(): number;
  94534. /**
  94535. * Sync a bone with this impostor
  94536. * @param bone The bone to sync to the impostor.
  94537. * @param boneMesh The mesh that the bone is influencing.
  94538. * @param jointPivot The pivot of the joint / bone in local space.
  94539. * @param distToJoint Optional distance from the impostor to the joint.
  94540. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  94541. */
  94542. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  94543. /**
  94544. * Sync impostor to a bone
  94545. * @param bone The bone that the impostor will be synced to.
  94546. * @param boneMesh The mesh that the bone is influencing.
  94547. * @param jointPivot The pivot of the joint / bone in local space.
  94548. * @param distToJoint Optional distance from the impostor to the joint.
  94549. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  94550. * @param boneAxis Optional vector3 axis the bone is aligned with
  94551. */
  94552. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  94553. /**
  94554. * No-Imposter type
  94555. */
  94556. static NoImpostor: number;
  94557. /**
  94558. * Sphere-Imposter type
  94559. */
  94560. static SphereImpostor: number;
  94561. /**
  94562. * Box-Imposter type
  94563. */
  94564. static BoxImpostor: number;
  94565. /**
  94566. * Plane-Imposter type
  94567. */
  94568. static PlaneImpostor: number;
  94569. /**
  94570. * Mesh-imposter type
  94571. */
  94572. static MeshImpostor: number;
  94573. /**
  94574. * Capsule-Impostor type (Ammo.js plugin only)
  94575. */
  94576. static CapsuleImpostor: number;
  94577. /**
  94578. * Cylinder-Imposter type
  94579. */
  94580. static CylinderImpostor: number;
  94581. /**
  94582. * Particle-Imposter type
  94583. */
  94584. static ParticleImpostor: number;
  94585. /**
  94586. * Heightmap-Imposter type
  94587. */
  94588. static HeightmapImpostor: number;
  94589. /**
  94590. * ConvexHull-Impostor type (Ammo.js plugin only)
  94591. */
  94592. static ConvexHullImpostor: number;
  94593. /**
  94594. * Custom-Imposter type (Ammo.js plugin only)
  94595. */
  94596. static CustomImpostor: number;
  94597. /**
  94598. * Rope-Imposter type
  94599. */
  94600. static RopeImpostor: number;
  94601. /**
  94602. * Cloth-Imposter type
  94603. */
  94604. static ClothImpostor: number;
  94605. /**
  94606. * Softbody-Imposter type
  94607. */
  94608. static SoftbodyImpostor: number;
  94609. }
  94610. }
  94611. declare module BABYLON {
  94612. /**
  94613. * @hidden
  94614. **/
  94615. export class _CreationDataStorage {
  94616. closePath?: boolean;
  94617. closeArray?: boolean;
  94618. idx: number[];
  94619. dashSize: number;
  94620. gapSize: number;
  94621. path3D: Path3D;
  94622. pathArray: Vector3[][];
  94623. arc: number;
  94624. radius: number;
  94625. cap: number;
  94626. tessellation: number;
  94627. }
  94628. /**
  94629. * @hidden
  94630. **/
  94631. class _InstanceDataStorage {
  94632. visibleInstances: any;
  94633. batchCache: _InstancesBatch;
  94634. instancesBufferSize: number;
  94635. instancesBuffer: Nullable<Buffer>;
  94636. instancesData: Float32Array;
  94637. overridenInstanceCount: number;
  94638. isFrozen: boolean;
  94639. previousBatch: Nullable<_InstancesBatch>;
  94640. hardwareInstancedRendering: boolean;
  94641. sideOrientation: number;
  94642. manualUpdate: boolean;
  94643. }
  94644. /**
  94645. * @hidden
  94646. **/
  94647. export class _InstancesBatch {
  94648. mustReturn: boolean;
  94649. visibleInstances: Nullable<InstancedMesh[]>[];
  94650. renderSelf: boolean[];
  94651. hardwareInstancedRendering: boolean[];
  94652. }
  94653. /**
  94654. * Class used to represent renderable models
  94655. */
  94656. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  94657. /**
  94658. * Mesh side orientation : usually the external or front surface
  94659. */
  94660. static readonly FRONTSIDE: number;
  94661. /**
  94662. * Mesh side orientation : usually the internal or back surface
  94663. */
  94664. static readonly BACKSIDE: number;
  94665. /**
  94666. * Mesh side orientation : both internal and external or front and back surfaces
  94667. */
  94668. static readonly DOUBLESIDE: number;
  94669. /**
  94670. * Mesh side orientation : by default, `FRONTSIDE`
  94671. */
  94672. static readonly DEFAULTSIDE: number;
  94673. /**
  94674. * Mesh cap setting : no cap
  94675. */
  94676. static readonly NO_CAP: number;
  94677. /**
  94678. * Mesh cap setting : one cap at the beginning of the mesh
  94679. */
  94680. static readonly CAP_START: number;
  94681. /**
  94682. * Mesh cap setting : one cap at the end of the mesh
  94683. */
  94684. static readonly CAP_END: number;
  94685. /**
  94686. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  94687. */
  94688. static readonly CAP_ALL: number;
  94689. /**
  94690. * Mesh pattern setting : no flip or rotate
  94691. */
  94692. static readonly NO_FLIP: number;
  94693. /**
  94694. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  94695. */
  94696. static readonly FLIP_TILE: number;
  94697. /**
  94698. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  94699. */
  94700. static readonly ROTATE_TILE: number;
  94701. /**
  94702. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  94703. */
  94704. static readonly FLIP_ROW: number;
  94705. /**
  94706. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  94707. */
  94708. static readonly ROTATE_ROW: number;
  94709. /**
  94710. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  94711. */
  94712. static readonly FLIP_N_ROTATE_TILE: number;
  94713. /**
  94714. * Mesh pattern setting : rotate pattern and rotate
  94715. */
  94716. static readonly FLIP_N_ROTATE_ROW: number;
  94717. /**
  94718. * Mesh tile positioning : part tiles same on left/right or top/bottom
  94719. */
  94720. static readonly CENTER: number;
  94721. /**
  94722. * Mesh tile positioning : part tiles on left
  94723. */
  94724. static readonly LEFT: number;
  94725. /**
  94726. * Mesh tile positioning : part tiles on right
  94727. */
  94728. static readonly RIGHT: number;
  94729. /**
  94730. * Mesh tile positioning : part tiles on top
  94731. */
  94732. static readonly TOP: number;
  94733. /**
  94734. * Mesh tile positioning : part tiles on bottom
  94735. */
  94736. static readonly BOTTOM: number;
  94737. /**
  94738. * Gets the default side orientation.
  94739. * @param orientation the orientation to value to attempt to get
  94740. * @returns the default orientation
  94741. * @hidden
  94742. */
  94743. static _GetDefaultSideOrientation(orientation?: number): number;
  94744. private _internalMeshDataInfo;
  94745. /**
  94746. * An event triggered before rendering the mesh
  94747. */
  94748. get onBeforeRenderObservable(): Observable<Mesh>;
  94749. /**
  94750. * An event triggered before binding the mesh
  94751. */
  94752. get onBeforeBindObservable(): Observable<Mesh>;
  94753. /**
  94754. * An event triggered after rendering the mesh
  94755. */
  94756. get onAfterRenderObservable(): Observable<Mesh>;
  94757. /**
  94758. * An event triggered before drawing the mesh
  94759. */
  94760. get onBeforeDrawObservable(): Observable<Mesh>;
  94761. private _onBeforeDrawObserver;
  94762. /**
  94763. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  94764. */
  94765. set onBeforeDraw(callback: () => void);
  94766. get hasInstances(): boolean;
  94767. /**
  94768. * Gets the delay loading state of the mesh (when delay loading is turned on)
  94769. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  94770. */
  94771. delayLoadState: number;
  94772. /**
  94773. * Gets the list of instances created from this mesh
  94774. * it is not supposed to be modified manually.
  94775. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  94776. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  94777. */
  94778. instances: InstancedMesh[];
  94779. /**
  94780. * Gets the file containing delay loading data for this mesh
  94781. */
  94782. delayLoadingFile: string;
  94783. /** @hidden */
  94784. _binaryInfo: any;
  94785. /**
  94786. * User defined function used to change how LOD level selection is done
  94787. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  94788. */
  94789. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  94790. /**
  94791. * Gets or sets the morph target manager
  94792. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  94793. */
  94794. get morphTargetManager(): Nullable<MorphTargetManager>;
  94795. set morphTargetManager(value: Nullable<MorphTargetManager>);
  94796. /** @hidden */
  94797. _creationDataStorage: Nullable<_CreationDataStorage>;
  94798. /** @hidden */
  94799. _geometry: Nullable<Geometry>;
  94800. /** @hidden */
  94801. _delayInfo: Array<string>;
  94802. /** @hidden */
  94803. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  94804. /** @hidden */
  94805. _instanceDataStorage: _InstanceDataStorage;
  94806. private _effectiveMaterial;
  94807. /** @hidden */
  94808. _shouldGenerateFlatShading: boolean;
  94809. /** @hidden */
  94810. _originalBuilderSideOrientation: number;
  94811. /**
  94812. * Use this property to change the original side orientation defined at construction time
  94813. */
  94814. overrideMaterialSideOrientation: Nullable<number>;
  94815. /**
  94816. * Gets the source mesh (the one used to clone this one from)
  94817. */
  94818. get source(): Nullable<Mesh>;
  94819. /**
  94820. * Gets or sets a boolean indicating that this mesh does not use index buffer
  94821. */
  94822. get isUnIndexed(): boolean;
  94823. set isUnIndexed(value: boolean);
  94824. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  94825. get worldMatrixInstancedBuffer(): Float32Array;
  94826. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  94827. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  94828. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  94829. /**
  94830. * @constructor
  94831. * @param name The value used by scene.getMeshByName() to do a lookup.
  94832. * @param scene The scene to add this mesh to.
  94833. * @param parent The parent of this mesh, if it has one
  94834. * @param source An optional Mesh from which geometry is shared, cloned.
  94835. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  94836. * When false, achieved by calling a clone(), also passing False.
  94837. * This will make creation of children, recursive.
  94838. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  94839. */
  94840. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  94841. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  94842. doNotInstantiate: boolean;
  94843. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  94844. /**
  94845. * Gets the class name
  94846. * @returns the string "Mesh".
  94847. */
  94848. getClassName(): string;
  94849. /** @hidden */
  94850. get _isMesh(): boolean;
  94851. /**
  94852. * Returns a description of this mesh
  94853. * @param fullDetails define if full details about this mesh must be used
  94854. * @returns a descriptive string representing this mesh
  94855. */
  94856. toString(fullDetails?: boolean): string;
  94857. /** @hidden */
  94858. _unBindEffect(): void;
  94859. /**
  94860. * Gets a boolean indicating if this mesh has LOD
  94861. */
  94862. get hasLODLevels(): boolean;
  94863. /**
  94864. * Gets the list of MeshLODLevel associated with the current mesh
  94865. * @returns an array of MeshLODLevel
  94866. */
  94867. getLODLevels(): MeshLODLevel[];
  94868. private _sortLODLevels;
  94869. /**
  94870. * Add a mesh as LOD level triggered at the given distance.
  94871. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94872. * @param distance The distance from the center of the object to show this level
  94873. * @param mesh The mesh to be added as LOD level (can be null)
  94874. * @return This mesh (for chaining)
  94875. */
  94876. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  94877. /**
  94878. * Returns the LOD level mesh at the passed distance or null if not found.
  94879. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94880. * @param distance The distance from the center of the object to show this level
  94881. * @returns a Mesh or `null`
  94882. */
  94883. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  94884. /**
  94885. * Remove a mesh from the LOD array
  94886. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94887. * @param mesh defines the mesh to be removed
  94888. * @return This mesh (for chaining)
  94889. */
  94890. removeLODLevel(mesh: Mesh): Mesh;
  94891. /**
  94892. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  94893. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  94894. * @param camera defines the camera to use to compute distance
  94895. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  94896. * @return This mesh (for chaining)
  94897. */
  94898. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  94899. /**
  94900. * Gets the mesh internal Geometry object
  94901. */
  94902. get geometry(): Nullable<Geometry>;
  94903. /**
  94904. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  94905. * @returns the total number of vertices
  94906. */
  94907. getTotalVertices(): number;
  94908. /**
  94909. * Returns the content of an associated vertex buffer
  94910. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  94911. * - VertexBuffer.PositionKind
  94912. * - VertexBuffer.UVKind
  94913. * - VertexBuffer.UV2Kind
  94914. * - VertexBuffer.UV3Kind
  94915. * - VertexBuffer.UV4Kind
  94916. * - VertexBuffer.UV5Kind
  94917. * - VertexBuffer.UV6Kind
  94918. * - VertexBuffer.ColorKind
  94919. * - VertexBuffer.MatricesIndicesKind
  94920. * - VertexBuffer.MatricesIndicesExtraKind
  94921. * - VertexBuffer.MatricesWeightsKind
  94922. * - VertexBuffer.MatricesWeightsExtraKind
  94923. * @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
  94924. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  94925. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  94926. */
  94927. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  94928. /**
  94929. * Returns the mesh VertexBuffer object from the requested `kind`
  94930. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  94931. * - VertexBuffer.PositionKind
  94932. * - VertexBuffer.NormalKind
  94933. * - VertexBuffer.UVKind
  94934. * - VertexBuffer.UV2Kind
  94935. * - VertexBuffer.UV3Kind
  94936. * - VertexBuffer.UV4Kind
  94937. * - VertexBuffer.UV5Kind
  94938. * - VertexBuffer.UV6Kind
  94939. * - VertexBuffer.ColorKind
  94940. * - VertexBuffer.MatricesIndicesKind
  94941. * - VertexBuffer.MatricesIndicesExtraKind
  94942. * - VertexBuffer.MatricesWeightsKind
  94943. * - VertexBuffer.MatricesWeightsExtraKind
  94944. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  94945. */
  94946. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  94947. /**
  94948. * Tests if a specific vertex buffer is associated with this mesh
  94949. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  94950. * - VertexBuffer.PositionKind
  94951. * - VertexBuffer.NormalKind
  94952. * - VertexBuffer.UVKind
  94953. * - VertexBuffer.UV2Kind
  94954. * - VertexBuffer.UV3Kind
  94955. * - VertexBuffer.UV4Kind
  94956. * - VertexBuffer.UV5Kind
  94957. * - VertexBuffer.UV6Kind
  94958. * - VertexBuffer.ColorKind
  94959. * - VertexBuffer.MatricesIndicesKind
  94960. * - VertexBuffer.MatricesIndicesExtraKind
  94961. * - VertexBuffer.MatricesWeightsKind
  94962. * - VertexBuffer.MatricesWeightsExtraKind
  94963. * @returns a boolean
  94964. */
  94965. isVerticesDataPresent(kind: string): boolean;
  94966. /**
  94967. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  94968. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  94969. * - VertexBuffer.PositionKind
  94970. * - VertexBuffer.UVKind
  94971. * - VertexBuffer.UV2Kind
  94972. * - VertexBuffer.UV3Kind
  94973. * - VertexBuffer.UV4Kind
  94974. * - VertexBuffer.UV5Kind
  94975. * - VertexBuffer.UV6Kind
  94976. * - VertexBuffer.ColorKind
  94977. * - VertexBuffer.MatricesIndicesKind
  94978. * - VertexBuffer.MatricesIndicesExtraKind
  94979. * - VertexBuffer.MatricesWeightsKind
  94980. * - VertexBuffer.MatricesWeightsExtraKind
  94981. * @returns a boolean
  94982. */
  94983. isVertexBufferUpdatable(kind: string): boolean;
  94984. /**
  94985. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  94986. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  94987. * - VertexBuffer.PositionKind
  94988. * - VertexBuffer.NormalKind
  94989. * - VertexBuffer.UVKind
  94990. * - VertexBuffer.UV2Kind
  94991. * - VertexBuffer.UV3Kind
  94992. * - VertexBuffer.UV4Kind
  94993. * - VertexBuffer.UV5Kind
  94994. * - VertexBuffer.UV6Kind
  94995. * - VertexBuffer.ColorKind
  94996. * - VertexBuffer.MatricesIndicesKind
  94997. * - VertexBuffer.MatricesIndicesExtraKind
  94998. * - VertexBuffer.MatricesWeightsKind
  94999. * - VertexBuffer.MatricesWeightsExtraKind
  95000. * @returns an array of strings
  95001. */
  95002. getVerticesDataKinds(): string[];
  95003. /**
  95004. * Returns a positive integer : the total number of indices in this mesh geometry.
  95005. * @returns the numner of indices or zero if the mesh has no geometry.
  95006. */
  95007. getTotalIndices(): number;
  95008. /**
  95009. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95010. * @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.
  95011. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95012. * @returns the indices array or an empty array if the mesh has no geometry
  95013. */
  95014. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95015. get isBlocked(): boolean;
  95016. /**
  95017. * Determine if the current mesh is ready to be rendered
  95018. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  95019. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  95020. * @returns true if all associated assets are ready (material, textures, shaders)
  95021. */
  95022. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  95023. /**
  95024. * 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.
  95025. */
  95026. get areNormalsFrozen(): boolean;
  95027. /**
  95028. * 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.
  95029. * @returns the current mesh
  95030. */
  95031. freezeNormals(): Mesh;
  95032. /**
  95033. * 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
  95034. * @returns the current mesh
  95035. */
  95036. unfreezeNormals(): Mesh;
  95037. /**
  95038. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  95039. */
  95040. set overridenInstanceCount(count: number);
  95041. /** @hidden */
  95042. _preActivate(): Mesh;
  95043. /** @hidden */
  95044. _preActivateForIntermediateRendering(renderId: number): Mesh;
  95045. /** @hidden */
  95046. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  95047. /**
  95048. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  95049. * This means the mesh underlying bounding box and sphere are recomputed.
  95050. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  95051. * @returns the current mesh
  95052. */
  95053. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  95054. /** @hidden */
  95055. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  95056. /**
  95057. * This function will subdivide the mesh into multiple submeshes
  95058. * @param count defines the expected number of submeshes
  95059. */
  95060. subdivide(count: number): void;
  95061. /**
  95062. * Copy a FloatArray into a specific associated vertex buffer
  95063. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95064. * - VertexBuffer.PositionKind
  95065. * - VertexBuffer.UVKind
  95066. * - VertexBuffer.UV2Kind
  95067. * - VertexBuffer.UV3Kind
  95068. * - VertexBuffer.UV4Kind
  95069. * - VertexBuffer.UV5Kind
  95070. * - VertexBuffer.UV6Kind
  95071. * - VertexBuffer.ColorKind
  95072. * - VertexBuffer.MatricesIndicesKind
  95073. * - VertexBuffer.MatricesIndicesExtraKind
  95074. * - VertexBuffer.MatricesWeightsKind
  95075. * - VertexBuffer.MatricesWeightsExtraKind
  95076. * @param data defines the data source
  95077. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  95078. * @param stride defines the data stride size (can be null)
  95079. * @returns the current mesh
  95080. */
  95081. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  95082. /**
  95083. * Delete a vertex buffer associated with this mesh
  95084. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  95085. * - VertexBuffer.PositionKind
  95086. * - VertexBuffer.UVKind
  95087. * - VertexBuffer.UV2Kind
  95088. * - VertexBuffer.UV3Kind
  95089. * - VertexBuffer.UV4Kind
  95090. * - VertexBuffer.UV5Kind
  95091. * - VertexBuffer.UV6Kind
  95092. * - VertexBuffer.ColorKind
  95093. * - VertexBuffer.MatricesIndicesKind
  95094. * - VertexBuffer.MatricesIndicesExtraKind
  95095. * - VertexBuffer.MatricesWeightsKind
  95096. * - VertexBuffer.MatricesWeightsExtraKind
  95097. */
  95098. removeVerticesData(kind: string): void;
  95099. /**
  95100. * Flags an associated vertex buffer as updatable
  95101. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  95102. * - VertexBuffer.PositionKind
  95103. * - VertexBuffer.UVKind
  95104. * - VertexBuffer.UV2Kind
  95105. * - VertexBuffer.UV3Kind
  95106. * - VertexBuffer.UV4Kind
  95107. * - VertexBuffer.UV5Kind
  95108. * - VertexBuffer.UV6Kind
  95109. * - VertexBuffer.ColorKind
  95110. * - VertexBuffer.MatricesIndicesKind
  95111. * - VertexBuffer.MatricesIndicesExtraKind
  95112. * - VertexBuffer.MatricesWeightsKind
  95113. * - VertexBuffer.MatricesWeightsExtraKind
  95114. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  95115. */
  95116. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  95117. /**
  95118. * Sets the mesh global Vertex Buffer
  95119. * @param buffer defines the buffer to use
  95120. * @returns the current mesh
  95121. */
  95122. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  95123. /**
  95124. * Update a specific associated vertex buffer
  95125. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95126. * - VertexBuffer.PositionKind
  95127. * - VertexBuffer.UVKind
  95128. * - VertexBuffer.UV2Kind
  95129. * - VertexBuffer.UV3Kind
  95130. * - VertexBuffer.UV4Kind
  95131. * - VertexBuffer.UV5Kind
  95132. * - VertexBuffer.UV6Kind
  95133. * - VertexBuffer.ColorKind
  95134. * - VertexBuffer.MatricesIndicesKind
  95135. * - VertexBuffer.MatricesIndicesExtraKind
  95136. * - VertexBuffer.MatricesWeightsKind
  95137. * - VertexBuffer.MatricesWeightsExtraKind
  95138. * @param data defines the data source
  95139. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  95140. * @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)
  95141. * @returns the current mesh
  95142. */
  95143. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  95144. /**
  95145. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  95146. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  95147. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  95148. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  95149. * @returns the current mesh
  95150. */
  95151. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  95152. /**
  95153. * Creates a un-shared specific occurence of the geometry for the mesh.
  95154. * @returns the current mesh
  95155. */
  95156. makeGeometryUnique(): Mesh;
  95157. /**
  95158. * Set the index buffer of this mesh
  95159. * @param indices defines the source data
  95160. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  95161. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  95162. * @returns the current mesh
  95163. */
  95164. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  95165. /**
  95166. * Update the current index buffer
  95167. * @param indices defines the source data
  95168. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  95169. * @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)
  95170. * @returns the current mesh
  95171. */
  95172. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  95173. /**
  95174. * Invert the geometry to move from a right handed system to a left handed one.
  95175. * @returns the current mesh
  95176. */
  95177. toLeftHanded(): Mesh;
  95178. /** @hidden */
  95179. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  95180. /** @hidden */
  95181. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  95182. /**
  95183. * Registers for this mesh a javascript function called just before the rendering process
  95184. * @param func defines the function to call before rendering this mesh
  95185. * @returns the current mesh
  95186. */
  95187. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  95188. /**
  95189. * Disposes a previously registered javascript function called before the rendering
  95190. * @param func defines the function to remove
  95191. * @returns the current mesh
  95192. */
  95193. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  95194. /**
  95195. * Registers for this mesh a javascript function called just after the rendering is complete
  95196. * @param func defines the function to call after rendering this mesh
  95197. * @returns the current mesh
  95198. */
  95199. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  95200. /**
  95201. * Disposes a previously registered javascript function called after the rendering.
  95202. * @param func defines the function to remove
  95203. * @returns the current mesh
  95204. */
  95205. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  95206. /** @hidden */
  95207. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  95208. /** @hidden */
  95209. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  95210. /** @hidden */
  95211. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  95212. /** @hidden */
  95213. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  95214. /** @hidden */
  95215. _rebuild(): void;
  95216. /** @hidden */
  95217. _freeze(): void;
  95218. /** @hidden */
  95219. _unFreeze(): void;
  95220. /**
  95221. * 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
  95222. * @param subMesh defines the subMesh to render
  95223. * @param enableAlphaMode defines if alpha mode can be changed
  95224. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  95225. * @returns the current mesh
  95226. */
  95227. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  95228. private _onBeforeDraw;
  95229. /**
  95230. * Renormalize the mesh and patch it up if there are no weights
  95231. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  95232. * However in the case of zero weights then we set just a single influence to 1.
  95233. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  95234. */
  95235. cleanMatrixWeights(): void;
  95236. private normalizeSkinFourWeights;
  95237. private normalizeSkinWeightsAndExtra;
  95238. /**
  95239. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  95240. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  95241. * the user know there was an issue with importing the mesh
  95242. * @returns a validation object with skinned, valid and report string
  95243. */
  95244. validateSkinning(): {
  95245. skinned: boolean;
  95246. valid: boolean;
  95247. report: string;
  95248. };
  95249. /** @hidden */
  95250. _checkDelayState(): Mesh;
  95251. private _queueLoad;
  95252. /**
  95253. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  95254. * A mesh is in the frustum if its bounding box intersects the frustum
  95255. * @param frustumPlanes defines the frustum to test
  95256. * @returns true if the mesh is in the frustum planes
  95257. */
  95258. isInFrustum(frustumPlanes: Plane[]): boolean;
  95259. /**
  95260. * Sets the mesh material by the material or multiMaterial `id` property
  95261. * @param id is a string identifying the material or the multiMaterial
  95262. * @returns the current mesh
  95263. */
  95264. setMaterialByID(id: string): Mesh;
  95265. /**
  95266. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  95267. * @returns an array of IAnimatable
  95268. */
  95269. getAnimatables(): IAnimatable[];
  95270. /**
  95271. * Modifies the mesh geometry according to the passed transformation matrix.
  95272. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  95273. * The mesh normals are modified using the same transformation.
  95274. * Note that, under the hood, this method sets a new VertexBuffer each call.
  95275. * @param transform defines the transform matrix to use
  95276. * @see http://doc.babylonjs.com/resources/baking_transformations
  95277. * @returns the current mesh
  95278. */
  95279. bakeTransformIntoVertices(transform: Matrix): Mesh;
  95280. /**
  95281. * Modifies the mesh geometry according to its own current World Matrix.
  95282. * The mesh World Matrix is then reset.
  95283. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  95284. * Note that, under the hood, this method sets a new VertexBuffer each call.
  95285. * @see http://doc.babylonjs.com/resources/baking_transformations
  95286. * @returns the current mesh
  95287. */
  95288. bakeCurrentTransformIntoVertices(): Mesh;
  95289. /** @hidden */
  95290. get _positions(): Nullable<Vector3[]>;
  95291. /** @hidden */
  95292. _resetPointsArrayCache(): Mesh;
  95293. /** @hidden */
  95294. _generatePointsArray(): boolean;
  95295. /**
  95296. * Returns a new Mesh object generated from the current mesh properties.
  95297. * This method must not get confused with createInstance()
  95298. * @param name is a string, the name given to the new mesh
  95299. * @param newParent can be any Node object (default `null`)
  95300. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  95301. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  95302. * @returns a new mesh
  95303. */
  95304. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  95305. /**
  95306. * Releases resources associated with this mesh.
  95307. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95308. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95309. */
  95310. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95311. /** @hidden */
  95312. _disposeInstanceSpecificData(): void;
  95313. /**
  95314. * Modifies the mesh geometry according to a displacement map.
  95315. * 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.
  95316. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  95317. * @param url is a string, the URL from the image file is to be downloaded.
  95318. * @param minHeight is the lower limit of the displacement.
  95319. * @param maxHeight is the upper limit of the displacement.
  95320. * @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.
  95321. * @param uvOffset is an optional vector2 used to offset UV.
  95322. * @param uvScale is an optional vector2 used to scale UV.
  95323. * @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.
  95324. * @returns the Mesh.
  95325. */
  95326. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  95327. /**
  95328. * Modifies the mesh geometry according to a displacementMap buffer.
  95329. * 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.
  95330. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  95331. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  95332. * @param heightMapWidth is the width of the buffer image.
  95333. * @param heightMapHeight is the height of the buffer image.
  95334. * @param minHeight is the lower limit of the displacement.
  95335. * @param maxHeight is the upper limit of the displacement.
  95336. * @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.
  95337. * @param uvOffset is an optional vector2 used to offset UV.
  95338. * @param uvScale is an optional vector2 used to scale UV.
  95339. * @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.
  95340. * @returns the Mesh.
  95341. */
  95342. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  95343. /**
  95344. * Modify the mesh to get a flat shading rendering.
  95345. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  95346. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  95347. * @returns current mesh
  95348. */
  95349. convertToFlatShadedMesh(): Mesh;
  95350. /**
  95351. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  95352. * In other words, more vertices, no more indices and a single bigger VBO.
  95353. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  95354. * @returns current mesh
  95355. */
  95356. convertToUnIndexedMesh(): Mesh;
  95357. /**
  95358. * Inverses facet orientations.
  95359. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  95360. * @param flipNormals will also inverts the normals
  95361. * @returns current mesh
  95362. */
  95363. flipFaces(flipNormals?: boolean): Mesh;
  95364. /**
  95365. * Increase the number of facets and hence vertices in a mesh
  95366. * Vertex normals are interpolated from existing vertex normals
  95367. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  95368. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  95369. */
  95370. increaseVertices(numberPerEdge: number): void;
  95371. /**
  95372. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  95373. * This will undo any application of covertToFlatShadedMesh
  95374. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  95375. */
  95376. forceSharedVertices(): void;
  95377. /** @hidden */
  95378. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  95379. /** @hidden */
  95380. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  95381. /**
  95382. * Creates a new InstancedMesh object from the mesh model.
  95383. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  95384. * @param name defines the name of the new instance
  95385. * @returns a new InstancedMesh
  95386. */
  95387. createInstance(name: string): InstancedMesh;
  95388. /**
  95389. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  95390. * After this call, all the mesh instances have the same submeshes than the current mesh.
  95391. * @returns the current mesh
  95392. */
  95393. synchronizeInstances(): Mesh;
  95394. /**
  95395. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  95396. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  95397. * This should be used together with the simplification to avoid disappearing triangles.
  95398. * @param successCallback an optional success callback to be called after the optimization finished.
  95399. * @returns the current mesh
  95400. */
  95401. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  95402. /**
  95403. * Serialize current mesh
  95404. * @param serializationObject defines the object which will receive the serialization data
  95405. */
  95406. serialize(serializationObject: any): void;
  95407. /** @hidden */
  95408. _syncGeometryWithMorphTargetManager(): void;
  95409. /** @hidden */
  95410. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  95411. /**
  95412. * Returns a new Mesh object parsed from the source provided.
  95413. * @param parsedMesh is the source
  95414. * @param scene defines the hosting scene
  95415. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  95416. * @returns a new Mesh
  95417. */
  95418. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  95419. /**
  95420. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  95421. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  95422. * @param name defines the name of the mesh to create
  95423. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  95424. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  95425. * @param closePath creates a seam between the first and the last points of each path of the path array
  95426. * @param offset is taken in account only if the `pathArray` is containing a single path
  95427. * @param scene defines the hosting scene
  95428. * @param updatable defines if the mesh must be flagged as updatable
  95429. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95430. * @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)
  95431. * @returns a new Mesh
  95432. */
  95433. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  95434. /**
  95435. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  95436. * @param name defines the name of the mesh to create
  95437. * @param radius sets the radius size (float) of the polygon (default 0.5)
  95438. * @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
  95439. * @param scene defines the hosting scene
  95440. * @param updatable defines if the mesh must be flagged as updatable
  95441. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95442. * @returns a new Mesh
  95443. */
  95444. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  95445. /**
  95446. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  95447. * @param name defines the name of the mesh to create
  95448. * @param size sets the size (float) of each box side (default 1)
  95449. * @param scene defines the hosting scene
  95450. * @param updatable defines if the mesh must be flagged as updatable
  95451. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95452. * @returns a new Mesh
  95453. */
  95454. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  95455. /**
  95456. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  95457. * @param name defines the name of the mesh to create
  95458. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  95459. * @param diameter sets the diameter size (float) of the sphere (default 1)
  95460. * @param scene defines the hosting scene
  95461. * @param updatable defines if the mesh must be flagged as updatable
  95462. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95463. * @returns a new Mesh
  95464. */
  95465. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95466. /**
  95467. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  95468. * @param name defines the name of the mesh to create
  95469. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  95470. * @param diameter sets the diameter size (float) of the sphere (default 1)
  95471. * @param scene defines the hosting scene
  95472. * @returns a new Mesh
  95473. */
  95474. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  95475. /**
  95476. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  95477. * @param name defines the name of the mesh to create
  95478. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  95479. * @param diameterTop set the top cap diameter (floats, default 1)
  95480. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  95481. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  95482. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  95483. * @param scene defines the hosting scene
  95484. * @param updatable defines if the mesh must be flagged as updatable
  95485. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95486. * @returns a new Mesh
  95487. */
  95488. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  95489. /**
  95490. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  95491. * @param name defines the name of the mesh to create
  95492. * @param diameter sets the diameter size (float) of the torus (default 1)
  95493. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  95494. * @param tessellation sets the number of torus sides (postive integer, default 16)
  95495. * @param scene defines the hosting scene
  95496. * @param updatable defines if the mesh must be flagged as updatable
  95497. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95498. * @returns a new Mesh
  95499. */
  95500. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95501. /**
  95502. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  95503. * @param name defines the name of the mesh to create
  95504. * @param radius sets the global radius size (float) of the torus knot (default 2)
  95505. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  95506. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  95507. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  95508. * @param p the number of windings on X axis (positive integers, default 2)
  95509. * @param q the number of windings on Y axis (positive integers, default 3)
  95510. * @param scene defines the hosting scene
  95511. * @param updatable defines if the mesh must be flagged as updatable
  95512. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95513. * @returns a new Mesh
  95514. */
  95515. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95516. /**
  95517. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  95518. * @param name defines the name of the mesh to create
  95519. * @param points is an array successive Vector3
  95520. * @param scene defines the hosting scene
  95521. * @param updatable defines if the mesh must be flagged as updatable
  95522. * @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).
  95523. * @returns a new Mesh
  95524. */
  95525. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  95526. /**
  95527. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  95528. * @param name defines the name of the mesh to create
  95529. * @param points is an array successive Vector3
  95530. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  95531. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  95532. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  95533. * @param scene defines the hosting scene
  95534. * @param updatable defines if the mesh must be flagged as updatable
  95535. * @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)
  95536. * @returns a new Mesh
  95537. */
  95538. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  95539. /**
  95540. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  95541. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  95542. * 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.
  95543. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95544. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  95545. * Remember you can only change the shape positions, not their number when updating a polygon.
  95546. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  95547. * @param name defines the name of the mesh to create
  95548. * @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
  95549. * @param scene defines the hosting scene
  95550. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  95551. * @param updatable defines if the mesh must be flagged as updatable
  95552. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95553. * @param earcutInjection can be used to inject your own earcut reference
  95554. * @returns a new Mesh
  95555. */
  95556. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  95557. /**
  95558. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  95559. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  95560. * @param name defines the name of the mesh to create
  95561. * @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
  95562. * @param depth defines the height of extrusion
  95563. * @param scene defines the hosting scene
  95564. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  95565. * @param updatable defines if the mesh must be flagged as updatable
  95566. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95567. * @param earcutInjection can be used to inject your own earcut reference
  95568. * @returns a new Mesh
  95569. */
  95570. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  95571. /**
  95572. * Creates an extruded shape mesh.
  95573. * 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
  95574. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  95575. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  95576. * @param name defines the name of the mesh to create
  95577. * @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
  95578. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  95579. * @param scale is the value to scale the shape
  95580. * @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
  95581. * @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
  95582. * @param scene defines the hosting scene
  95583. * @param updatable defines if the mesh must be flagged as updatable
  95584. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95585. * @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)
  95586. * @returns a new Mesh
  95587. */
  95588. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  95589. /**
  95590. * Creates an custom extruded shape mesh.
  95591. * The custom extrusion is a parametric shape.
  95592. * It has no predefined shape. Its final shape will depend on the input parameters.
  95593. * Please consider using the same method from the MeshBuilder class instead
  95594. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  95595. * @param name defines the name of the mesh to create
  95596. * @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
  95597. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  95598. * @param scaleFunction is a custom Javascript function called on each path point
  95599. * @param rotationFunction is a custom Javascript function called on each path point
  95600. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  95601. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  95602. * @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
  95603. * @param scene defines the hosting scene
  95604. * @param updatable defines if the mesh must be flagged as updatable
  95605. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95606. * @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)
  95607. * @returns a new Mesh
  95608. */
  95609. 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;
  95610. /**
  95611. * Creates lathe mesh.
  95612. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  95613. * Please consider using the same method from the MeshBuilder class instead
  95614. * @param name defines the name of the mesh to create
  95615. * @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
  95616. * @param radius is the radius value of the lathe
  95617. * @param tessellation is the side number of the lathe.
  95618. * @param scene defines the hosting scene
  95619. * @param updatable defines if the mesh must be flagged as updatable
  95620. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95621. * @returns a new Mesh
  95622. */
  95623. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95624. /**
  95625. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  95626. * @param name defines the name of the mesh to create
  95627. * @param size sets the size (float) of both sides of the plane at once (default 1)
  95628. * @param scene defines the hosting scene
  95629. * @param updatable defines if the mesh must be flagged as updatable
  95630. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95631. * @returns a new Mesh
  95632. */
  95633. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  95634. /**
  95635. * Creates a ground mesh.
  95636. * Please consider using the same method from the MeshBuilder class instead
  95637. * @param name defines the name of the mesh to create
  95638. * @param width set the width of the ground
  95639. * @param height set the height of the ground
  95640. * @param subdivisions sets the number of subdivisions per side
  95641. * @param scene defines the hosting scene
  95642. * @param updatable defines if the mesh must be flagged as updatable
  95643. * @returns a new Mesh
  95644. */
  95645. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  95646. /**
  95647. * Creates a tiled ground mesh.
  95648. * Please consider using the same method from the MeshBuilder class instead
  95649. * @param name defines the name of the mesh to create
  95650. * @param xmin set the ground minimum X coordinate
  95651. * @param zmin set the ground minimum Y coordinate
  95652. * @param xmax set the ground maximum X coordinate
  95653. * @param zmax set the ground maximum Z coordinate
  95654. * @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
  95655. * @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
  95656. * @param scene defines the hosting scene
  95657. * @param updatable defines if the mesh must be flagged as updatable
  95658. * @returns a new Mesh
  95659. */
  95660. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  95661. w: number;
  95662. h: number;
  95663. }, precision: {
  95664. w: number;
  95665. h: number;
  95666. }, scene: Scene, updatable?: boolean): Mesh;
  95667. /**
  95668. * Creates a ground mesh from a height map.
  95669. * Please consider using the same method from the MeshBuilder class instead
  95670. * @see http://doc.babylonjs.com/babylon101/height_map
  95671. * @param name defines the name of the mesh to create
  95672. * @param url sets the URL of the height map image resource
  95673. * @param width set the ground width size
  95674. * @param height set the ground height size
  95675. * @param subdivisions sets the number of subdivision per side
  95676. * @param minHeight is the minimum altitude on the ground
  95677. * @param maxHeight is the maximum altitude on the ground
  95678. * @param scene defines the hosting scene
  95679. * @param updatable defines if the mesh must be flagged as updatable
  95680. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  95681. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  95682. * @returns a new Mesh
  95683. */
  95684. 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;
  95685. /**
  95686. * Creates a tube mesh.
  95687. * The tube is a parametric shape.
  95688. * It has no predefined shape. Its final shape will depend on the input parameters.
  95689. * Please consider using the same method from the MeshBuilder class instead
  95690. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  95691. * @param name defines the name of the mesh to create
  95692. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  95693. * @param radius sets the tube radius size
  95694. * @param tessellation is the number of sides on the tubular surface
  95695. * @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
  95696. * @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
  95697. * @param scene defines the hosting scene
  95698. * @param updatable defines if the mesh must be flagged as updatable
  95699. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  95700. * @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)
  95701. * @returns a new Mesh
  95702. */
  95703. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  95704. (i: number, distance: number): number;
  95705. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  95706. /**
  95707. * Creates a polyhedron mesh.
  95708. * Please consider using the same method from the MeshBuilder class instead.
  95709. * * 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
  95710. * * The parameter `size` (positive float, default 1) sets the polygon size
  95711. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  95712. * * 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`
  95713. * * 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
  95714. * * 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)`)
  95715. * * 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
  95716. * * 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
  95717. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95718. * * If you create a double-sided mesh, you can choose what parts of 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
  95719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95720. * @param name defines the name of the mesh to create
  95721. * @param options defines the options used to create the mesh
  95722. * @param scene defines the hosting scene
  95723. * @returns a new Mesh
  95724. */
  95725. static CreatePolyhedron(name: string, options: {
  95726. type?: number;
  95727. size?: number;
  95728. sizeX?: number;
  95729. sizeY?: number;
  95730. sizeZ?: number;
  95731. custom?: any;
  95732. faceUV?: Vector4[];
  95733. faceColors?: Color4[];
  95734. updatable?: boolean;
  95735. sideOrientation?: number;
  95736. }, scene: Scene): Mesh;
  95737. /**
  95738. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  95739. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  95740. * * 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`)
  95741. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  95742. * * 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
  95743. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95744. * * If you create a double-sided mesh, you can choose what parts of 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
  95745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95746. * @param name defines the name of the mesh
  95747. * @param options defines the options used to create the mesh
  95748. * @param scene defines the hosting scene
  95749. * @returns a new Mesh
  95750. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  95751. */
  95752. static CreateIcoSphere(name: string, options: {
  95753. radius?: number;
  95754. flat?: boolean;
  95755. subdivisions?: number;
  95756. sideOrientation?: number;
  95757. updatable?: boolean;
  95758. }, scene: Scene): Mesh;
  95759. /**
  95760. * Creates a decal mesh.
  95761. * Please consider using the same method from the MeshBuilder class instead.
  95762. * A decal is a mesh usually applied as a model onto the surface of another mesh
  95763. * @param name defines the name of the mesh
  95764. * @param sourceMesh defines the mesh receiving the decal
  95765. * @param position sets the position of the decal in world coordinates
  95766. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  95767. * @param size sets the decal scaling
  95768. * @param angle sets the angle to rotate the decal
  95769. * @returns a new Mesh
  95770. */
  95771. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  95772. /**
  95773. * Prepare internal position array for software CPU skinning
  95774. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  95775. */
  95776. setPositionsForCPUSkinning(): Float32Array;
  95777. /**
  95778. * Prepare internal normal array for software CPU skinning
  95779. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  95780. */
  95781. setNormalsForCPUSkinning(): Float32Array;
  95782. /**
  95783. * Updates the vertex buffer by applying transformation from the bones
  95784. * @param skeleton defines the skeleton to apply to current mesh
  95785. * @returns the current mesh
  95786. */
  95787. applySkeleton(skeleton: Skeleton): Mesh;
  95788. /**
  95789. * 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
  95790. * @param meshes defines the list of meshes to scan
  95791. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  95792. */
  95793. static MinMax(meshes: AbstractMesh[]): {
  95794. min: Vector3;
  95795. max: Vector3;
  95796. };
  95797. /**
  95798. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  95799. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  95800. * @returns a vector3
  95801. */
  95802. static Center(meshesOrMinMaxVector: {
  95803. min: Vector3;
  95804. max: Vector3;
  95805. } | AbstractMesh[]): Vector3;
  95806. /**
  95807. * Merge the array of meshes into a single mesh for performance reasons.
  95808. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  95809. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  95810. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  95811. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  95812. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  95813. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  95814. * @returns a new mesh
  95815. */
  95816. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  95817. /** @hidden */
  95818. addInstance(instance: InstancedMesh): void;
  95819. /** @hidden */
  95820. removeInstance(instance: InstancedMesh): void;
  95821. }
  95822. }
  95823. declare module BABYLON {
  95824. /**
  95825. * This is the base class of all the camera used in the application.
  95826. * @see http://doc.babylonjs.com/features/cameras
  95827. */
  95828. export class Camera extends Node {
  95829. /** @hidden */
  95830. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  95831. /**
  95832. * This is the default projection mode used by the cameras.
  95833. * It helps recreating a feeling of perspective and better appreciate depth.
  95834. * This is the best way to simulate real life cameras.
  95835. */
  95836. static readonly PERSPECTIVE_CAMERA: number;
  95837. /**
  95838. * This helps creating camera with an orthographic mode.
  95839. * 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.
  95840. */
  95841. static readonly ORTHOGRAPHIC_CAMERA: number;
  95842. /**
  95843. * This is the default FOV mode for perspective cameras.
  95844. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  95845. */
  95846. static readonly FOVMODE_VERTICAL_FIXED: number;
  95847. /**
  95848. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  95849. */
  95850. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  95851. /**
  95852. * This specifies ther is no need for a camera rig.
  95853. * Basically only one eye is rendered corresponding to the camera.
  95854. */
  95855. static readonly RIG_MODE_NONE: number;
  95856. /**
  95857. * Simulates a camera Rig with one blue eye and one red eye.
  95858. * This can be use with 3d blue and red glasses.
  95859. */
  95860. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  95861. /**
  95862. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  95863. */
  95864. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  95865. /**
  95866. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  95867. */
  95868. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  95869. /**
  95870. * Defines that both eyes of the camera will be rendered over under each other.
  95871. */
  95872. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  95873. /**
  95874. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  95875. */
  95876. static readonly RIG_MODE_VR: number;
  95877. /**
  95878. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  95879. */
  95880. static readonly RIG_MODE_WEBVR: number;
  95881. /**
  95882. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  95883. */
  95884. static readonly RIG_MODE_CUSTOM: number;
  95885. /**
  95886. * Defines if by default attaching controls should prevent the default javascript event to continue.
  95887. */
  95888. static ForceAttachControlToAlwaysPreventDefault: boolean;
  95889. /**
  95890. * Define the input manager associated with the camera.
  95891. */
  95892. inputs: CameraInputsManager<Camera>;
  95893. /** @hidden */
  95894. _position: Vector3;
  95895. /**
  95896. * Define the current local position of the camera in the scene
  95897. */
  95898. get position(): Vector3;
  95899. set position(newPosition: Vector3);
  95900. /**
  95901. * The vector the camera should consider as up.
  95902. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  95903. */
  95904. upVector: Vector3;
  95905. /**
  95906. * Define the current limit on the left side for an orthographic camera
  95907. * In scene unit
  95908. */
  95909. orthoLeft: Nullable<number>;
  95910. /**
  95911. * Define the current limit on the right side for an orthographic camera
  95912. * In scene unit
  95913. */
  95914. orthoRight: Nullable<number>;
  95915. /**
  95916. * Define the current limit on the bottom side for an orthographic camera
  95917. * In scene unit
  95918. */
  95919. orthoBottom: Nullable<number>;
  95920. /**
  95921. * Define the current limit on the top side for an orthographic camera
  95922. * In scene unit
  95923. */
  95924. orthoTop: Nullable<number>;
  95925. /**
  95926. * Field Of View is set in Radians. (default is 0.8)
  95927. */
  95928. fov: number;
  95929. /**
  95930. * Define the minimum distance the camera can see from.
  95931. * This is important to note that the depth buffer are not infinite and the closer it starts
  95932. * the more your scene might encounter depth fighting issue.
  95933. */
  95934. minZ: number;
  95935. /**
  95936. * Define the maximum distance the camera can see to.
  95937. * This is important to note that the depth buffer are not infinite and the further it end
  95938. * the more your scene might encounter depth fighting issue.
  95939. */
  95940. maxZ: number;
  95941. /**
  95942. * Define the default inertia of the camera.
  95943. * This helps giving a smooth feeling to the camera movement.
  95944. */
  95945. inertia: number;
  95946. /**
  95947. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  95948. */
  95949. mode: number;
  95950. /**
  95951. * Define wether the camera is intermediate.
  95952. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  95953. */
  95954. isIntermediate: boolean;
  95955. /**
  95956. * Define the viewport of the camera.
  95957. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  95958. */
  95959. viewport: Viewport;
  95960. /**
  95961. * Restricts the camera to viewing objects with the same layerMask.
  95962. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  95963. */
  95964. layerMask: number;
  95965. /**
  95966. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  95967. */
  95968. fovMode: number;
  95969. /**
  95970. * Rig mode of the camera.
  95971. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  95972. * This is normally controlled byt the camera themselves as internal use.
  95973. */
  95974. cameraRigMode: number;
  95975. /**
  95976. * Defines the distance between both "eyes" in case of a RIG
  95977. */
  95978. interaxialDistance: number;
  95979. /**
  95980. * Defines if stereoscopic rendering is done side by side or over under.
  95981. */
  95982. isStereoscopicSideBySide: boolean;
  95983. /**
  95984. * 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
  95985. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  95986. * else in the scene. (Eg. security camera)
  95987. *
  95988. * 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)
  95989. */
  95990. customRenderTargets: RenderTargetTexture[];
  95991. /**
  95992. * When set, the camera will render to this render target instead of the default canvas
  95993. *
  95994. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  95995. */
  95996. outputRenderTarget: Nullable<RenderTargetTexture>;
  95997. /**
  95998. * Observable triggered when the camera view matrix has changed.
  95999. */
  96000. onViewMatrixChangedObservable: Observable<Camera>;
  96001. /**
  96002. * Observable triggered when the camera Projection matrix has changed.
  96003. */
  96004. onProjectionMatrixChangedObservable: Observable<Camera>;
  96005. /**
  96006. * Observable triggered when the inputs have been processed.
  96007. */
  96008. onAfterCheckInputsObservable: Observable<Camera>;
  96009. /**
  96010. * Observable triggered when reset has been called and applied to the camera.
  96011. */
  96012. onRestoreStateObservable: Observable<Camera>;
  96013. /** @hidden */
  96014. _cameraRigParams: any;
  96015. /** @hidden */
  96016. _rigCameras: Camera[];
  96017. /** @hidden */
  96018. _rigPostProcess: Nullable<PostProcess>;
  96019. protected _webvrViewMatrix: Matrix;
  96020. /** @hidden */
  96021. _skipRendering: boolean;
  96022. /** @hidden */
  96023. _projectionMatrix: Matrix;
  96024. /** @hidden */
  96025. _postProcesses: Nullable<PostProcess>[];
  96026. /** @hidden */
  96027. _activeMeshes: SmartArray<AbstractMesh>;
  96028. protected _globalPosition: Vector3;
  96029. /** @hidden */
  96030. _computedViewMatrix: Matrix;
  96031. private _doNotComputeProjectionMatrix;
  96032. private _transformMatrix;
  96033. private _frustumPlanes;
  96034. private _refreshFrustumPlanes;
  96035. private _storedFov;
  96036. private _stateStored;
  96037. /**
  96038. * Instantiates a new camera object.
  96039. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  96040. * @see http://doc.babylonjs.com/features/cameras
  96041. * @param name Defines the name of the camera in the scene
  96042. * @param position Defines the position of the camera
  96043. * @param scene Defines the scene the camera belongs too
  96044. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  96045. */
  96046. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96047. /**
  96048. * Store current camera state (fov, position, etc..)
  96049. * @returns the camera
  96050. */
  96051. storeState(): Camera;
  96052. /**
  96053. * Restores the camera state values if it has been stored. You must call storeState() first
  96054. */
  96055. protected _restoreStateValues(): boolean;
  96056. /**
  96057. * Restored camera state. You must call storeState() first.
  96058. * @returns true if restored and false otherwise
  96059. */
  96060. restoreState(): boolean;
  96061. /**
  96062. * Gets the class name of the camera.
  96063. * @returns the class name
  96064. */
  96065. getClassName(): string;
  96066. /** @hidden */
  96067. readonly _isCamera: boolean;
  96068. /**
  96069. * Gets a string representation of the camera useful for debug purpose.
  96070. * @param fullDetails Defines that a more verboe level of logging is required
  96071. * @returns the string representation
  96072. */
  96073. toString(fullDetails?: boolean): string;
  96074. /**
  96075. * Gets the current world space position of the camera.
  96076. */
  96077. get globalPosition(): Vector3;
  96078. /**
  96079. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  96080. * @returns the active meshe list
  96081. */
  96082. getActiveMeshes(): SmartArray<AbstractMesh>;
  96083. /**
  96084. * Check wether a mesh is part of the current active mesh list of the camera
  96085. * @param mesh Defines the mesh to check
  96086. * @returns true if active, false otherwise
  96087. */
  96088. isActiveMesh(mesh: Mesh): boolean;
  96089. /**
  96090. * Is this camera ready to be used/rendered
  96091. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  96092. * @return true if the camera is ready
  96093. */
  96094. isReady(completeCheck?: boolean): boolean;
  96095. /** @hidden */
  96096. _initCache(): void;
  96097. /** @hidden */
  96098. _updateCache(ignoreParentClass?: boolean): void;
  96099. /** @hidden */
  96100. _isSynchronized(): boolean;
  96101. /** @hidden */
  96102. _isSynchronizedViewMatrix(): boolean;
  96103. /** @hidden */
  96104. _isSynchronizedProjectionMatrix(): boolean;
  96105. /**
  96106. * Attach the input controls to a specific dom element to get the input from.
  96107. * @param element Defines the element the controls should be listened from
  96108. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96109. */
  96110. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96111. /**
  96112. * Detach the current controls from the specified dom element.
  96113. * @param element Defines the element to stop listening the inputs from
  96114. */
  96115. detachControl(element: HTMLElement): void;
  96116. /**
  96117. * Update the camera state according to the different inputs gathered during the frame.
  96118. */
  96119. update(): void;
  96120. /** @hidden */
  96121. _checkInputs(): void;
  96122. /** @hidden */
  96123. get rigCameras(): Camera[];
  96124. /**
  96125. * Gets the post process used by the rig cameras
  96126. */
  96127. get rigPostProcess(): Nullable<PostProcess>;
  96128. /**
  96129. * Internal, gets the first post proces.
  96130. * @returns the first post process to be run on this camera.
  96131. */
  96132. _getFirstPostProcess(): Nullable<PostProcess>;
  96133. private _cascadePostProcessesToRigCams;
  96134. /**
  96135. * Attach a post process to the camera.
  96136. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  96137. * @param postProcess The post process to attach to the camera
  96138. * @param insertAt The position of the post process in case several of them are in use in the scene
  96139. * @returns the position the post process has been inserted at
  96140. */
  96141. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  96142. /**
  96143. * Detach a post process to the camera.
  96144. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  96145. * @param postProcess The post process to detach from the camera
  96146. */
  96147. detachPostProcess(postProcess: PostProcess): void;
  96148. /**
  96149. * Gets the current world matrix of the camera
  96150. */
  96151. getWorldMatrix(): Matrix;
  96152. /** @hidden */
  96153. _getViewMatrix(): Matrix;
  96154. /**
  96155. * Gets the current view matrix of the camera.
  96156. * @param force forces the camera to recompute the matrix without looking at the cached state
  96157. * @returns the view matrix
  96158. */
  96159. getViewMatrix(force?: boolean): Matrix;
  96160. /**
  96161. * Freeze the projection matrix.
  96162. * It will prevent the cache check of the camera projection compute and can speed up perf
  96163. * if no parameter of the camera are meant to change
  96164. * @param projection Defines manually a projection if necessary
  96165. */
  96166. freezeProjectionMatrix(projection?: Matrix): void;
  96167. /**
  96168. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  96169. */
  96170. unfreezeProjectionMatrix(): void;
  96171. /**
  96172. * Gets the current projection matrix of the camera.
  96173. * @param force forces the camera to recompute the matrix without looking at the cached state
  96174. * @returns the projection matrix
  96175. */
  96176. getProjectionMatrix(force?: boolean): Matrix;
  96177. /**
  96178. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  96179. * @returns a Matrix
  96180. */
  96181. getTransformationMatrix(): Matrix;
  96182. private _updateFrustumPlanes;
  96183. /**
  96184. * Checks if a cullable object (mesh...) is in the camera frustum
  96185. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  96186. * @param target The object to check
  96187. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  96188. * @returns true if the object is in frustum otherwise false
  96189. */
  96190. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  96191. /**
  96192. * Checks if a cullable object (mesh...) is in the camera frustum
  96193. * Unlike isInFrustum this cheks the full bounding box
  96194. * @param target The object to check
  96195. * @returns true if the object is in frustum otherwise false
  96196. */
  96197. isCompletelyInFrustum(target: ICullable): boolean;
  96198. /**
  96199. * Gets a ray in the forward direction from the camera.
  96200. * @param length Defines the length of the ray to create
  96201. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  96202. * @param origin Defines the start point of the ray which defaults to the camera position
  96203. * @returns the forward ray
  96204. */
  96205. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  96206. /**
  96207. * Releases resources associated with this node.
  96208. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96209. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96210. */
  96211. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96212. /** @hidden */
  96213. _isLeftCamera: boolean;
  96214. /**
  96215. * Gets the left camera of a rig setup in case of Rigged Camera
  96216. */
  96217. get isLeftCamera(): boolean;
  96218. /** @hidden */
  96219. _isRightCamera: boolean;
  96220. /**
  96221. * Gets the right camera of a rig setup in case of Rigged Camera
  96222. */
  96223. get isRightCamera(): boolean;
  96224. /**
  96225. * Gets the left camera of a rig setup in case of Rigged Camera
  96226. */
  96227. get leftCamera(): Nullable<FreeCamera>;
  96228. /**
  96229. * Gets the right camera of a rig setup in case of Rigged Camera
  96230. */
  96231. get rightCamera(): Nullable<FreeCamera>;
  96232. /**
  96233. * Gets the left camera target of a rig setup in case of Rigged Camera
  96234. * @returns the target position
  96235. */
  96236. getLeftTarget(): Nullable<Vector3>;
  96237. /**
  96238. * Gets the right camera target of a rig setup in case of Rigged Camera
  96239. * @returns the target position
  96240. */
  96241. getRightTarget(): Nullable<Vector3>;
  96242. /**
  96243. * @hidden
  96244. */
  96245. setCameraRigMode(mode: number, rigParams: any): void;
  96246. /** @hidden */
  96247. static _setStereoscopicRigMode(camera: Camera): void;
  96248. /** @hidden */
  96249. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  96250. /** @hidden */
  96251. static _setVRRigMode(camera: Camera, rigParams: any): void;
  96252. /** @hidden */
  96253. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  96254. /** @hidden */
  96255. _getVRProjectionMatrix(): Matrix;
  96256. protected _updateCameraRotationMatrix(): void;
  96257. protected _updateWebVRCameraRotationMatrix(): void;
  96258. /**
  96259. * This function MUST be overwritten by the different WebVR cameras available.
  96260. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  96261. * @hidden
  96262. */
  96263. _getWebVRProjectionMatrix(): Matrix;
  96264. /**
  96265. * This function MUST be overwritten by the different WebVR cameras available.
  96266. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  96267. * @hidden
  96268. */
  96269. _getWebVRViewMatrix(): Matrix;
  96270. /** @hidden */
  96271. setCameraRigParameter(name: string, value: any): void;
  96272. /**
  96273. * needs to be overridden by children so sub has required properties to be copied
  96274. * @hidden
  96275. */
  96276. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  96277. /**
  96278. * May need to be overridden by children
  96279. * @hidden
  96280. */
  96281. _updateRigCameras(): void;
  96282. /** @hidden */
  96283. _setupInputs(): void;
  96284. /**
  96285. * Serialiaze the camera setup to a json represention
  96286. * @returns the JSON representation
  96287. */
  96288. serialize(): any;
  96289. /**
  96290. * Clones the current camera.
  96291. * @param name The cloned camera name
  96292. * @returns the cloned camera
  96293. */
  96294. clone(name: string): Camera;
  96295. /**
  96296. * Gets the direction of the camera relative to a given local axis.
  96297. * @param localAxis Defines the reference axis to provide a relative direction.
  96298. * @return the direction
  96299. */
  96300. getDirection(localAxis: Vector3): Vector3;
  96301. /**
  96302. * Returns the current camera absolute rotation
  96303. */
  96304. get absoluteRotation(): Quaternion;
  96305. /**
  96306. * Gets the direction of the camera relative to a given local axis into a passed vector.
  96307. * @param localAxis Defines the reference axis to provide a relative direction.
  96308. * @param result Defines the vector to store the result in
  96309. */
  96310. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  96311. /**
  96312. * Gets a camera constructor for a given camera type
  96313. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  96314. * @param name The name of the camera the result will be able to instantiate
  96315. * @param scene The scene the result will construct the camera in
  96316. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  96317. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  96318. * @returns a factory method to construc the camera
  96319. */
  96320. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  96321. /**
  96322. * Compute the world matrix of the camera.
  96323. * @returns the camera world matrix
  96324. */
  96325. computeWorldMatrix(): Matrix;
  96326. /**
  96327. * Parse a JSON and creates the camera from the parsed information
  96328. * @param parsedCamera The JSON to parse
  96329. * @param scene The scene to instantiate the camera in
  96330. * @returns the newly constructed camera
  96331. */
  96332. static Parse(parsedCamera: any, scene: Scene): Camera;
  96333. }
  96334. }
  96335. declare module BABYLON {
  96336. /**
  96337. * Class containing static functions to help procedurally build meshes
  96338. */
  96339. export class DiscBuilder {
  96340. /**
  96341. * Creates a plane polygonal mesh. By default, this is a disc
  96342. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  96343. * * 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
  96344. * * 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
  96345. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96346. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96348. * @param name defines the name of the mesh
  96349. * @param options defines the options used to create the mesh
  96350. * @param scene defines the hosting scene
  96351. * @returns the plane polygonal mesh
  96352. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  96353. */
  96354. static CreateDisc(name: string, options: {
  96355. radius?: number;
  96356. tessellation?: number;
  96357. arc?: number;
  96358. updatable?: boolean;
  96359. sideOrientation?: number;
  96360. frontUVs?: Vector4;
  96361. backUVs?: Vector4;
  96362. }, scene?: Nullable<Scene>): Mesh;
  96363. }
  96364. }
  96365. declare module BABYLON {
  96366. /**
  96367. * This represents all the required information to add a fresnel effect on a material:
  96368. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96369. */
  96370. export class FresnelParameters {
  96371. private _isEnabled;
  96372. /**
  96373. * Define if the fresnel effect is enable or not.
  96374. */
  96375. get isEnabled(): boolean;
  96376. set isEnabled(value: boolean);
  96377. /**
  96378. * Define the color used on edges (grazing angle)
  96379. */
  96380. leftColor: Color3;
  96381. /**
  96382. * Define the color used on center
  96383. */
  96384. rightColor: Color3;
  96385. /**
  96386. * Define bias applied to computed fresnel term
  96387. */
  96388. bias: number;
  96389. /**
  96390. * Defined the power exponent applied to fresnel term
  96391. */
  96392. power: number;
  96393. /**
  96394. * Clones the current fresnel and its valuues
  96395. * @returns a clone fresnel configuration
  96396. */
  96397. clone(): FresnelParameters;
  96398. /**
  96399. * Serializes the current fresnel parameters to a JSON representation.
  96400. * @return the JSON serialization
  96401. */
  96402. serialize(): any;
  96403. /**
  96404. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  96405. * @param parsedFresnelParameters Define the JSON representation
  96406. * @returns the parsed parameters
  96407. */
  96408. static Parse(parsedFresnelParameters: any): FresnelParameters;
  96409. }
  96410. }
  96411. declare module BABYLON {
  96412. /**
  96413. * Base class of materials working in push mode in babylon JS
  96414. * @hidden
  96415. */
  96416. export class PushMaterial extends Material {
  96417. protected _activeEffect: Effect;
  96418. protected _normalMatrix: Matrix;
  96419. /**
  96420. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  96421. * This means that the material can keep using a previous shader while a new one is being compiled.
  96422. * This is mostly used when shader parallel compilation is supported (true by default)
  96423. */
  96424. allowShaderHotSwapping: boolean;
  96425. constructor(name: string, scene: Scene);
  96426. getEffect(): Effect;
  96427. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  96428. /**
  96429. * Binds the given world matrix to the active effect
  96430. *
  96431. * @param world the matrix to bind
  96432. */
  96433. bindOnlyWorldMatrix(world: Matrix): void;
  96434. /**
  96435. * Binds the given normal matrix to the active effect
  96436. *
  96437. * @param normalMatrix the matrix to bind
  96438. */
  96439. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  96440. bind(world: Matrix, mesh?: Mesh): void;
  96441. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  96442. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  96443. }
  96444. }
  96445. declare module BABYLON {
  96446. /**
  96447. * This groups all the flags used to control the materials channel.
  96448. */
  96449. export class MaterialFlags {
  96450. private static _DiffuseTextureEnabled;
  96451. /**
  96452. * Are diffuse textures enabled in the application.
  96453. */
  96454. static get DiffuseTextureEnabled(): boolean;
  96455. static set DiffuseTextureEnabled(value: boolean);
  96456. private static _AmbientTextureEnabled;
  96457. /**
  96458. * Are ambient textures enabled in the application.
  96459. */
  96460. static get AmbientTextureEnabled(): boolean;
  96461. static set AmbientTextureEnabled(value: boolean);
  96462. private static _OpacityTextureEnabled;
  96463. /**
  96464. * Are opacity textures enabled in the application.
  96465. */
  96466. static get OpacityTextureEnabled(): boolean;
  96467. static set OpacityTextureEnabled(value: boolean);
  96468. private static _ReflectionTextureEnabled;
  96469. /**
  96470. * Are reflection textures enabled in the application.
  96471. */
  96472. static get ReflectionTextureEnabled(): boolean;
  96473. static set ReflectionTextureEnabled(value: boolean);
  96474. private static _EmissiveTextureEnabled;
  96475. /**
  96476. * Are emissive textures enabled in the application.
  96477. */
  96478. static get EmissiveTextureEnabled(): boolean;
  96479. static set EmissiveTextureEnabled(value: boolean);
  96480. private static _SpecularTextureEnabled;
  96481. /**
  96482. * Are specular textures enabled in the application.
  96483. */
  96484. static get SpecularTextureEnabled(): boolean;
  96485. static set SpecularTextureEnabled(value: boolean);
  96486. private static _BumpTextureEnabled;
  96487. /**
  96488. * Are bump textures enabled in the application.
  96489. */
  96490. static get BumpTextureEnabled(): boolean;
  96491. static set BumpTextureEnabled(value: boolean);
  96492. private static _LightmapTextureEnabled;
  96493. /**
  96494. * Are lightmap textures enabled in the application.
  96495. */
  96496. static get LightmapTextureEnabled(): boolean;
  96497. static set LightmapTextureEnabled(value: boolean);
  96498. private static _RefractionTextureEnabled;
  96499. /**
  96500. * Are refraction textures enabled in the application.
  96501. */
  96502. static get RefractionTextureEnabled(): boolean;
  96503. static set RefractionTextureEnabled(value: boolean);
  96504. private static _ColorGradingTextureEnabled;
  96505. /**
  96506. * Are color grading textures enabled in the application.
  96507. */
  96508. static get ColorGradingTextureEnabled(): boolean;
  96509. static set ColorGradingTextureEnabled(value: boolean);
  96510. private static _FresnelEnabled;
  96511. /**
  96512. * Are fresnels enabled in the application.
  96513. */
  96514. static get FresnelEnabled(): boolean;
  96515. static set FresnelEnabled(value: boolean);
  96516. private static _ClearCoatTextureEnabled;
  96517. /**
  96518. * Are clear coat textures enabled in the application.
  96519. */
  96520. static get ClearCoatTextureEnabled(): boolean;
  96521. static set ClearCoatTextureEnabled(value: boolean);
  96522. private static _ClearCoatBumpTextureEnabled;
  96523. /**
  96524. * Are clear coat bump textures enabled in the application.
  96525. */
  96526. static get ClearCoatBumpTextureEnabled(): boolean;
  96527. static set ClearCoatBumpTextureEnabled(value: boolean);
  96528. private static _ClearCoatTintTextureEnabled;
  96529. /**
  96530. * Are clear coat tint textures enabled in the application.
  96531. */
  96532. static get ClearCoatTintTextureEnabled(): boolean;
  96533. static set ClearCoatTintTextureEnabled(value: boolean);
  96534. private static _SheenTextureEnabled;
  96535. /**
  96536. * Are sheen textures enabled in the application.
  96537. */
  96538. static get SheenTextureEnabled(): boolean;
  96539. static set SheenTextureEnabled(value: boolean);
  96540. private static _AnisotropicTextureEnabled;
  96541. /**
  96542. * Are anisotropic textures enabled in the application.
  96543. */
  96544. static get AnisotropicTextureEnabled(): boolean;
  96545. static set AnisotropicTextureEnabled(value: boolean);
  96546. private static _ThicknessTextureEnabled;
  96547. /**
  96548. * Are thickness textures enabled in the application.
  96549. */
  96550. static get ThicknessTextureEnabled(): boolean;
  96551. static set ThicknessTextureEnabled(value: boolean);
  96552. }
  96553. }
  96554. declare module BABYLON {
  96555. /** @hidden */
  96556. export var defaultFragmentDeclaration: {
  96557. name: string;
  96558. shader: string;
  96559. };
  96560. }
  96561. declare module BABYLON {
  96562. /** @hidden */
  96563. export var defaultUboDeclaration: {
  96564. name: string;
  96565. shader: string;
  96566. };
  96567. }
  96568. declare module BABYLON {
  96569. /** @hidden */
  96570. export var lightFragmentDeclaration: {
  96571. name: string;
  96572. shader: string;
  96573. };
  96574. }
  96575. declare module BABYLON {
  96576. /** @hidden */
  96577. export var lightUboDeclaration: {
  96578. name: string;
  96579. shader: string;
  96580. };
  96581. }
  96582. declare module BABYLON {
  96583. /** @hidden */
  96584. export var lightsFragmentFunctions: {
  96585. name: string;
  96586. shader: string;
  96587. };
  96588. }
  96589. declare module BABYLON {
  96590. /** @hidden */
  96591. export var shadowsFragmentFunctions: {
  96592. name: string;
  96593. shader: string;
  96594. };
  96595. }
  96596. declare module BABYLON {
  96597. /** @hidden */
  96598. export var fresnelFunction: {
  96599. name: string;
  96600. shader: string;
  96601. };
  96602. }
  96603. declare module BABYLON {
  96604. /** @hidden */
  96605. export var reflectionFunction: {
  96606. name: string;
  96607. shader: string;
  96608. };
  96609. }
  96610. declare module BABYLON {
  96611. /** @hidden */
  96612. export var bumpFragmentFunctions: {
  96613. name: string;
  96614. shader: string;
  96615. };
  96616. }
  96617. declare module BABYLON {
  96618. /** @hidden */
  96619. export var logDepthDeclaration: {
  96620. name: string;
  96621. shader: string;
  96622. };
  96623. }
  96624. declare module BABYLON {
  96625. /** @hidden */
  96626. export var bumpFragment: {
  96627. name: string;
  96628. shader: string;
  96629. };
  96630. }
  96631. declare module BABYLON {
  96632. /** @hidden */
  96633. export var depthPrePass: {
  96634. name: string;
  96635. shader: string;
  96636. };
  96637. }
  96638. declare module BABYLON {
  96639. /** @hidden */
  96640. export var lightFragment: {
  96641. name: string;
  96642. shader: string;
  96643. };
  96644. }
  96645. declare module BABYLON {
  96646. /** @hidden */
  96647. export var logDepthFragment: {
  96648. name: string;
  96649. shader: string;
  96650. };
  96651. }
  96652. declare module BABYLON {
  96653. /** @hidden */
  96654. export var defaultPixelShader: {
  96655. name: string;
  96656. shader: string;
  96657. };
  96658. }
  96659. declare module BABYLON {
  96660. /** @hidden */
  96661. export var defaultVertexDeclaration: {
  96662. name: string;
  96663. shader: string;
  96664. };
  96665. }
  96666. declare module BABYLON {
  96667. /** @hidden */
  96668. export var bumpVertexDeclaration: {
  96669. name: string;
  96670. shader: string;
  96671. };
  96672. }
  96673. declare module BABYLON {
  96674. /** @hidden */
  96675. export var bumpVertex: {
  96676. name: string;
  96677. shader: string;
  96678. };
  96679. }
  96680. declare module BABYLON {
  96681. /** @hidden */
  96682. export var fogVertex: {
  96683. name: string;
  96684. shader: string;
  96685. };
  96686. }
  96687. declare module BABYLON {
  96688. /** @hidden */
  96689. export var shadowsVertex: {
  96690. name: string;
  96691. shader: string;
  96692. };
  96693. }
  96694. declare module BABYLON {
  96695. /** @hidden */
  96696. export var pointCloudVertex: {
  96697. name: string;
  96698. shader: string;
  96699. };
  96700. }
  96701. declare module BABYLON {
  96702. /** @hidden */
  96703. export var logDepthVertex: {
  96704. name: string;
  96705. shader: string;
  96706. };
  96707. }
  96708. declare module BABYLON {
  96709. /** @hidden */
  96710. export var defaultVertexShader: {
  96711. name: string;
  96712. shader: string;
  96713. };
  96714. }
  96715. declare module BABYLON {
  96716. /** @hidden */
  96717. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  96718. MAINUV1: boolean;
  96719. MAINUV2: boolean;
  96720. DIFFUSE: boolean;
  96721. DIFFUSEDIRECTUV: number;
  96722. AMBIENT: boolean;
  96723. AMBIENTDIRECTUV: number;
  96724. OPACITY: boolean;
  96725. OPACITYDIRECTUV: number;
  96726. OPACITYRGB: boolean;
  96727. REFLECTION: boolean;
  96728. EMISSIVE: boolean;
  96729. EMISSIVEDIRECTUV: number;
  96730. SPECULAR: boolean;
  96731. SPECULARDIRECTUV: number;
  96732. BUMP: boolean;
  96733. BUMPDIRECTUV: number;
  96734. PARALLAX: boolean;
  96735. PARALLAXOCCLUSION: boolean;
  96736. SPECULAROVERALPHA: boolean;
  96737. CLIPPLANE: boolean;
  96738. CLIPPLANE2: boolean;
  96739. CLIPPLANE3: boolean;
  96740. CLIPPLANE4: boolean;
  96741. CLIPPLANE5: boolean;
  96742. CLIPPLANE6: boolean;
  96743. ALPHATEST: boolean;
  96744. DEPTHPREPASS: boolean;
  96745. ALPHAFROMDIFFUSE: boolean;
  96746. POINTSIZE: boolean;
  96747. FOG: boolean;
  96748. SPECULARTERM: boolean;
  96749. DIFFUSEFRESNEL: boolean;
  96750. OPACITYFRESNEL: boolean;
  96751. REFLECTIONFRESNEL: boolean;
  96752. REFRACTIONFRESNEL: boolean;
  96753. EMISSIVEFRESNEL: boolean;
  96754. FRESNEL: boolean;
  96755. NORMAL: boolean;
  96756. UV1: boolean;
  96757. UV2: boolean;
  96758. VERTEXCOLOR: boolean;
  96759. VERTEXALPHA: boolean;
  96760. NUM_BONE_INFLUENCERS: number;
  96761. BonesPerMesh: number;
  96762. BONETEXTURE: boolean;
  96763. INSTANCES: boolean;
  96764. GLOSSINESS: boolean;
  96765. ROUGHNESS: boolean;
  96766. EMISSIVEASILLUMINATION: boolean;
  96767. LINKEMISSIVEWITHDIFFUSE: boolean;
  96768. REFLECTIONFRESNELFROMSPECULAR: boolean;
  96769. LIGHTMAP: boolean;
  96770. LIGHTMAPDIRECTUV: number;
  96771. OBJECTSPACE_NORMALMAP: boolean;
  96772. USELIGHTMAPASSHADOWMAP: boolean;
  96773. REFLECTIONMAP_3D: boolean;
  96774. REFLECTIONMAP_SPHERICAL: boolean;
  96775. REFLECTIONMAP_PLANAR: boolean;
  96776. REFLECTIONMAP_CUBIC: boolean;
  96777. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  96778. REFLECTIONMAP_PROJECTION: boolean;
  96779. REFLECTIONMAP_SKYBOX: boolean;
  96780. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  96781. REFLECTIONMAP_EXPLICIT: boolean;
  96782. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  96783. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  96784. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  96785. INVERTCUBICMAP: boolean;
  96786. LOGARITHMICDEPTH: boolean;
  96787. REFRACTION: boolean;
  96788. REFRACTIONMAP_3D: boolean;
  96789. REFLECTIONOVERALPHA: boolean;
  96790. TWOSIDEDLIGHTING: boolean;
  96791. SHADOWFLOAT: boolean;
  96792. MORPHTARGETS: boolean;
  96793. MORPHTARGETS_NORMAL: boolean;
  96794. MORPHTARGETS_TANGENT: boolean;
  96795. MORPHTARGETS_UV: boolean;
  96796. NUM_MORPH_INFLUENCERS: number;
  96797. NONUNIFORMSCALING: boolean;
  96798. PREMULTIPLYALPHA: boolean;
  96799. IMAGEPROCESSING: boolean;
  96800. VIGNETTE: boolean;
  96801. VIGNETTEBLENDMODEMULTIPLY: boolean;
  96802. VIGNETTEBLENDMODEOPAQUE: boolean;
  96803. TONEMAPPING: boolean;
  96804. TONEMAPPING_ACES: boolean;
  96805. CONTRAST: boolean;
  96806. COLORCURVES: boolean;
  96807. COLORGRADING: boolean;
  96808. COLORGRADING3D: boolean;
  96809. SAMPLER3DGREENDEPTH: boolean;
  96810. SAMPLER3DBGRMAP: boolean;
  96811. IMAGEPROCESSINGPOSTPROCESS: boolean;
  96812. MULTIVIEW: boolean;
  96813. /**
  96814. * If the reflection texture on this material is in linear color space
  96815. * @hidden
  96816. */
  96817. IS_REFLECTION_LINEAR: boolean;
  96818. /**
  96819. * If the refraction texture on this material is in linear color space
  96820. * @hidden
  96821. */
  96822. IS_REFRACTION_LINEAR: boolean;
  96823. EXPOSURE: boolean;
  96824. constructor();
  96825. setReflectionMode(modeToEnable: string): void;
  96826. }
  96827. /**
  96828. * This is the default material used in Babylon. It is the best trade off between quality
  96829. * and performances.
  96830. * @see http://doc.babylonjs.com/babylon101/materials
  96831. */
  96832. export class StandardMaterial extends PushMaterial {
  96833. private _diffuseTexture;
  96834. /**
  96835. * The basic texture of the material as viewed under a light.
  96836. */
  96837. diffuseTexture: Nullable<BaseTexture>;
  96838. private _ambientTexture;
  96839. /**
  96840. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  96841. */
  96842. ambientTexture: Nullable<BaseTexture>;
  96843. private _opacityTexture;
  96844. /**
  96845. * Define the transparency of the material from a texture.
  96846. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  96847. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  96848. */
  96849. opacityTexture: Nullable<BaseTexture>;
  96850. private _reflectionTexture;
  96851. /**
  96852. * Define the texture used to display the reflection.
  96853. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96854. */
  96855. reflectionTexture: Nullable<BaseTexture>;
  96856. private _emissiveTexture;
  96857. /**
  96858. * Define texture of the material as if self lit.
  96859. * This will be mixed in the final result even in the absence of light.
  96860. */
  96861. emissiveTexture: Nullable<BaseTexture>;
  96862. private _specularTexture;
  96863. /**
  96864. * Define how the color and intensity of the highlight given by the light in the material.
  96865. */
  96866. specularTexture: Nullable<BaseTexture>;
  96867. private _bumpTexture;
  96868. /**
  96869. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  96870. * 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.
  96871. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  96872. */
  96873. bumpTexture: Nullable<BaseTexture>;
  96874. private _lightmapTexture;
  96875. /**
  96876. * Complex lighting can be computationally expensive to compute at runtime.
  96877. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  96878. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  96879. */
  96880. lightmapTexture: Nullable<BaseTexture>;
  96881. private _refractionTexture;
  96882. /**
  96883. * Define the texture used to display the refraction.
  96884. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96885. */
  96886. refractionTexture: Nullable<BaseTexture>;
  96887. /**
  96888. * The color of the material lit by the environmental background lighting.
  96889. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  96890. */
  96891. ambientColor: Color3;
  96892. /**
  96893. * The basic color of the material as viewed under a light.
  96894. */
  96895. diffuseColor: Color3;
  96896. /**
  96897. * Define how the color and intensity of the highlight given by the light in the material.
  96898. */
  96899. specularColor: Color3;
  96900. /**
  96901. * Define the color of the material as if self lit.
  96902. * This will be mixed in the final result even in the absence of light.
  96903. */
  96904. emissiveColor: Color3;
  96905. /**
  96906. * Defines how sharp are the highlights in the material.
  96907. * The bigger the value the sharper giving a more glossy feeling to the result.
  96908. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  96909. */
  96910. specularPower: number;
  96911. private _useAlphaFromDiffuseTexture;
  96912. /**
  96913. * Does the transparency come from the diffuse texture alpha channel.
  96914. */
  96915. useAlphaFromDiffuseTexture: boolean;
  96916. private _useEmissiveAsIllumination;
  96917. /**
  96918. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  96919. */
  96920. useEmissiveAsIllumination: boolean;
  96921. private _linkEmissiveWithDiffuse;
  96922. /**
  96923. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  96924. * the emissive level when the final color is close to one.
  96925. */
  96926. linkEmissiveWithDiffuse: boolean;
  96927. private _useSpecularOverAlpha;
  96928. /**
  96929. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  96930. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  96931. */
  96932. useSpecularOverAlpha: boolean;
  96933. private _useReflectionOverAlpha;
  96934. /**
  96935. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  96936. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  96937. */
  96938. useReflectionOverAlpha: boolean;
  96939. private _disableLighting;
  96940. /**
  96941. * Does lights from the scene impacts this material.
  96942. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  96943. */
  96944. disableLighting: boolean;
  96945. private _useObjectSpaceNormalMap;
  96946. /**
  96947. * Allows using an object space normal map (instead of tangent space).
  96948. */
  96949. useObjectSpaceNormalMap: boolean;
  96950. private _useParallax;
  96951. /**
  96952. * Is parallax enabled or not.
  96953. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  96954. */
  96955. useParallax: boolean;
  96956. private _useParallaxOcclusion;
  96957. /**
  96958. * Is parallax occlusion enabled or not.
  96959. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  96960. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  96961. */
  96962. useParallaxOcclusion: boolean;
  96963. /**
  96964. * 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.
  96965. */
  96966. parallaxScaleBias: number;
  96967. private _roughness;
  96968. /**
  96969. * Helps to define how blurry the reflections should appears in the material.
  96970. */
  96971. roughness: number;
  96972. /**
  96973. * In case of refraction, define the value of the index of refraction.
  96974. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96975. */
  96976. indexOfRefraction: number;
  96977. /**
  96978. * Invert the refraction texture alongside the y axis.
  96979. * It can be useful with procedural textures or probe for instance.
  96980. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96981. */
  96982. invertRefractionY: boolean;
  96983. /**
  96984. * Defines the alpha limits in alpha test mode.
  96985. */
  96986. alphaCutOff: number;
  96987. private _useLightmapAsShadowmap;
  96988. /**
  96989. * In case of light mapping, define whether the map contains light or shadow informations.
  96990. */
  96991. useLightmapAsShadowmap: boolean;
  96992. private _diffuseFresnelParameters;
  96993. /**
  96994. * Define the diffuse fresnel parameters of the material.
  96995. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96996. */
  96997. diffuseFresnelParameters: FresnelParameters;
  96998. private _opacityFresnelParameters;
  96999. /**
  97000. * Define the opacity fresnel parameters of the material.
  97001. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97002. */
  97003. opacityFresnelParameters: FresnelParameters;
  97004. private _reflectionFresnelParameters;
  97005. /**
  97006. * Define the reflection fresnel parameters of the material.
  97007. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97008. */
  97009. reflectionFresnelParameters: FresnelParameters;
  97010. private _refractionFresnelParameters;
  97011. /**
  97012. * Define the refraction fresnel parameters of the material.
  97013. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97014. */
  97015. refractionFresnelParameters: FresnelParameters;
  97016. private _emissiveFresnelParameters;
  97017. /**
  97018. * Define the emissive fresnel parameters of the material.
  97019. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97020. */
  97021. emissiveFresnelParameters: FresnelParameters;
  97022. private _useReflectionFresnelFromSpecular;
  97023. /**
  97024. * If true automatically deducts the fresnels values from the material specularity.
  97025. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97026. */
  97027. useReflectionFresnelFromSpecular: boolean;
  97028. private _useGlossinessFromSpecularMapAlpha;
  97029. /**
  97030. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  97031. */
  97032. useGlossinessFromSpecularMapAlpha: boolean;
  97033. private _maxSimultaneousLights;
  97034. /**
  97035. * Defines the maximum number of lights that can be used in the material
  97036. */
  97037. maxSimultaneousLights: number;
  97038. private _invertNormalMapX;
  97039. /**
  97040. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  97041. */
  97042. invertNormalMapX: boolean;
  97043. private _invertNormalMapY;
  97044. /**
  97045. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  97046. */
  97047. invertNormalMapY: boolean;
  97048. private _twoSidedLighting;
  97049. /**
  97050. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  97051. */
  97052. twoSidedLighting: boolean;
  97053. /**
  97054. * Default configuration related to image processing available in the standard Material.
  97055. */
  97056. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  97057. /**
  97058. * Gets the image processing configuration used either in this material.
  97059. */
  97060. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  97061. /**
  97062. * Sets the Default image processing configuration used either in the this material.
  97063. *
  97064. * If sets to null, the scene one is in use.
  97065. */
  97066. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  97067. /**
  97068. * Keep track of the image processing observer to allow dispose and replace.
  97069. */
  97070. private _imageProcessingObserver;
  97071. /**
  97072. * Attaches a new image processing configuration to the Standard Material.
  97073. * @param configuration
  97074. */
  97075. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  97076. /**
  97077. * Gets wether the color curves effect is enabled.
  97078. */
  97079. get cameraColorCurvesEnabled(): boolean;
  97080. /**
  97081. * Sets wether the color curves effect is enabled.
  97082. */
  97083. set cameraColorCurvesEnabled(value: boolean);
  97084. /**
  97085. * Gets wether the color grading effect is enabled.
  97086. */
  97087. get cameraColorGradingEnabled(): boolean;
  97088. /**
  97089. * Gets wether the color grading effect is enabled.
  97090. */
  97091. set cameraColorGradingEnabled(value: boolean);
  97092. /**
  97093. * Gets wether tonemapping is enabled or not.
  97094. */
  97095. get cameraToneMappingEnabled(): boolean;
  97096. /**
  97097. * Sets wether tonemapping is enabled or not
  97098. */
  97099. set cameraToneMappingEnabled(value: boolean);
  97100. /**
  97101. * The camera exposure used on this material.
  97102. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  97103. * This corresponds to a photographic exposure.
  97104. */
  97105. get cameraExposure(): number;
  97106. /**
  97107. * The camera exposure used on this material.
  97108. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  97109. * This corresponds to a photographic exposure.
  97110. */
  97111. set cameraExposure(value: number);
  97112. /**
  97113. * Gets The camera contrast used on this material.
  97114. */
  97115. get cameraContrast(): number;
  97116. /**
  97117. * Sets The camera contrast used on this material.
  97118. */
  97119. set cameraContrast(value: number);
  97120. /**
  97121. * Gets the Color Grading 2D Lookup Texture.
  97122. */
  97123. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  97124. /**
  97125. * Sets the Color Grading 2D Lookup Texture.
  97126. */
  97127. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  97128. /**
  97129. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  97130. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97131. * 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;
  97132. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97133. */
  97134. get cameraColorCurves(): Nullable<ColorCurves>;
  97135. /**
  97136. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  97137. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97138. * 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;
  97139. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97140. */
  97141. set cameraColorCurves(value: Nullable<ColorCurves>);
  97142. /**
  97143. * Custom callback helping to override the default shader used in the material.
  97144. */
  97145. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  97146. protected _renderTargets: SmartArray<RenderTargetTexture>;
  97147. protected _worldViewProjectionMatrix: Matrix;
  97148. protected _globalAmbientColor: Color3;
  97149. protected _useLogarithmicDepth: boolean;
  97150. protected _rebuildInParallel: boolean;
  97151. /**
  97152. * Instantiates a new standard material.
  97153. * This is the default material used in Babylon. It is the best trade off between quality
  97154. * and performances.
  97155. * @see http://doc.babylonjs.com/babylon101/materials
  97156. * @param name Define the name of the material in the scene
  97157. * @param scene Define the scene the material belong to
  97158. */
  97159. constructor(name: string, scene: Scene);
  97160. /**
  97161. * Gets a boolean indicating that current material needs to register RTT
  97162. */
  97163. get hasRenderTargetTextures(): boolean;
  97164. /**
  97165. * Gets the current class name of the material e.g. "StandardMaterial"
  97166. * Mainly use in serialization.
  97167. * @returns the class name
  97168. */
  97169. getClassName(): string;
  97170. /**
  97171. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  97172. * You can try switching to logarithmic depth.
  97173. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  97174. */
  97175. get useLogarithmicDepth(): boolean;
  97176. set useLogarithmicDepth(value: boolean);
  97177. /**
  97178. * Specifies if the material will require alpha blending
  97179. * @returns a boolean specifying if alpha blending is needed
  97180. */
  97181. needAlphaBlending(): boolean;
  97182. /**
  97183. * Specifies if this material should be rendered in alpha test mode
  97184. * @returns a boolean specifying if an alpha test is needed.
  97185. */
  97186. needAlphaTesting(): boolean;
  97187. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  97188. /**
  97189. * Get the texture used for alpha test purpose.
  97190. * @returns the diffuse texture in case of the standard material.
  97191. */
  97192. getAlphaTestTexture(): Nullable<BaseTexture>;
  97193. /**
  97194. * Get if the submesh is ready to be used and all its information available.
  97195. * Child classes can use it to update shaders
  97196. * @param mesh defines the mesh to check
  97197. * @param subMesh defines which submesh to check
  97198. * @param useInstances specifies that instances should be used
  97199. * @returns a boolean indicating that the submesh is ready or not
  97200. */
  97201. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97202. /**
  97203. * Builds the material UBO layouts.
  97204. * Used internally during the effect preparation.
  97205. */
  97206. buildUniformLayout(): void;
  97207. /**
  97208. * Unbinds the material from the mesh
  97209. */
  97210. unbind(): void;
  97211. /**
  97212. * Binds the submesh to this material by preparing the effect and shader to draw
  97213. * @param world defines the world transformation matrix
  97214. * @param mesh defines the mesh containing the submesh
  97215. * @param subMesh defines the submesh to bind the material to
  97216. */
  97217. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97218. /**
  97219. * Get the list of animatables in the material.
  97220. * @returns the list of animatables object used in the material
  97221. */
  97222. getAnimatables(): IAnimatable[];
  97223. /**
  97224. * Gets the active textures from the material
  97225. * @returns an array of textures
  97226. */
  97227. getActiveTextures(): BaseTexture[];
  97228. /**
  97229. * Specifies if the material uses a texture
  97230. * @param texture defines the texture to check against the material
  97231. * @returns a boolean specifying if the material uses the texture
  97232. */
  97233. hasTexture(texture: BaseTexture): boolean;
  97234. /**
  97235. * Disposes the material
  97236. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97237. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97238. */
  97239. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  97240. /**
  97241. * Makes a duplicate of the material, and gives it a new name
  97242. * @param name defines the new name for the duplicated material
  97243. * @returns the cloned material
  97244. */
  97245. clone(name: string): StandardMaterial;
  97246. /**
  97247. * Serializes this material in a JSON representation
  97248. * @returns the serialized material object
  97249. */
  97250. serialize(): any;
  97251. /**
  97252. * Creates a standard material from parsed material data
  97253. * @param source defines the JSON representation of the material
  97254. * @param scene defines the hosting scene
  97255. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97256. * @returns a new standard material
  97257. */
  97258. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  97259. /**
  97260. * Are diffuse textures enabled in the application.
  97261. */
  97262. static get DiffuseTextureEnabled(): boolean;
  97263. static set DiffuseTextureEnabled(value: boolean);
  97264. /**
  97265. * Are ambient textures enabled in the application.
  97266. */
  97267. static get AmbientTextureEnabled(): boolean;
  97268. static set AmbientTextureEnabled(value: boolean);
  97269. /**
  97270. * Are opacity textures enabled in the application.
  97271. */
  97272. static get OpacityTextureEnabled(): boolean;
  97273. static set OpacityTextureEnabled(value: boolean);
  97274. /**
  97275. * Are reflection textures enabled in the application.
  97276. */
  97277. static get ReflectionTextureEnabled(): boolean;
  97278. static set ReflectionTextureEnabled(value: boolean);
  97279. /**
  97280. * Are emissive textures enabled in the application.
  97281. */
  97282. static get EmissiveTextureEnabled(): boolean;
  97283. static set EmissiveTextureEnabled(value: boolean);
  97284. /**
  97285. * Are specular textures enabled in the application.
  97286. */
  97287. static get SpecularTextureEnabled(): boolean;
  97288. static set SpecularTextureEnabled(value: boolean);
  97289. /**
  97290. * Are bump textures enabled in the application.
  97291. */
  97292. static get BumpTextureEnabled(): boolean;
  97293. static set BumpTextureEnabled(value: boolean);
  97294. /**
  97295. * Are lightmap textures enabled in the application.
  97296. */
  97297. static get LightmapTextureEnabled(): boolean;
  97298. static set LightmapTextureEnabled(value: boolean);
  97299. /**
  97300. * Are refraction textures enabled in the application.
  97301. */
  97302. static get RefractionTextureEnabled(): boolean;
  97303. static set RefractionTextureEnabled(value: boolean);
  97304. /**
  97305. * Are color grading textures enabled in the application.
  97306. */
  97307. static get ColorGradingTextureEnabled(): boolean;
  97308. static set ColorGradingTextureEnabled(value: boolean);
  97309. /**
  97310. * Are fresnels enabled in the application.
  97311. */
  97312. static get FresnelEnabled(): boolean;
  97313. static set FresnelEnabled(value: boolean);
  97314. }
  97315. }
  97316. declare module BABYLON {
  97317. /**
  97318. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  97319. *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.
  97320. * The SPS is also a particle system. It provides some methods to manage the particles.
  97321. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  97322. *
  97323. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  97324. */
  97325. export class SolidParticleSystem implements IDisposable {
  97326. /**
  97327. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  97328. * Example : var p = SPS.particles[i];
  97329. */
  97330. particles: SolidParticle[];
  97331. /**
  97332. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  97333. */
  97334. nbParticles: number;
  97335. /**
  97336. * If the particles must ever face the camera (default false). Useful for planar particles.
  97337. */
  97338. billboard: boolean;
  97339. /**
  97340. * Recompute normals when adding a shape
  97341. */
  97342. recomputeNormals: boolean;
  97343. /**
  97344. * This a counter ofr your own usage. It's not set by any SPS functions.
  97345. */
  97346. counter: number;
  97347. /**
  97348. * The SPS name. This name is also given to the underlying mesh.
  97349. */
  97350. name: string;
  97351. /**
  97352. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  97353. */
  97354. mesh: Mesh;
  97355. /**
  97356. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  97357. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  97358. */
  97359. vars: any;
  97360. /**
  97361. * This array is populated when the SPS is set as 'pickable'.
  97362. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  97363. * Each element of this array is an object `{idx: int, faceId: int}`.
  97364. * `idx` is the picked particle index in the `SPS.particles` array
  97365. * `faceId` is the picked face index counted within this particle.
  97366. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  97367. */
  97368. pickedParticles: {
  97369. idx: number;
  97370. faceId: number;
  97371. }[];
  97372. /**
  97373. * This array is populated when `enableDepthSort` is set to true.
  97374. * Each element of this array is an instance of the class DepthSortedParticle.
  97375. */
  97376. depthSortedParticles: DepthSortedParticle[];
  97377. /**
  97378. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  97379. * @hidden
  97380. */
  97381. _bSphereOnly: boolean;
  97382. /**
  97383. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  97384. * @hidden
  97385. */
  97386. _bSphereRadiusFactor: number;
  97387. private _scene;
  97388. private _positions;
  97389. private _indices;
  97390. private _normals;
  97391. private _colors;
  97392. private _uvs;
  97393. private _indices32;
  97394. private _positions32;
  97395. private _normals32;
  97396. private _fixedNormal32;
  97397. private _colors32;
  97398. private _uvs32;
  97399. private _index;
  97400. private _updatable;
  97401. private _pickable;
  97402. private _isVisibilityBoxLocked;
  97403. private _alwaysVisible;
  97404. private _depthSort;
  97405. private _expandable;
  97406. private _shapeCounter;
  97407. private _copy;
  97408. private _color;
  97409. private _computeParticleColor;
  97410. private _computeParticleTexture;
  97411. private _computeParticleRotation;
  97412. private _computeParticleVertex;
  97413. private _computeBoundingBox;
  97414. private _depthSortParticles;
  97415. private _camera;
  97416. private _mustUnrotateFixedNormals;
  97417. private _particlesIntersect;
  97418. private _needs32Bits;
  97419. private _isNotBuilt;
  97420. private _lastParticleId;
  97421. private _idxOfId;
  97422. private _multimaterialEnabled;
  97423. private _useModelMaterial;
  97424. private _indicesByMaterial;
  97425. private _materialIndexes;
  97426. private _depthSortFunction;
  97427. private _materialSortFunction;
  97428. private _materials;
  97429. private _multimaterial;
  97430. private _materialIndexesById;
  97431. private _defaultMaterial;
  97432. private _autoUpdateSubMeshes;
  97433. /**
  97434. * Creates a SPS (Solid Particle System) object.
  97435. * @param name (String) is the SPS name, this will be the underlying mesh name.
  97436. * @param scene (Scene) is the scene in which the SPS is added.
  97437. * @param options defines the options of the sps e.g.
  97438. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  97439. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  97440. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  97441. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  97442. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  97443. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  97444. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  97445. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  97446. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  97447. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  97448. */
  97449. constructor(name: string, scene: Scene, options?: {
  97450. updatable?: boolean;
  97451. isPickable?: boolean;
  97452. enableDepthSort?: boolean;
  97453. particleIntersection?: boolean;
  97454. boundingSphereOnly?: boolean;
  97455. bSphereRadiusFactor?: number;
  97456. expandable?: boolean;
  97457. useModelMaterial?: boolean;
  97458. enableMultiMaterial?: boolean;
  97459. });
  97460. /**
  97461. * Builds the SPS underlying mesh. Returns a standard Mesh.
  97462. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  97463. * @returns the created mesh
  97464. */
  97465. buildMesh(): Mesh;
  97466. /**
  97467. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  97468. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  97469. * Thus the particles generated from `digest()` have their property `position` set yet.
  97470. * @param mesh ( Mesh ) is the mesh to be digested
  97471. * @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
  97472. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  97473. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  97474. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  97475. * @returns the current SPS
  97476. */
  97477. digest(mesh: Mesh, options?: {
  97478. facetNb?: number;
  97479. number?: number;
  97480. delta?: number;
  97481. storage?: [];
  97482. }): SolidParticleSystem;
  97483. /**
  97484. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  97485. * @hidden
  97486. */
  97487. private _unrotateFixedNormals;
  97488. /**
  97489. * Resets the temporary working copy particle
  97490. * @hidden
  97491. */
  97492. private _resetCopy;
  97493. /**
  97494. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  97495. * @param p the current index in the positions array to be updated
  97496. * @param ind the current index in the indices array
  97497. * @param shape a Vector3 array, the shape geometry
  97498. * @param positions the positions array to be updated
  97499. * @param meshInd the shape indices array
  97500. * @param indices the indices array to be updated
  97501. * @param meshUV the shape uv array
  97502. * @param uvs the uv array to be updated
  97503. * @param meshCol the shape color array
  97504. * @param colors the color array to be updated
  97505. * @param meshNor the shape normals array
  97506. * @param normals the normals array to be updated
  97507. * @param idx the particle index
  97508. * @param idxInShape the particle index in its shape
  97509. * @param options the addShape() method passed options
  97510. * @model the particle model
  97511. * @hidden
  97512. */
  97513. private _meshBuilder;
  97514. /**
  97515. * Returns a shape Vector3 array from positions float array
  97516. * @param positions float array
  97517. * @returns a vector3 array
  97518. * @hidden
  97519. */
  97520. private _posToShape;
  97521. /**
  97522. * Returns a shapeUV array from a float uvs (array deep copy)
  97523. * @param uvs as a float array
  97524. * @returns a shapeUV array
  97525. * @hidden
  97526. */
  97527. private _uvsToShapeUV;
  97528. /**
  97529. * Adds a new particle object in the particles array
  97530. * @param idx particle index in particles array
  97531. * @param id particle id
  97532. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  97533. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  97534. * @param model particle ModelShape object
  97535. * @param shapeId model shape identifier
  97536. * @param idxInShape index of the particle in the current model
  97537. * @param bInfo model bounding info object
  97538. * @param storage target storage array, if any
  97539. * @hidden
  97540. */
  97541. private _addParticle;
  97542. /**
  97543. * Adds some particles to the SPS from the model shape. Returns the shape id.
  97544. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  97545. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  97546. * @param nb (positive integer) the number of particles to be created from this model
  97547. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  97548. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  97549. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  97550. * @returns the number of shapes in the system
  97551. */
  97552. addShape(mesh: Mesh, nb: number, options?: {
  97553. positionFunction?: any;
  97554. vertexFunction?: any;
  97555. storage?: [];
  97556. }): number;
  97557. /**
  97558. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  97559. * @hidden
  97560. */
  97561. private _rebuildParticle;
  97562. /**
  97563. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  97564. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  97565. * @returns the SPS.
  97566. */
  97567. rebuildMesh(reset?: boolean): SolidParticleSystem;
  97568. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  97569. * Returns an array with the removed particles.
  97570. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  97571. * The SPS can't be empty so at least one particle needs to remain in place.
  97572. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  97573. * @param start index of the first particle to remove
  97574. * @param end index of the last particle to remove (included)
  97575. * @returns an array populated with the removed particles
  97576. */
  97577. removeParticles(start: number, end: number): SolidParticle[];
  97578. /**
  97579. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  97580. * @param solidParticleArray an array populated with Solid Particles objects
  97581. * @returns the SPS
  97582. */
  97583. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  97584. /**
  97585. * Creates a new particle and modifies the SPS mesh geometry :
  97586. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  97587. * - calls _addParticle() to populate the particle array
  97588. * factorized code from addShape() and insertParticlesFromArray()
  97589. * @param idx particle index in the particles array
  97590. * @param i particle index in its shape
  97591. * @param modelShape particle ModelShape object
  97592. * @param shape shape vertex array
  97593. * @param meshInd shape indices array
  97594. * @param meshUV shape uv array
  97595. * @param meshCol shape color array
  97596. * @param meshNor shape normals array
  97597. * @param bbInfo shape bounding info
  97598. * @param storage target particle storage
  97599. * @options addShape() passed options
  97600. * @hidden
  97601. */
  97602. private _insertNewParticle;
  97603. /**
  97604. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  97605. * This method calls `updateParticle()` for each particle of the SPS.
  97606. * For an animated SPS, it is usually called within the render loop.
  97607. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  97608. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  97609. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  97610. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  97611. * @returns the SPS.
  97612. */
  97613. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  97614. /**
  97615. * Disposes the SPS.
  97616. */
  97617. dispose(): void;
  97618. /**
  97619. * Returns a SolidParticle object from its identifier : particle.id
  97620. * @param id (integer) the particle Id
  97621. * @returns the searched particle or null if not found in the SPS.
  97622. */
  97623. getParticleById(id: number): Nullable<SolidParticle>;
  97624. /**
  97625. * Returns a new array populated with the particles having the passed shapeId.
  97626. * @param shapeId (integer) the shape identifier
  97627. * @returns a new solid particle array
  97628. */
  97629. getParticlesByShapeId(shapeId: number): SolidParticle[];
  97630. /**
  97631. * Populates the passed array "ref" with the particles having the passed shapeId.
  97632. * @param shapeId the shape identifier
  97633. * @returns the SPS
  97634. * @param ref
  97635. */
  97636. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  97637. /**
  97638. * Computes the required SubMeshes according the materials assigned to the particles.
  97639. * @returns the solid particle system.
  97640. * Does nothing if called before the SPS mesh is built.
  97641. */
  97642. computeSubMeshes(): SolidParticleSystem;
  97643. /**
  97644. * Sorts the solid particles by material when MultiMaterial is enabled.
  97645. * Updates the indices32 array.
  97646. * Updates the indicesByMaterial array.
  97647. * Updates the mesh indices array.
  97648. * @returns the SPS
  97649. * @hidden
  97650. */
  97651. private _sortParticlesByMaterial;
  97652. /**
  97653. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  97654. * @hidden
  97655. */
  97656. private _setMaterialIndexesById;
  97657. /**
  97658. * Returns an array with unique values of Materials from the passed array
  97659. * @param array the material array to be checked and filtered
  97660. * @hidden
  97661. */
  97662. private _filterUniqueMaterialId;
  97663. /**
  97664. * Sets a new Standard Material as _defaultMaterial if not already set.
  97665. * @hidden
  97666. */
  97667. private _setDefaultMaterial;
  97668. /**
  97669. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  97670. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97671. * @returns the SPS.
  97672. */
  97673. refreshVisibleSize(): SolidParticleSystem;
  97674. /**
  97675. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  97676. * @param size the size (float) of the visibility box
  97677. * note : this doesn't lock the SPS mesh bounding box.
  97678. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97679. */
  97680. setVisibilityBox(size: number): void;
  97681. /**
  97682. * Gets whether the SPS as always visible or not
  97683. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97684. */
  97685. get isAlwaysVisible(): boolean;
  97686. /**
  97687. * Sets the SPS as always visible or not
  97688. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97689. */
  97690. set isAlwaysVisible(val: boolean);
  97691. /**
  97692. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  97693. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97694. */
  97695. set isVisibilityBoxLocked(val: boolean);
  97696. /**
  97697. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  97698. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  97699. */
  97700. get isVisibilityBoxLocked(): boolean;
  97701. /**
  97702. * Tells to `setParticles()` to compute the particle rotations or not.
  97703. * Default value : true. The SPS is faster when it's set to false.
  97704. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  97705. */
  97706. set computeParticleRotation(val: boolean);
  97707. /**
  97708. * Tells to `setParticles()` to compute the particle colors or not.
  97709. * Default value : true. The SPS is faster when it's set to false.
  97710. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  97711. */
  97712. set computeParticleColor(val: boolean);
  97713. set computeParticleTexture(val: boolean);
  97714. /**
  97715. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  97716. * Default value : false. The SPS is faster when it's set to false.
  97717. * Note : the particle custom vertex positions aren't stored values.
  97718. */
  97719. set computeParticleVertex(val: boolean);
  97720. /**
  97721. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  97722. */
  97723. set computeBoundingBox(val: boolean);
  97724. /**
  97725. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  97726. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  97727. * Default : `true`
  97728. */
  97729. set depthSortParticles(val: boolean);
  97730. /**
  97731. * Gets if `setParticles()` computes the particle rotations or not.
  97732. * Default value : true. The SPS is faster when it's set to false.
  97733. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  97734. */
  97735. get computeParticleRotation(): boolean;
  97736. /**
  97737. * Gets if `setParticles()` computes the particle colors or not.
  97738. * Default value : true. The SPS is faster when it's set to false.
  97739. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  97740. */
  97741. get computeParticleColor(): boolean;
  97742. /**
  97743. * Gets if `setParticles()` computes the particle textures or not.
  97744. * Default value : true. The SPS is faster when it's set to false.
  97745. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  97746. */
  97747. get computeParticleTexture(): boolean;
  97748. /**
  97749. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  97750. * Default value : false. The SPS is faster when it's set to false.
  97751. * Note : the particle custom vertex positions aren't stored values.
  97752. */
  97753. get computeParticleVertex(): boolean;
  97754. /**
  97755. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  97756. */
  97757. get computeBoundingBox(): boolean;
  97758. /**
  97759. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  97760. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  97761. * Default : `true`
  97762. */
  97763. get depthSortParticles(): boolean;
  97764. /**
  97765. * Gets if the SPS is created as expandable at construction time.
  97766. * Default : `false`
  97767. */
  97768. get expandable(): boolean;
  97769. /**
  97770. * Gets if the SPS supports the Multi Materials
  97771. */
  97772. get multimaterialEnabled(): boolean;
  97773. /**
  97774. * Gets if the SPS uses the model materials for its own multimaterial.
  97775. */
  97776. get useModelMaterial(): boolean;
  97777. /**
  97778. * The SPS used material array.
  97779. */
  97780. get materials(): Material[];
  97781. /**
  97782. * Sets the SPS MultiMaterial from the passed materials.
  97783. * Note : the passed array is internally copied and not used then by reference.
  97784. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  97785. */
  97786. setMultiMaterial(materials: Material[]): void;
  97787. /**
  97788. * The SPS computed multimaterial object
  97789. */
  97790. get multimaterial(): MultiMaterial;
  97791. set multimaterial(mm: MultiMaterial);
  97792. /**
  97793. * If the subMeshes must be updated on the next call to setParticles()
  97794. */
  97795. get autoUpdateSubMeshes(): boolean;
  97796. set autoUpdateSubMeshes(val: boolean);
  97797. /**
  97798. * This function does nothing. It may be overwritten to set all the particle first values.
  97799. * The SPS doesn't call this function, you may have to call it by your own.
  97800. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  97801. */
  97802. initParticles(): void;
  97803. /**
  97804. * This function does nothing. It may be overwritten to recycle a particle.
  97805. * The SPS doesn't call this function, you may have to call it by your own.
  97806. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  97807. * @param particle The particle to recycle
  97808. * @returns the recycled particle
  97809. */
  97810. recycleParticle(particle: SolidParticle): SolidParticle;
  97811. /**
  97812. * Updates a particle : this function should be overwritten by the user.
  97813. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  97814. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  97815. * @example : just set a particle position or velocity and recycle conditions
  97816. * @param particle The particle to update
  97817. * @returns the updated particle
  97818. */
  97819. updateParticle(particle: SolidParticle): SolidParticle;
  97820. /**
  97821. * Updates a vertex of a particle : it can be overwritten by the user.
  97822. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  97823. * @param particle the current particle
  97824. * @param vertex the current index of the current particle
  97825. * @param pt the index of the current vertex in the particle shape
  97826. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  97827. * @example : just set a vertex particle position
  97828. * @returns the updated vertex
  97829. */
  97830. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  97831. /**
  97832. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  97833. * This does nothing and may be overwritten by the user.
  97834. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  97835. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  97836. * @param update the boolean update value actually passed to setParticles()
  97837. */
  97838. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  97839. /**
  97840. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  97841. * This will be passed three parameters.
  97842. * This does nothing and may be overwritten by the user.
  97843. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  97844. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  97845. * @param update the boolean update value actually passed to setParticles()
  97846. */
  97847. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  97848. }
  97849. }
  97850. declare module BABYLON {
  97851. /**
  97852. * Represents one particle of a solid particle system.
  97853. */
  97854. export class SolidParticle {
  97855. /**
  97856. * particle global index
  97857. */
  97858. idx: number;
  97859. /**
  97860. * particle identifier
  97861. */
  97862. id: number;
  97863. /**
  97864. * The color of the particle
  97865. */
  97866. color: Nullable<Color4>;
  97867. /**
  97868. * The world space position of the particle.
  97869. */
  97870. position: Vector3;
  97871. /**
  97872. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  97873. */
  97874. rotation: Vector3;
  97875. /**
  97876. * The world space rotation quaternion of the particle.
  97877. */
  97878. rotationQuaternion: Nullable<Quaternion>;
  97879. /**
  97880. * The scaling of the particle.
  97881. */
  97882. scaling: Vector3;
  97883. /**
  97884. * The uvs of the particle.
  97885. */
  97886. uvs: Vector4;
  97887. /**
  97888. * The current speed of the particle.
  97889. */
  97890. velocity: Vector3;
  97891. /**
  97892. * The pivot point in the particle local space.
  97893. */
  97894. pivot: Vector3;
  97895. /**
  97896. * Must the particle be translated from its pivot point in its local space ?
  97897. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  97898. * Default : false
  97899. */
  97900. translateFromPivot: boolean;
  97901. /**
  97902. * Is the particle active or not ?
  97903. */
  97904. alive: boolean;
  97905. /**
  97906. * Is the particle visible or not ?
  97907. */
  97908. isVisible: boolean;
  97909. /**
  97910. * Index of this particle in the global "positions" array (Internal use)
  97911. * @hidden
  97912. */
  97913. _pos: number;
  97914. /**
  97915. * @hidden Index of this particle in the global "indices" array (Internal use)
  97916. */
  97917. _ind: number;
  97918. /**
  97919. * @hidden ModelShape of this particle (Internal use)
  97920. */
  97921. _model: ModelShape;
  97922. /**
  97923. * ModelShape id of this particle
  97924. */
  97925. shapeId: number;
  97926. /**
  97927. * Index of the particle in its shape id
  97928. */
  97929. idxInShape: number;
  97930. /**
  97931. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  97932. */
  97933. _modelBoundingInfo: BoundingInfo;
  97934. /**
  97935. * @hidden Particle BoundingInfo object (Internal use)
  97936. */
  97937. _boundingInfo: BoundingInfo;
  97938. /**
  97939. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  97940. */
  97941. _sps: SolidParticleSystem;
  97942. /**
  97943. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  97944. */
  97945. _stillInvisible: boolean;
  97946. /**
  97947. * @hidden Last computed particle rotation matrix
  97948. */
  97949. _rotationMatrix: number[];
  97950. /**
  97951. * Parent particle Id, if any.
  97952. * Default null.
  97953. */
  97954. parentId: Nullable<number>;
  97955. /**
  97956. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  97957. */
  97958. materialIndex: Nullable<number>;
  97959. /**
  97960. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  97961. * The possible values are :
  97962. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  97963. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  97964. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  97965. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  97966. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  97967. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  97968. * */
  97969. cullingStrategy: number;
  97970. /**
  97971. * @hidden Internal global position in the SPS.
  97972. */
  97973. _globalPosition: Vector3;
  97974. /**
  97975. * Creates a Solid Particle object.
  97976. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  97977. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  97978. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  97979. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  97980. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  97981. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  97982. * @param shapeId (integer) is the model shape identifier in the SPS.
  97983. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  97984. * @param sps defines the sps it is associated to
  97985. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  97986. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  97987. */
  97988. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  97989. /**
  97990. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  97991. * @param target the particle target
  97992. * @returns the current particle
  97993. */
  97994. copyToRef(target: SolidParticle): SolidParticle;
  97995. /**
  97996. * Legacy support, changed scale to scaling
  97997. */
  97998. get scale(): Vector3;
  97999. /**
  98000. * Legacy support, changed scale to scaling
  98001. */
  98002. set scale(scale: Vector3);
  98003. /**
  98004. * Legacy support, changed quaternion to rotationQuaternion
  98005. */
  98006. get quaternion(): Nullable<Quaternion>;
  98007. /**
  98008. * Legacy support, changed quaternion to rotationQuaternion
  98009. */
  98010. set quaternion(q: Nullable<Quaternion>);
  98011. /**
  98012. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  98013. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  98014. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  98015. * @returns true if it intersects
  98016. */
  98017. intersectsMesh(target: Mesh | SolidParticle): boolean;
  98018. /**
  98019. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  98020. * A particle is in the frustum if its bounding box intersects the frustum
  98021. * @param frustumPlanes defines the frustum to test
  98022. * @returns true if the particle is in the frustum planes
  98023. */
  98024. isInFrustum(frustumPlanes: Plane[]): boolean;
  98025. /**
  98026. * get the rotation matrix of the particle
  98027. * @hidden
  98028. */
  98029. getRotationMatrix(m: Matrix): void;
  98030. }
  98031. /**
  98032. * Represents the shape of the model used by one particle of a solid particle system.
  98033. * SPS internal tool, don't use it manually.
  98034. */
  98035. export class ModelShape {
  98036. /**
  98037. * The shape id
  98038. * @hidden
  98039. */
  98040. shapeID: number;
  98041. /**
  98042. * flat array of model positions (internal use)
  98043. * @hidden
  98044. */
  98045. _shape: Vector3[];
  98046. /**
  98047. * flat array of model UVs (internal use)
  98048. * @hidden
  98049. */
  98050. _shapeUV: number[];
  98051. /**
  98052. * color array of the model
  98053. * @hidden
  98054. */
  98055. _shapeColors: number[];
  98056. /**
  98057. * indices array of the model
  98058. * @hidden
  98059. */
  98060. _indices: number[];
  98061. /**
  98062. * normals array of the model
  98063. * @hidden
  98064. */
  98065. _normals: number[];
  98066. /**
  98067. * length of the shape in the model indices array (internal use)
  98068. * @hidden
  98069. */
  98070. _indicesLength: number;
  98071. /**
  98072. * Custom position function (internal use)
  98073. * @hidden
  98074. */
  98075. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  98076. /**
  98077. * Custom vertex function (internal use)
  98078. * @hidden
  98079. */
  98080. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  98081. /**
  98082. * Model material (internal use)
  98083. * @hidden
  98084. */
  98085. _material: Nullable<Material>;
  98086. /**
  98087. * 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.
  98088. * SPS internal tool, don't use it manually.
  98089. * @hidden
  98090. */
  98091. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  98092. }
  98093. /**
  98094. * Represents a Depth Sorted Particle in the solid particle system.
  98095. * @hidden
  98096. */
  98097. export class DepthSortedParticle {
  98098. /**
  98099. * Index of the particle in the "indices" array
  98100. */
  98101. ind: number;
  98102. /**
  98103. * Length of the particle shape in the "indices" array
  98104. */
  98105. indicesLength: number;
  98106. /**
  98107. * Squared distance from the particle to the camera
  98108. */
  98109. sqDistance: number;
  98110. /**
  98111. * Material index when used with MultiMaterials
  98112. */
  98113. materialIndex: number;
  98114. /**
  98115. * Creates a new sorted particle
  98116. * @param materialIndex
  98117. */
  98118. constructor(ind: number, indLength: number, materialIndex: number);
  98119. }
  98120. }
  98121. declare module BABYLON {
  98122. /**
  98123. * @hidden
  98124. */
  98125. export class _MeshCollisionData {
  98126. _checkCollisions: boolean;
  98127. _collisionMask: number;
  98128. _collisionGroup: number;
  98129. _collider: Nullable<Collider>;
  98130. _oldPositionForCollisions: Vector3;
  98131. _diffPositionForCollisions: Vector3;
  98132. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  98133. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  98134. }
  98135. }
  98136. declare module BABYLON {
  98137. /** @hidden */
  98138. class _FacetDataStorage {
  98139. facetPositions: Vector3[];
  98140. facetNormals: Vector3[];
  98141. facetPartitioning: number[][];
  98142. facetNb: number;
  98143. partitioningSubdivisions: number;
  98144. partitioningBBoxRatio: number;
  98145. facetDataEnabled: boolean;
  98146. facetParameters: any;
  98147. bbSize: Vector3;
  98148. subDiv: {
  98149. max: number;
  98150. X: number;
  98151. Y: number;
  98152. Z: number;
  98153. };
  98154. facetDepthSort: boolean;
  98155. facetDepthSortEnabled: boolean;
  98156. depthSortedIndices: IndicesArray;
  98157. depthSortedFacets: {
  98158. ind: number;
  98159. sqDistance: number;
  98160. }[];
  98161. facetDepthSortFunction: (f1: {
  98162. ind: number;
  98163. sqDistance: number;
  98164. }, f2: {
  98165. ind: number;
  98166. sqDistance: number;
  98167. }) => number;
  98168. facetDepthSortFrom: Vector3;
  98169. facetDepthSortOrigin: Vector3;
  98170. invertedMatrix: Matrix;
  98171. }
  98172. /**
  98173. * @hidden
  98174. **/
  98175. class _InternalAbstractMeshDataInfo {
  98176. _hasVertexAlpha: boolean;
  98177. _useVertexColors: boolean;
  98178. _numBoneInfluencers: number;
  98179. _applyFog: boolean;
  98180. _receiveShadows: boolean;
  98181. _facetData: _FacetDataStorage;
  98182. _visibility: number;
  98183. _skeleton: Nullable<Skeleton>;
  98184. _layerMask: number;
  98185. _computeBonesUsingShaders: boolean;
  98186. _isActive: boolean;
  98187. _onlyForInstances: boolean;
  98188. _isActiveIntermediate: boolean;
  98189. _onlyForInstancesIntermediate: boolean;
  98190. _actAsRegularMesh: boolean;
  98191. }
  98192. /**
  98193. * Class used to store all common mesh properties
  98194. */
  98195. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  98196. /** No occlusion */
  98197. static OCCLUSION_TYPE_NONE: number;
  98198. /** Occlusion set to optimisitic */
  98199. static OCCLUSION_TYPE_OPTIMISTIC: number;
  98200. /** Occlusion set to strict */
  98201. static OCCLUSION_TYPE_STRICT: number;
  98202. /** Use an accurante occlusion algorithm */
  98203. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  98204. /** Use a conservative occlusion algorithm */
  98205. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  98206. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  98207. * Test order :
  98208. * Is the bounding sphere outside the frustum ?
  98209. * If not, are the bounding box vertices outside the frustum ?
  98210. * It not, then the cullable object is in the frustum.
  98211. */
  98212. static readonly CULLINGSTRATEGY_STANDARD: number;
  98213. /** Culling strategy : Bounding Sphere Only.
  98214. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  98215. * It's also less accurate than the standard because some not visible objects can still be selected.
  98216. * Test : is the bounding sphere outside the frustum ?
  98217. * If not, then the cullable object is in the frustum.
  98218. */
  98219. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  98220. /** Culling strategy : Optimistic Inclusion.
  98221. * This in an inclusion test first, then the standard exclusion test.
  98222. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  98223. * 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.
  98224. * Anyway, it's as accurate as the standard strategy.
  98225. * Test :
  98226. * Is the cullable object bounding sphere center in the frustum ?
  98227. * If not, apply the default culling strategy.
  98228. */
  98229. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  98230. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  98231. * This in an inclusion test first, then the bounding sphere only exclusion test.
  98232. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  98233. * 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.
  98234. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  98235. * Test :
  98236. * Is the cullable object bounding sphere center in the frustum ?
  98237. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  98238. */
  98239. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  98240. /**
  98241. * No billboard
  98242. */
  98243. static get BILLBOARDMODE_NONE(): number;
  98244. /** Billboard on X axis */
  98245. static get BILLBOARDMODE_X(): number;
  98246. /** Billboard on Y axis */
  98247. static get BILLBOARDMODE_Y(): number;
  98248. /** Billboard on Z axis */
  98249. static get BILLBOARDMODE_Z(): number;
  98250. /** Billboard on all axes */
  98251. static get BILLBOARDMODE_ALL(): number;
  98252. /** Billboard on using position instead of orientation */
  98253. static get BILLBOARDMODE_USE_POSITION(): number;
  98254. /** @hidden */
  98255. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  98256. /**
  98257. * The culling strategy to use to check whether the mesh must be rendered or not.
  98258. * This value can be changed at any time and will be used on the next render mesh selection.
  98259. * The possible values are :
  98260. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  98261. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  98262. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  98263. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  98264. * Please read each static variable documentation to get details about the culling process.
  98265. * */
  98266. cullingStrategy: number;
  98267. /**
  98268. * Gets the number of facets in the mesh
  98269. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  98270. */
  98271. get facetNb(): number;
  98272. /**
  98273. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  98274. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  98275. */
  98276. get partitioningSubdivisions(): number;
  98277. set partitioningSubdivisions(nb: number);
  98278. /**
  98279. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  98280. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  98281. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  98282. */
  98283. get partitioningBBoxRatio(): number;
  98284. set partitioningBBoxRatio(ratio: number);
  98285. /**
  98286. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  98287. * Works only for updatable meshes.
  98288. * Doesn't work with multi-materials
  98289. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  98290. */
  98291. get mustDepthSortFacets(): boolean;
  98292. set mustDepthSortFacets(sort: boolean);
  98293. /**
  98294. * The location (Vector3) where the facet depth sort must be computed from.
  98295. * By default, the active camera position.
  98296. * Used only when facet depth sort is enabled
  98297. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  98298. */
  98299. get facetDepthSortFrom(): Vector3;
  98300. set facetDepthSortFrom(location: Vector3);
  98301. /**
  98302. * gets a boolean indicating if facetData is enabled
  98303. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  98304. */
  98305. get isFacetDataEnabled(): boolean;
  98306. /** @hidden */
  98307. _updateNonUniformScalingState(value: boolean): boolean;
  98308. /**
  98309. * An event triggered when this mesh collides with another one
  98310. */
  98311. onCollideObservable: Observable<AbstractMesh>;
  98312. /** Set a function to call when this mesh collides with another one */
  98313. set onCollide(callback: () => void);
  98314. /**
  98315. * An event triggered when the collision's position changes
  98316. */
  98317. onCollisionPositionChangeObservable: Observable<Vector3>;
  98318. /** Set a function to call when the collision's position changes */
  98319. set onCollisionPositionChange(callback: () => void);
  98320. /**
  98321. * An event triggered when material is changed
  98322. */
  98323. onMaterialChangedObservable: Observable<AbstractMesh>;
  98324. /**
  98325. * Gets or sets the orientation for POV movement & rotation
  98326. */
  98327. definedFacingForward: boolean;
  98328. /** @hidden */
  98329. _occlusionQuery: Nullable<WebGLQuery>;
  98330. /** @hidden */
  98331. _renderingGroup: Nullable<RenderingGroup>;
  98332. /**
  98333. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  98334. */
  98335. get visibility(): number;
  98336. /**
  98337. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  98338. */
  98339. set visibility(value: number);
  98340. /** Gets or sets the alpha index used to sort transparent meshes
  98341. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  98342. */
  98343. alphaIndex: number;
  98344. /**
  98345. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  98346. */
  98347. isVisible: boolean;
  98348. /**
  98349. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  98350. */
  98351. isPickable: boolean;
  98352. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  98353. showSubMeshesBoundingBox: boolean;
  98354. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  98355. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  98356. */
  98357. isBlocker: boolean;
  98358. /**
  98359. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  98360. */
  98361. enablePointerMoveEvents: boolean;
  98362. /**
  98363. * Specifies the rendering group id for this mesh (0 by default)
  98364. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  98365. */
  98366. renderingGroupId: number;
  98367. private _material;
  98368. /** Gets or sets current material */
  98369. get material(): Nullable<Material>;
  98370. set material(value: Nullable<Material>);
  98371. /**
  98372. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  98373. * @see http://doc.babylonjs.com/babylon101/shadows
  98374. */
  98375. get receiveShadows(): boolean;
  98376. set receiveShadows(value: boolean);
  98377. /** Defines color to use when rendering outline */
  98378. outlineColor: Color3;
  98379. /** Define width to use when rendering outline */
  98380. outlineWidth: number;
  98381. /** Defines color to use when rendering overlay */
  98382. overlayColor: Color3;
  98383. /** Defines alpha to use when rendering overlay */
  98384. overlayAlpha: number;
  98385. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  98386. get hasVertexAlpha(): boolean;
  98387. set hasVertexAlpha(value: boolean);
  98388. /** 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) */
  98389. get useVertexColors(): boolean;
  98390. set useVertexColors(value: boolean);
  98391. /**
  98392. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  98393. */
  98394. get computeBonesUsingShaders(): boolean;
  98395. set computeBonesUsingShaders(value: boolean);
  98396. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  98397. get numBoneInfluencers(): number;
  98398. set numBoneInfluencers(value: number);
  98399. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  98400. get applyFog(): boolean;
  98401. set applyFog(value: boolean);
  98402. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  98403. useOctreeForRenderingSelection: boolean;
  98404. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  98405. useOctreeForPicking: boolean;
  98406. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  98407. useOctreeForCollisions: boolean;
  98408. /**
  98409. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  98410. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  98411. */
  98412. get layerMask(): number;
  98413. set layerMask(value: number);
  98414. /**
  98415. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  98416. */
  98417. alwaysSelectAsActiveMesh: boolean;
  98418. /**
  98419. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  98420. */
  98421. doNotSyncBoundingInfo: boolean;
  98422. /**
  98423. * Gets or sets the current action manager
  98424. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  98425. */
  98426. actionManager: Nullable<AbstractActionManager>;
  98427. private _meshCollisionData;
  98428. /**
  98429. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  98430. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98431. */
  98432. ellipsoid: Vector3;
  98433. /**
  98434. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  98435. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98436. */
  98437. ellipsoidOffset: Vector3;
  98438. /**
  98439. * Gets or sets a collision mask used to mask collisions (default is -1).
  98440. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  98441. */
  98442. get collisionMask(): number;
  98443. set collisionMask(mask: number);
  98444. /**
  98445. * Gets or sets the current collision group mask (-1 by default).
  98446. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  98447. */
  98448. get collisionGroup(): number;
  98449. set collisionGroup(mask: number);
  98450. /**
  98451. * Defines edge width used when edgesRenderer is enabled
  98452. * @see https://www.babylonjs-playground.com/#10OJSG#13
  98453. */
  98454. edgesWidth: number;
  98455. /**
  98456. * Defines edge color used when edgesRenderer is enabled
  98457. * @see https://www.babylonjs-playground.com/#10OJSG#13
  98458. */
  98459. edgesColor: Color4;
  98460. /** @hidden */
  98461. _edgesRenderer: Nullable<IEdgesRenderer>;
  98462. /** @hidden */
  98463. _masterMesh: Nullable<AbstractMesh>;
  98464. /** @hidden */
  98465. _boundingInfo: Nullable<BoundingInfo>;
  98466. /** @hidden */
  98467. _renderId: number;
  98468. /**
  98469. * Gets or sets the list of subMeshes
  98470. * @see http://doc.babylonjs.com/how_to/multi_materials
  98471. */
  98472. subMeshes: SubMesh[];
  98473. /** @hidden */
  98474. _intersectionsInProgress: AbstractMesh[];
  98475. /** @hidden */
  98476. _unIndexed: boolean;
  98477. /** @hidden */
  98478. _lightSources: Light[];
  98479. /** Gets the list of lights affecting that mesh */
  98480. get lightSources(): Light[];
  98481. /** @hidden */
  98482. get _positions(): Nullable<Vector3[]>;
  98483. /** @hidden */
  98484. _waitingData: {
  98485. lods: Nullable<any>;
  98486. actions: Nullable<any>;
  98487. freezeWorldMatrix: Nullable<boolean>;
  98488. };
  98489. /** @hidden */
  98490. _bonesTransformMatrices: Nullable<Float32Array>;
  98491. /** @hidden */
  98492. _transformMatrixTexture: Nullable<RawTexture>;
  98493. /**
  98494. * Gets or sets a skeleton to apply skining transformations
  98495. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  98496. */
  98497. set skeleton(value: Nullable<Skeleton>);
  98498. get skeleton(): Nullable<Skeleton>;
  98499. /**
  98500. * An event triggered when the mesh is rebuilt.
  98501. */
  98502. onRebuildObservable: Observable<AbstractMesh>;
  98503. /**
  98504. * Creates a new AbstractMesh
  98505. * @param name defines the name of the mesh
  98506. * @param scene defines the hosting scene
  98507. */
  98508. constructor(name: string, scene?: Nullable<Scene>);
  98509. /**
  98510. * Returns the string "AbstractMesh"
  98511. * @returns "AbstractMesh"
  98512. */
  98513. getClassName(): string;
  98514. /**
  98515. * Gets a string representation of the current mesh
  98516. * @param fullDetails defines a boolean indicating if full details must be included
  98517. * @returns a string representation of the current mesh
  98518. */
  98519. toString(fullDetails?: boolean): string;
  98520. /**
  98521. * @hidden
  98522. */
  98523. protected _getEffectiveParent(): Nullable<Node>;
  98524. /** @hidden */
  98525. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  98526. /** @hidden */
  98527. _rebuild(): void;
  98528. /** @hidden */
  98529. _resyncLightSources(): void;
  98530. /** @hidden */
  98531. _resyncLightSource(light: Light): void;
  98532. /** @hidden */
  98533. _unBindEffect(): void;
  98534. /** @hidden */
  98535. _removeLightSource(light: Light, dispose: boolean): void;
  98536. private _markSubMeshesAsDirty;
  98537. /** @hidden */
  98538. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  98539. /** @hidden */
  98540. _markSubMeshesAsAttributesDirty(): void;
  98541. /** @hidden */
  98542. _markSubMeshesAsMiscDirty(): void;
  98543. /**
  98544. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  98545. */
  98546. get scaling(): Vector3;
  98547. set scaling(newScaling: Vector3);
  98548. /**
  98549. * Returns true if the mesh is blocked. Implemented by child classes
  98550. */
  98551. get isBlocked(): boolean;
  98552. /**
  98553. * Returns the mesh itself by default. Implemented by child classes
  98554. * @param camera defines the camera to use to pick the right LOD level
  98555. * @returns the currentAbstractMesh
  98556. */
  98557. getLOD(camera: Camera): Nullable<AbstractMesh>;
  98558. /**
  98559. * Returns 0 by default. Implemented by child classes
  98560. * @returns an integer
  98561. */
  98562. getTotalVertices(): number;
  98563. /**
  98564. * Returns a positive integer : the total number of indices in this mesh geometry.
  98565. * @returns the numner of indices or zero if the mesh has no geometry.
  98566. */
  98567. getTotalIndices(): number;
  98568. /**
  98569. * Returns null by default. Implemented by child classes
  98570. * @returns null
  98571. */
  98572. getIndices(): Nullable<IndicesArray>;
  98573. /**
  98574. * Returns the array of the requested vertex data kind. Implemented by child classes
  98575. * @param kind defines the vertex data kind to use
  98576. * @returns null
  98577. */
  98578. getVerticesData(kind: string): Nullable<FloatArray>;
  98579. /**
  98580. * Sets the vertex data of the mesh geometry for the requested `kind`.
  98581. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  98582. * Note that a new underlying VertexBuffer object is created each call.
  98583. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  98584. * @param kind defines vertex data kind:
  98585. * * VertexBuffer.PositionKind
  98586. * * VertexBuffer.UVKind
  98587. * * VertexBuffer.UV2Kind
  98588. * * VertexBuffer.UV3Kind
  98589. * * VertexBuffer.UV4Kind
  98590. * * VertexBuffer.UV5Kind
  98591. * * VertexBuffer.UV6Kind
  98592. * * VertexBuffer.ColorKind
  98593. * * VertexBuffer.MatricesIndicesKind
  98594. * * VertexBuffer.MatricesIndicesExtraKind
  98595. * * VertexBuffer.MatricesWeightsKind
  98596. * * VertexBuffer.MatricesWeightsExtraKind
  98597. * @param data defines the data source
  98598. * @param updatable defines if the data must be flagged as updatable (or static)
  98599. * @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
  98600. * @returns the current mesh
  98601. */
  98602. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  98603. /**
  98604. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  98605. * If the mesh has no geometry, it is simply returned as it is.
  98606. * @param kind defines vertex data kind:
  98607. * * VertexBuffer.PositionKind
  98608. * * VertexBuffer.UVKind
  98609. * * VertexBuffer.UV2Kind
  98610. * * VertexBuffer.UV3Kind
  98611. * * VertexBuffer.UV4Kind
  98612. * * VertexBuffer.UV5Kind
  98613. * * VertexBuffer.UV6Kind
  98614. * * VertexBuffer.ColorKind
  98615. * * VertexBuffer.MatricesIndicesKind
  98616. * * VertexBuffer.MatricesIndicesExtraKind
  98617. * * VertexBuffer.MatricesWeightsKind
  98618. * * VertexBuffer.MatricesWeightsExtraKind
  98619. * @param data defines the data source
  98620. * @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
  98621. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  98622. * @returns the current mesh
  98623. */
  98624. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  98625. /**
  98626. * Sets the mesh indices,
  98627. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  98628. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  98629. * @param totalVertices Defines the total number of vertices
  98630. * @returns the current mesh
  98631. */
  98632. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  98633. /**
  98634. * Gets a boolean indicating if specific vertex data is present
  98635. * @param kind defines the vertex data kind to use
  98636. * @returns true is data kind is present
  98637. */
  98638. isVerticesDataPresent(kind: string): boolean;
  98639. /**
  98640. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  98641. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  98642. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  98643. * @returns a BoundingInfo
  98644. */
  98645. getBoundingInfo(): BoundingInfo;
  98646. /**
  98647. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  98648. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  98649. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  98650. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  98651. * @returns the current mesh
  98652. */
  98653. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  98654. /**
  98655. * Overwrite the current bounding info
  98656. * @param boundingInfo defines the new bounding info
  98657. * @returns the current mesh
  98658. */
  98659. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  98660. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  98661. get useBones(): boolean;
  98662. /** @hidden */
  98663. _preActivate(): void;
  98664. /** @hidden */
  98665. _preActivateForIntermediateRendering(renderId: number): void;
  98666. /** @hidden */
  98667. _activate(renderId: number, intermediateRendering: boolean): boolean;
  98668. /** @hidden */
  98669. _postActivate(): void;
  98670. /** @hidden */
  98671. _freeze(): void;
  98672. /** @hidden */
  98673. _unFreeze(): void;
  98674. /**
  98675. * Gets the current world matrix
  98676. * @returns a Matrix
  98677. */
  98678. getWorldMatrix(): Matrix;
  98679. /** @hidden */
  98680. _getWorldMatrixDeterminant(): number;
  98681. /**
  98682. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  98683. */
  98684. get isAnInstance(): boolean;
  98685. /**
  98686. * Gets a boolean indicating if this mesh has instances
  98687. */
  98688. get hasInstances(): boolean;
  98689. /**
  98690. * Perform relative position change from the point of view of behind the front of the mesh.
  98691. * This is performed taking into account the meshes current rotation, so you do not have to care.
  98692. * Supports definition of mesh facing forward or backward
  98693. * @param amountRight defines the distance on the right axis
  98694. * @param amountUp defines the distance on the up axis
  98695. * @param amountForward defines the distance on the forward axis
  98696. * @returns the current mesh
  98697. */
  98698. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  98699. /**
  98700. * Calculate relative position change from the point of view of behind the front of the mesh.
  98701. * This is performed taking into account the meshes current rotation, so you do not have to care.
  98702. * Supports definition of mesh facing forward or backward
  98703. * @param amountRight defines the distance on the right axis
  98704. * @param amountUp defines the distance on the up axis
  98705. * @param amountForward defines the distance on the forward axis
  98706. * @returns the new displacement vector
  98707. */
  98708. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  98709. /**
  98710. * Perform relative rotation change from the point of view of behind the front of the mesh.
  98711. * Supports definition of mesh facing forward or backward
  98712. * @param flipBack defines the flip
  98713. * @param twirlClockwise defines the twirl
  98714. * @param tiltRight defines the tilt
  98715. * @returns the current mesh
  98716. */
  98717. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  98718. /**
  98719. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  98720. * Supports definition of mesh facing forward or backward.
  98721. * @param flipBack defines the flip
  98722. * @param twirlClockwise defines the twirl
  98723. * @param tiltRight defines the tilt
  98724. * @returns the new rotation vector
  98725. */
  98726. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  98727. /**
  98728. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  98729. * This means the mesh underlying bounding box and sphere are recomputed.
  98730. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  98731. * @returns the current mesh
  98732. */
  98733. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  98734. /** @hidden */
  98735. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  98736. /** @hidden */
  98737. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  98738. /** @hidden */
  98739. _updateBoundingInfo(): AbstractMesh;
  98740. /** @hidden */
  98741. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  98742. /** @hidden */
  98743. protected _afterComputeWorldMatrix(): void;
  98744. /** @hidden */
  98745. get _effectiveMesh(): AbstractMesh;
  98746. /**
  98747. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  98748. * A mesh is in the frustum if its bounding box intersects the frustum
  98749. * @param frustumPlanes defines the frustum to test
  98750. * @returns true if the mesh is in the frustum planes
  98751. */
  98752. isInFrustum(frustumPlanes: Plane[]): boolean;
  98753. /**
  98754. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  98755. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  98756. * @param frustumPlanes defines the frustum to test
  98757. * @returns true if the mesh is completely in the frustum planes
  98758. */
  98759. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  98760. /**
  98761. * True if the mesh intersects another mesh or a SolidParticle object
  98762. * @param mesh defines a target mesh or SolidParticle to test
  98763. * @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)
  98764. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  98765. * @returns true if there is an intersection
  98766. */
  98767. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  98768. /**
  98769. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  98770. * @param point defines the point to test
  98771. * @returns true if there is an intersection
  98772. */
  98773. intersectsPoint(point: Vector3): boolean;
  98774. /**
  98775. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  98776. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98777. */
  98778. get checkCollisions(): boolean;
  98779. set checkCollisions(collisionEnabled: boolean);
  98780. /**
  98781. * Gets Collider object used to compute collisions (not physics)
  98782. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98783. */
  98784. get collider(): Nullable<Collider>;
  98785. /**
  98786. * Move the mesh using collision engine
  98787. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  98788. * @param displacement defines the requested displacement vector
  98789. * @returns the current mesh
  98790. */
  98791. moveWithCollisions(displacement: Vector3): AbstractMesh;
  98792. private _onCollisionPositionChange;
  98793. /** @hidden */
  98794. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  98795. /** @hidden */
  98796. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  98797. /** @hidden */
  98798. _checkCollision(collider: Collider): AbstractMesh;
  98799. /** @hidden */
  98800. _generatePointsArray(): boolean;
  98801. /**
  98802. * Checks if the passed Ray intersects with the mesh
  98803. * @param ray defines the ray to use
  98804. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  98805. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98806. * @returns the picking info
  98807. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  98808. */
  98809. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  98810. /**
  98811. * Clones the current mesh
  98812. * @param name defines the mesh name
  98813. * @param newParent defines the new mesh parent
  98814. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  98815. * @returns the new mesh
  98816. */
  98817. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  98818. /**
  98819. * Disposes all the submeshes of the current meshnp
  98820. * @returns the current mesh
  98821. */
  98822. releaseSubMeshes(): AbstractMesh;
  98823. /**
  98824. * Releases resources associated with this abstract mesh.
  98825. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98826. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98827. */
  98828. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98829. /**
  98830. * Adds the passed mesh as a child to the current mesh
  98831. * @param mesh defines the child mesh
  98832. * @returns the current mesh
  98833. */
  98834. addChild(mesh: AbstractMesh): AbstractMesh;
  98835. /**
  98836. * Removes the passed mesh from the current mesh children list
  98837. * @param mesh defines the child mesh
  98838. * @returns the current mesh
  98839. */
  98840. removeChild(mesh: AbstractMesh): AbstractMesh;
  98841. /** @hidden */
  98842. private _initFacetData;
  98843. /**
  98844. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  98845. * This method can be called within the render loop.
  98846. * 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
  98847. * @returns the current mesh
  98848. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98849. */
  98850. updateFacetData(): AbstractMesh;
  98851. /**
  98852. * Returns the facetLocalNormals array.
  98853. * The normals are expressed in the mesh local spac
  98854. * @returns an array of Vector3
  98855. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98856. */
  98857. getFacetLocalNormals(): Vector3[];
  98858. /**
  98859. * Returns the facetLocalPositions array.
  98860. * The facet positions are expressed in the mesh local space
  98861. * @returns an array of Vector3
  98862. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98863. */
  98864. getFacetLocalPositions(): Vector3[];
  98865. /**
  98866. * Returns the facetLocalPartioning array
  98867. * @returns an array of array of numbers
  98868. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98869. */
  98870. getFacetLocalPartitioning(): number[][];
  98871. /**
  98872. * Returns the i-th facet position in the world system.
  98873. * This method allocates a new Vector3 per call
  98874. * @param i defines the facet index
  98875. * @returns a new Vector3
  98876. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98877. */
  98878. getFacetPosition(i: number): Vector3;
  98879. /**
  98880. * Sets the reference Vector3 with the i-th facet position in the world system
  98881. * @param i defines the facet index
  98882. * @param ref defines the target vector
  98883. * @returns the current mesh
  98884. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98885. */
  98886. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  98887. /**
  98888. * Returns the i-th facet normal in the world system.
  98889. * This method allocates a new Vector3 per call
  98890. * @param i defines the facet index
  98891. * @returns a new Vector3
  98892. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98893. */
  98894. getFacetNormal(i: number): Vector3;
  98895. /**
  98896. * Sets the reference Vector3 with the i-th facet normal in the world system
  98897. * @param i defines the facet index
  98898. * @param ref defines the target vector
  98899. * @returns the current mesh
  98900. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98901. */
  98902. getFacetNormalToRef(i: number, ref: Vector3): this;
  98903. /**
  98904. * 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)
  98905. * @param x defines x coordinate
  98906. * @param y defines y coordinate
  98907. * @param z defines z coordinate
  98908. * @returns the array of facet indexes
  98909. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98910. */
  98911. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  98912. /**
  98913. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  98914. * @param projected sets as the (x,y,z) world projection on the facet
  98915. * @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
  98916. * @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
  98917. * @param x defines x coordinate
  98918. * @param y defines y coordinate
  98919. * @param z defines z coordinate
  98920. * @returns the face index if found (or null instead)
  98921. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98922. */
  98923. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  98924. /**
  98925. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  98926. * @param projected sets as the (x,y,z) local projection on the facet
  98927. * @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
  98928. * @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
  98929. * @param x defines x coordinate
  98930. * @param y defines y coordinate
  98931. * @param z defines z coordinate
  98932. * @returns the face index if found (or null instead)
  98933. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98934. */
  98935. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  98936. /**
  98937. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  98938. * @returns the parameters
  98939. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98940. */
  98941. getFacetDataParameters(): any;
  98942. /**
  98943. * Disables the feature FacetData and frees the related memory
  98944. * @returns the current mesh
  98945. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  98946. */
  98947. disableFacetData(): AbstractMesh;
  98948. /**
  98949. * Updates the AbstractMesh indices array
  98950. * @param indices defines the data source
  98951. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  98952. * @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)
  98953. * @returns the current mesh
  98954. */
  98955. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  98956. /**
  98957. * Creates new normals data for the mesh
  98958. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  98959. * @returns the current mesh
  98960. */
  98961. createNormals(updatable: boolean): AbstractMesh;
  98962. /**
  98963. * Align the mesh with a normal
  98964. * @param normal defines the normal to use
  98965. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  98966. * @returns the current mesh
  98967. */
  98968. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  98969. /** @hidden */
  98970. _checkOcclusionQuery(): boolean;
  98971. /**
  98972. * Disables the mesh edge rendering mode
  98973. * @returns the currentAbstractMesh
  98974. */
  98975. disableEdgesRendering(): AbstractMesh;
  98976. /**
  98977. * Enables the edge rendering mode on the mesh.
  98978. * This mode makes the mesh edges visible
  98979. * @param epsilon defines the maximal distance between two angles to detect a face
  98980. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  98981. * @returns the currentAbstractMesh
  98982. * @see https://www.babylonjs-playground.com/#19O9TU#0
  98983. */
  98984. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  98985. }
  98986. }
  98987. declare module BABYLON {
  98988. /**
  98989. * Interface used to define ActionEvent
  98990. */
  98991. export interface IActionEvent {
  98992. /** The mesh or sprite that triggered the action */
  98993. source: any;
  98994. /** The X mouse cursor position at the time of the event */
  98995. pointerX: number;
  98996. /** The Y mouse cursor position at the time of the event */
  98997. pointerY: number;
  98998. /** The mesh that is currently pointed at (can be null) */
  98999. meshUnderPointer: Nullable<AbstractMesh>;
  99000. /** the original (browser) event that triggered the ActionEvent */
  99001. sourceEvent?: any;
  99002. /** additional data for the event */
  99003. additionalData?: any;
  99004. }
  99005. /**
  99006. * ActionEvent is the event being sent when an action is triggered.
  99007. */
  99008. export class ActionEvent implements IActionEvent {
  99009. /** The mesh or sprite that triggered the action */
  99010. source: any;
  99011. /** The X mouse cursor position at the time of the event */
  99012. pointerX: number;
  99013. /** The Y mouse cursor position at the time of the event */
  99014. pointerY: number;
  99015. /** The mesh that is currently pointed at (can be null) */
  99016. meshUnderPointer: Nullable<AbstractMesh>;
  99017. /** the original (browser) event that triggered the ActionEvent */
  99018. sourceEvent?: any;
  99019. /** additional data for the event */
  99020. additionalData?: any;
  99021. /**
  99022. * Creates a new ActionEvent
  99023. * @param source The mesh or sprite that triggered the action
  99024. * @param pointerX The X mouse cursor position at the time of the event
  99025. * @param pointerY The Y mouse cursor position at the time of the event
  99026. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  99027. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  99028. * @param additionalData additional data for the event
  99029. */
  99030. constructor(
  99031. /** The mesh or sprite that triggered the action */
  99032. source: any,
  99033. /** The X mouse cursor position at the time of the event */
  99034. pointerX: number,
  99035. /** The Y mouse cursor position at the time of the event */
  99036. pointerY: number,
  99037. /** The mesh that is currently pointed at (can be null) */
  99038. meshUnderPointer: Nullable<AbstractMesh>,
  99039. /** the original (browser) event that triggered the ActionEvent */
  99040. sourceEvent?: any,
  99041. /** additional data for the event */
  99042. additionalData?: any);
  99043. /**
  99044. * Helper function to auto-create an ActionEvent from a source mesh.
  99045. * @param source The source mesh that triggered the event
  99046. * @param evt The original (browser) event
  99047. * @param additionalData additional data for the event
  99048. * @returns the new ActionEvent
  99049. */
  99050. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  99051. /**
  99052. * Helper function to auto-create an ActionEvent from a source sprite
  99053. * @param source The source sprite that triggered the event
  99054. * @param scene Scene associated with the sprite
  99055. * @param evt The original (browser) event
  99056. * @param additionalData additional data for the event
  99057. * @returns the new ActionEvent
  99058. */
  99059. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  99060. /**
  99061. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  99062. * @param scene the scene where the event occurred
  99063. * @param evt The original (browser) event
  99064. * @returns the new ActionEvent
  99065. */
  99066. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  99067. /**
  99068. * Helper function to auto-create an ActionEvent from a primitive
  99069. * @param prim defines the target primitive
  99070. * @param pointerPos defines the pointer position
  99071. * @param evt The original (browser) event
  99072. * @param additionalData additional data for the event
  99073. * @returns the new ActionEvent
  99074. */
  99075. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  99076. }
  99077. }
  99078. declare module BABYLON {
  99079. /**
  99080. * Abstract class used to decouple action Manager from scene and meshes.
  99081. * Do not instantiate.
  99082. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99083. */
  99084. export abstract class AbstractActionManager implements IDisposable {
  99085. /** Gets the list of active triggers */
  99086. static Triggers: {
  99087. [key: string]: number;
  99088. };
  99089. /** Gets the cursor to use when hovering items */
  99090. hoverCursor: string;
  99091. /** Gets the list of actions */
  99092. actions: IAction[];
  99093. /**
  99094. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  99095. */
  99096. isRecursive: boolean;
  99097. /**
  99098. * Releases all associated resources
  99099. */
  99100. abstract dispose(): void;
  99101. /**
  99102. * Does this action manager has pointer triggers
  99103. */
  99104. abstract get hasPointerTriggers(): boolean;
  99105. /**
  99106. * Does this action manager has pick triggers
  99107. */
  99108. abstract get hasPickTriggers(): boolean;
  99109. /**
  99110. * Process a specific trigger
  99111. * @param trigger defines the trigger to process
  99112. * @param evt defines the event details to be processed
  99113. */
  99114. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  99115. /**
  99116. * Does this action manager handles actions of any of the given triggers
  99117. * @param triggers defines the triggers to be tested
  99118. * @return a boolean indicating whether one (or more) of the triggers is handled
  99119. */
  99120. abstract hasSpecificTriggers(triggers: number[]): boolean;
  99121. /**
  99122. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  99123. * speed.
  99124. * @param triggerA defines the trigger to be tested
  99125. * @param triggerB defines the trigger to be tested
  99126. * @return a boolean indicating whether one (or more) of the triggers is handled
  99127. */
  99128. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  99129. /**
  99130. * Does this action manager handles actions of a given trigger
  99131. * @param trigger defines the trigger to be tested
  99132. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  99133. * @return whether the trigger is handled
  99134. */
  99135. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  99136. /**
  99137. * Serialize this manager to a JSON object
  99138. * @param name defines the property name to store this manager
  99139. * @returns a JSON representation of this manager
  99140. */
  99141. abstract serialize(name: string): any;
  99142. /**
  99143. * Registers an action to this action manager
  99144. * @param action defines the action to be registered
  99145. * @return the action amended (prepared) after registration
  99146. */
  99147. abstract registerAction(action: IAction): Nullable<IAction>;
  99148. /**
  99149. * Unregisters an action to this action manager
  99150. * @param action defines the action to be unregistered
  99151. * @return a boolean indicating whether the action has been unregistered
  99152. */
  99153. abstract unregisterAction(action: IAction): Boolean;
  99154. /**
  99155. * Does exist one action manager with at least one trigger
  99156. **/
  99157. static get HasTriggers(): boolean;
  99158. /**
  99159. * Does exist one action manager with at least one pick trigger
  99160. **/
  99161. static get HasPickTriggers(): boolean;
  99162. /**
  99163. * Does exist one action manager that handles actions of a given trigger
  99164. * @param trigger defines the trigger to be tested
  99165. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  99166. **/
  99167. static HasSpecificTrigger(trigger: number): boolean;
  99168. }
  99169. }
  99170. declare module BABYLON {
  99171. /**
  99172. * Defines how a node can be built from a string name.
  99173. */
  99174. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  99175. /**
  99176. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  99177. */
  99178. export class Node implements IBehaviorAware<Node> {
  99179. /** @hidden */
  99180. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  99181. private static _NodeConstructors;
  99182. /**
  99183. * Add a new node constructor
  99184. * @param type defines the type name of the node to construct
  99185. * @param constructorFunc defines the constructor function
  99186. */
  99187. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  99188. /**
  99189. * Returns a node constructor based on type name
  99190. * @param type defines the type name
  99191. * @param name defines the new node name
  99192. * @param scene defines the hosting scene
  99193. * @param options defines optional options to transmit to constructors
  99194. * @returns the new constructor or null
  99195. */
  99196. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  99197. /**
  99198. * Gets or sets the name of the node
  99199. */
  99200. name: string;
  99201. /**
  99202. * Gets or sets the id of the node
  99203. */
  99204. id: string;
  99205. /**
  99206. * Gets or sets the unique id of the node
  99207. */
  99208. uniqueId: number;
  99209. /**
  99210. * Gets or sets a string used to store user defined state for the node
  99211. */
  99212. state: string;
  99213. /**
  99214. * Gets or sets an object used to store user defined information for the node
  99215. */
  99216. metadata: any;
  99217. /**
  99218. * For internal use only. Please do not use.
  99219. */
  99220. reservedDataStore: any;
  99221. /**
  99222. * List of inspectable custom properties (used by the Inspector)
  99223. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  99224. */
  99225. inspectableCustomProperties: IInspectable[];
  99226. private _doNotSerialize;
  99227. /**
  99228. * Gets or sets a boolean used to define if the node must be serialized
  99229. */
  99230. get doNotSerialize(): boolean;
  99231. set doNotSerialize(value: boolean);
  99232. /** @hidden */
  99233. _isDisposed: boolean;
  99234. /**
  99235. * Gets a list of Animations associated with the node
  99236. */
  99237. animations: Animation[];
  99238. protected _ranges: {
  99239. [name: string]: Nullable<AnimationRange>;
  99240. };
  99241. /**
  99242. * Callback raised when the node is ready to be used
  99243. */
  99244. onReady: Nullable<(node: Node) => void>;
  99245. private _isEnabled;
  99246. private _isParentEnabled;
  99247. private _isReady;
  99248. /** @hidden */
  99249. _currentRenderId: number;
  99250. private _parentUpdateId;
  99251. /** @hidden */
  99252. _childUpdateId: number;
  99253. /** @hidden */
  99254. _waitingParentId: Nullable<string>;
  99255. /** @hidden */
  99256. _scene: Scene;
  99257. /** @hidden */
  99258. _cache: any;
  99259. private _parentNode;
  99260. private _children;
  99261. /** @hidden */
  99262. _worldMatrix: Matrix;
  99263. /** @hidden */
  99264. _worldMatrixDeterminant: number;
  99265. /** @hidden */
  99266. _worldMatrixDeterminantIsDirty: boolean;
  99267. /** @hidden */
  99268. private _sceneRootNodesIndex;
  99269. /**
  99270. * Gets a boolean indicating if the node has been disposed
  99271. * @returns true if the node was disposed
  99272. */
  99273. isDisposed(): boolean;
  99274. /**
  99275. * Gets or sets the parent of the node (without keeping the current position in the scene)
  99276. * @see https://doc.babylonjs.com/how_to/parenting
  99277. */
  99278. set parent(parent: Nullable<Node>);
  99279. get parent(): Nullable<Node>;
  99280. /** @hidden */
  99281. _addToSceneRootNodes(): void;
  99282. /** @hidden */
  99283. _removeFromSceneRootNodes(): void;
  99284. private _animationPropertiesOverride;
  99285. /**
  99286. * Gets or sets the animation properties override
  99287. */
  99288. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  99289. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  99290. /**
  99291. * Gets a string idenfifying the name of the class
  99292. * @returns "Node" string
  99293. */
  99294. getClassName(): string;
  99295. /** @hidden */
  99296. readonly _isNode: boolean;
  99297. /**
  99298. * An event triggered when the mesh is disposed
  99299. */
  99300. onDisposeObservable: Observable<Node>;
  99301. private _onDisposeObserver;
  99302. /**
  99303. * Sets a callback that will be raised when the node will be disposed
  99304. */
  99305. set onDispose(callback: () => void);
  99306. /**
  99307. * Creates a new Node
  99308. * @param name the name and id to be given to this node
  99309. * @param scene the scene this node will be added to
  99310. */
  99311. constructor(name: string, scene?: Nullable<Scene>);
  99312. /**
  99313. * Gets the scene of the node
  99314. * @returns a scene
  99315. */
  99316. getScene(): Scene;
  99317. /**
  99318. * Gets the engine of the node
  99319. * @returns a Engine
  99320. */
  99321. getEngine(): Engine;
  99322. private _behaviors;
  99323. /**
  99324. * Attach a behavior to the node
  99325. * @see http://doc.babylonjs.com/features/behaviour
  99326. * @param behavior defines the behavior to attach
  99327. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  99328. * @returns the current Node
  99329. */
  99330. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  99331. /**
  99332. * Remove an attached behavior
  99333. * @see http://doc.babylonjs.com/features/behaviour
  99334. * @param behavior defines the behavior to attach
  99335. * @returns the current Node
  99336. */
  99337. removeBehavior(behavior: Behavior<Node>): Node;
  99338. /**
  99339. * Gets the list of attached behaviors
  99340. * @see http://doc.babylonjs.com/features/behaviour
  99341. */
  99342. get behaviors(): Behavior<Node>[];
  99343. /**
  99344. * Gets an attached behavior by name
  99345. * @param name defines the name of the behavior to look for
  99346. * @see http://doc.babylonjs.com/features/behaviour
  99347. * @returns null if behavior was not found else the requested behavior
  99348. */
  99349. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  99350. /**
  99351. * Returns the latest update of the World matrix
  99352. * @returns a Matrix
  99353. */
  99354. getWorldMatrix(): Matrix;
  99355. /** @hidden */
  99356. _getWorldMatrixDeterminant(): number;
  99357. /**
  99358. * Returns directly the latest state of the mesh World matrix.
  99359. * A Matrix is returned.
  99360. */
  99361. get worldMatrixFromCache(): Matrix;
  99362. /** @hidden */
  99363. _initCache(): void;
  99364. /** @hidden */
  99365. updateCache(force?: boolean): void;
  99366. /** @hidden */
  99367. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  99368. /** @hidden */
  99369. _updateCache(ignoreParentClass?: boolean): void;
  99370. /** @hidden */
  99371. _isSynchronized(): boolean;
  99372. /** @hidden */
  99373. _markSyncedWithParent(): void;
  99374. /** @hidden */
  99375. isSynchronizedWithParent(): boolean;
  99376. /** @hidden */
  99377. isSynchronized(): boolean;
  99378. /**
  99379. * Is this node ready to be used/rendered
  99380. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  99381. * @return true if the node is ready
  99382. */
  99383. isReady(completeCheck?: boolean): boolean;
  99384. /**
  99385. * Is this node enabled?
  99386. * 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
  99387. * @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
  99388. * @return whether this node (and its parent) is enabled
  99389. */
  99390. isEnabled(checkAncestors?: boolean): boolean;
  99391. /** @hidden */
  99392. protected _syncParentEnabledState(): void;
  99393. /**
  99394. * Set the enabled state of this node
  99395. * @param value defines the new enabled state
  99396. */
  99397. setEnabled(value: boolean): void;
  99398. /**
  99399. * Is this node a descendant of the given node?
  99400. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  99401. * @param ancestor defines the parent node to inspect
  99402. * @returns a boolean indicating if this node is a descendant of the given node
  99403. */
  99404. isDescendantOf(ancestor: Node): boolean;
  99405. /** @hidden */
  99406. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  99407. /**
  99408. * Will return all nodes that have this node as ascendant
  99409. * @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
  99410. * @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
  99411. * @return all children nodes of all types
  99412. */
  99413. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  99414. /**
  99415. * Get all child-meshes of this node
  99416. * @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)
  99417. * @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
  99418. * @returns an array of AbstractMesh
  99419. */
  99420. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  99421. /**
  99422. * Get all direct children of this node
  99423. * @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
  99424. * @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)
  99425. * @returns an array of Node
  99426. */
  99427. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  99428. /** @hidden */
  99429. _setReady(state: boolean): void;
  99430. /**
  99431. * Get an animation by name
  99432. * @param name defines the name of the animation to look for
  99433. * @returns null if not found else the requested animation
  99434. */
  99435. getAnimationByName(name: string): Nullable<Animation>;
  99436. /**
  99437. * Creates an animation range for this node
  99438. * @param name defines the name of the range
  99439. * @param from defines the starting key
  99440. * @param to defines the end key
  99441. */
  99442. createAnimationRange(name: string, from: number, to: number): void;
  99443. /**
  99444. * Delete a specific animation range
  99445. * @param name defines the name of the range to delete
  99446. * @param deleteFrames defines if animation frames from the range must be deleted as well
  99447. */
  99448. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  99449. /**
  99450. * Get an animation range by name
  99451. * @param name defines the name of the animation range to look for
  99452. * @returns null if not found else the requested animation range
  99453. */
  99454. getAnimationRange(name: string): Nullable<AnimationRange>;
  99455. /**
  99456. * Gets the list of all animation ranges defined on this node
  99457. * @returns an array
  99458. */
  99459. getAnimationRanges(): Nullable<AnimationRange>[];
  99460. /**
  99461. * Will start the animation sequence
  99462. * @param name defines the range frames for animation sequence
  99463. * @param loop defines if the animation should loop (false by default)
  99464. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  99465. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  99466. * @returns the object created for this animation. If range does not exist, it will return null
  99467. */
  99468. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  99469. /**
  99470. * Serialize animation ranges into a JSON compatible object
  99471. * @returns serialization object
  99472. */
  99473. serializeAnimationRanges(): any;
  99474. /**
  99475. * Computes the world matrix of the node
  99476. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  99477. * @returns the world matrix
  99478. */
  99479. computeWorldMatrix(force?: boolean): Matrix;
  99480. /**
  99481. * Releases resources associated with this node.
  99482. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99483. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99484. */
  99485. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99486. /**
  99487. * Parse animation range data from a serialization object and store them into a given node
  99488. * @param node defines where to store the animation ranges
  99489. * @param parsedNode defines the serialization object to read data from
  99490. * @param scene defines the hosting scene
  99491. */
  99492. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  99493. /**
  99494. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  99495. * @param includeDescendants Include bounding info from descendants as well (true by default)
  99496. * @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
  99497. * @returns the new bounding vectors
  99498. */
  99499. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  99500. min: Vector3;
  99501. max: Vector3;
  99502. };
  99503. }
  99504. }
  99505. declare module BABYLON {
  99506. /**
  99507. * @hidden
  99508. */
  99509. export class _IAnimationState {
  99510. key: number;
  99511. repeatCount: number;
  99512. workValue?: any;
  99513. loopMode?: number;
  99514. offsetValue?: any;
  99515. highLimitValue?: any;
  99516. }
  99517. /**
  99518. * Class used to store any kind of animation
  99519. */
  99520. export class Animation {
  99521. /**Name of the animation */
  99522. name: string;
  99523. /**Property to animate */
  99524. targetProperty: string;
  99525. /**The frames per second of the animation */
  99526. framePerSecond: number;
  99527. /**The data type of the animation */
  99528. dataType: number;
  99529. /**The loop mode of the animation */
  99530. loopMode?: number | undefined;
  99531. /**Specifies if blending should be enabled */
  99532. enableBlending?: boolean | undefined;
  99533. /**
  99534. * Use matrix interpolation instead of using direct key value when animating matrices
  99535. */
  99536. static AllowMatricesInterpolation: boolean;
  99537. /**
  99538. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  99539. */
  99540. static AllowMatrixDecomposeForInterpolation: boolean;
  99541. /**
  99542. * Stores the key frames of the animation
  99543. */
  99544. private _keys;
  99545. /**
  99546. * Stores the easing function of the animation
  99547. */
  99548. private _easingFunction;
  99549. /**
  99550. * @hidden Internal use only
  99551. */
  99552. _runtimeAnimations: RuntimeAnimation[];
  99553. /**
  99554. * The set of event that will be linked to this animation
  99555. */
  99556. private _events;
  99557. /**
  99558. * Stores an array of target property paths
  99559. */
  99560. targetPropertyPath: string[];
  99561. /**
  99562. * Stores the blending speed of the animation
  99563. */
  99564. blendingSpeed: number;
  99565. /**
  99566. * Stores the animation ranges for the animation
  99567. */
  99568. private _ranges;
  99569. /**
  99570. * @hidden Internal use
  99571. */
  99572. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  99573. /**
  99574. * Sets up an animation
  99575. * @param property The property to animate
  99576. * @param animationType The animation type to apply
  99577. * @param framePerSecond The frames per second of the animation
  99578. * @param easingFunction The easing function used in the animation
  99579. * @returns The created animation
  99580. */
  99581. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  99582. /**
  99583. * Create and start an animation on a node
  99584. * @param name defines the name of the global animation that will be run on all nodes
  99585. * @param node defines the root node where the animation will take place
  99586. * @param targetProperty defines property to animate
  99587. * @param framePerSecond defines the number of frame per second yo use
  99588. * @param totalFrame defines the number of frames in total
  99589. * @param from defines the initial value
  99590. * @param to defines the final value
  99591. * @param loopMode defines which loop mode you want to use (off by default)
  99592. * @param easingFunction defines the easing function to use (linear by default)
  99593. * @param onAnimationEnd defines the callback to call when animation end
  99594. * @returns the animatable created for this animation
  99595. */
  99596. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  99597. /**
  99598. * Create and start an animation on a node and its descendants
  99599. * @param name defines the name of the global animation that will be run on all nodes
  99600. * @param node defines the root node where the animation will take place
  99601. * @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
  99602. * @param targetProperty defines property to animate
  99603. * @param framePerSecond defines the number of frame per second to use
  99604. * @param totalFrame defines the number of frames in total
  99605. * @param from defines the initial value
  99606. * @param to defines the final value
  99607. * @param loopMode defines which loop mode you want to use (off by default)
  99608. * @param easingFunction defines the easing function to use (linear by default)
  99609. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  99610. * @returns the list of animatables created for all nodes
  99611. * @example https://www.babylonjs-playground.com/#MH0VLI
  99612. */
  99613. 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[]>;
  99614. /**
  99615. * Creates a new animation, merges it with the existing animations and starts it
  99616. * @param name Name of the animation
  99617. * @param node Node which contains the scene that begins the animations
  99618. * @param targetProperty Specifies which property to animate
  99619. * @param framePerSecond The frames per second of the animation
  99620. * @param totalFrame The total number of frames
  99621. * @param from The frame at the beginning of the animation
  99622. * @param to The frame at the end of the animation
  99623. * @param loopMode Specifies the loop mode of the animation
  99624. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  99625. * @param onAnimationEnd Callback to run once the animation is complete
  99626. * @returns Nullable animation
  99627. */
  99628. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  99629. /**
  99630. * Transition property of an host to the target Value
  99631. * @param property The property to transition
  99632. * @param targetValue The target Value of the property
  99633. * @param host The object where the property to animate belongs
  99634. * @param scene Scene used to run the animation
  99635. * @param frameRate Framerate (in frame/s) to use
  99636. * @param transition The transition type we want to use
  99637. * @param duration The duration of the animation, in milliseconds
  99638. * @param onAnimationEnd Callback trigger at the end of the animation
  99639. * @returns Nullable animation
  99640. */
  99641. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  99642. /**
  99643. * Return the array of runtime animations currently using this animation
  99644. */
  99645. get runtimeAnimations(): RuntimeAnimation[];
  99646. /**
  99647. * Specifies if any of the runtime animations are currently running
  99648. */
  99649. get hasRunningRuntimeAnimations(): boolean;
  99650. /**
  99651. * Initializes the animation
  99652. * @param name Name of the animation
  99653. * @param targetProperty Property to animate
  99654. * @param framePerSecond The frames per second of the animation
  99655. * @param dataType The data type of the animation
  99656. * @param loopMode The loop mode of the animation
  99657. * @param enableBlending Specifies if blending should be enabled
  99658. */
  99659. constructor(
  99660. /**Name of the animation */
  99661. name: string,
  99662. /**Property to animate */
  99663. targetProperty: string,
  99664. /**The frames per second of the animation */
  99665. framePerSecond: number,
  99666. /**The data type of the animation */
  99667. dataType: number,
  99668. /**The loop mode of the animation */
  99669. loopMode?: number | undefined,
  99670. /**Specifies if blending should be enabled */
  99671. enableBlending?: boolean | undefined);
  99672. /**
  99673. * Converts the animation to a string
  99674. * @param fullDetails support for multiple levels of logging within scene loading
  99675. * @returns String form of the animation
  99676. */
  99677. toString(fullDetails?: boolean): string;
  99678. /**
  99679. * Add an event to this animation
  99680. * @param event Event to add
  99681. */
  99682. addEvent(event: AnimationEvent): void;
  99683. /**
  99684. * Remove all events found at the given frame
  99685. * @param frame The frame to remove events from
  99686. */
  99687. removeEvents(frame: number): void;
  99688. /**
  99689. * Retrieves all the events from the animation
  99690. * @returns Events from the animation
  99691. */
  99692. getEvents(): AnimationEvent[];
  99693. /**
  99694. * Creates an animation range
  99695. * @param name Name of the animation range
  99696. * @param from Starting frame of the animation range
  99697. * @param to Ending frame of the animation
  99698. */
  99699. createRange(name: string, from: number, to: number): void;
  99700. /**
  99701. * Deletes an animation range by name
  99702. * @param name Name of the animation range to delete
  99703. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  99704. */
  99705. deleteRange(name: string, deleteFrames?: boolean): void;
  99706. /**
  99707. * Gets the animation range by name, or null if not defined
  99708. * @param name Name of the animation range
  99709. * @returns Nullable animation range
  99710. */
  99711. getRange(name: string): Nullable<AnimationRange>;
  99712. /**
  99713. * Gets the key frames from the animation
  99714. * @returns The key frames of the animation
  99715. */
  99716. getKeys(): Array<IAnimationKey>;
  99717. /**
  99718. * Gets the highest frame rate of the animation
  99719. * @returns Highest frame rate of the animation
  99720. */
  99721. getHighestFrame(): number;
  99722. /**
  99723. * Gets the easing function of the animation
  99724. * @returns Easing function of the animation
  99725. */
  99726. getEasingFunction(): IEasingFunction;
  99727. /**
  99728. * Sets the easing function of the animation
  99729. * @param easingFunction A custom mathematical formula for animation
  99730. */
  99731. setEasingFunction(easingFunction: EasingFunction): void;
  99732. /**
  99733. * Interpolates a scalar linearly
  99734. * @param startValue Start value of the animation curve
  99735. * @param endValue End value of the animation curve
  99736. * @param gradient Scalar amount to interpolate
  99737. * @returns Interpolated scalar value
  99738. */
  99739. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  99740. /**
  99741. * Interpolates a scalar cubically
  99742. * @param startValue Start value of the animation curve
  99743. * @param outTangent End tangent of the animation
  99744. * @param endValue End value of the animation curve
  99745. * @param inTangent Start tangent of the animation curve
  99746. * @param gradient Scalar amount to interpolate
  99747. * @returns Interpolated scalar value
  99748. */
  99749. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  99750. /**
  99751. * Interpolates a quaternion using a spherical linear interpolation
  99752. * @param startValue Start value of the animation curve
  99753. * @param endValue End value of the animation curve
  99754. * @param gradient Scalar amount to interpolate
  99755. * @returns Interpolated quaternion value
  99756. */
  99757. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  99758. /**
  99759. * Interpolates a quaternion cubically
  99760. * @param startValue Start value of the animation curve
  99761. * @param outTangent End tangent of the animation curve
  99762. * @param endValue End value of the animation curve
  99763. * @param inTangent Start tangent of the animation curve
  99764. * @param gradient Scalar amount to interpolate
  99765. * @returns Interpolated quaternion value
  99766. */
  99767. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  99768. /**
  99769. * Interpolates a Vector3 linearl
  99770. * @param startValue Start value of the animation curve
  99771. * @param endValue End value of the animation curve
  99772. * @param gradient Scalar amount to interpolate
  99773. * @returns Interpolated scalar value
  99774. */
  99775. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  99776. /**
  99777. * Interpolates a Vector3 cubically
  99778. * @param startValue Start value of the animation curve
  99779. * @param outTangent End tangent of the animation
  99780. * @param endValue End value of the animation curve
  99781. * @param inTangent Start tangent of the animation curve
  99782. * @param gradient Scalar amount to interpolate
  99783. * @returns InterpolatedVector3 value
  99784. */
  99785. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  99786. /**
  99787. * Interpolates a Vector2 linearly
  99788. * @param startValue Start value of the animation curve
  99789. * @param endValue End value of the animation curve
  99790. * @param gradient Scalar amount to interpolate
  99791. * @returns Interpolated Vector2 value
  99792. */
  99793. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  99794. /**
  99795. * Interpolates a Vector2 cubically
  99796. * @param startValue Start value of the animation curve
  99797. * @param outTangent End tangent of the animation
  99798. * @param endValue End value of the animation curve
  99799. * @param inTangent Start tangent of the animation curve
  99800. * @param gradient Scalar amount to interpolate
  99801. * @returns Interpolated Vector2 value
  99802. */
  99803. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  99804. /**
  99805. * Interpolates a size linearly
  99806. * @param startValue Start value of the animation curve
  99807. * @param endValue End value of the animation curve
  99808. * @param gradient Scalar amount to interpolate
  99809. * @returns Interpolated Size value
  99810. */
  99811. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  99812. /**
  99813. * Interpolates a Color3 linearly
  99814. * @param startValue Start value of the animation curve
  99815. * @param endValue End value of the animation curve
  99816. * @param gradient Scalar amount to interpolate
  99817. * @returns Interpolated Color3 value
  99818. */
  99819. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  99820. /**
  99821. * Interpolates a Color4 linearly
  99822. * @param startValue Start value of the animation curve
  99823. * @param endValue End value of the animation curve
  99824. * @param gradient Scalar amount to interpolate
  99825. * @returns Interpolated Color3 value
  99826. */
  99827. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  99828. /**
  99829. * @hidden Internal use only
  99830. */
  99831. _getKeyValue(value: any): any;
  99832. /**
  99833. * @hidden Internal use only
  99834. */
  99835. _interpolate(currentFrame: number, state: _IAnimationState): any;
  99836. /**
  99837. * Defines the function to use to interpolate matrices
  99838. * @param startValue defines the start matrix
  99839. * @param endValue defines the end matrix
  99840. * @param gradient defines the gradient between both matrices
  99841. * @param result defines an optional target matrix where to store the interpolation
  99842. * @returns the interpolated matrix
  99843. */
  99844. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  99845. /**
  99846. * Makes a copy of the animation
  99847. * @returns Cloned animation
  99848. */
  99849. clone(): Animation;
  99850. /**
  99851. * Sets the key frames of the animation
  99852. * @param values The animation key frames to set
  99853. */
  99854. setKeys(values: Array<IAnimationKey>): void;
  99855. /**
  99856. * Serializes the animation to an object
  99857. * @returns Serialized object
  99858. */
  99859. serialize(): any;
  99860. /**
  99861. * Float animation type
  99862. */
  99863. static readonly ANIMATIONTYPE_FLOAT: number;
  99864. /**
  99865. * Vector3 animation type
  99866. */
  99867. static readonly ANIMATIONTYPE_VECTOR3: number;
  99868. /**
  99869. * Quaternion animation type
  99870. */
  99871. static readonly ANIMATIONTYPE_QUATERNION: number;
  99872. /**
  99873. * Matrix animation type
  99874. */
  99875. static readonly ANIMATIONTYPE_MATRIX: number;
  99876. /**
  99877. * Color3 animation type
  99878. */
  99879. static readonly ANIMATIONTYPE_COLOR3: number;
  99880. /**
  99881. * Color3 animation type
  99882. */
  99883. static readonly ANIMATIONTYPE_COLOR4: number;
  99884. /**
  99885. * Vector2 animation type
  99886. */
  99887. static readonly ANIMATIONTYPE_VECTOR2: number;
  99888. /**
  99889. * Size animation type
  99890. */
  99891. static readonly ANIMATIONTYPE_SIZE: number;
  99892. /**
  99893. * Relative Loop Mode
  99894. */
  99895. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  99896. /**
  99897. * Cycle Loop Mode
  99898. */
  99899. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  99900. /**
  99901. * Constant Loop Mode
  99902. */
  99903. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  99904. /** @hidden */
  99905. static _UniversalLerp(left: any, right: any, amount: number): any;
  99906. /**
  99907. * Parses an animation object and creates an animation
  99908. * @param parsedAnimation Parsed animation object
  99909. * @returns Animation object
  99910. */
  99911. static Parse(parsedAnimation: any): Animation;
  99912. /**
  99913. * Appends the serialized animations from the source animations
  99914. * @param source Source containing the animations
  99915. * @param destination Target to store the animations
  99916. */
  99917. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  99918. }
  99919. }
  99920. declare module BABYLON {
  99921. /**
  99922. * Interface containing an array of animations
  99923. */
  99924. export interface IAnimatable {
  99925. /**
  99926. * Array of animations
  99927. */
  99928. animations: Nullable<Array<Animation>>;
  99929. }
  99930. }
  99931. declare module BABYLON {
  99932. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  99933. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99934. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99935. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99936. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99937. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99938. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99939. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99940. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99941. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99942. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99943. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99944. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99945. /**
  99946. * Decorator used to define property that can be serialized as reference to a camera
  99947. * @param sourceName defines the name of the property to decorate
  99948. */
  99949. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  99950. /**
  99951. * Class used to help serialization objects
  99952. */
  99953. export class SerializationHelper {
  99954. /** @hidden */
  99955. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  99956. /** @hidden */
  99957. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  99958. /** @hidden */
  99959. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  99960. /** @hidden */
  99961. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  99962. /**
  99963. * Appends the serialized animations from the source animations
  99964. * @param source Source containing the animations
  99965. * @param destination Target to store the animations
  99966. */
  99967. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  99968. /**
  99969. * Static function used to serialized a specific entity
  99970. * @param entity defines the entity to serialize
  99971. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  99972. * @returns a JSON compatible object representing the serialization of the entity
  99973. */
  99974. static Serialize<T>(entity: T, serializationObject?: any): any;
  99975. /**
  99976. * Creates a new entity from a serialization data object
  99977. * @param creationFunction defines a function used to instanciated the new entity
  99978. * @param source defines the source serialization data
  99979. * @param scene defines the hosting scene
  99980. * @param rootUrl defines the root url for resources
  99981. * @returns a new entity
  99982. */
  99983. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  99984. /**
  99985. * Clones an object
  99986. * @param creationFunction defines the function used to instanciate the new object
  99987. * @param source defines the source object
  99988. * @returns the cloned object
  99989. */
  99990. static Clone<T>(creationFunction: () => T, source: T): T;
  99991. /**
  99992. * Instanciates a new object based on a source one (some data will be shared between both object)
  99993. * @param creationFunction defines the function used to instanciate the new object
  99994. * @param source defines the source object
  99995. * @returns the new object
  99996. */
  99997. static Instanciate<T>(creationFunction: () => T, source: T): T;
  99998. }
  99999. }
  100000. declare module BABYLON {
  100001. /**
  100002. * Class used to manipulate GUIDs
  100003. */
  100004. export class GUID {
  100005. /**
  100006. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  100007. * Be aware Math.random() could cause collisions, but:
  100008. * "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"
  100009. * @returns a pseudo random id
  100010. */
  100011. static RandomId(): string;
  100012. }
  100013. }
  100014. declare module BABYLON {
  100015. /**
  100016. * Base class of all the textures in babylon.
  100017. * It groups all the common properties the materials, post process, lights... might need
  100018. * in order to make a correct use of the texture.
  100019. */
  100020. export class BaseTexture implements IAnimatable {
  100021. /**
  100022. * Default anisotropic filtering level for the application.
  100023. * It is set to 4 as a good tradeoff between perf and quality.
  100024. */
  100025. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  100026. /**
  100027. * Gets or sets the unique id of the texture
  100028. */
  100029. uniqueId: number;
  100030. /**
  100031. * Define the name of the texture.
  100032. */
  100033. name: string;
  100034. /**
  100035. * Gets or sets an object used to store user defined information.
  100036. */
  100037. metadata: any;
  100038. /**
  100039. * For internal use only. Please do not use.
  100040. */
  100041. reservedDataStore: any;
  100042. private _hasAlpha;
  100043. /**
  100044. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  100045. */
  100046. set hasAlpha(value: boolean);
  100047. get hasAlpha(): boolean;
  100048. /**
  100049. * Defines if the alpha value should be determined via the rgb values.
  100050. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  100051. */
  100052. getAlphaFromRGB: boolean;
  100053. /**
  100054. * Intensity or strength of the texture.
  100055. * It is commonly used by materials to fine tune the intensity of the texture
  100056. */
  100057. level: number;
  100058. /**
  100059. * Define the UV chanel to use starting from 0 and defaulting to 0.
  100060. * This is part of the texture as textures usually maps to one uv set.
  100061. */
  100062. coordinatesIndex: number;
  100063. private _coordinatesMode;
  100064. /**
  100065. * How a texture is mapped.
  100066. *
  100067. * | Value | Type | Description |
  100068. * | ----- | ----------------------------------- | ----------- |
  100069. * | 0 | EXPLICIT_MODE | |
  100070. * | 1 | SPHERICAL_MODE | |
  100071. * | 2 | PLANAR_MODE | |
  100072. * | 3 | CUBIC_MODE | |
  100073. * | 4 | PROJECTION_MODE | |
  100074. * | 5 | SKYBOX_MODE | |
  100075. * | 6 | INVCUBIC_MODE | |
  100076. * | 7 | EQUIRECTANGULAR_MODE | |
  100077. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  100078. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  100079. */
  100080. set coordinatesMode(value: number);
  100081. get coordinatesMode(): number;
  100082. /**
  100083. * | Value | Type | Description |
  100084. * | ----- | ------------------ | ----------- |
  100085. * | 0 | CLAMP_ADDRESSMODE | |
  100086. * | 1 | WRAP_ADDRESSMODE | |
  100087. * | 2 | MIRROR_ADDRESSMODE | |
  100088. */
  100089. wrapU: number;
  100090. /**
  100091. * | Value | Type | Description |
  100092. * | ----- | ------------------ | ----------- |
  100093. * | 0 | CLAMP_ADDRESSMODE | |
  100094. * | 1 | WRAP_ADDRESSMODE | |
  100095. * | 2 | MIRROR_ADDRESSMODE | |
  100096. */
  100097. wrapV: number;
  100098. /**
  100099. * | Value | Type | Description |
  100100. * | ----- | ------------------ | ----------- |
  100101. * | 0 | CLAMP_ADDRESSMODE | |
  100102. * | 1 | WRAP_ADDRESSMODE | |
  100103. * | 2 | MIRROR_ADDRESSMODE | |
  100104. */
  100105. wrapR: number;
  100106. /**
  100107. * With compliant hardware and browser (supporting anisotropic filtering)
  100108. * this defines the level of anisotropic filtering in the texture.
  100109. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  100110. */
  100111. anisotropicFilteringLevel: number;
  100112. /**
  100113. * Define if the texture is a cube texture or if false a 2d texture.
  100114. */
  100115. get isCube(): boolean;
  100116. set isCube(value: boolean);
  100117. /**
  100118. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  100119. */
  100120. get is3D(): boolean;
  100121. set is3D(value: boolean);
  100122. /**
  100123. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  100124. */
  100125. get is2DArray(): boolean;
  100126. set is2DArray(value: boolean);
  100127. /**
  100128. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  100129. * HDR texture are usually stored in linear space.
  100130. * This only impacts the PBR and Background materials
  100131. */
  100132. gammaSpace: boolean;
  100133. /**
  100134. * Gets or sets whether or not the texture contains RGBD data.
  100135. */
  100136. get isRGBD(): boolean;
  100137. set isRGBD(value: boolean);
  100138. /**
  100139. * Is Z inverted in the texture (useful in a cube texture).
  100140. */
  100141. invertZ: boolean;
  100142. /**
  100143. * Are mip maps generated for this texture or not.
  100144. */
  100145. get noMipmap(): boolean;
  100146. /**
  100147. * @hidden
  100148. */
  100149. lodLevelInAlpha: boolean;
  100150. /**
  100151. * With prefiltered texture, defined the offset used during the prefiltering steps.
  100152. */
  100153. get lodGenerationOffset(): number;
  100154. set lodGenerationOffset(value: number);
  100155. /**
  100156. * With prefiltered texture, defined the scale used during the prefiltering steps.
  100157. */
  100158. get lodGenerationScale(): number;
  100159. set lodGenerationScale(value: number);
  100160. /**
  100161. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  100162. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  100163. * average roughness values.
  100164. */
  100165. get linearSpecularLOD(): boolean;
  100166. set linearSpecularLOD(value: boolean);
  100167. /**
  100168. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  100169. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  100170. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  100171. */
  100172. get irradianceTexture(): Nullable<BaseTexture>;
  100173. set irradianceTexture(value: Nullable<BaseTexture>);
  100174. /**
  100175. * Define if the texture is a render target.
  100176. */
  100177. isRenderTarget: boolean;
  100178. /**
  100179. * Define the unique id of the texture in the scene.
  100180. */
  100181. get uid(): string;
  100182. /**
  100183. * Return a string representation of the texture.
  100184. * @returns the texture as a string
  100185. */
  100186. toString(): string;
  100187. /**
  100188. * Get the class name of the texture.
  100189. * @returns "BaseTexture"
  100190. */
  100191. getClassName(): string;
  100192. /**
  100193. * Define the list of animation attached to the texture.
  100194. */
  100195. animations: Animation[];
  100196. /**
  100197. * An event triggered when the texture is disposed.
  100198. */
  100199. onDisposeObservable: Observable<BaseTexture>;
  100200. private _onDisposeObserver;
  100201. /**
  100202. * Callback triggered when the texture has been disposed.
  100203. * Kept for back compatibility, you can use the onDisposeObservable instead.
  100204. */
  100205. set onDispose(callback: () => void);
  100206. /**
  100207. * Define the current state of the loading sequence when in delayed load mode.
  100208. */
  100209. delayLoadState: number;
  100210. private _scene;
  100211. /** @hidden */
  100212. _texture: Nullable<InternalTexture>;
  100213. private _uid;
  100214. /**
  100215. * Define if the texture is preventinga material to render or not.
  100216. * If not and the texture is not ready, the engine will use a default black texture instead.
  100217. */
  100218. get isBlocking(): boolean;
  100219. /**
  100220. * Instantiates a new BaseTexture.
  100221. * Base class of all the textures in babylon.
  100222. * It groups all the common properties the materials, post process, lights... might need
  100223. * in order to make a correct use of the texture.
  100224. * @param scene Define the scene the texture blongs to
  100225. */
  100226. constructor(scene: Nullable<Scene>);
  100227. /**
  100228. * Get the scene the texture belongs to.
  100229. * @returns the scene or null if undefined
  100230. */
  100231. getScene(): Nullable<Scene>;
  100232. /**
  100233. * Get the texture transform matrix used to offset tile the texture for istance.
  100234. * @returns the transformation matrix
  100235. */
  100236. getTextureMatrix(): Matrix;
  100237. /**
  100238. * Get the texture reflection matrix used to rotate/transform the reflection.
  100239. * @returns the reflection matrix
  100240. */
  100241. getReflectionTextureMatrix(): Matrix;
  100242. /**
  100243. * Get the underlying lower level texture from Babylon.
  100244. * @returns the insternal texture
  100245. */
  100246. getInternalTexture(): Nullable<InternalTexture>;
  100247. /**
  100248. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  100249. * @returns true if ready or not blocking
  100250. */
  100251. isReadyOrNotBlocking(): boolean;
  100252. /**
  100253. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  100254. * @returns true if fully ready
  100255. */
  100256. isReady(): boolean;
  100257. private _cachedSize;
  100258. /**
  100259. * Get the size of the texture.
  100260. * @returns the texture size.
  100261. */
  100262. getSize(): ISize;
  100263. /**
  100264. * Get the base size of the texture.
  100265. * It can be different from the size if the texture has been resized for POT for instance
  100266. * @returns the base size
  100267. */
  100268. getBaseSize(): ISize;
  100269. /**
  100270. * Update the sampling mode of the texture.
  100271. * Default is Trilinear mode.
  100272. *
  100273. * | Value | Type | Description |
  100274. * | ----- | ------------------ | ----------- |
  100275. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  100276. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  100277. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  100278. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  100279. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  100280. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  100281. * | 7 | NEAREST_LINEAR | |
  100282. * | 8 | NEAREST_NEAREST | |
  100283. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  100284. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  100285. * | 11 | LINEAR_LINEAR | |
  100286. * | 12 | LINEAR_NEAREST | |
  100287. *
  100288. * > _mag_: magnification filter (close to the viewer)
  100289. * > _min_: minification filter (far from the viewer)
  100290. * > _mip_: filter used between mip map levels
  100291. *@param samplingMode Define the new sampling mode of the texture
  100292. */
  100293. updateSamplingMode(samplingMode: number): void;
  100294. /**
  100295. * Scales the texture if is `canRescale()`
  100296. * @param ratio the resize factor we want to use to rescale
  100297. */
  100298. scale(ratio: number): void;
  100299. /**
  100300. * Get if the texture can rescale.
  100301. */
  100302. get canRescale(): boolean;
  100303. /** @hidden */
  100304. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  100305. /** @hidden */
  100306. _rebuild(): void;
  100307. /**
  100308. * Triggers the load sequence in delayed load mode.
  100309. */
  100310. delayLoad(): void;
  100311. /**
  100312. * Clones the texture.
  100313. * @returns the cloned texture
  100314. */
  100315. clone(): Nullable<BaseTexture>;
  100316. /**
  100317. * Get the texture underlying type (INT, FLOAT...)
  100318. */
  100319. get textureType(): number;
  100320. /**
  100321. * Get the texture underlying format (RGB, RGBA...)
  100322. */
  100323. get textureFormat(): number;
  100324. /**
  100325. * Indicates that textures need to be re-calculated for all materials
  100326. */
  100327. protected _markAllSubMeshesAsTexturesDirty(): void;
  100328. /**
  100329. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  100330. * This will returns an RGBA array buffer containing either in values (0-255) or
  100331. * float values (0-1) depending of the underlying buffer type.
  100332. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  100333. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  100334. * @param buffer defines a user defined buffer to fill with data (can be null)
  100335. * @returns The Array buffer containing the pixels data.
  100336. */
  100337. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  100338. /**
  100339. * Release and destroy the underlying lower level texture aka internalTexture.
  100340. */
  100341. releaseInternalTexture(): void;
  100342. /** @hidden */
  100343. get _lodTextureHigh(): Nullable<BaseTexture>;
  100344. /** @hidden */
  100345. get _lodTextureMid(): Nullable<BaseTexture>;
  100346. /** @hidden */
  100347. get _lodTextureLow(): Nullable<BaseTexture>;
  100348. /**
  100349. * Dispose the texture and release its associated resources.
  100350. */
  100351. dispose(): void;
  100352. /**
  100353. * Serialize the texture into a JSON representation that can be parsed later on.
  100354. * @returns the JSON representation of the texture
  100355. */
  100356. serialize(): any;
  100357. /**
  100358. * Helper function to be called back once a list of texture contains only ready textures.
  100359. * @param textures Define the list of textures to wait for
  100360. * @param callback Define the callback triggered once the entire list will be ready
  100361. */
  100362. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  100363. }
  100364. }
  100365. declare module BABYLON {
  100366. /**
  100367. * Options to be used when creating an effect.
  100368. */
  100369. export interface IEffectCreationOptions {
  100370. /**
  100371. * Atrributes that will be used in the shader.
  100372. */
  100373. attributes: string[];
  100374. /**
  100375. * Uniform varible names that will be set in the shader.
  100376. */
  100377. uniformsNames: string[];
  100378. /**
  100379. * Uniform buffer variable names that will be set in the shader.
  100380. */
  100381. uniformBuffersNames: string[];
  100382. /**
  100383. * Sampler texture variable names that will be set in the shader.
  100384. */
  100385. samplers: string[];
  100386. /**
  100387. * Define statements that will be set in the shader.
  100388. */
  100389. defines: any;
  100390. /**
  100391. * Possible fallbacks for this effect to improve performance when needed.
  100392. */
  100393. fallbacks: Nullable<IEffectFallbacks>;
  100394. /**
  100395. * Callback that will be called when the shader is compiled.
  100396. */
  100397. onCompiled: Nullable<(effect: Effect) => void>;
  100398. /**
  100399. * Callback that will be called if an error occurs during shader compilation.
  100400. */
  100401. onError: Nullable<(effect: Effect, errors: string) => void>;
  100402. /**
  100403. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  100404. */
  100405. indexParameters?: any;
  100406. /**
  100407. * Max number of lights that can be used in the shader.
  100408. */
  100409. maxSimultaneousLights?: number;
  100410. /**
  100411. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  100412. */
  100413. transformFeedbackVaryings?: Nullable<string[]>;
  100414. }
  100415. /**
  100416. * Effect containing vertex and fragment shader that can be executed on an object.
  100417. */
  100418. export class Effect implements IDisposable {
  100419. /**
  100420. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  100421. */
  100422. static ShadersRepository: string;
  100423. /**
  100424. * Name of the effect.
  100425. */
  100426. name: any;
  100427. /**
  100428. * String container all the define statements that should be set on the shader.
  100429. */
  100430. defines: string;
  100431. /**
  100432. * Callback that will be called when the shader is compiled.
  100433. */
  100434. onCompiled: Nullable<(effect: Effect) => void>;
  100435. /**
  100436. * Callback that will be called if an error occurs during shader compilation.
  100437. */
  100438. onError: Nullable<(effect: Effect, errors: string) => void>;
  100439. /**
  100440. * Callback that will be called when effect is bound.
  100441. */
  100442. onBind: Nullable<(effect: Effect) => void>;
  100443. /**
  100444. * Unique ID of the effect.
  100445. */
  100446. uniqueId: number;
  100447. /**
  100448. * Observable that will be called when the shader is compiled.
  100449. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  100450. */
  100451. onCompileObservable: Observable<Effect>;
  100452. /**
  100453. * Observable that will be called if an error occurs during shader compilation.
  100454. */
  100455. onErrorObservable: Observable<Effect>;
  100456. /** @hidden */
  100457. _onBindObservable: Nullable<Observable<Effect>>;
  100458. /**
  100459. * Observable that will be called when effect is bound.
  100460. */
  100461. get onBindObservable(): Observable<Effect>;
  100462. /** @hidden */
  100463. _bonesComputationForcedToCPU: boolean;
  100464. private static _uniqueIdSeed;
  100465. private _engine;
  100466. private _uniformBuffersNames;
  100467. private _uniformsNames;
  100468. private _samplerList;
  100469. private _samplers;
  100470. private _isReady;
  100471. private _compilationError;
  100472. private _allFallbacksProcessed;
  100473. private _attributesNames;
  100474. private _attributes;
  100475. private _attributeLocationByName;
  100476. private _uniforms;
  100477. /**
  100478. * Key for the effect.
  100479. * @hidden
  100480. */
  100481. _key: string;
  100482. private _indexParameters;
  100483. private _fallbacks;
  100484. private _vertexSourceCode;
  100485. private _fragmentSourceCode;
  100486. private _vertexSourceCodeOverride;
  100487. private _fragmentSourceCodeOverride;
  100488. private _transformFeedbackVaryings;
  100489. /**
  100490. * Compiled shader to webGL program.
  100491. * @hidden
  100492. */
  100493. _pipelineContext: Nullable<IPipelineContext>;
  100494. private _valueCache;
  100495. private static _baseCache;
  100496. /**
  100497. * Instantiates an effect.
  100498. * An effect can be used to create/manage/execute vertex and fragment shaders.
  100499. * @param baseName Name of the effect.
  100500. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  100501. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  100502. * @param samplers List of sampler variables that will be passed to the shader.
  100503. * @param engine Engine to be used to render the effect
  100504. * @param defines Define statements to be added to the shader.
  100505. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  100506. * @param onCompiled Callback that will be called when the shader is compiled.
  100507. * @param onError Callback that will be called if an error occurs during shader compilation.
  100508. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  100509. */
  100510. 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);
  100511. private _useFinalCode;
  100512. /**
  100513. * Unique key for this effect
  100514. */
  100515. get key(): string;
  100516. /**
  100517. * If the effect has been compiled and prepared.
  100518. * @returns if the effect is compiled and prepared.
  100519. */
  100520. isReady(): boolean;
  100521. private _isReadyInternal;
  100522. /**
  100523. * The engine the effect was initialized with.
  100524. * @returns the engine.
  100525. */
  100526. getEngine(): Engine;
  100527. /**
  100528. * The pipeline context for this effect
  100529. * @returns the associated pipeline context
  100530. */
  100531. getPipelineContext(): Nullable<IPipelineContext>;
  100532. /**
  100533. * The set of names of attribute variables for the shader.
  100534. * @returns An array of attribute names.
  100535. */
  100536. getAttributesNames(): string[];
  100537. /**
  100538. * Returns the attribute at the given index.
  100539. * @param index The index of the attribute.
  100540. * @returns The location of the attribute.
  100541. */
  100542. getAttributeLocation(index: number): number;
  100543. /**
  100544. * Returns the attribute based on the name of the variable.
  100545. * @param name of the attribute to look up.
  100546. * @returns the attribute location.
  100547. */
  100548. getAttributeLocationByName(name: string): number;
  100549. /**
  100550. * The number of attributes.
  100551. * @returns the numnber of attributes.
  100552. */
  100553. getAttributesCount(): number;
  100554. /**
  100555. * Gets the index of a uniform variable.
  100556. * @param uniformName of the uniform to look up.
  100557. * @returns the index.
  100558. */
  100559. getUniformIndex(uniformName: string): number;
  100560. /**
  100561. * Returns the attribute based on the name of the variable.
  100562. * @param uniformName of the uniform to look up.
  100563. * @returns the location of the uniform.
  100564. */
  100565. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  100566. /**
  100567. * Returns an array of sampler variable names
  100568. * @returns The array of sampler variable neames.
  100569. */
  100570. getSamplers(): string[];
  100571. /**
  100572. * The error from the last compilation.
  100573. * @returns the error string.
  100574. */
  100575. getCompilationError(): string;
  100576. /**
  100577. * Gets a boolean indicating that all fallbacks were used during compilation
  100578. * @returns true if all fallbacks were used
  100579. */
  100580. allFallbacksProcessed(): boolean;
  100581. /**
  100582. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  100583. * @param func The callback to be used.
  100584. */
  100585. executeWhenCompiled(func: (effect: Effect) => void): void;
  100586. private _checkIsReady;
  100587. private _loadShader;
  100588. /**
  100589. * Recompiles the webGL program
  100590. * @param vertexSourceCode The source code for the vertex shader.
  100591. * @param fragmentSourceCode The source code for the fragment shader.
  100592. * @param onCompiled Callback called when completed.
  100593. * @param onError Callback called on error.
  100594. * @hidden
  100595. */
  100596. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  100597. /**
  100598. * Prepares the effect
  100599. * @hidden
  100600. */
  100601. _prepareEffect(): void;
  100602. private _processCompilationErrors;
  100603. /**
  100604. * Checks if the effect is supported. (Must be called after compilation)
  100605. */
  100606. get isSupported(): boolean;
  100607. /**
  100608. * Binds a texture to the engine to be used as output of the shader.
  100609. * @param channel Name of the output variable.
  100610. * @param texture Texture to bind.
  100611. * @hidden
  100612. */
  100613. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  100614. /**
  100615. * Sets a texture on the engine to be used in the shader.
  100616. * @param channel Name of the sampler variable.
  100617. * @param texture Texture to set.
  100618. */
  100619. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  100620. /**
  100621. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  100622. * @param channel Name of the sampler variable.
  100623. * @param texture Texture to set.
  100624. */
  100625. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  100626. /**
  100627. * Sets an array of textures on the engine to be used in the shader.
  100628. * @param channel Name of the variable.
  100629. * @param textures Textures to set.
  100630. */
  100631. setTextureArray(channel: string, textures: BaseTexture[]): void;
  100632. /**
  100633. * 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)
  100634. * @param channel Name of the sampler variable.
  100635. * @param postProcess Post process to get the input texture from.
  100636. */
  100637. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  100638. /**
  100639. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  100640. * 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)
  100641. * @param channel Name of the sampler variable.
  100642. * @param postProcess Post process to get the output texture from.
  100643. */
  100644. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  100645. /** @hidden */
  100646. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  100647. /** @hidden */
  100648. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  100649. /** @hidden */
  100650. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  100651. /** @hidden */
  100652. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  100653. /**
  100654. * Binds a buffer to a uniform.
  100655. * @param buffer Buffer to bind.
  100656. * @param name Name of the uniform variable to bind to.
  100657. */
  100658. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  100659. /**
  100660. * Binds block to a uniform.
  100661. * @param blockName Name of the block to bind.
  100662. * @param index Index to bind.
  100663. */
  100664. bindUniformBlock(blockName: string, index: number): void;
  100665. /**
  100666. * Sets an interger value on a uniform variable.
  100667. * @param uniformName Name of the variable.
  100668. * @param value Value to be set.
  100669. * @returns this effect.
  100670. */
  100671. setInt(uniformName: string, value: number): Effect;
  100672. /**
  100673. * Sets an int array on a uniform variable.
  100674. * @param uniformName Name of the variable.
  100675. * @param array array to be set.
  100676. * @returns this effect.
  100677. */
  100678. setIntArray(uniformName: string, array: Int32Array): Effect;
  100679. /**
  100680. * 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)
  100681. * @param uniformName Name of the variable.
  100682. * @param array array to be set.
  100683. * @returns this effect.
  100684. */
  100685. setIntArray2(uniformName: string, array: Int32Array): Effect;
  100686. /**
  100687. * 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)
  100688. * @param uniformName Name of the variable.
  100689. * @param array array to be set.
  100690. * @returns this effect.
  100691. */
  100692. setIntArray3(uniformName: string, array: Int32Array): Effect;
  100693. /**
  100694. * 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)
  100695. * @param uniformName Name of the variable.
  100696. * @param array array to be set.
  100697. * @returns this effect.
  100698. */
  100699. setIntArray4(uniformName: string, array: Int32Array): Effect;
  100700. /**
  100701. * Sets an float array on a uniform variable.
  100702. * @param uniformName Name of the variable.
  100703. * @param array array to be set.
  100704. * @returns this effect.
  100705. */
  100706. setFloatArray(uniformName: string, array: Float32Array): Effect;
  100707. /**
  100708. * 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)
  100709. * @param uniformName Name of the variable.
  100710. * @param array array to be set.
  100711. * @returns this effect.
  100712. */
  100713. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  100714. /**
  100715. * 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)
  100716. * @param uniformName Name of the variable.
  100717. * @param array array to be set.
  100718. * @returns this effect.
  100719. */
  100720. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  100721. /**
  100722. * 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)
  100723. * @param uniformName Name of the variable.
  100724. * @param array array to be set.
  100725. * @returns this effect.
  100726. */
  100727. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  100728. /**
  100729. * Sets an array on a uniform variable.
  100730. * @param uniformName Name of the variable.
  100731. * @param array array to be set.
  100732. * @returns this effect.
  100733. */
  100734. setArray(uniformName: string, array: number[]): Effect;
  100735. /**
  100736. * 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)
  100737. * @param uniformName Name of the variable.
  100738. * @param array array to be set.
  100739. * @returns this effect.
  100740. */
  100741. setArray2(uniformName: string, array: number[]): Effect;
  100742. /**
  100743. * 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)
  100744. * @param uniformName Name of the variable.
  100745. * @param array array to be set.
  100746. * @returns this effect.
  100747. */
  100748. setArray3(uniformName: string, array: number[]): Effect;
  100749. /**
  100750. * 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)
  100751. * @param uniformName Name of the variable.
  100752. * @param array array to be set.
  100753. * @returns this effect.
  100754. */
  100755. setArray4(uniformName: string, array: number[]): Effect;
  100756. /**
  100757. * Sets matrices on a uniform variable.
  100758. * @param uniformName Name of the variable.
  100759. * @param matrices matrices to be set.
  100760. * @returns this effect.
  100761. */
  100762. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  100763. /**
  100764. * Sets matrix on a uniform variable.
  100765. * @param uniformName Name of the variable.
  100766. * @param matrix matrix to be set.
  100767. * @returns this effect.
  100768. */
  100769. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  100770. /**
  100771. * 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)
  100772. * @param uniformName Name of the variable.
  100773. * @param matrix matrix to be set.
  100774. * @returns this effect.
  100775. */
  100776. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  100777. /**
  100778. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  100779. * @param uniformName Name of the variable.
  100780. * @param matrix matrix to be set.
  100781. * @returns this effect.
  100782. */
  100783. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  100784. /**
  100785. * Sets a float on a uniform variable.
  100786. * @param uniformName Name of the variable.
  100787. * @param value value to be set.
  100788. * @returns this effect.
  100789. */
  100790. setFloat(uniformName: string, value: number): Effect;
  100791. /**
  100792. * Sets a boolean on a uniform variable.
  100793. * @param uniformName Name of the variable.
  100794. * @param bool value to be set.
  100795. * @returns this effect.
  100796. */
  100797. setBool(uniformName: string, bool: boolean): Effect;
  100798. /**
  100799. * Sets a Vector2 on a uniform variable.
  100800. * @param uniformName Name of the variable.
  100801. * @param vector2 vector2 to be set.
  100802. * @returns this effect.
  100803. */
  100804. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  100805. /**
  100806. * Sets a float2 on a uniform variable.
  100807. * @param uniformName Name of the variable.
  100808. * @param x First float in float2.
  100809. * @param y Second float in float2.
  100810. * @returns this effect.
  100811. */
  100812. setFloat2(uniformName: string, x: number, y: number): Effect;
  100813. /**
  100814. * Sets a Vector3 on a uniform variable.
  100815. * @param uniformName Name of the variable.
  100816. * @param vector3 Value to be set.
  100817. * @returns this effect.
  100818. */
  100819. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  100820. /**
  100821. * Sets a float3 on a uniform variable.
  100822. * @param uniformName Name of the variable.
  100823. * @param x First float in float3.
  100824. * @param y Second float in float3.
  100825. * @param z Third float in float3.
  100826. * @returns this effect.
  100827. */
  100828. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  100829. /**
  100830. * Sets a Vector4 on a uniform variable.
  100831. * @param uniformName Name of the variable.
  100832. * @param vector4 Value to be set.
  100833. * @returns this effect.
  100834. */
  100835. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  100836. /**
  100837. * Sets a float4 on a uniform variable.
  100838. * @param uniformName Name of the variable.
  100839. * @param x First float in float4.
  100840. * @param y Second float in float4.
  100841. * @param z Third float in float4.
  100842. * @param w Fourth float in float4.
  100843. * @returns this effect.
  100844. */
  100845. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  100846. /**
  100847. * Sets a Color3 on a uniform variable.
  100848. * @param uniformName Name of the variable.
  100849. * @param color3 Value to be set.
  100850. * @returns this effect.
  100851. */
  100852. setColor3(uniformName: string, color3: IColor3Like): Effect;
  100853. /**
  100854. * Sets a Color4 on a uniform variable.
  100855. * @param uniformName Name of the variable.
  100856. * @param color3 Value to be set.
  100857. * @param alpha Alpha value to be set.
  100858. * @returns this effect.
  100859. */
  100860. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  100861. /**
  100862. * Sets a Color4 on a uniform variable
  100863. * @param uniformName defines the name of the variable
  100864. * @param color4 defines the value to be set
  100865. * @returns this effect.
  100866. */
  100867. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  100868. /** Release all associated resources */
  100869. dispose(): void;
  100870. /**
  100871. * This function will add a new shader to the shader store
  100872. * @param name the name of the shader
  100873. * @param pixelShader optional pixel shader content
  100874. * @param vertexShader optional vertex shader content
  100875. */
  100876. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  100877. /**
  100878. * Store of each shader (The can be looked up using effect.key)
  100879. */
  100880. static ShadersStore: {
  100881. [key: string]: string;
  100882. };
  100883. /**
  100884. * Store of each included file for a shader (The can be looked up using effect.key)
  100885. */
  100886. static IncludesShadersStore: {
  100887. [key: string]: string;
  100888. };
  100889. /**
  100890. * Resets the cache of effects.
  100891. */
  100892. static ResetCache(): void;
  100893. }
  100894. }
  100895. declare module BABYLON {
  100896. /**
  100897. * Interface used to describe the capabilities of the engine relatively to the current browser
  100898. */
  100899. export interface EngineCapabilities {
  100900. /** Maximum textures units per fragment shader */
  100901. maxTexturesImageUnits: number;
  100902. /** Maximum texture units per vertex shader */
  100903. maxVertexTextureImageUnits: number;
  100904. /** Maximum textures units in the entire pipeline */
  100905. maxCombinedTexturesImageUnits: number;
  100906. /** Maximum texture size */
  100907. maxTextureSize: number;
  100908. /** Maximum texture samples */
  100909. maxSamples?: number;
  100910. /** Maximum cube texture size */
  100911. maxCubemapTextureSize: number;
  100912. /** Maximum render texture size */
  100913. maxRenderTextureSize: number;
  100914. /** Maximum number of vertex attributes */
  100915. maxVertexAttribs: number;
  100916. /** Maximum number of varyings */
  100917. maxVaryingVectors: number;
  100918. /** Maximum number of uniforms per vertex shader */
  100919. maxVertexUniformVectors: number;
  100920. /** Maximum number of uniforms per fragment shader */
  100921. maxFragmentUniformVectors: number;
  100922. /** Defines if standard derivates (dx/dy) are supported */
  100923. standardDerivatives: boolean;
  100924. /** Defines if s3tc texture compression is supported */
  100925. s3tc?: WEBGL_compressed_texture_s3tc;
  100926. /** Defines if pvrtc texture compression is supported */
  100927. pvrtc: any;
  100928. /** Defines if etc1 texture compression is supported */
  100929. etc1: any;
  100930. /** Defines if etc2 texture compression is supported */
  100931. etc2: any;
  100932. /** Defines if astc texture compression is supported */
  100933. astc: any;
  100934. /** Defines if float textures are supported */
  100935. textureFloat: boolean;
  100936. /** Defines if vertex array objects are supported */
  100937. vertexArrayObject: boolean;
  100938. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  100939. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  100940. /** Gets the maximum level of anisotropy supported */
  100941. maxAnisotropy: number;
  100942. /** Defines if instancing is supported */
  100943. instancedArrays: boolean;
  100944. /** Defines if 32 bits indices are supported */
  100945. uintIndices: boolean;
  100946. /** Defines if high precision shaders are supported */
  100947. highPrecisionShaderSupported: boolean;
  100948. /** Defines if depth reading in the fragment shader is supported */
  100949. fragmentDepthSupported: boolean;
  100950. /** Defines if float texture linear filtering is supported*/
  100951. textureFloatLinearFiltering: boolean;
  100952. /** Defines if rendering to float textures is supported */
  100953. textureFloatRender: boolean;
  100954. /** Defines if half float textures are supported*/
  100955. textureHalfFloat: boolean;
  100956. /** Defines if half float texture linear filtering is supported*/
  100957. textureHalfFloatLinearFiltering: boolean;
  100958. /** Defines if rendering to half float textures is supported */
  100959. textureHalfFloatRender: boolean;
  100960. /** Defines if textureLOD shader command is supported */
  100961. textureLOD: boolean;
  100962. /** Defines if draw buffers extension is supported */
  100963. drawBuffersExtension: boolean;
  100964. /** Defines if depth textures are supported */
  100965. depthTextureExtension: boolean;
  100966. /** Defines if float color buffer are supported */
  100967. colorBufferFloat: boolean;
  100968. /** Gets disjoint timer query extension (null if not supported) */
  100969. timerQuery?: EXT_disjoint_timer_query;
  100970. /** Defines if timestamp can be used with timer query */
  100971. canUseTimestampForTimerQuery: boolean;
  100972. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  100973. multiview?: any;
  100974. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  100975. oculusMultiview?: any;
  100976. /** Function used to let the system compiles shaders in background */
  100977. parallelShaderCompile?: {
  100978. COMPLETION_STATUS_KHR: number;
  100979. };
  100980. /** Max number of texture samples for MSAA */
  100981. maxMSAASamples: number;
  100982. /** Defines if the blend min max extension is supported */
  100983. blendMinMax: boolean;
  100984. }
  100985. }
  100986. declare module BABYLON {
  100987. /**
  100988. * @hidden
  100989. **/
  100990. export class DepthCullingState {
  100991. private _isDepthTestDirty;
  100992. private _isDepthMaskDirty;
  100993. private _isDepthFuncDirty;
  100994. private _isCullFaceDirty;
  100995. private _isCullDirty;
  100996. private _isZOffsetDirty;
  100997. private _isFrontFaceDirty;
  100998. private _depthTest;
  100999. private _depthMask;
  101000. private _depthFunc;
  101001. private _cull;
  101002. private _cullFace;
  101003. private _zOffset;
  101004. private _frontFace;
  101005. /**
  101006. * Initializes the state.
  101007. */
  101008. constructor();
  101009. get isDirty(): boolean;
  101010. get zOffset(): number;
  101011. set zOffset(value: number);
  101012. get cullFace(): Nullable<number>;
  101013. set cullFace(value: Nullable<number>);
  101014. get cull(): Nullable<boolean>;
  101015. set cull(value: Nullable<boolean>);
  101016. get depthFunc(): Nullable<number>;
  101017. set depthFunc(value: Nullable<number>);
  101018. get depthMask(): boolean;
  101019. set depthMask(value: boolean);
  101020. get depthTest(): boolean;
  101021. set depthTest(value: boolean);
  101022. get frontFace(): Nullable<number>;
  101023. set frontFace(value: Nullable<number>);
  101024. reset(): void;
  101025. apply(gl: WebGLRenderingContext): void;
  101026. }
  101027. }
  101028. declare module BABYLON {
  101029. /**
  101030. * @hidden
  101031. **/
  101032. export class StencilState {
  101033. /** 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 */
  101034. static readonly ALWAYS: number;
  101035. /** Passed to stencilOperation to specify that stencil value must be kept */
  101036. static readonly KEEP: number;
  101037. /** Passed to stencilOperation to specify that stencil value must be replaced */
  101038. static readonly REPLACE: number;
  101039. private _isStencilTestDirty;
  101040. private _isStencilMaskDirty;
  101041. private _isStencilFuncDirty;
  101042. private _isStencilOpDirty;
  101043. private _stencilTest;
  101044. private _stencilMask;
  101045. private _stencilFunc;
  101046. private _stencilFuncRef;
  101047. private _stencilFuncMask;
  101048. private _stencilOpStencilFail;
  101049. private _stencilOpDepthFail;
  101050. private _stencilOpStencilDepthPass;
  101051. get isDirty(): boolean;
  101052. get stencilFunc(): number;
  101053. set stencilFunc(value: number);
  101054. get stencilFuncRef(): number;
  101055. set stencilFuncRef(value: number);
  101056. get stencilFuncMask(): number;
  101057. set stencilFuncMask(value: number);
  101058. get stencilOpStencilFail(): number;
  101059. set stencilOpStencilFail(value: number);
  101060. get stencilOpDepthFail(): number;
  101061. set stencilOpDepthFail(value: number);
  101062. get stencilOpStencilDepthPass(): number;
  101063. set stencilOpStencilDepthPass(value: number);
  101064. get stencilMask(): number;
  101065. set stencilMask(value: number);
  101066. get stencilTest(): boolean;
  101067. set stencilTest(value: boolean);
  101068. constructor();
  101069. reset(): void;
  101070. apply(gl: WebGLRenderingContext): void;
  101071. }
  101072. }
  101073. declare module BABYLON {
  101074. /**
  101075. * @hidden
  101076. **/
  101077. export class AlphaState {
  101078. private _isAlphaBlendDirty;
  101079. private _isBlendFunctionParametersDirty;
  101080. private _isBlendEquationParametersDirty;
  101081. private _isBlendConstantsDirty;
  101082. private _alphaBlend;
  101083. private _blendFunctionParameters;
  101084. private _blendEquationParameters;
  101085. private _blendConstants;
  101086. /**
  101087. * Initializes the state.
  101088. */
  101089. constructor();
  101090. get isDirty(): boolean;
  101091. get alphaBlend(): boolean;
  101092. set alphaBlend(value: boolean);
  101093. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  101094. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  101095. setAlphaEquationParameters(rgb: number, alpha: number): void;
  101096. reset(): void;
  101097. apply(gl: WebGLRenderingContext): void;
  101098. }
  101099. }
  101100. declare module BABYLON {
  101101. /** @hidden */
  101102. export class WebGL2ShaderProcessor implements IShaderProcessor {
  101103. attributeProcessor(attribute: string): string;
  101104. varyingProcessor(varying: string, isFragment: boolean): string;
  101105. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  101106. }
  101107. }
  101108. declare module BABYLON {
  101109. /**
  101110. * Interface for attribute information associated with buffer instanciation
  101111. */
  101112. export interface InstancingAttributeInfo {
  101113. /**
  101114. * Name of the GLSL attribute
  101115. * if attribute index is not specified, this is used to retrieve the index from the effect
  101116. */
  101117. attributeName: string;
  101118. /**
  101119. * Index/offset of the attribute in the vertex shader
  101120. * if not specified, this will be computes from the name.
  101121. */
  101122. index?: number;
  101123. /**
  101124. * size of the attribute, 1, 2, 3 or 4
  101125. */
  101126. attributeSize: number;
  101127. /**
  101128. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  101129. */
  101130. offset: number;
  101131. /**
  101132. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  101133. * default to 1
  101134. */
  101135. divisor?: number;
  101136. /**
  101137. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  101138. * default is FLOAT
  101139. */
  101140. attributeType?: number;
  101141. /**
  101142. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  101143. */
  101144. normalized?: boolean;
  101145. }
  101146. }
  101147. declare module BABYLON {
  101148. interface ThinEngine {
  101149. /**
  101150. * Update a video texture
  101151. * @param texture defines the texture to update
  101152. * @param video defines the video element to use
  101153. * @param invertY defines if data must be stored with Y axis inverted
  101154. */
  101155. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  101156. }
  101157. }
  101158. declare module BABYLON {
  101159. /**
  101160. * Settings for finer control over video usage
  101161. */
  101162. export interface VideoTextureSettings {
  101163. /**
  101164. * Applies `autoplay` to video, if specified
  101165. */
  101166. autoPlay?: boolean;
  101167. /**
  101168. * Applies `loop` to video, if specified
  101169. */
  101170. loop?: boolean;
  101171. /**
  101172. * Automatically updates internal texture from video at every frame in the render loop
  101173. */
  101174. autoUpdateTexture: boolean;
  101175. /**
  101176. * Image src displayed during the video loading or until the user interacts with the video.
  101177. */
  101178. poster?: string;
  101179. }
  101180. /**
  101181. * If you want to display a video in your scene, this is the special texture for that.
  101182. * This special texture works similar to other textures, with the exception of a few parameters.
  101183. * @see https://doc.babylonjs.com/how_to/video_texture
  101184. */
  101185. export class VideoTexture extends Texture {
  101186. /**
  101187. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  101188. */
  101189. readonly autoUpdateTexture: boolean;
  101190. /**
  101191. * The video instance used by the texture internally
  101192. */
  101193. readonly video: HTMLVideoElement;
  101194. private _onUserActionRequestedObservable;
  101195. /**
  101196. * Event triggerd when a dom action is required by the user to play the video.
  101197. * This happens due to recent changes in browser policies preventing video to auto start.
  101198. */
  101199. get onUserActionRequestedObservable(): Observable<Texture>;
  101200. private _generateMipMaps;
  101201. private _engine;
  101202. private _stillImageCaptured;
  101203. private _displayingPosterTexture;
  101204. private _settings;
  101205. private _createInternalTextureOnEvent;
  101206. private _frameId;
  101207. /**
  101208. * Creates a video texture.
  101209. * If you want to display a video in your scene, this is the special texture for that.
  101210. * This special texture works similar to other textures, with the exception of a few parameters.
  101211. * @see https://doc.babylonjs.com/how_to/video_texture
  101212. * @param name optional name, will detect from video source, if not defined
  101213. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  101214. * @param scene is obviously the current scene.
  101215. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  101216. * @param invertY is false by default but can be used to invert video on Y axis
  101217. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  101218. * @param settings allows finer control over video usage
  101219. */
  101220. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  101221. private _getName;
  101222. private _getVideo;
  101223. private _createInternalTexture;
  101224. private reset;
  101225. /**
  101226. * @hidden Internal method to initiate `update`.
  101227. */
  101228. _rebuild(): void;
  101229. /**
  101230. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  101231. */
  101232. update(): void;
  101233. /**
  101234. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  101235. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  101236. */
  101237. updateTexture(isVisible: boolean): void;
  101238. protected _updateInternalTexture: () => void;
  101239. /**
  101240. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  101241. * @param url New url.
  101242. */
  101243. updateURL(url: string): void;
  101244. /**
  101245. * Dispose the texture and release its associated resources.
  101246. */
  101247. dispose(): void;
  101248. /**
  101249. * Creates a video texture straight from a stream.
  101250. * @param scene Define the scene the texture should be created in
  101251. * @param stream Define the stream the texture should be created from
  101252. * @returns The created video texture as a promise
  101253. */
  101254. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  101255. /**
  101256. * Creates a video texture straight from your WebCam video feed.
  101257. * @param scene Define the scene the texture should be created in
  101258. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  101259. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  101260. * @returns The created video texture as a promise
  101261. */
  101262. static CreateFromWebCamAsync(scene: Scene, constraints: {
  101263. minWidth: number;
  101264. maxWidth: number;
  101265. minHeight: number;
  101266. maxHeight: number;
  101267. deviceId: string;
  101268. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  101269. /**
  101270. * Creates a video texture straight from your WebCam video feed.
  101271. * @param scene Define the scene the texture should be created in
  101272. * @param onReady Define a callback to triggered once the texture will be ready
  101273. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  101274. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  101275. */
  101276. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  101277. minWidth: number;
  101278. maxWidth: number;
  101279. minHeight: number;
  101280. maxHeight: number;
  101281. deviceId: string;
  101282. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  101283. }
  101284. }
  101285. declare module BABYLON {
  101286. /**
  101287. * Defines the interface used by objects working like Scene
  101288. * @hidden
  101289. */
  101290. interface ISceneLike {
  101291. _addPendingData(data: any): void;
  101292. _removePendingData(data: any): void;
  101293. offlineProvider: IOfflineProvider;
  101294. }
  101295. /** Interface defining initialization parameters for Engine class */
  101296. export interface EngineOptions extends WebGLContextAttributes {
  101297. /**
  101298. * Defines if the engine should no exceed a specified device ratio
  101299. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  101300. */
  101301. limitDeviceRatio?: number;
  101302. /**
  101303. * Defines if webvr should be enabled automatically
  101304. * @see http://doc.babylonjs.com/how_to/webvr_camera
  101305. */
  101306. autoEnableWebVR?: boolean;
  101307. /**
  101308. * Defines if webgl2 should be turned off even if supported
  101309. * @see http://doc.babylonjs.com/features/webgl2
  101310. */
  101311. disableWebGL2Support?: boolean;
  101312. /**
  101313. * Defines if webaudio should be initialized as well
  101314. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101315. */
  101316. audioEngine?: boolean;
  101317. /**
  101318. * Defines if animations should run using a deterministic lock step
  101319. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101320. */
  101321. deterministicLockstep?: boolean;
  101322. /** Defines the maximum steps to use with deterministic lock step mode */
  101323. lockstepMaxSteps?: number;
  101324. /** Defines the seconds between each deterministic lock step */
  101325. timeStep?: number;
  101326. /**
  101327. * Defines that engine should ignore context lost events
  101328. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  101329. */
  101330. doNotHandleContextLost?: boolean;
  101331. /**
  101332. * Defines that engine should ignore modifying touch action attribute and style
  101333. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  101334. */
  101335. doNotHandleTouchAction?: boolean;
  101336. /**
  101337. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  101338. */
  101339. useHighPrecisionFloats?: boolean;
  101340. }
  101341. /**
  101342. * The base engine class (root of all engines)
  101343. */
  101344. export class ThinEngine {
  101345. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  101346. static ExceptionList: ({
  101347. key: string;
  101348. capture: string;
  101349. captureConstraint: number;
  101350. targets: string[];
  101351. } | {
  101352. key: string;
  101353. capture: null;
  101354. captureConstraint: null;
  101355. targets: string[];
  101356. })[];
  101357. /** @hidden */
  101358. static _TextureLoaders: IInternalTextureLoader[];
  101359. /**
  101360. * Returns the current npm package of the sdk
  101361. */
  101362. static get NpmPackage(): string;
  101363. /**
  101364. * Returns the current version of the framework
  101365. */
  101366. static get Version(): string;
  101367. /**
  101368. * Returns a string describing the current engine
  101369. */
  101370. get description(): string;
  101371. /**
  101372. * Gets or sets the epsilon value used by collision engine
  101373. */
  101374. static CollisionsEpsilon: number;
  101375. /**
  101376. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  101377. */
  101378. static get ShadersRepository(): string;
  101379. static set ShadersRepository(value: string);
  101380. /**
  101381. * Gets or sets the textures that the engine should not attempt to load as compressed
  101382. */
  101383. protected _excludedCompressedTextures: string[];
  101384. /**
  101385. * Filters the compressed texture formats to only include
  101386. * files that are not included in the skippable list
  101387. *
  101388. * @param url the current extension
  101389. * @param textureFormatInUse the current compressed texture format
  101390. * @returns "format" string
  101391. */
  101392. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  101393. /** @hidden */
  101394. _shaderProcessor: IShaderProcessor;
  101395. /**
  101396. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  101397. */
  101398. forcePOTTextures: boolean;
  101399. /**
  101400. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  101401. */
  101402. isFullscreen: boolean;
  101403. /**
  101404. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  101405. */
  101406. cullBackFaces: boolean;
  101407. /**
  101408. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  101409. */
  101410. renderEvenInBackground: boolean;
  101411. /**
  101412. * Gets or sets a boolean indicating that cache can be kept between frames
  101413. */
  101414. preventCacheWipeBetweenFrames: boolean;
  101415. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  101416. validateShaderPrograms: boolean;
  101417. /**
  101418. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  101419. * This can provide greater z depth for distant objects.
  101420. */
  101421. useReverseDepthBuffer: boolean;
  101422. /**
  101423. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  101424. */
  101425. disableUniformBuffers: boolean;
  101426. /** @hidden */
  101427. _uniformBuffers: UniformBuffer[];
  101428. /**
  101429. * Gets a boolean indicating that the engine supports uniform buffers
  101430. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  101431. */
  101432. get supportsUniformBuffers(): boolean;
  101433. /** @hidden */
  101434. _gl: WebGLRenderingContext;
  101435. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  101436. protected _windowIsBackground: boolean;
  101437. protected _webGLVersion: number;
  101438. protected _creationOptions: EngineOptions;
  101439. protected _highPrecisionShadersAllowed: boolean;
  101440. /** @hidden */
  101441. get _shouldUseHighPrecisionShader(): boolean;
  101442. /**
  101443. * Gets a boolean indicating that only power of 2 textures are supported
  101444. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  101445. */
  101446. get needPOTTextures(): boolean;
  101447. /** @hidden */
  101448. _badOS: boolean;
  101449. /** @hidden */
  101450. _badDesktopOS: boolean;
  101451. private _hardwareScalingLevel;
  101452. /** @hidden */
  101453. _caps: EngineCapabilities;
  101454. private _isStencilEnable;
  101455. private _glVersion;
  101456. private _glRenderer;
  101457. private _glVendor;
  101458. /** @hidden */
  101459. _videoTextureSupported: boolean;
  101460. protected _renderingQueueLaunched: boolean;
  101461. protected _activeRenderLoops: (() => void)[];
  101462. /**
  101463. * Observable signaled when a context lost event is raised
  101464. */
  101465. onContextLostObservable: Observable<ThinEngine>;
  101466. /**
  101467. * Observable signaled when a context restored event is raised
  101468. */
  101469. onContextRestoredObservable: Observable<ThinEngine>;
  101470. private _onContextLost;
  101471. private _onContextRestored;
  101472. protected _contextWasLost: boolean;
  101473. /** @hidden */
  101474. _doNotHandleContextLost: boolean;
  101475. /**
  101476. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  101477. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  101478. */
  101479. get doNotHandleContextLost(): boolean;
  101480. set doNotHandleContextLost(value: boolean);
  101481. /**
  101482. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  101483. */
  101484. disableVertexArrayObjects: boolean;
  101485. /** @hidden */
  101486. protected _colorWrite: boolean;
  101487. /** @hidden */
  101488. protected _colorWriteChanged: boolean;
  101489. /** @hidden */
  101490. protected _depthCullingState: DepthCullingState;
  101491. /** @hidden */
  101492. protected _stencilState: StencilState;
  101493. /** @hidden */
  101494. _alphaState: AlphaState;
  101495. /** @hidden */
  101496. _alphaMode: number;
  101497. /** @hidden */
  101498. _alphaEquation: number;
  101499. /** @hidden */
  101500. _internalTexturesCache: InternalTexture[];
  101501. /** @hidden */
  101502. protected _activeChannel: number;
  101503. private _currentTextureChannel;
  101504. /** @hidden */
  101505. protected _boundTexturesCache: {
  101506. [key: string]: Nullable<InternalTexture>;
  101507. };
  101508. /** @hidden */
  101509. protected _currentEffect: Nullable<Effect>;
  101510. /** @hidden */
  101511. protected _currentProgram: Nullable<WebGLProgram>;
  101512. private _compiledEffects;
  101513. private _vertexAttribArraysEnabled;
  101514. /** @hidden */
  101515. protected _cachedViewport: Nullable<IViewportLike>;
  101516. private _cachedVertexArrayObject;
  101517. /** @hidden */
  101518. protected _cachedVertexBuffers: any;
  101519. /** @hidden */
  101520. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  101521. /** @hidden */
  101522. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  101523. /** @hidden */
  101524. _currentRenderTarget: Nullable<InternalTexture>;
  101525. private _uintIndicesCurrentlySet;
  101526. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  101527. /** @hidden */
  101528. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  101529. private _currentBufferPointers;
  101530. private _currentInstanceLocations;
  101531. private _currentInstanceBuffers;
  101532. private _textureUnits;
  101533. /** @hidden */
  101534. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  101535. /** @hidden */
  101536. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  101537. /** @hidden */
  101538. _boundRenderFunction: any;
  101539. private _vaoRecordInProgress;
  101540. private _mustWipeVertexAttributes;
  101541. private _emptyTexture;
  101542. private _emptyCubeTexture;
  101543. private _emptyTexture3D;
  101544. private _emptyTexture2DArray;
  101545. /** @hidden */
  101546. _frameHandler: number;
  101547. private _nextFreeTextureSlots;
  101548. private _maxSimultaneousTextures;
  101549. private _activeRequests;
  101550. protected _texturesSupported: string[];
  101551. /** @hidden */
  101552. _textureFormatInUse: Nullable<string>;
  101553. protected get _supportsHardwareTextureRescaling(): boolean;
  101554. /**
  101555. * Gets the list of texture formats supported
  101556. */
  101557. get texturesSupported(): Array<string>;
  101558. /**
  101559. * Gets the list of texture formats in use
  101560. */
  101561. get textureFormatInUse(): Nullable<string>;
  101562. /**
  101563. * Gets the current viewport
  101564. */
  101565. get currentViewport(): Nullable<IViewportLike>;
  101566. /**
  101567. * Gets the default empty texture
  101568. */
  101569. get emptyTexture(): InternalTexture;
  101570. /**
  101571. * Gets the default empty 3D texture
  101572. */
  101573. get emptyTexture3D(): InternalTexture;
  101574. /**
  101575. * Gets the default empty 2D array texture
  101576. */
  101577. get emptyTexture2DArray(): InternalTexture;
  101578. /**
  101579. * Gets the default empty cube texture
  101580. */
  101581. get emptyCubeTexture(): InternalTexture;
  101582. /**
  101583. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  101584. */
  101585. readonly premultipliedAlpha: boolean;
  101586. /**
  101587. * Observable event triggered before each texture is initialized
  101588. */
  101589. onBeforeTextureInitObservable: Observable<Texture>;
  101590. /**
  101591. * Creates a new engine
  101592. * @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
  101593. * @param antialias defines enable antialiasing (default: false)
  101594. * @param options defines further options to be sent to the getContext() function
  101595. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  101596. */
  101597. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  101598. private _rebuildInternalTextures;
  101599. private _rebuildEffects;
  101600. /**
  101601. * Gets a boolean indicating if all created effects are ready
  101602. * @returns true if all effects are ready
  101603. */
  101604. areAllEffectsReady(): boolean;
  101605. protected _rebuildBuffers(): void;
  101606. private _initGLContext;
  101607. /**
  101608. * Gets version of the current webGL context
  101609. */
  101610. get webGLVersion(): number;
  101611. /**
  101612. * Gets a string idenfifying the name of the class
  101613. * @returns "Engine" string
  101614. */
  101615. getClassName(): string;
  101616. /**
  101617. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  101618. */
  101619. get isStencilEnable(): boolean;
  101620. /** @hidden */
  101621. _prepareWorkingCanvas(): void;
  101622. /**
  101623. * Reset the texture cache to empty state
  101624. */
  101625. resetTextureCache(): void;
  101626. /**
  101627. * Gets an object containing information about the current webGL context
  101628. * @returns an object containing the vender, the renderer and the version of the current webGL context
  101629. */
  101630. getGlInfo(): {
  101631. vendor: string;
  101632. renderer: string;
  101633. version: string;
  101634. };
  101635. /**
  101636. * Defines the hardware scaling level.
  101637. * By default the hardware scaling level is computed from the window device ratio.
  101638. * 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.
  101639. * @param level defines the level to use
  101640. */
  101641. setHardwareScalingLevel(level: number): void;
  101642. /**
  101643. * Gets the current hardware scaling level.
  101644. * By default the hardware scaling level is computed from the window device ratio.
  101645. * 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.
  101646. * @returns a number indicating the current hardware scaling level
  101647. */
  101648. getHardwareScalingLevel(): number;
  101649. /**
  101650. * Gets the list of loaded textures
  101651. * @returns an array containing all loaded textures
  101652. */
  101653. getLoadedTexturesCache(): InternalTexture[];
  101654. /**
  101655. * Gets the object containing all engine capabilities
  101656. * @returns the EngineCapabilities object
  101657. */
  101658. getCaps(): EngineCapabilities;
  101659. /**
  101660. * stop executing a render loop function and remove it from the execution array
  101661. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  101662. */
  101663. stopRenderLoop(renderFunction?: () => void): void;
  101664. /** @hidden */
  101665. _renderLoop(): void;
  101666. /**
  101667. * Gets the HTML canvas attached with the current webGL context
  101668. * @returns a HTML canvas
  101669. */
  101670. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  101671. /**
  101672. * Gets host window
  101673. * @returns the host window object
  101674. */
  101675. getHostWindow(): Nullable<Window>;
  101676. /**
  101677. * Gets the current render width
  101678. * @param useScreen defines if screen size must be used (or the current render target if any)
  101679. * @returns a number defining the current render width
  101680. */
  101681. getRenderWidth(useScreen?: boolean): number;
  101682. /**
  101683. * Gets the current render height
  101684. * @param useScreen defines if screen size must be used (or the current render target if any)
  101685. * @returns a number defining the current render height
  101686. */
  101687. getRenderHeight(useScreen?: boolean): number;
  101688. /**
  101689. * Can be used to override the current requestAnimationFrame requester.
  101690. * @hidden
  101691. */
  101692. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  101693. /**
  101694. * Register and execute a render loop. The engine can have more than one render function
  101695. * @param renderFunction defines the function to continuously execute
  101696. */
  101697. runRenderLoop(renderFunction: () => void): void;
  101698. /**
  101699. * Clear the current render buffer or the current render target (if any is set up)
  101700. * @param color defines the color to use
  101701. * @param backBuffer defines if the back buffer must be cleared
  101702. * @param depth defines if the depth buffer must be cleared
  101703. * @param stencil defines if the stencil buffer must be cleared
  101704. */
  101705. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  101706. private _viewportCached;
  101707. /** @hidden */
  101708. _viewport(x: number, y: number, width: number, height: number): void;
  101709. /**
  101710. * Set the WebGL's viewport
  101711. * @param viewport defines the viewport element to be used
  101712. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  101713. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  101714. */
  101715. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  101716. /**
  101717. * Begin a new frame
  101718. */
  101719. beginFrame(): void;
  101720. /**
  101721. * Enf the current frame
  101722. */
  101723. endFrame(): void;
  101724. /**
  101725. * Resize the view according to the canvas' size
  101726. */
  101727. resize(): void;
  101728. /**
  101729. * Force a specific size of the canvas
  101730. * @param width defines the new canvas' width
  101731. * @param height defines the new canvas' height
  101732. */
  101733. setSize(width: number, height: number): void;
  101734. /**
  101735. * Binds the frame buffer to the specified texture.
  101736. * @param texture The texture to render to or null for the default canvas
  101737. * @param faceIndex The face of the texture to render to in case of cube texture
  101738. * @param requiredWidth The width of the target to render to
  101739. * @param requiredHeight The height of the target to render to
  101740. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  101741. * @param depthStencilTexture The depth stencil texture to use to render
  101742. * @param lodLevel defines le lod level to bind to the frame buffer
  101743. */
  101744. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  101745. /** @hidden */
  101746. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  101747. /**
  101748. * Unbind the current render target texture from the webGL context
  101749. * @param texture defines the render target texture to unbind
  101750. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  101751. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  101752. */
  101753. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  101754. /**
  101755. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  101756. */
  101757. flushFramebuffer(): void;
  101758. /**
  101759. * Unbind the current render target and bind the default framebuffer
  101760. */
  101761. restoreDefaultFramebuffer(): void;
  101762. /** @hidden */
  101763. protected _resetVertexBufferBinding(): void;
  101764. /**
  101765. * Creates a vertex buffer
  101766. * @param data the data for the vertex buffer
  101767. * @returns the new WebGL static buffer
  101768. */
  101769. createVertexBuffer(data: DataArray): DataBuffer;
  101770. private _createVertexBuffer;
  101771. /**
  101772. * Creates a dynamic vertex buffer
  101773. * @param data the data for the dynamic vertex buffer
  101774. * @returns the new WebGL dynamic buffer
  101775. */
  101776. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  101777. protected _resetIndexBufferBinding(): void;
  101778. /**
  101779. * Creates a new index buffer
  101780. * @param indices defines the content of the index buffer
  101781. * @param updatable defines if the index buffer must be updatable
  101782. * @returns a new webGL buffer
  101783. */
  101784. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  101785. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  101786. /**
  101787. * Bind a webGL buffer to the webGL context
  101788. * @param buffer defines the buffer to bind
  101789. */
  101790. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  101791. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  101792. private bindBuffer;
  101793. /**
  101794. * update the bound buffer with the given data
  101795. * @param data defines the data to update
  101796. */
  101797. updateArrayBuffer(data: Float32Array): void;
  101798. private _vertexAttribPointer;
  101799. private _bindIndexBufferWithCache;
  101800. private _bindVertexBuffersAttributes;
  101801. /**
  101802. * Records a vertex array object
  101803. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  101804. * @param vertexBuffers defines the list of vertex buffers to store
  101805. * @param indexBuffer defines the index buffer to store
  101806. * @param effect defines the effect to store
  101807. * @returns the new vertex array object
  101808. */
  101809. recordVertexArrayObject(vertexBuffers: {
  101810. [key: string]: VertexBuffer;
  101811. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  101812. /**
  101813. * Bind a specific vertex array object
  101814. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  101815. * @param vertexArrayObject defines the vertex array object to bind
  101816. * @param indexBuffer defines the index buffer to bind
  101817. */
  101818. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  101819. /**
  101820. * Bind webGl buffers directly to the webGL context
  101821. * @param vertexBuffer defines the vertex buffer to bind
  101822. * @param indexBuffer defines the index buffer to bind
  101823. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  101824. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  101825. * @param effect defines the effect associated with the vertex buffer
  101826. */
  101827. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  101828. private _unbindVertexArrayObject;
  101829. /**
  101830. * Bind a list of vertex buffers to the webGL context
  101831. * @param vertexBuffers defines the list of vertex buffers to bind
  101832. * @param indexBuffer defines the index buffer to bind
  101833. * @param effect defines the effect associated with the vertex buffers
  101834. */
  101835. bindBuffers(vertexBuffers: {
  101836. [key: string]: Nullable<VertexBuffer>;
  101837. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  101838. /**
  101839. * Unbind all instance attributes
  101840. */
  101841. unbindInstanceAttributes(): void;
  101842. /**
  101843. * Release and free the memory of a vertex array object
  101844. * @param vao defines the vertex array object to delete
  101845. */
  101846. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  101847. /** @hidden */
  101848. _releaseBuffer(buffer: DataBuffer): boolean;
  101849. protected _deleteBuffer(buffer: DataBuffer): void;
  101850. /**
  101851. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  101852. * @param instancesBuffer defines the webGL buffer to update and bind
  101853. * @param data defines the data to store in the buffer
  101854. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  101855. */
  101856. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  101857. /**
  101858. * Bind the content of a webGL buffer used with instanciation
  101859. * @param instancesBuffer defines the webGL buffer to bind
  101860. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  101861. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  101862. */
  101863. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  101864. /**
  101865. * Disable the instance attribute corresponding to the name in parameter
  101866. * @param name defines the name of the attribute to disable
  101867. */
  101868. disableInstanceAttributeByName(name: string): void;
  101869. /**
  101870. * Disable the instance attribute corresponding to the location in parameter
  101871. * @param attributeLocation defines the attribute location of the attribute to disable
  101872. */
  101873. disableInstanceAttribute(attributeLocation: number): void;
  101874. /**
  101875. * Disable the attribute corresponding to the location in parameter
  101876. * @param attributeLocation defines the attribute location of the attribute to disable
  101877. */
  101878. disableAttributeByIndex(attributeLocation: number): void;
  101879. /**
  101880. * Send a draw order
  101881. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  101882. * @param indexStart defines the starting index
  101883. * @param indexCount defines the number of index to draw
  101884. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101885. */
  101886. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  101887. /**
  101888. * Draw a list of points
  101889. * @param verticesStart defines the index of first vertex to draw
  101890. * @param verticesCount defines the count of vertices to draw
  101891. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101892. */
  101893. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101894. /**
  101895. * Draw a list of unindexed primitives
  101896. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  101897. * @param verticesStart defines the index of first vertex to draw
  101898. * @param verticesCount defines the count of vertices to draw
  101899. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101900. */
  101901. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101902. /**
  101903. * Draw a list of indexed primitives
  101904. * @param fillMode defines the primitive to use
  101905. * @param indexStart defines the starting index
  101906. * @param indexCount defines the number of index to draw
  101907. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101908. */
  101909. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  101910. /**
  101911. * Draw a list of unindexed primitives
  101912. * @param fillMode defines the primitive to use
  101913. * @param verticesStart defines the index of first vertex to draw
  101914. * @param verticesCount defines the count of vertices to draw
  101915. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  101916. */
  101917. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  101918. private _drawMode;
  101919. /** @hidden */
  101920. protected _reportDrawCall(): void;
  101921. /** @hidden */
  101922. _releaseEffect(effect: Effect): void;
  101923. /** @hidden */
  101924. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  101925. /**
  101926. * Create a new effect (used to store vertex/fragment shaders)
  101927. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  101928. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  101929. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  101930. * @param samplers defines an array of string used to represent textures
  101931. * @param defines defines the string containing the defines to use to compile the shaders
  101932. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  101933. * @param onCompiled defines a function to call when the effect creation is successful
  101934. * @param onError defines a function to call when the effect creation has failed
  101935. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  101936. * @returns the new Effect
  101937. */
  101938. 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;
  101939. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  101940. private _compileShader;
  101941. private _compileRawShader;
  101942. /**
  101943. * Directly creates a webGL program
  101944. * @param pipelineContext defines the pipeline context to attach to
  101945. * @param vertexCode defines the vertex shader code to use
  101946. * @param fragmentCode defines the fragment shader code to use
  101947. * @param context defines the webGL context to use (if not set, the current one will be used)
  101948. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  101949. * @returns the new webGL program
  101950. */
  101951. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  101952. /**
  101953. * Creates a webGL program
  101954. * @param pipelineContext defines the pipeline context to attach to
  101955. * @param vertexCode defines the vertex shader code to use
  101956. * @param fragmentCode defines the fragment shader code to use
  101957. * @param defines defines the string containing the defines to use to compile the shaders
  101958. * @param context defines the webGL context to use (if not set, the current one will be used)
  101959. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  101960. * @returns the new webGL program
  101961. */
  101962. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  101963. /**
  101964. * Creates a new pipeline context
  101965. * @returns the new pipeline
  101966. */
  101967. createPipelineContext(): IPipelineContext;
  101968. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  101969. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  101970. /** @hidden */
  101971. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  101972. /** @hidden */
  101973. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  101974. /** @hidden */
  101975. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  101976. /**
  101977. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  101978. * @param pipelineContext defines the pipeline context to use
  101979. * @param uniformsNames defines the list of uniform names
  101980. * @returns an array of webGL uniform locations
  101981. */
  101982. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  101983. /**
  101984. * Gets the lsit of active attributes for a given webGL program
  101985. * @param pipelineContext defines the pipeline context to use
  101986. * @param attributesNames defines the list of attribute names to get
  101987. * @returns an array of indices indicating the offset of each attribute
  101988. */
  101989. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  101990. /**
  101991. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  101992. * @param effect defines the effect to activate
  101993. */
  101994. enableEffect(effect: Nullable<Effect>): void;
  101995. /**
  101996. * Set the value of an uniform to a number (int)
  101997. * @param uniform defines the webGL uniform location where to store the value
  101998. * @param value defines the int number to store
  101999. */
  102000. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  102001. /**
  102002. * Set the value of an uniform to an array of int32
  102003. * @param uniform defines the webGL uniform location where to store the value
  102004. * @param array defines the array of int32 to store
  102005. */
  102006. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  102007. /**
  102008. * Set the value of an uniform to an array of int32 (stored as vec2)
  102009. * @param uniform defines the webGL uniform location where to store the value
  102010. * @param array defines the array of int32 to store
  102011. */
  102012. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  102013. /**
  102014. * Set the value of an uniform to an array of int32 (stored as vec3)
  102015. * @param uniform defines the webGL uniform location where to store the value
  102016. * @param array defines the array of int32 to store
  102017. */
  102018. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  102019. /**
  102020. * Set the value of an uniform to an array of int32 (stored as vec4)
  102021. * @param uniform defines the webGL uniform location where to store the value
  102022. * @param array defines the array of int32 to store
  102023. */
  102024. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  102025. /**
  102026. * Set the value of an uniform to an array of number
  102027. * @param uniform defines the webGL uniform location where to store the value
  102028. * @param array defines the array of number to store
  102029. */
  102030. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  102031. /**
  102032. * Set the value of an uniform to an array of number (stored as vec2)
  102033. * @param uniform defines the webGL uniform location where to store the value
  102034. * @param array defines the array of number to store
  102035. */
  102036. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  102037. /**
  102038. * Set the value of an uniform to an array of number (stored as vec3)
  102039. * @param uniform defines the webGL uniform location where to store the value
  102040. * @param array defines the array of number to store
  102041. */
  102042. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  102043. /**
  102044. * Set the value of an uniform to an array of number (stored as vec4)
  102045. * @param uniform defines the webGL uniform location where to store the value
  102046. * @param array defines the array of number to store
  102047. */
  102048. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  102049. /**
  102050. * Set the value of an uniform to an array of float32 (stored as matrices)
  102051. * @param uniform defines the webGL uniform location where to store the value
  102052. * @param matrices defines the array of float32 to store
  102053. */
  102054. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  102055. /**
  102056. * Set the value of an uniform to a matrix (3x3)
  102057. * @param uniform defines the webGL uniform location where to store the value
  102058. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  102059. */
  102060. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  102061. /**
  102062. * Set the value of an uniform to a matrix (2x2)
  102063. * @param uniform defines the webGL uniform location where to store the value
  102064. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  102065. */
  102066. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  102067. /**
  102068. * Set the value of an uniform to a number (float)
  102069. * @param uniform defines the webGL uniform location where to store the value
  102070. * @param value defines the float number to store
  102071. */
  102072. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  102073. /**
  102074. * Set the value of an uniform to a vec2
  102075. * @param uniform defines the webGL uniform location where to store the value
  102076. * @param x defines the 1st component of the value
  102077. * @param y defines the 2nd component of the value
  102078. */
  102079. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  102080. /**
  102081. * Set the value of an uniform to a vec3
  102082. * @param uniform defines the webGL uniform location where to store the value
  102083. * @param x defines the 1st component of the value
  102084. * @param y defines the 2nd component of the value
  102085. * @param z defines the 3rd component of the value
  102086. */
  102087. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  102088. /**
  102089. * Set the value of an uniform to a vec4
  102090. * @param uniform defines the webGL uniform location where to store the value
  102091. * @param x defines the 1st component of the value
  102092. * @param y defines the 2nd component of the value
  102093. * @param z defines the 3rd component of the value
  102094. * @param w defines the 4th component of the value
  102095. */
  102096. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  102097. /**
  102098. * Apply all cached states (depth, culling, stencil and alpha)
  102099. */
  102100. applyStates(): void;
  102101. /**
  102102. * Enable or disable color writing
  102103. * @param enable defines the state to set
  102104. */
  102105. setColorWrite(enable: boolean): void;
  102106. /**
  102107. * Gets a boolean indicating if color writing is enabled
  102108. * @returns the current color writing state
  102109. */
  102110. getColorWrite(): boolean;
  102111. /**
  102112. * Gets the depth culling state manager
  102113. */
  102114. get depthCullingState(): DepthCullingState;
  102115. /**
  102116. * Gets the alpha state manager
  102117. */
  102118. get alphaState(): AlphaState;
  102119. /**
  102120. * Gets the stencil state manager
  102121. */
  102122. get stencilState(): StencilState;
  102123. /**
  102124. * Clears the list of texture accessible through engine.
  102125. * This can help preventing texture load conflict due to name collision.
  102126. */
  102127. clearInternalTexturesCache(): void;
  102128. /**
  102129. * Force the entire cache to be cleared
  102130. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  102131. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  102132. */
  102133. wipeCaches(bruteForce?: boolean): void;
  102134. /** @hidden */
  102135. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  102136. min: number;
  102137. mag: number;
  102138. };
  102139. /** @hidden */
  102140. _createTexture(): WebGLTexture;
  102141. /**
  102142. * Usually called from Texture.ts.
  102143. * Passed information to create a WebGLTexture
  102144. * @param urlArg defines a value which contains one of the following:
  102145. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  102146. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  102147. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  102148. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  102149. * @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)
  102150. * @param scene needed for loading to the correct scene
  102151. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  102152. * @param onLoad optional callback to be called upon successful completion
  102153. * @param onError optional callback to be called upon failure
  102154. * @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
  102155. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  102156. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  102157. * @param forcedExtension defines the extension to use to pick the right loader
  102158. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  102159. * @param mimeType defines an optional mime type
  102160. * @returns a InternalTexture for assignment back into BABYLON.Texture
  102161. */
  102162. 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 | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  102163. /**
  102164. * Loads an image as an HTMLImageElement.
  102165. * @param input url string, ArrayBuffer, or Blob to load
  102166. * @param onLoad callback called when the image successfully loads
  102167. * @param onError callback called when the image fails to load
  102168. * @param offlineProvider offline provider for caching
  102169. * @param mimeType optional mime type
  102170. * @returns the HTMLImageElement of the loaded image
  102171. * @hidden
  102172. */
  102173. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  102174. /**
  102175. * @hidden
  102176. */
  102177. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  102178. /**
  102179. * Creates a raw texture
  102180. * @param data defines the data to store in the texture
  102181. * @param width defines the width of the texture
  102182. * @param height defines the height of the texture
  102183. * @param format defines the format of the data
  102184. * @param generateMipMaps defines if the engine should generate the mip levels
  102185. * @param invertY defines if data must be stored with Y axis inverted
  102186. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  102187. * @param compression defines the compression used (null by default)
  102188. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  102189. * @returns the raw texture inside an InternalTexture
  102190. */
  102191. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  102192. /**
  102193. * Creates a new raw cube texture
  102194. * @param data defines the array of data to use to create each face
  102195. * @param size defines the size of the textures
  102196. * @param format defines the format of the data
  102197. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  102198. * @param generateMipMaps defines if the engine should generate the mip levels
  102199. * @param invertY defines if data must be stored with Y axis inverted
  102200. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102201. * @param compression defines the compression used (null by default)
  102202. * @returns the cube texture as an InternalTexture
  102203. */
  102204. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  102205. /**
  102206. * Creates a new raw 3D texture
  102207. * @param data defines the data used to create the texture
  102208. * @param width defines the width of the texture
  102209. * @param height defines the height of the texture
  102210. * @param depth defines the depth of the texture
  102211. * @param format defines the format of the texture
  102212. * @param generateMipMaps defines if the engine must generate mip levels
  102213. * @param invertY defines if data must be stored with Y axis inverted
  102214. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102215. * @param compression defines the compressed used (can be null)
  102216. * @param textureType defines the compressed used (can be null)
  102217. * @returns a new raw 3D texture (stored in an InternalTexture)
  102218. */
  102219. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  102220. /**
  102221. * Creates a new raw 2D array texture
  102222. * @param data defines the data used to create the texture
  102223. * @param width defines the width of the texture
  102224. * @param height defines the height of the texture
  102225. * @param depth defines the number of layers of the texture
  102226. * @param format defines the format of the texture
  102227. * @param generateMipMaps defines if the engine must generate mip levels
  102228. * @param invertY defines if data must be stored with Y axis inverted
  102229. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102230. * @param compression defines the compressed used (can be null)
  102231. * @param textureType defines the compressed used (can be null)
  102232. * @returns a new raw 2D array texture (stored in an InternalTexture)
  102233. */
  102234. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  102235. private _unpackFlipYCached;
  102236. /**
  102237. * In case you are sharing the context with other applications, it might
  102238. * be interested to not cache the unpack flip y state to ensure a consistent
  102239. * value would be set.
  102240. */
  102241. enableUnpackFlipYCached: boolean;
  102242. /** @hidden */
  102243. _unpackFlipY(value: boolean): void;
  102244. /** @hidden */
  102245. _getUnpackAlignement(): number;
  102246. private _getTextureTarget;
  102247. /**
  102248. * Update the sampling mode of a given texture
  102249. * @param samplingMode defines the required sampling mode
  102250. * @param texture defines the texture to update
  102251. * @param generateMipMaps defines whether to generate mipmaps for the texture
  102252. */
  102253. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  102254. /**
  102255. * Update the sampling mode of a given texture
  102256. * @param texture defines the texture to update
  102257. * @param wrapU defines the texture wrap mode of the u coordinates
  102258. * @param wrapV defines the texture wrap mode of the v coordinates
  102259. * @param wrapR defines the texture wrap mode of the r coordinates
  102260. */
  102261. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  102262. /** @hidden */
  102263. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  102264. width: number;
  102265. height: number;
  102266. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  102267. /** @hidden */
  102268. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  102269. /** @hidden */
  102270. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  102271. /** @hidden */
  102272. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  102273. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  102274. private _prepareWebGLTexture;
  102275. /** @hidden */
  102276. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  102277. private _getDepthStencilBuffer;
  102278. /** @hidden */
  102279. _releaseFramebufferObjects(texture: InternalTexture): void;
  102280. /** @hidden */
  102281. _releaseTexture(texture: InternalTexture): void;
  102282. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  102283. protected _setProgram(program: WebGLProgram): void;
  102284. protected _boundUniforms: {
  102285. [key: number]: WebGLUniformLocation;
  102286. };
  102287. /**
  102288. * Binds an effect to the webGL context
  102289. * @param effect defines the effect to bind
  102290. */
  102291. bindSamplers(effect: Effect): void;
  102292. private _activateCurrentTexture;
  102293. /** @hidden */
  102294. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  102295. /** @hidden */
  102296. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  102297. /**
  102298. * Unbind all textures from the webGL context
  102299. */
  102300. unbindAllTextures(): void;
  102301. /**
  102302. * Sets a texture to the according uniform.
  102303. * @param channel The texture channel
  102304. * @param uniform The uniform to set
  102305. * @param texture The texture to apply
  102306. */
  102307. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  102308. private _bindSamplerUniformToChannel;
  102309. private _getTextureWrapMode;
  102310. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  102311. /**
  102312. * Sets an array of texture to the webGL context
  102313. * @param channel defines the channel where the texture array must be set
  102314. * @param uniform defines the associated uniform location
  102315. * @param textures defines the array of textures to bind
  102316. */
  102317. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  102318. /** @hidden */
  102319. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  102320. private _setTextureParameterFloat;
  102321. private _setTextureParameterInteger;
  102322. /**
  102323. * Unbind all vertex attributes from the webGL context
  102324. */
  102325. unbindAllAttributes(): void;
  102326. /**
  102327. * 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
  102328. */
  102329. releaseEffects(): void;
  102330. /**
  102331. * Dispose and release all associated resources
  102332. */
  102333. dispose(): void;
  102334. /**
  102335. * Attach a new callback raised when context lost event is fired
  102336. * @param callback defines the callback to call
  102337. */
  102338. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  102339. /**
  102340. * Attach a new callback raised when context restored event is fired
  102341. * @param callback defines the callback to call
  102342. */
  102343. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  102344. /**
  102345. * Get the current error code of the webGL context
  102346. * @returns the error code
  102347. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  102348. */
  102349. getError(): number;
  102350. private _canRenderToFloatFramebuffer;
  102351. private _canRenderToHalfFloatFramebuffer;
  102352. private _canRenderToFramebuffer;
  102353. /** @hidden */
  102354. _getWebGLTextureType(type: number): number;
  102355. /** @hidden */
  102356. _getInternalFormat(format: number): number;
  102357. /** @hidden */
  102358. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  102359. /** @hidden */
  102360. _getRGBAMultiSampleBufferFormat(type: number): number;
  102361. /** @hidden */
  102362. _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;
  102363. /**
  102364. * Loads a file from a url
  102365. * @param url url to load
  102366. * @param onSuccess callback called when the file successfully loads
  102367. * @param onProgress callback called while file is loading (if the server supports this mode)
  102368. * @param offlineProvider defines the offline provider for caching
  102369. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  102370. * @param onError callback called when the file fails to load
  102371. * @returns a file request object
  102372. * @hidden
  102373. */
  102374. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  102375. /**
  102376. * Reads pixels from the current frame buffer. Please note that this function can be slow
  102377. * @param x defines the x coordinate of the rectangle where pixels must be read
  102378. * @param y defines the y coordinate of the rectangle where pixels must be read
  102379. * @param width defines the width of the rectangle where pixels must be read
  102380. * @param height defines the height of the rectangle where pixels must be read
  102381. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  102382. * @returns a Uint8Array containing RGBA colors
  102383. */
  102384. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  102385. private static _isSupported;
  102386. /**
  102387. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  102388. * @returns true if the engine can be created
  102389. * @ignorenaming
  102390. */
  102391. static isSupported(): boolean;
  102392. /**
  102393. * Find the next highest power of two.
  102394. * @param x Number to start search from.
  102395. * @return Next highest power of two.
  102396. */
  102397. static CeilingPOT(x: number): number;
  102398. /**
  102399. * Find the next lowest power of two.
  102400. * @param x Number to start search from.
  102401. * @return Next lowest power of two.
  102402. */
  102403. static FloorPOT(x: number): number;
  102404. /**
  102405. * Find the nearest power of two.
  102406. * @param x Number to start search from.
  102407. * @return Next nearest power of two.
  102408. */
  102409. static NearestPOT(x: number): number;
  102410. /**
  102411. * Get the closest exponent of two
  102412. * @param value defines the value to approximate
  102413. * @param max defines the maximum value to return
  102414. * @param mode defines how to define the closest value
  102415. * @returns closest exponent of two of the given value
  102416. */
  102417. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  102418. /**
  102419. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  102420. * @param func - the function to be called
  102421. * @param requester - the object that will request the next frame. Falls back to window.
  102422. * @returns frame number
  102423. */
  102424. static QueueNewFrame(func: () => void, requester?: any): number;
  102425. /**
  102426. * Gets host document
  102427. * @returns the host document object
  102428. */
  102429. getHostDocument(): Nullable<Document>;
  102430. }
  102431. }
  102432. declare module BABYLON {
  102433. /**
  102434. * Class representing spherical harmonics coefficients to the 3rd degree
  102435. */
  102436. export class SphericalHarmonics {
  102437. /**
  102438. * Defines whether or not the harmonics have been prescaled for rendering.
  102439. */
  102440. preScaled: boolean;
  102441. /**
  102442. * The l0,0 coefficients of the spherical harmonics
  102443. */
  102444. l00: Vector3;
  102445. /**
  102446. * The l1,-1 coefficients of the spherical harmonics
  102447. */
  102448. l1_1: Vector3;
  102449. /**
  102450. * The l1,0 coefficients of the spherical harmonics
  102451. */
  102452. l10: Vector3;
  102453. /**
  102454. * The l1,1 coefficients of the spherical harmonics
  102455. */
  102456. l11: Vector3;
  102457. /**
  102458. * The l2,-2 coefficients of the spherical harmonics
  102459. */
  102460. l2_2: Vector3;
  102461. /**
  102462. * The l2,-1 coefficients of the spherical harmonics
  102463. */
  102464. l2_1: Vector3;
  102465. /**
  102466. * The l2,0 coefficients of the spherical harmonics
  102467. */
  102468. l20: Vector3;
  102469. /**
  102470. * The l2,1 coefficients of the spherical harmonics
  102471. */
  102472. l21: Vector3;
  102473. /**
  102474. * The l2,2 coefficients of the spherical harmonics
  102475. */
  102476. l22: Vector3;
  102477. /**
  102478. * Adds a light to the spherical harmonics
  102479. * @param direction the direction of the light
  102480. * @param color the color of the light
  102481. * @param deltaSolidAngle the delta solid angle of the light
  102482. */
  102483. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  102484. /**
  102485. * Scales the spherical harmonics by the given amount
  102486. * @param scale the amount to scale
  102487. */
  102488. scaleInPlace(scale: number): void;
  102489. /**
  102490. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  102491. *
  102492. * ```
  102493. * E_lm = A_l * L_lm
  102494. * ```
  102495. *
  102496. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  102497. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  102498. * the scaling factors are given in equation 9.
  102499. */
  102500. convertIncidentRadianceToIrradiance(): void;
  102501. /**
  102502. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  102503. *
  102504. * ```
  102505. * L = (1/pi) * E * rho
  102506. * ```
  102507. *
  102508. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  102509. */
  102510. convertIrradianceToLambertianRadiance(): void;
  102511. /**
  102512. * Integrates the reconstruction coefficients directly in to the SH preventing further
  102513. * required operations at run time.
  102514. *
  102515. * This is simply done by scaling back the SH with Ylm constants parameter.
  102516. * The trigonometric part being applied by the shader at run time.
  102517. */
  102518. preScaleForRendering(): void;
  102519. /**
  102520. * Constructs a spherical harmonics from an array.
  102521. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  102522. * @returns the spherical harmonics
  102523. */
  102524. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  102525. /**
  102526. * Gets the spherical harmonics from polynomial
  102527. * @param polynomial the spherical polynomial
  102528. * @returns the spherical harmonics
  102529. */
  102530. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  102531. }
  102532. /**
  102533. * Class representing spherical polynomial coefficients to the 3rd degree
  102534. */
  102535. export class SphericalPolynomial {
  102536. private _harmonics;
  102537. /**
  102538. * The spherical harmonics used to create the polynomials.
  102539. */
  102540. get preScaledHarmonics(): SphericalHarmonics;
  102541. /**
  102542. * The x coefficients of the spherical polynomial
  102543. */
  102544. x: Vector3;
  102545. /**
  102546. * The y coefficients of the spherical polynomial
  102547. */
  102548. y: Vector3;
  102549. /**
  102550. * The z coefficients of the spherical polynomial
  102551. */
  102552. z: Vector3;
  102553. /**
  102554. * The xx coefficients of the spherical polynomial
  102555. */
  102556. xx: Vector3;
  102557. /**
  102558. * The yy coefficients of the spherical polynomial
  102559. */
  102560. yy: Vector3;
  102561. /**
  102562. * The zz coefficients of the spherical polynomial
  102563. */
  102564. zz: Vector3;
  102565. /**
  102566. * The xy coefficients of the spherical polynomial
  102567. */
  102568. xy: Vector3;
  102569. /**
  102570. * The yz coefficients of the spherical polynomial
  102571. */
  102572. yz: Vector3;
  102573. /**
  102574. * The zx coefficients of the spherical polynomial
  102575. */
  102576. zx: Vector3;
  102577. /**
  102578. * Adds an ambient color to the spherical polynomial
  102579. * @param color the color to add
  102580. */
  102581. addAmbient(color: Color3): void;
  102582. /**
  102583. * Scales the spherical polynomial by the given amount
  102584. * @param scale the amount to scale
  102585. */
  102586. scaleInPlace(scale: number): void;
  102587. /**
  102588. * Gets the spherical polynomial from harmonics
  102589. * @param harmonics the spherical harmonics
  102590. * @returns the spherical polynomial
  102591. */
  102592. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  102593. /**
  102594. * Constructs a spherical polynomial from an array.
  102595. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  102596. * @returns the spherical polynomial
  102597. */
  102598. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  102599. }
  102600. }
  102601. declare module BABYLON {
  102602. /**
  102603. * Defines the source of the internal texture
  102604. */
  102605. export enum InternalTextureSource {
  102606. /**
  102607. * The source of the texture data is unknown
  102608. */
  102609. Unknown = 0,
  102610. /**
  102611. * Texture data comes from an URL
  102612. */
  102613. Url = 1,
  102614. /**
  102615. * Texture data is only used for temporary storage
  102616. */
  102617. Temp = 2,
  102618. /**
  102619. * Texture data comes from raw data (ArrayBuffer)
  102620. */
  102621. Raw = 3,
  102622. /**
  102623. * Texture content is dynamic (video or dynamic texture)
  102624. */
  102625. Dynamic = 4,
  102626. /**
  102627. * Texture content is generated by rendering to it
  102628. */
  102629. RenderTarget = 5,
  102630. /**
  102631. * Texture content is part of a multi render target process
  102632. */
  102633. MultiRenderTarget = 6,
  102634. /**
  102635. * Texture data comes from a cube data file
  102636. */
  102637. Cube = 7,
  102638. /**
  102639. * Texture data comes from a raw cube data
  102640. */
  102641. CubeRaw = 8,
  102642. /**
  102643. * Texture data come from a prefiltered cube data file
  102644. */
  102645. CubePrefiltered = 9,
  102646. /**
  102647. * Texture content is raw 3D data
  102648. */
  102649. Raw3D = 10,
  102650. /**
  102651. * Texture content is raw 2D array data
  102652. */
  102653. Raw2DArray = 11,
  102654. /**
  102655. * Texture content is a depth texture
  102656. */
  102657. Depth = 12,
  102658. /**
  102659. * Texture data comes from a raw cube data encoded with RGBD
  102660. */
  102661. CubeRawRGBD = 13
  102662. }
  102663. /**
  102664. * Class used to store data associated with WebGL texture data for the engine
  102665. * This class should not be used directly
  102666. */
  102667. export class InternalTexture {
  102668. /** @hidden */
  102669. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  102670. /**
  102671. * Defines if the texture is ready
  102672. */
  102673. isReady: boolean;
  102674. /**
  102675. * Defines if the texture is a cube texture
  102676. */
  102677. isCube: boolean;
  102678. /**
  102679. * Defines if the texture contains 3D data
  102680. */
  102681. is3D: boolean;
  102682. /**
  102683. * Defines if the texture contains 2D array data
  102684. */
  102685. is2DArray: boolean;
  102686. /**
  102687. * Defines if the texture contains multiview data
  102688. */
  102689. isMultiview: boolean;
  102690. /**
  102691. * Gets the URL used to load this texture
  102692. */
  102693. url: string;
  102694. /**
  102695. * Gets the sampling mode of the texture
  102696. */
  102697. samplingMode: number;
  102698. /**
  102699. * Gets a boolean indicating if the texture needs mipmaps generation
  102700. */
  102701. generateMipMaps: boolean;
  102702. /**
  102703. * Gets the number of samples used by the texture (WebGL2+ only)
  102704. */
  102705. samples: number;
  102706. /**
  102707. * Gets the type of the texture (int, float...)
  102708. */
  102709. type: number;
  102710. /**
  102711. * Gets the format of the texture (RGB, RGBA...)
  102712. */
  102713. format: number;
  102714. /**
  102715. * Observable called when the texture is loaded
  102716. */
  102717. onLoadedObservable: Observable<InternalTexture>;
  102718. /**
  102719. * Gets the width of the texture
  102720. */
  102721. width: number;
  102722. /**
  102723. * Gets the height of the texture
  102724. */
  102725. height: number;
  102726. /**
  102727. * Gets the depth of the texture
  102728. */
  102729. depth: number;
  102730. /**
  102731. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  102732. */
  102733. baseWidth: number;
  102734. /**
  102735. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  102736. */
  102737. baseHeight: number;
  102738. /**
  102739. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  102740. */
  102741. baseDepth: number;
  102742. /**
  102743. * Gets a boolean indicating if the texture is inverted on Y axis
  102744. */
  102745. invertY: boolean;
  102746. /** @hidden */
  102747. _invertVScale: boolean;
  102748. /** @hidden */
  102749. _associatedChannel: number;
  102750. /** @hidden */
  102751. _source: InternalTextureSource;
  102752. /** @hidden */
  102753. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  102754. /** @hidden */
  102755. _bufferView: Nullable<ArrayBufferView>;
  102756. /** @hidden */
  102757. _bufferViewArray: Nullable<ArrayBufferView[]>;
  102758. /** @hidden */
  102759. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  102760. /** @hidden */
  102761. _size: number;
  102762. /** @hidden */
  102763. _extension: string;
  102764. /** @hidden */
  102765. _files: Nullable<string[]>;
  102766. /** @hidden */
  102767. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  102768. /** @hidden */
  102769. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  102770. /** @hidden */
  102771. _framebuffer: Nullable<WebGLFramebuffer>;
  102772. /** @hidden */
  102773. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  102774. /** @hidden */
  102775. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  102776. /** @hidden */
  102777. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  102778. /** @hidden */
  102779. _attachments: Nullable<number[]>;
  102780. /** @hidden */
  102781. _cachedCoordinatesMode: Nullable<number>;
  102782. /** @hidden */
  102783. _cachedWrapU: Nullable<number>;
  102784. /** @hidden */
  102785. _cachedWrapV: Nullable<number>;
  102786. /** @hidden */
  102787. _cachedWrapR: Nullable<number>;
  102788. /** @hidden */
  102789. _cachedAnisotropicFilteringLevel: Nullable<number>;
  102790. /** @hidden */
  102791. _isDisabled: boolean;
  102792. /** @hidden */
  102793. _compression: Nullable<string>;
  102794. /** @hidden */
  102795. _generateStencilBuffer: boolean;
  102796. /** @hidden */
  102797. _generateDepthBuffer: boolean;
  102798. /** @hidden */
  102799. _comparisonFunction: number;
  102800. /** @hidden */
  102801. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  102802. /** @hidden */
  102803. _lodGenerationScale: number;
  102804. /** @hidden */
  102805. _lodGenerationOffset: number;
  102806. /** @hidden */
  102807. _colorTextureArray: Nullable<WebGLTexture>;
  102808. /** @hidden */
  102809. _depthStencilTextureArray: Nullable<WebGLTexture>;
  102810. /** @hidden */
  102811. _lodTextureHigh: Nullable<BaseTexture>;
  102812. /** @hidden */
  102813. _lodTextureMid: Nullable<BaseTexture>;
  102814. /** @hidden */
  102815. _lodTextureLow: Nullable<BaseTexture>;
  102816. /** @hidden */
  102817. _isRGBD: boolean;
  102818. /** @hidden */
  102819. _linearSpecularLOD: boolean;
  102820. /** @hidden */
  102821. _irradianceTexture: Nullable<BaseTexture>;
  102822. /** @hidden */
  102823. _webGLTexture: Nullable<WebGLTexture>;
  102824. /** @hidden */
  102825. _references: number;
  102826. private _engine;
  102827. /**
  102828. * Gets the Engine the texture belongs to.
  102829. * @returns The babylon engine
  102830. */
  102831. getEngine(): ThinEngine;
  102832. /**
  102833. * Gets the data source type of the texture
  102834. */
  102835. get source(): InternalTextureSource;
  102836. /**
  102837. * Creates a new InternalTexture
  102838. * @param engine defines the engine to use
  102839. * @param source defines the type of data that will be used
  102840. * @param delayAllocation if the texture allocation should be delayed (default: false)
  102841. */
  102842. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  102843. /**
  102844. * Increments the number of references (ie. the number of Texture that point to it)
  102845. */
  102846. incrementReferences(): void;
  102847. /**
  102848. * Change the size of the texture (not the size of the content)
  102849. * @param width defines the new width
  102850. * @param height defines the new height
  102851. * @param depth defines the new depth (1 by default)
  102852. */
  102853. updateSize(width: int, height: int, depth?: int): void;
  102854. /** @hidden */
  102855. _rebuild(): void;
  102856. /** @hidden */
  102857. _swapAndDie(target: InternalTexture): void;
  102858. /**
  102859. * Dispose the current allocated resources
  102860. */
  102861. dispose(): void;
  102862. }
  102863. }
  102864. declare module BABYLON {
  102865. /**
  102866. * Class used to work with sound analyzer using fast fourier transform (FFT)
  102867. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102868. */
  102869. export class Analyser {
  102870. /**
  102871. * Gets or sets the smoothing
  102872. * @ignorenaming
  102873. */
  102874. SMOOTHING: number;
  102875. /**
  102876. * Gets or sets the FFT table size
  102877. * @ignorenaming
  102878. */
  102879. FFT_SIZE: number;
  102880. /**
  102881. * Gets or sets the bar graph amplitude
  102882. * @ignorenaming
  102883. */
  102884. BARGRAPHAMPLITUDE: number;
  102885. /**
  102886. * Gets or sets the position of the debug canvas
  102887. * @ignorenaming
  102888. */
  102889. DEBUGCANVASPOS: {
  102890. x: number;
  102891. y: number;
  102892. };
  102893. /**
  102894. * Gets or sets the debug canvas size
  102895. * @ignorenaming
  102896. */
  102897. DEBUGCANVASSIZE: {
  102898. width: number;
  102899. height: number;
  102900. };
  102901. private _byteFreqs;
  102902. private _byteTime;
  102903. private _floatFreqs;
  102904. private _webAudioAnalyser;
  102905. private _debugCanvas;
  102906. private _debugCanvasContext;
  102907. private _scene;
  102908. private _registerFunc;
  102909. private _audioEngine;
  102910. /**
  102911. * Creates a new analyser
  102912. * @param scene defines hosting scene
  102913. */
  102914. constructor(scene: Scene);
  102915. /**
  102916. * Get the number of data values you will have to play with for the visualization
  102917. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  102918. * @returns a number
  102919. */
  102920. getFrequencyBinCount(): number;
  102921. /**
  102922. * Gets the current frequency data as a byte array
  102923. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  102924. * @returns a Uint8Array
  102925. */
  102926. getByteFrequencyData(): Uint8Array;
  102927. /**
  102928. * Gets the current waveform as a byte array
  102929. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  102930. * @returns a Uint8Array
  102931. */
  102932. getByteTimeDomainData(): Uint8Array;
  102933. /**
  102934. * Gets the current frequency data as a float array
  102935. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  102936. * @returns a Float32Array
  102937. */
  102938. getFloatFrequencyData(): Float32Array;
  102939. /**
  102940. * Renders the debug canvas
  102941. */
  102942. drawDebugCanvas(): void;
  102943. /**
  102944. * Stops rendering the debug canvas and removes it
  102945. */
  102946. stopDebugCanvas(): void;
  102947. /**
  102948. * Connects two audio nodes
  102949. * @param inputAudioNode defines first node to connect
  102950. * @param outputAudioNode defines second node to connect
  102951. */
  102952. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  102953. /**
  102954. * Releases all associated resources
  102955. */
  102956. dispose(): void;
  102957. }
  102958. }
  102959. declare module BABYLON {
  102960. /**
  102961. * This represents an audio engine and it is responsible
  102962. * to play, synchronize and analyse sounds throughout the application.
  102963. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102964. */
  102965. export interface IAudioEngine extends IDisposable {
  102966. /**
  102967. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  102968. */
  102969. readonly canUseWebAudio: boolean;
  102970. /**
  102971. * Gets the current AudioContext if available.
  102972. */
  102973. readonly audioContext: Nullable<AudioContext>;
  102974. /**
  102975. * The master gain node defines the global audio volume of your audio engine.
  102976. */
  102977. readonly masterGain: GainNode;
  102978. /**
  102979. * Gets whether or not mp3 are supported by your browser.
  102980. */
  102981. readonly isMP3supported: boolean;
  102982. /**
  102983. * Gets whether or not ogg are supported by your browser.
  102984. */
  102985. readonly isOGGsupported: boolean;
  102986. /**
  102987. * Defines if Babylon should emit a warning if WebAudio is not supported.
  102988. * @ignoreNaming
  102989. */
  102990. WarnedWebAudioUnsupported: boolean;
  102991. /**
  102992. * Defines if the audio engine relies on a custom unlocked button.
  102993. * In this case, the embedded button will not be displayed.
  102994. */
  102995. useCustomUnlockedButton: boolean;
  102996. /**
  102997. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  102998. */
  102999. readonly unlocked: boolean;
  103000. /**
  103001. * Event raised when audio has been unlocked on the browser.
  103002. */
  103003. onAudioUnlockedObservable: Observable<AudioEngine>;
  103004. /**
  103005. * Event raised when audio has been locked on the browser.
  103006. */
  103007. onAudioLockedObservable: Observable<AudioEngine>;
  103008. /**
  103009. * Flags the audio engine in Locked state.
  103010. * This happens due to new browser policies preventing audio to autoplay.
  103011. */
  103012. lock(): void;
  103013. /**
  103014. * Unlocks the audio engine once a user action has been done on the dom.
  103015. * This is helpful to resume play once browser policies have been satisfied.
  103016. */
  103017. unlock(): void;
  103018. }
  103019. /**
  103020. * This represents the default audio engine used in babylon.
  103021. * It is responsible to play, synchronize and analyse sounds throughout the application.
  103022. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103023. */
  103024. export class AudioEngine implements IAudioEngine {
  103025. private _audioContext;
  103026. private _audioContextInitialized;
  103027. private _muteButton;
  103028. private _hostElement;
  103029. /**
  103030. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  103031. */
  103032. canUseWebAudio: boolean;
  103033. /**
  103034. * The master gain node defines the global audio volume of your audio engine.
  103035. */
  103036. masterGain: GainNode;
  103037. /**
  103038. * Defines if Babylon should emit a warning if WebAudio is not supported.
  103039. * @ignoreNaming
  103040. */
  103041. WarnedWebAudioUnsupported: boolean;
  103042. /**
  103043. * Gets whether or not mp3 are supported by your browser.
  103044. */
  103045. isMP3supported: boolean;
  103046. /**
  103047. * Gets whether or not ogg are supported by your browser.
  103048. */
  103049. isOGGsupported: boolean;
  103050. /**
  103051. * Gets whether audio has been unlocked on the device.
  103052. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  103053. * a user interaction has happened.
  103054. */
  103055. unlocked: boolean;
  103056. /**
  103057. * Defines if the audio engine relies on a custom unlocked button.
  103058. * In this case, the embedded button will not be displayed.
  103059. */
  103060. useCustomUnlockedButton: boolean;
  103061. /**
  103062. * Event raised when audio has been unlocked on the browser.
  103063. */
  103064. onAudioUnlockedObservable: Observable<AudioEngine>;
  103065. /**
  103066. * Event raised when audio has been locked on the browser.
  103067. */
  103068. onAudioLockedObservable: Observable<AudioEngine>;
  103069. /**
  103070. * Gets the current AudioContext if available.
  103071. */
  103072. get audioContext(): Nullable<AudioContext>;
  103073. private _connectedAnalyser;
  103074. /**
  103075. * Instantiates a new audio engine.
  103076. *
  103077. * There should be only one per page as some browsers restrict the number
  103078. * of audio contexts you can create.
  103079. * @param hostElement defines the host element where to display the mute icon if necessary
  103080. */
  103081. constructor(hostElement?: Nullable<HTMLElement>);
  103082. /**
  103083. * Flags the audio engine in Locked state.
  103084. * This happens due to new browser policies preventing audio to autoplay.
  103085. */
  103086. lock(): void;
  103087. /**
  103088. * Unlocks the audio engine once a user action has been done on the dom.
  103089. * This is helpful to resume play once browser policies have been satisfied.
  103090. */
  103091. unlock(): void;
  103092. private _resumeAudioContext;
  103093. private _initializeAudioContext;
  103094. private _tryToRun;
  103095. private _triggerRunningState;
  103096. private _triggerSuspendedState;
  103097. private _displayMuteButton;
  103098. private _moveButtonToTopLeft;
  103099. private _onResize;
  103100. private _hideMuteButton;
  103101. /**
  103102. * Destroy and release the resources associated with the audio ccontext.
  103103. */
  103104. dispose(): void;
  103105. /**
  103106. * Gets the global volume sets on the master gain.
  103107. * @returns the global volume if set or -1 otherwise
  103108. */
  103109. getGlobalVolume(): number;
  103110. /**
  103111. * Sets the global volume of your experience (sets on the master gain).
  103112. * @param newVolume Defines the new global volume of the application
  103113. */
  103114. setGlobalVolume(newVolume: number): void;
  103115. /**
  103116. * Connect the audio engine to an audio analyser allowing some amazing
  103117. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  103118. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  103119. * @param analyser The analyser to connect to the engine
  103120. */
  103121. connectToAnalyser(analyser: Analyser): void;
  103122. }
  103123. }
  103124. declare module BABYLON {
  103125. /**
  103126. * Interface used to present a loading screen while loading a scene
  103127. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  103128. */
  103129. export interface ILoadingScreen {
  103130. /**
  103131. * Function called to display the loading screen
  103132. */
  103133. displayLoadingUI: () => void;
  103134. /**
  103135. * Function called to hide the loading screen
  103136. */
  103137. hideLoadingUI: () => void;
  103138. /**
  103139. * Gets or sets the color to use for the background
  103140. */
  103141. loadingUIBackgroundColor: string;
  103142. /**
  103143. * Gets or sets the text to display while loading
  103144. */
  103145. loadingUIText: string;
  103146. }
  103147. /**
  103148. * Class used for the default loading screen
  103149. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  103150. */
  103151. export class DefaultLoadingScreen implements ILoadingScreen {
  103152. private _renderingCanvas;
  103153. private _loadingText;
  103154. private _loadingDivBackgroundColor;
  103155. private _loadingDiv;
  103156. private _loadingTextDiv;
  103157. /** Gets or sets the logo url to use for the default loading screen */
  103158. static DefaultLogoUrl: string;
  103159. /** Gets or sets the spinner url to use for the default loading screen */
  103160. static DefaultSpinnerUrl: string;
  103161. /**
  103162. * Creates a new default loading screen
  103163. * @param _renderingCanvas defines the canvas used to render the scene
  103164. * @param _loadingText defines the default text to display
  103165. * @param _loadingDivBackgroundColor defines the default background color
  103166. */
  103167. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  103168. /**
  103169. * Function called to display the loading screen
  103170. */
  103171. displayLoadingUI(): void;
  103172. /**
  103173. * Function called to hide the loading screen
  103174. */
  103175. hideLoadingUI(): void;
  103176. /**
  103177. * Gets or sets the text to display while loading
  103178. */
  103179. set loadingUIText(text: string);
  103180. get loadingUIText(): string;
  103181. /**
  103182. * Gets or sets the color to use for the background
  103183. */
  103184. get loadingUIBackgroundColor(): string;
  103185. set loadingUIBackgroundColor(color: string);
  103186. private _resizeLoadingUI;
  103187. }
  103188. }
  103189. declare module BABYLON {
  103190. /**
  103191. * Interface for any object that can request an animation frame
  103192. */
  103193. export interface ICustomAnimationFrameRequester {
  103194. /**
  103195. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  103196. */
  103197. renderFunction?: Function;
  103198. /**
  103199. * Called to request the next frame to render to
  103200. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  103201. */
  103202. requestAnimationFrame: Function;
  103203. /**
  103204. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  103205. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  103206. */
  103207. requestID?: number;
  103208. }
  103209. }
  103210. declare module BABYLON {
  103211. /**
  103212. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  103213. */
  103214. export class PerformanceMonitor {
  103215. private _enabled;
  103216. private _rollingFrameTime;
  103217. private _lastFrameTimeMs;
  103218. /**
  103219. * constructor
  103220. * @param frameSampleSize The number of samples required to saturate the sliding window
  103221. */
  103222. constructor(frameSampleSize?: number);
  103223. /**
  103224. * Samples current frame
  103225. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  103226. */
  103227. sampleFrame(timeMs?: number): void;
  103228. /**
  103229. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  103230. */
  103231. get averageFrameTime(): number;
  103232. /**
  103233. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  103234. */
  103235. get averageFrameTimeVariance(): number;
  103236. /**
  103237. * Returns the frame time of the most recent frame
  103238. */
  103239. get instantaneousFrameTime(): number;
  103240. /**
  103241. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  103242. */
  103243. get averageFPS(): number;
  103244. /**
  103245. * Returns the average framerate in frames per second using the most recent frame time
  103246. */
  103247. get instantaneousFPS(): number;
  103248. /**
  103249. * Returns true if enough samples have been taken to completely fill the sliding window
  103250. */
  103251. get isSaturated(): boolean;
  103252. /**
  103253. * Enables contributions to the sliding window sample set
  103254. */
  103255. enable(): void;
  103256. /**
  103257. * Disables contributions to the sliding window sample set
  103258. * Samples will not be interpolated over the disabled period
  103259. */
  103260. disable(): void;
  103261. /**
  103262. * Returns true if sampling is enabled
  103263. */
  103264. get isEnabled(): boolean;
  103265. /**
  103266. * Resets performance monitor
  103267. */
  103268. reset(): void;
  103269. }
  103270. /**
  103271. * RollingAverage
  103272. *
  103273. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  103274. */
  103275. export class RollingAverage {
  103276. /**
  103277. * Current average
  103278. */
  103279. average: number;
  103280. /**
  103281. * Current variance
  103282. */
  103283. variance: number;
  103284. protected _samples: Array<number>;
  103285. protected _sampleCount: number;
  103286. protected _pos: number;
  103287. protected _m2: number;
  103288. /**
  103289. * constructor
  103290. * @param length The number of samples required to saturate the sliding window
  103291. */
  103292. constructor(length: number);
  103293. /**
  103294. * Adds a sample to the sample set
  103295. * @param v The sample value
  103296. */
  103297. add(v: number): void;
  103298. /**
  103299. * Returns previously added values or null if outside of history or outside the sliding window domain
  103300. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  103301. * @return Value previously recorded with add() or null if outside of range
  103302. */
  103303. history(i: number): number;
  103304. /**
  103305. * Returns true if enough samples have been taken to completely fill the sliding window
  103306. * @return true if sample-set saturated
  103307. */
  103308. isSaturated(): boolean;
  103309. /**
  103310. * Resets the rolling average (equivalent to 0 samples taken so far)
  103311. */
  103312. reset(): void;
  103313. /**
  103314. * Wraps a value around the sample range boundaries
  103315. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  103316. * @return Wrapped position in sample range
  103317. */
  103318. protected _wrapPosition(i: number): number;
  103319. }
  103320. }
  103321. declare module BABYLON {
  103322. /**
  103323. * This class is used to track a performance counter which is number based.
  103324. * The user has access to many properties which give statistics of different nature.
  103325. *
  103326. * The implementer can track two kinds of Performance Counter: time and count.
  103327. * 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.
  103328. * 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.
  103329. */
  103330. export class PerfCounter {
  103331. /**
  103332. * Gets or sets a global boolean to turn on and off all the counters
  103333. */
  103334. static Enabled: boolean;
  103335. /**
  103336. * Returns the smallest value ever
  103337. */
  103338. get min(): number;
  103339. /**
  103340. * Returns the biggest value ever
  103341. */
  103342. get max(): number;
  103343. /**
  103344. * Returns the average value since the performance counter is running
  103345. */
  103346. get average(): number;
  103347. /**
  103348. * Returns the average value of the last second the counter was monitored
  103349. */
  103350. get lastSecAverage(): number;
  103351. /**
  103352. * Returns the current value
  103353. */
  103354. get current(): number;
  103355. /**
  103356. * Gets the accumulated total
  103357. */
  103358. get total(): number;
  103359. /**
  103360. * Gets the total value count
  103361. */
  103362. get count(): number;
  103363. /**
  103364. * Creates a new counter
  103365. */
  103366. constructor();
  103367. /**
  103368. * Call this method to start monitoring a new frame.
  103369. * 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.
  103370. */
  103371. fetchNewFrame(): void;
  103372. /**
  103373. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  103374. * @param newCount the count value to add to the monitored count
  103375. * @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.
  103376. */
  103377. addCount(newCount: number, fetchResult: boolean): void;
  103378. /**
  103379. * Start monitoring this performance counter
  103380. */
  103381. beginMonitoring(): void;
  103382. /**
  103383. * Compute the time lapsed since the previous beginMonitoring() call.
  103384. * @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
  103385. */
  103386. endMonitoring(newFrame?: boolean): void;
  103387. private _fetchResult;
  103388. private _startMonitoringTime;
  103389. private _min;
  103390. private _max;
  103391. private _average;
  103392. private _current;
  103393. private _totalValueCount;
  103394. private _totalAccumulated;
  103395. private _lastSecAverage;
  103396. private _lastSecAccumulated;
  103397. private _lastSecTime;
  103398. private _lastSecValueCount;
  103399. }
  103400. }
  103401. declare module BABYLON {
  103402. interface ThinEngine {
  103403. /**
  103404. * Sets alpha constants used by some alpha blending modes
  103405. * @param r defines the red component
  103406. * @param g defines the green component
  103407. * @param b defines the blue component
  103408. * @param a defines the alpha component
  103409. */
  103410. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  103411. /**
  103412. * Sets the current alpha mode
  103413. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  103414. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  103415. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  103416. */
  103417. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  103418. /**
  103419. * Gets the current alpha mode
  103420. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  103421. * @returns the current alpha mode
  103422. */
  103423. getAlphaMode(): number;
  103424. /**
  103425. * Sets the current alpha equation
  103426. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  103427. */
  103428. setAlphaEquation(equation: number): void;
  103429. /**
  103430. * Gets the current alpha equation.
  103431. * @returns the current alpha equation
  103432. */
  103433. getAlphaEquation(): number;
  103434. }
  103435. }
  103436. declare module BABYLON {
  103437. /**
  103438. * Defines the interface used by display changed events
  103439. */
  103440. export interface IDisplayChangedEventArgs {
  103441. /** Gets the vrDisplay object (if any) */
  103442. vrDisplay: Nullable<any>;
  103443. /** Gets a boolean indicating if webVR is supported */
  103444. vrSupported: boolean;
  103445. }
  103446. /**
  103447. * Defines the interface used by objects containing a viewport (like a camera)
  103448. */
  103449. interface IViewportOwnerLike {
  103450. /**
  103451. * Gets or sets the viewport
  103452. */
  103453. viewport: IViewportLike;
  103454. }
  103455. /**
  103456. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  103457. */
  103458. export class Engine extends ThinEngine {
  103459. /** Defines that alpha blending is disabled */
  103460. static readonly ALPHA_DISABLE: number;
  103461. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  103462. static readonly ALPHA_ADD: number;
  103463. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  103464. static readonly ALPHA_COMBINE: number;
  103465. /** Defines that alpha blending to DEST - SRC * DEST */
  103466. static readonly ALPHA_SUBTRACT: number;
  103467. /** Defines that alpha blending to SRC * DEST */
  103468. static readonly ALPHA_MULTIPLY: number;
  103469. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  103470. static readonly ALPHA_MAXIMIZED: number;
  103471. /** Defines that alpha blending to SRC + DEST */
  103472. static readonly ALPHA_ONEONE: number;
  103473. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  103474. static readonly ALPHA_PREMULTIPLIED: number;
  103475. /**
  103476. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  103477. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  103478. */
  103479. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  103480. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  103481. static readonly ALPHA_INTERPOLATE: number;
  103482. /**
  103483. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  103484. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  103485. */
  103486. static readonly ALPHA_SCREENMODE: number;
  103487. /** Defines that the ressource is not delayed*/
  103488. static readonly DELAYLOADSTATE_NONE: number;
  103489. /** Defines that the ressource was successfully delay loaded */
  103490. static readonly DELAYLOADSTATE_LOADED: number;
  103491. /** Defines that the ressource is currently delay loading */
  103492. static readonly DELAYLOADSTATE_LOADING: number;
  103493. /** Defines that the ressource is delayed and has not started loading */
  103494. static readonly DELAYLOADSTATE_NOTLOADED: number;
  103495. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  103496. static readonly NEVER: number;
  103497. /** 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 */
  103498. static readonly ALWAYS: number;
  103499. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  103500. static readonly LESS: number;
  103501. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  103502. static readonly EQUAL: number;
  103503. /** 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 */
  103504. static readonly LEQUAL: number;
  103505. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  103506. static readonly GREATER: number;
  103507. /** 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 */
  103508. static readonly GEQUAL: number;
  103509. /** 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 */
  103510. static readonly NOTEQUAL: number;
  103511. /** Passed to stencilOperation to specify that stencil value must be kept */
  103512. static readonly KEEP: number;
  103513. /** Passed to stencilOperation to specify that stencil value must be replaced */
  103514. static readonly REPLACE: number;
  103515. /** Passed to stencilOperation to specify that stencil value must be incremented */
  103516. static readonly INCR: number;
  103517. /** Passed to stencilOperation to specify that stencil value must be decremented */
  103518. static readonly DECR: number;
  103519. /** Passed to stencilOperation to specify that stencil value must be inverted */
  103520. static readonly INVERT: number;
  103521. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  103522. static readonly INCR_WRAP: number;
  103523. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  103524. static readonly DECR_WRAP: number;
  103525. /** Texture is not repeating outside of 0..1 UVs */
  103526. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  103527. /** Texture is repeating outside of 0..1 UVs */
  103528. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  103529. /** Texture is repeating and mirrored */
  103530. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  103531. /** ALPHA */
  103532. static readonly TEXTUREFORMAT_ALPHA: number;
  103533. /** LUMINANCE */
  103534. static readonly TEXTUREFORMAT_LUMINANCE: number;
  103535. /** LUMINANCE_ALPHA */
  103536. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  103537. /** RGB */
  103538. static readonly TEXTUREFORMAT_RGB: number;
  103539. /** RGBA */
  103540. static readonly TEXTUREFORMAT_RGBA: number;
  103541. /** RED */
  103542. static readonly TEXTUREFORMAT_RED: number;
  103543. /** RED (2nd reference) */
  103544. static readonly TEXTUREFORMAT_R: number;
  103545. /** RG */
  103546. static readonly TEXTUREFORMAT_RG: number;
  103547. /** RED_INTEGER */
  103548. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  103549. /** RED_INTEGER (2nd reference) */
  103550. static readonly TEXTUREFORMAT_R_INTEGER: number;
  103551. /** RG_INTEGER */
  103552. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  103553. /** RGB_INTEGER */
  103554. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  103555. /** RGBA_INTEGER */
  103556. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  103557. /** UNSIGNED_BYTE */
  103558. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  103559. /** UNSIGNED_BYTE (2nd reference) */
  103560. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  103561. /** FLOAT */
  103562. static readonly TEXTURETYPE_FLOAT: number;
  103563. /** HALF_FLOAT */
  103564. static readonly TEXTURETYPE_HALF_FLOAT: number;
  103565. /** BYTE */
  103566. static readonly TEXTURETYPE_BYTE: number;
  103567. /** SHORT */
  103568. static readonly TEXTURETYPE_SHORT: number;
  103569. /** UNSIGNED_SHORT */
  103570. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  103571. /** INT */
  103572. static readonly TEXTURETYPE_INT: number;
  103573. /** UNSIGNED_INT */
  103574. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  103575. /** UNSIGNED_SHORT_4_4_4_4 */
  103576. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  103577. /** UNSIGNED_SHORT_5_5_5_1 */
  103578. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  103579. /** UNSIGNED_SHORT_5_6_5 */
  103580. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  103581. /** UNSIGNED_INT_2_10_10_10_REV */
  103582. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  103583. /** UNSIGNED_INT_24_8 */
  103584. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  103585. /** UNSIGNED_INT_10F_11F_11F_REV */
  103586. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  103587. /** UNSIGNED_INT_5_9_9_9_REV */
  103588. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  103589. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  103590. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  103591. /** nearest is mag = nearest and min = nearest and mip = linear */
  103592. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  103593. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103594. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  103595. /** Trilinear is mag = linear and min = linear and mip = linear */
  103596. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  103597. /** nearest is mag = nearest and min = nearest and mip = linear */
  103598. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  103599. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103600. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  103601. /** Trilinear is mag = linear and min = linear and mip = linear */
  103602. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  103603. /** mag = nearest and min = nearest and mip = nearest */
  103604. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  103605. /** mag = nearest and min = linear and mip = nearest */
  103606. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  103607. /** mag = nearest and min = linear and mip = linear */
  103608. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  103609. /** mag = nearest and min = linear and mip = none */
  103610. static readonly TEXTURE_NEAREST_LINEAR: number;
  103611. /** mag = nearest and min = nearest and mip = none */
  103612. static readonly TEXTURE_NEAREST_NEAREST: number;
  103613. /** mag = linear and min = nearest and mip = nearest */
  103614. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  103615. /** mag = linear and min = nearest and mip = linear */
  103616. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  103617. /** mag = linear and min = linear and mip = none */
  103618. static readonly TEXTURE_LINEAR_LINEAR: number;
  103619. /** mag = linear and min = nearest and mip = none */
  103620. static readonly TEXTURE_LINEAR_NEAREST: number;
  103621. /** Explicit coordinates mode */
  103622. static readonly TEXTURE_EXPLICIT_MODE: number;
  103623. /** Spherical coordinates mode */
  103624. static readonly TEXTURE_SPHERICAL_MODE: number;
  103625. /** Planar coordinates mode */
  103626. static readonly TEXTURE_PLANAR_MODE: number;
  103627. /** Cubic coordinates mode */
  103628. static readonly TEXTURE_CUBIC_MODE: number;
  103629. /** Projection coordinates mode */
  103630. static readonly TEXTURE_PROJECTION_MODE: number;
  103631. /** Skybox coordinates mode */
  103632. static readonly TEXTURE_SKYBOX_MODE: number;
  103633. /** Inverse Cubic coordinates mode */
  103634. static readonly TEXTURE_INVCUBIC_MODE: number;
  103635. /** Equirectangular coordinates mode */
  103636. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  103637. /** Equirectangular Fixed coordinates mode */
  103638. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  103639. /** Equirectangular Fixed Mirrored coordinates mode */
  103640. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  103641. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  103642. static readonly SCALEMODE_FLOOR: number;
  103643. /** Defines that texture rescaling will look for the nearest power of 2 size */
  103644. static readonly SCALEMODE_NEAREST: number;
  103645. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  103646. static readonly SCALEMODE_CEILING: number;
  103647. /**
  103648. * Returns the current npm package of the sdk
  103649. */
  103650. static get NpmPackage(): string;
  103651. /**
  103652. * Returns the current version of the framework
  103653. */
  103654. static get Version(): string;
  103655. /** Gets the list of created engines */
  103656. static get Instances(): Engine[];
  103657. /**
  103658. * Gets the latest created engine
  103659. */
  103660. static get LastCreatedEngine(): Nullable<Engine>;
  103661. /**
  103662. * Gets the latest created scene
  103663. */
  103664. static get LastCreatedScene(): Nullable<Scene>;
  103665. /**
  103666. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  103667. * @param flag defines which part of the materials must be marked as dirty
  103668. * @param predicate defines a predicate used to filter which materials should be affected
  103669. */
  103670. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  103671. /**
  103672. * Method called to create the default loading screen.
  103673. * This can be overriden in your own app.
  103674. * @param canvas The rendering canvas element
  103675. * @returns The loading screen
  103676. */
  103677. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  103678. /**
  103679. * Method called to create the default rescale post process on each engine.
  103680. */
  103681. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  103682. /**
  103683. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  103684. **/
  103685. enableOfflineSupport: boolean;
  103686. /**
  103687. * 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)
  103688. **/
  103689. disableManifestCheck: boolean;
  103690. /**
  103691. * Gets the list of created scenes
  103692. */
  103693. scenes: Scene[];
  103694. /**
  103695. * Event raised when a new scene is created
  103696. */
  103697. onNewSceneAddedObservable: Observable<Scene>;
  103698. /**
  103699. * Gets the list of created postprocesses
  103700. */
  103701. postProcesses: PostProcess[];
  103702. /**
  103703. * Gets a boolean indicating if the pointer is currently locked
  103704. */
  103705. isPointerLock: boolean;
  103706. /**
  103707. * Observable event triggered each time the rendering canvas is resized
  103708. */
  103709. onResizeObservable: Observable<Engine>;
  103710. /**
  103711. * Observable event triggered each time the canvas loses focus
  103712. */
  103713. onCanvasBlurObservable: Observable<Engine>;
  103714. /**
  103715. * Observable event triggered each time the canvas gains focus
  103716. */
  103717. onCanvasFocusObservable: Observable<Engine>;
  103718. /**
  103719. * Observable event triggered each time the canvas receives pointerout event
  103720. */
  103721. onCanvasPointerOutObservable: Observable<PointerEvent>;
  103722. /**
  103723. * Observable raised when the engine begins a new frame
  103724. */
  103725. onBeginFrameObservable: Observable<Engine>;
  103726. /**
  103727. * If set, will be used to request the next animation frame for the render loop
  103728. */
  103729. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  103730. /**
  103731. * Observable raised when the engine ends the current frame
  103732. */
  103733. onEndFrameObservable: Observable<Engine>;
  103734. /**
  103735. * Observable raised when the engine is about to compile a shader
  103736. */
  103737. onBeforeShaderCompilationObservable: Observable<Engine>;
  103738. /**
  103739. * Observable raised when the engine has jsut compiled a shader
  103740. */
  103741. onAfterShaderCompilationObservable: Observable<Engine>;
  103742. /**
  103743. * Gets the audio engine
  103744. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103745. * @ignorenaming
  103746. */
  103747. static audioEngine: IAudioEngine;
  103748. /**
  103749. * Default AudioEngine factory responsible of creating the Audio Engine.
  103750. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  103751. */
  103752. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  103753. /**
  103754. * Default offline support factory responsible of creating a tool used to store data locally.
  103755. * By default, this will create a Database object if the workload has been embedded.
  103756. */
  103757. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  103758. private _loadingScreen;
  103759. private _pointerLockRequested;
  103760. private _dummyFramebuffer;
  103761. private _rescalePostProcess;
  103762. private _deterministicLockstep;
  103763. private _lockstepMaxSteps;
  103764. private _timeStep;
  103765. protected get _supportsHardwareTextureRescaling(): boolean;
  103766. private _fps;
  103767. private _deltaTime;
  103768. /** @hidden */
  103769. _drawCalls: PerfCounter;
  103770. /**
  103771. * Turn this value on if you want to pause FPS computation when in background
  103772. */
  103773. disablePerformanceMonitorInBackground: boolean;
  103774. private _performanceMonitor;
  103775. /**
  103776. * Gets the performance monitor attached to this engine
  103777. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  103778. */
  103779. get performanceMonitor(): PerformanceMonitor;
  103780. private _onFocus;
  103781. private _onBlur;
  103782. private _onCanvasPointerOut;
  103783. private _onCanvasBlur;
  103784. private _onCanvasFocus;
  103785. private _onFullscreenChange;
  103786. private _onPointerLockChange;
  103787. /**
  103788. * Gets the HTML element used to attach event listeners
  103789. * @returns a HTML element
  103790. */
  103791. getInputElement(): Nullable<HTMLElement>;
  103792. /**
  103793. * Creates a new engine
  103794. * @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
  103795. * @param antialias defines enable antialiasing (default: false)
  103796. * @param options defines further options to be sent to the getContext() function
  103797. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  103798. */
  103799. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  103800. /**
  103801. * Gets current aspect ratio
  103802. * @param viewportOwner defines the camera to use to get the aspect ratio
  103803. * @param useScreen defines if screen size must be used (or the current render target if any)
  103804. * @returns a number defining the aspect ratio
  103805. */
  103806. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  103807. /**
  103808. * Gets current screen aspect ratio
  103809. * @returns a number defining the aspect ratio
  103810. */
  103811. getScreenAspectRatio(): number;
  103812. /**
  103813. * Gets the client rect of the HTML canvas attached with the current webGL context
  103814. * @returns a client rectanglee
  103815. */
  103816. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  103817. /**
  103818. * Gets the client rect of the HTML element used for events
  103819. * @returns a client rectanglee
  103820. */
  103821. getInputElementClientRect(): Nullable<ClientRect>;
  103822. /**
  103823. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  103824. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103825. * @returns true if engine is in deterministic lock step mode
  103826. */
  103827. isDeterministicLockStep(): boolean;
  103828. /**
  103829. * Gets the max steps when engine is running in deterministic lock step
  103830. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103831. * @returns the max steps
  103832. */
  103833. getLockstepMaxSteps(): number;
  103834. /**
  103835. * Returns the time in ms between steps when using deterministic lock step.
  103836. * @returns time step in (ms)
  103837. */
  103838. getTimeStep(): number;
  103839. /**
  103840. * Force the mipmap generation for the given render target texture
  103841. * @param texture defines the render target texture to use
  103842. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  103843. */
  103844. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  103845. /** States */
  103846. /**
  103847. * Set various states to the webGL context
  103848. * @param culling defines backface culling state
  103849. * @param zOffset defines the value to apply to zOffset (0 by default)
  103850. * @param force defines if states must be applied even if cache is up to date
  103851. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  103852. */
  103853. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  103854. /**
  103855. * Set the z offset to apply to current rendering
  103856. * @param value defines the offset to apply
  103857. */
  103858. setZOffset(value: number): void;
  103859. /**
  103860. * Gets the current value of the zOffset
  103861. * @returns the current zOffset state
  103862. */
  103863. getZOffset(): number;
  103864. /**
  103865. * Enable or disable depth buffering
  103866. * @param enable defines the state to set
  103867. */
  103868. setDepthBuffer(enable: boolean): void;
  103869. /**
  103870. * Gets a boolean indicating if depth writing is enabled
  103871. * @returns the current depth writing state
  103872. */
  103873. getDepthWrite(): boolean;
  103874. /**
  103875. * Enable or disable depth writing
  103876. * @param enable defines the state to set
  103877. */
  103878. setDepthWrite(enable: boolean): void;
  103879. /**
  103880. * Gets a boolean indicating if stencil buffer is enabled
  103881. * @returns the current stencil buffer state
  103882. */
  103883. getStencilBuffer(): boolean;
  103884. /**
  103885. * Enable or disable the stencil buffer
  103886. * @param enable defines if the stencil buffer must be enabled or disabled
  103887. */
  103888. setStencilBuffer(enable: boolean): void;
  103889. /**
  103890. * Gets the current stencil mask
  103891. * @returns a number defining the new stencil mask to use
  103892. */
  103893. getStencilMask(): number;
  103894. /**
  103895. * Sets the current stencil mask
  103896. * @param mask defines the new stencil mask to use
  103897. */
  103898. setStencilMask(mask: number): void;
  103899. /**
  103900. * Gets the current stencil function
  103901. * @returns a number defining the stencil function to use
  103902. */
  103903. getStencilFunction(): number;
  103904. /**
  103905. * Gets the current stencil reference value
  103906. * @returns a number defining the stencil reference value to use
  103907. */
  103908. getStencilFunctionReference(): number;
  103909. /**
  103910. * Gets the current stencil mask
  103911. * @returns a number defining the stencil mask to use
  103912. */
  103913. getStencilFunctionMask(): number;
  103914. /**
  103915. * Sets the current stencil function
  103916. * @param stencilFunc defines the new stencil function to use
  103917. */
  103918. setStencilFunction(stencilFunc: number): void;
  103919. /**
  103920. * Sets the current stencil reference
  103921. * @param reference defines the new stencil reference to use
  103922. */
  103923. setStencilFunctionReference(reference: number): void;
  103924. /**
  103925. * Sets the current stencil mask
  103926. * @param mask defines the new stencil mask to use
  103927. */
  103928. setStencilFunctionMask(mask: number): void;
  103929. /**
  103930. * Gets the current stencil operation when stencil fails
  103931. * @returns a number defining stencil operation to use when stencil fails
  103932. */
  103933. getStencilOperationFail(): number;
  103934. /**
  103935. * Gets the current stencil operation when depth fails
  103936. * @returns a number defining stencil operation to use when depth fails
  103937. */
  103938. getStencilOperationDepthFail(): number;
  103939. /**
  103940. * Gets the current stencil operation when stencil passes
  103941. * @returns a number defining stencil operation to use when stencil passes
  103942. */
  103943. getStencilOperationPass(): number;
  103944. /**
  103945. * Sets the stencil operation to use when stencil fails
  103946. * @param operation defines the stencil operation to use when stencil fails
  103947. */
  103948. setStencilOperationFail(operation: number): void;
  103949. /**
  103950. * Sets the stencil operation to use when depth fails
  103951. * @param operation defines the stencil operation to use when depth fails
  103952. */
  103953. setStencilOperationDepthFail(operation: number): void;
  103954. /**
  103955. * Sets the stencil operation to use when stencil passes
  103956. * @param operation defines the stencil operation to use when stencil passes
  103957. */
  103958. setStencilOperationPass(operation: number): void;
  103959. /**
  103960. * Sets a boolean indicating if the dithering state is enabled or disabled
  103961. * @param value defines the dithering state
  103962. */
  103963. setDitheringState(value: boolean): void;
  103964. /**
  103965. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  103966. * @param value defines the rasterizer state
  103967. */
  103968. setRasterizerState(value: boolean): void;
  103969. /**
  103970. * Gets the current depth function
  103971. * @returns a number defining the depth function
  103972. */
  103973. getDepthFunction(): Nullable<number>;
  103974. /**
  103975. * Sets the current depth function
  103976. * @param depthFunc defines the function to use
  103977. */
  103978. setDepthFunction(depthFunc: number): void;
  103979. /**
  103980. * Sets the current depth function to GREATER
  103981. */
  103982. setDepthFunctionToGreater(): void;
  103983. /**
  103984. * Sets the current depth function to GEQUAL
  103985. */
  103986. setDepthFunctionToGreaterOrEqual(): void;
  103987. /**
  103988. * Sets the current depth function to LESS
  103989. */
  103990. setDepthFunctionToLess(): void;
  103991. /**
  103992. * Sets the current depth function to LEQUAL
  103993. */
  103994. setDepthFunctionToLessOrEqual(): void;
  103995. private _cachedStencilBuffer;
  103996. private _cachedStencilFunction;
  103997. private _cachedStencilMask;
  103998. private _cachedStencilOperationPass;
  103999. private _cachedStencilOperationFail;
  104000. private _cachedStencilOperationDepthFail;
  104001. private _cachedStencilReference;
  104002. /**
  104003. * Caches the the state of the stencil buffer
  104004. */
  104005. cacheStencilState(): void;
  104006. /**
  104007. * Restores the state of the stencil buffer
  104008. */
  104009. restoreStencilState(): void;
  104010. /**
  104011. * Directly set the WebGL Viewport
  104012. * @param x defines the x coordinate of the viewport (in screen space)
  104013. * @param y defines the y coordinate of the viewport (in screen space)
  104014. * @param width defines the width of the viewport (in screen space)
  104015. * @param height defines the height of the viewport (in screen space)
  104016. * @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
  104017. */
  104018. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  104019. /**
  104020. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  104021. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  104022. * @param y defines the y-coordinate of the corner of the clear rectangle
  104023. * @param width defines the width of the clear rectangle
  104024. * @param height defines the height of the clear rectangle
  104025. * @param clearColor defines the clear color
  104026. */
  104027. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  104028. /**
  104029. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  104030. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  104031. * @param y defines the y-coordinate of the corner of the clear rectangle
  104032. * @param width defines the width of the clear rectangle
  104033. * @param height defines the height of the clear rectangle
  104034. */
  104035. enableScissor(x: number, y: number, width: number, height: number): void;
  104036. /**
  104037. * Disable previously set scissor test rectangle
  104038. */
  104039. disableScissor(): void;
  104040. protected _reportDrawCall(): void;
  104041. /**
  104042. * Initializes a webVR display and starts listening to display change events
  104043. * The onVRDisplayChangedObservable will be notified upon these changes
  104044. * @returns The onVRDisplayChangedObservable
  104045. */
  104046. initWebVR(): Observable<IDisplayChangedEventArgs>;
  104047. /** @hidden */
  104048. _prepareVRComponent(): void;
  104049. /** @hidden */
  104050. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  104051. /** @hidden */
  104052. _submitVRFrame(): void;
  104053. /**
  104054. * Call this function to leave webVR mode
  104055. * Will do nothing if webVR is not supported or if there is no webVR device
  104056. * @see http://doc.babylonjs.com/how_to/webvr_camera
  104057. */
  104058. disableVR(): void;
  104059. /**
  104060. * Gets a boolean indicating that the system is in VR mode and is presenting
  104061. * @returns true if VR mode is engaged
  104062. */
  104063. isVRPresenting(): boolean;
  104064. /** @hidden */
  104065. _requestVRFrame(): void;
  104066. /** @hidden */
  104067. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  104068. /**
  104069. * Gets the source code of the vertex shader associated with a specific webGL program
  104070. * @param program defines the program to use
  104071. * @returns a string containing the source code of the vertex shader associated with the program
  104072. */
  104073. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  104074. /**
  104075. * Gets the source code of the fragment shader associated with a specific webGL program
  104076. * @param program defines the program to use
  104077. * @returns a string containing the source code of the fragment shader associated with the program
  104078. */
  104079. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  104080. /**
  104081. * Sets a depth stencil texture from a render target to the according uniform.
  104082. * @param channel The texture channel
  104083. * @param uniform The uniform to set
  104084. * @param texture The render target texture containing the depth stencil texture to apply
  104085. */
  104086. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  104087. /**
  104088. * Sets a texture to the webGL context from a postprocess
  104089. * @param channel defines the channel to use
  104090. * @param postProcess defines the source postprocess
  104091. */
  104092. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  104093. /**
  104094. * Binds the output of the passed in post process to the texture channel specified
  104095. * @param channel The channel the texture should be bound to
  104096. * @param postProcess The post process which's output should be bound
  104097. */
  104098. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  104099. /** @hidden */
  104100. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  104101. protected _rebuildBuffers(): void;
  104102. /** @hidden */
  104103. _renderFrame(): void;
  104104. _renderLoop(): void;
  104105. /** @hidden */
  104106. _renderViews(): boolean;
  104107. /**
  104108. * Toggle full screen mode
  104109. * @param requestPointerLock defines if a pointer lock should be requested from the user
  104110. */
  104111. switchFullscreen(requestPointerLock: boolean): void;
  104112. /**
  104113. * Enters full screen mode
  104114. * @param requestPointerLock defines if a pointer lock should be requested from the user
  104115. */
  104116. enterFullscreen(requestPointerLock: boolean): void;
  104117. /**
  104118. * Exits full screen mode
  104119. */
  104120. exitFullscreen(): void;
  104121. /**
  104122. * Enters Pointerlock mode
  104123. */
  104124. enterPointerlock(): void;
  104125. /**
  104126. * Exits Pointerlock mode
  104127. */
  104128. exitPointerlock(): void;
  104129. /**
  104130. * Begin a new frame
  104131. */
  104132. beginFrame(): void;
  104133. /**
  104134. * Enf the current frame
  104135. */
  104136. endFrame(): void;
  104137. resize(): void;
  104138. /**
  104139. * Set the compressed texture format to use, based on the formats you have, and the formats
  104140. * supported by the hardware / browser.
  104141. *
  104142. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  104143. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  104144. * to API arguments needed to compressed textures. This puts the burden on the container
  104145. * generator to house the arcane code for determining these for current & future formats.
  104146. *
  104147. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  104148. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  104149. *
  104150. * Note: The result of this call is not taken into account when a texture is base64.
  104151. *
  104152. * @param formatsAvailable defines the list of those format families you have created
  104153. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  104154. *
  104155. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  104156. * @returns The extension selected.
  104157. */
  104158. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  104159. /**
  104160. * Set the compressed texture extensions or file names to skip.
  104161. *
  104162. * @param skippedFiles defines the list of those texture files you want to skip
  104163. * Example: [".dds", ".env", "myfile.png"]
  104164. */
  104165. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  104166. /**
  104167. * Force a specific size of the canvas
  104168. * @param width defines the new canvas' width
  104169. * @param height defines the new canvas' height
  104170. */
  104171. setSize(width: number, height: number): void;
  104172. /**
  104173. * Updates a dynamic vertex buffer.
  104174. * @param vertexBuffer the vertex buffer to update
  104175. * @param data the data used to update the vertex buffer
  104176. * @param byteOffset the byte offset of the data
  104177. * @param byteLength the byte length of the data
  104178. */
  104179. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  104180. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  104181. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104182. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104183. _releaseTexture(texture: InternalTexture): void;
  104184. /**
  104185. * @hidden
  104186. * Rescales a texture
  104187. * @param source input texutre
  104188. * @param destination destination texture
  104189. * @param scene scene to use to render the resize
  104190. * @param internalFormat format to use when resizing
  104191. * @param onComplete callback to be called when resize has completed
  104192. */
  104193. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  104194. /**
  104195. * Gets the current framerate
  104196. * @returns a number representing the framerate
  104197. */
  104198. getFps(): number;
  104199. /**
  104200. * Gets the time spent between current and previous frame
  104201. * @returns a number representing the delta time in ms
  104202. */
  104203. getDeltaTime(): number;
  104204. private _measureFps;
  104205. /** @hidden */
  104206. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  104207. /**
  104208. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  104209. * @param renderTarget The render target to set the frame buffer for
  104210. */
  104211. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  104212. /**
  104213. * Update a dynamic index buffer
  104214. * @param indexBuffer defines the target index buffer
  104215. * @param indices defines the data to update
  104216. * @param offset defines the offset in the target index buffer where update should start
  104217. */
  104218. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  104219. /**
  104220. * Updates the sample count of a render target texture
  104221. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  104222. * @param texture defines the texture to update
  104223. * @param samples defines the sample count to set
  104224. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  104225. */
  104226. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  104227. /**
  104228. * Updates a depth texture Comparison Mode and Function.
  104229. * If the comparison Function is equal to 0, the mode will be set to none.
  104230. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  104231. * @param texture The texture to set the comparison function for
  104232. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  104233. */
  104234. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  104235. /**
  104236. * Creates a webGL buffer to use with instanciation
  104237. * @param capacity defines the size of the buffer
  104238. * @returns the webGL buffer
  104239. */
  104240. createInstancesBuffer(capacity: number): DataBuffer;
  104241. /**
  104242. * Delete a webGL buffer used with instanciation
  104243. * @param buffer defines the webGL buffer to delete
  104244. */
  104245. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  104246. /** @hidden */
  104247. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  104248. dispose(): void;
  104249. private _disableTouchAction;
  104250. /**
  104251. * Display the loading screen
  104252. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104253. */
  104254. displayLoadingUI(): void;
  104255. /**
  104256. * Hide the loading screen
  104257. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104258. */
  104259. hideLoadingUI(): void;
  104260. /**
  104261. * Gets the current loading screen object
  104262. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104263. */
  104264. get loadingScreen(): ILoadingScreen;
  104265. /**
  104266. * Sets the current loading screen object
  104267. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104268. */
  104269. set loadingScreen(loadingScreen: ILoadingScreen);
  104270. /**
  104271. * Sets the current loading screen text
  104272. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104273. */
  104274. set loadingUIText(text: string);
  104275. /**
  104276. * Sets the current loading screen background color
  104277. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  104278. */
  104279. set loadingUIBackgroundColor(color: string);
  104280. /** Pointerlock and fullscreen */
  104281. /**
  104282. * Ask the browser to promote the current element to pointerlock mode
  104283. * @param element defines the DOM element to promote
  104284. */
  104285. static _RequestPointerlock(element: HTMLElement): void;
  104286. /**
  104287. * Asks the browser to exit pointerlock mode
  104288. */
  104289. static _ExitPointerlock(): void;
  104290. /**
  104291. * Ask the browser to promote the current element to fullscreen rendering mode
  104292. * @param element defines the DOM element to promote
  104293. */
  104294. static _RequestFullscreen(element: HTMLElement): void;
  104295. /**
  104296. * Asks the browser to exit fullscreen mode
  104297. */
  104298. static _ExitFullscreen(): void;
  104299. }
  104300. }
  104301. declare module BABYLON {
  104302. /**
  104303. * The engine store class is responsible to hold all the instances of Engine and Scene created
  104304. * during the life time of the application.
  104305. */
  104306. export class EngineStore {
  104307. /** Gets the list of created engines */
  104308. static Instances: Engine[];
  104309. /** @hidden */
  104310. static _LastCreatedScene: Nullable<Scene>;
  104311. /**
  104312. * Gets the latest created engine
  104313. */
  104314. static get LastCreatedEngine(): Nullable<Engine>;
  104315. /**
  104316. * Gets the latest created scene
  104317. */
  104318. static get LastCreatedScene(): Nullable<Scene>;
  104319. /**
  104320. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  104321. * @ignorenaming
  104322. */
  104323. static UseFallbackTexture: boolean;
  104324. /**
  104325. * Texture content used if a texture cannot loaded
  104326. * @ignorenaming
  104327. */
  104328. static FallbackTexture: string;
  104329. }
  104330. }
  104331. declare module BABYLON {
  104332. /**
  104333. * Helper class that provides a small promise polyfill
  104334. */
  104335. export class PromisePolyfill {
  104336. /**
  104337. * Static function used to check if the polyfill is required
  104338. * If this is the case then the function will inject the polyfill to window.Promise
  104339. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  104340. */
  104341. static Apply(force?: boolean): void;
  104342. }
  104343. }
  104344. declare module BABYLON {
  104345. /**
  104346. * Interface for screenshot methods with describe argument called `size` as object with options
  104347. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  104348. */
  104349. export interface IScreenshotSize {
  104350. /**
  104351. * number in pixels for canvas height
  104352. */
  104353. height?: number;
  104354. /**
  104355. * multiplier allowing render at a higher or lower resolution
  104356. * If value is defined then height and width will be ignored and taken from camera
  104357. */
  104358. precision?: number;
  104359. /**
  104360. * number in pixels for canvas width
  104361. */
  104362. width?: number;
  104363. }
  104364. }
  104365. declare module BABYLON {
  104366. interface IColor4Like {
  104367. r: float;
  104368. g: float;
  104369. b: float;
  104370. a: float;
  104371. }
  104372. /**
  104373. * Class containing a set of static utilities functions
  104374. */
  104375. export class Tools {
  104376. /**
  104377. * Gets or sets the base URL to use to load assets
  104378. */
  104379. static get BaseUrl(): string;
  104380. static set BaseUrl(value: string);
  104381. /**
  104382. * Enable/Disable Custom HTTP Request Headers globally.
  104383. * default = false
  104384. * @see CustomRequestHeaders
  104385. */
  104386. static UseCustomRequestHeaders: boolean;
  104387. /**
  104388. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  104389. * i.e. when loading files, where the server/service expects an Authorization header
  104390. */
  104391. static CustomRequestHeaders: {
  104392. [key: string]: string;
  104393. };
  104394. /**
  104395. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  104396. */
  104397. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  104398. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  104399. /**
  104400. * Default behaviour for cors in the application.
  104401. * It can be a string if the expected behavior is identical in the entire app.
  104402. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  104403. */
  104404. static CorsBehavior: string | ((url: string | string[]) => string);
  104405. /**
  104406. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  104407. * @ignorenaming
  104408. */
  104409. static get UseFallbackTexture(): boolean;
  104410. static set UseFallbackTexture(value: boolean);
  104411. /**
  104412. * Use this object to register external classes like custom textures or material
  104413. * to allow the laoders to instantiate them
  104414. */
  104415. static get RegisteredExternalClasses(): {
  104416. [key: string]: Object;
  104417. };
  104418. static set RegisteredExternalClasses(classes: {
  104419. [key: string]: Object;
  104420. });
  104421. /**
  104422. * Texture content used if a texture cannot loaded
  104423. * @ignorenaming
  104424. */
  104425. static get fallbackTexture(): string;
  104426. static set fallbackTexture(value: string);
  104427. /**
  104428. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  104429. * @param u defines the coordinate on X axis
  104430. * @param v defines the coordinate on Y axis
  104431. * @param width defines the width of the source data
  104432. * @param height defines the height of the source data
  104433. * @param pixels defines the source byte array
  104434. * @param color defines the output color
  104435. */
  104436. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  104437. /**
  104438. * Interpolates between a and b via alpha
  104439. * @param a The lower value (returned when alpha = 0)
  104440. * @param b The upper value (returned when alpha = 1)
  104441. * @param alpha The interpolation-factor
  104442. * @return The mixed value
  104443. */
  104444. static Mix(a: number, b: number, alpha: number): number;
  104445. /**
  104446. * Tries to instantiate a new object from a given class name
  104447. * @param className defines the class name to instantiate
  104448. * @returns the new object or null if the system was not able to do the instantiation
  104449. */
  104450. static Instantiate(className: string): any;
  104451. /**
  104452. * Provides a slice function that will work even on IE
  104453. * @param data defines the array to slice
  104454. * @param start defines the start of the data (optional)
  104455. * @param end defines the end of the data (optional)
  104456. * @returns the new sliced array
  104457. */
  104458. static Slice<T>(data: T, start?: number, end?: number): T;
  104459. /**
  104460. * Polyfill for setImmediate
  104461. * @param action defines the action to execute after the current execution block
  104462. */
  104463. static SetImmediate(action: () => void): void;
  104464. /**
  104465. * Function indicating if a number is an exponent of 2
  104466. * @param value defines the value to test
  104467. * @returns true if the value is an exponent of 2
  104468. */
  104469. static IsExponentOfTwo(value: number): boolean;
  104470. private static _tmpFloatArray;
  104471. /**
  104472. * Returns the nearest 32-bit single precision float representation of a Number
  104473. * @param value A Number. If the parameter is of a different type, it will get converted
  104474. * to a number or to NaN if it cannot be converted
  104475. * @returns number
  104476. */
  104477. static FloatRound(value: number): number;
  104478. /**
  104479. * Extracts the filename from a path
  104480. * @param path defines the path to use
  104481. * @returns the filename
  104482. */
  104483. static GetFilename(path: string): string;
  104484. /**
  104485. * Extracts the "folder" part of a path (everything before the filename).
  104486. * @param uri The URI to extract the info from
  104487. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  104488. * @returns The "folder" part of the path
  104489. */
  104490. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  104491. /**
  104492. * Extracts text content from a DOM element hierarchy
  104493. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  104494. */
  104495. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  104496. /**
  104497. * Convert an angle in radians to degrees
  104498. * @param angle defines the angle to convert
  104499. * @returns the angle in degrees
  104500. */
  104501. static ToDegrees(angle: number): number;
  104502. /**
  104503. * Convert an angle in degrees to radians
  104504. * @param angle defines the angle to convert
  104505. * @returns the angle in radians
  104506. */
  104507. static ToRadians(angle: number): number;
  104508. /**
  104509. * Returns an array if obj is not an array
  104510. * @param obj defines the object to evaluate as an array
  104511. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  104512. * @returns either obj directly if obj is an array or a new array containing obj
  104513. */
  104514. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  104515. /**
  104516. * Gets the pointer prefix to use
  104517. * @returns "pointer" if touch is enabled. Else returns "mouse"
  104518. */
  104519. static GetPointerPrefix(): string;
  104520. /**
  104521. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  104522. * @param url define the url we are trying
  104523. * @param element define the dom element where to configure the cors policy
  104524. */
  104525. static SetCorsBehavior(url: string | string[], element: {
  104526. crossOrigin: string | null;
  104527. }): void;
  104528. /**
  104529. * Removes unwanted characters from an url
  104530. * @param url defines the url to clean
  104531. * @returns the cleaned url
  104532. */
  104533. static CleanUrl(url: string): string;
  104534. /**
  104535. * Gets or sets a function used to pre-process url before using them to load assets
  104536. */
  104537. static get PreprocessUrl(): (url: string) => string;
  104538. static set PreprocessUrl(processor: (url: string) => string);
  104539. /**
  104540. * Loads an image as an HTMLImageElement.
  104541. * @param input url string, ArrayBuffer, or Blob to load
  104542. * @param onLoad callback called when the image successfully loads
  104543. * @param onError callback called when the image fails to load
  104544. * @param offlineProvider offline provider for caching
  104545. * @param mimeType optional mime type
  104546. * @returns the HTMLImageElement of the loaded image
  104547. */
  104548. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  104549. /**
  104550. * Loads a file from a url
  104551. * @param url url string, ArrayBuffer, or Blob to load
  104552. * @param onSuccess callback called when the file successfully loads
  104553. * @param onProgress callback called while file is loading (if the server supports this mode)
  104554. * @param offlineProvider defines the offline provider for caching
  104555. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  104556. * @param onError callback called when the file fails to load
  104557. * @returns a file request object
  104558. */
  104559. 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;
  104560. /**
  104561. * Loads a file from a url
  104562. * @param url the file url to load
  104563. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  104564. */
  104565. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  104566. /**
  104567. * Load a script (identified by an url). When the url returns, the
  104568. * content of this file is added into a new script element, attached to the DOM (body element)
  104569. * @param scriptUrl defines the url of the script to laod
  104570. * @param onSuccess defines the callback called when the script is loaded
  104571. * @param onError defines the callback to call if an error occurs
  104572. * @param scriptId defines the id of the script element
  104573. */
  104574. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  104575. /**
  104576. * Load an asynchronous script (identified by an url). When the url returns, the
  104577. * content of this file is added into a new script element, attached to the DOM (body element)
  104578. * @param scriptUrl defines the url of the script to laod
  104579. * @param scriptId defines the id of the script element
  104580. * @returns a promise request object
  104581. */
  104582. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  104583. /**
  104584. * Loads a file from a blob
  104585. * @param fileToLoad defines the blob to use
  104586. * @param callback defines the callback to call when data is loaded
  104587. * @param progressCallback defines the callback to call during loading process
  104588. * @returns a file request object
  104589. */
  104590. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  104591. /**
  104592. * Reads a file from a File object
  104593. * @param file defines the file to load
  104594. * @param onSuccess defines the callback to call when data is loaded
  104595. * @param onProgress defines the callback to call during loading process
  104596. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  104597. * @param onError defines the callback to call when an error occurs
  104598. * @returns a file request object
  104599. */
  104600. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  104601. /**
  104602. * Creates a data url from a given string content
  104603. * @param content defines the content to convert
  104604. * @returns the new data url link
  104605. */
  104606. static FileAsURL(content: string): string;
  104607. /**
  104608. * Format the given number to a specific decimal format
  104609. * @param value defines the number to format
  104610. * @param decimals defines the number of decimals to use
  104611. * @returns the formatted string
  104612. */
  104613. static Format(value: number, decimals?: number): string;
  104614. /**
  104615. * Tries to copy an object by duplicating every property
  104616. * @param source defines the source object
  104617. * @param destination defines the target object
  104618. * @param doNotCopyList defines a list of properties to avoid
  104619. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  104620. */
  104621. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  104622. /**
  104623. * Gets a boolean indicating if the given object has no own property
  104624. * @param obj defines the object to test
  104625. * @returns true if object has no own property
  104626. */
  104627. static IsEmpty(obj: any): boolean;
  104628. /**
  104629. * Function used to register events at window level
  104630. * @param windowElement defines the Window object to use
  104631. * @param events defines the events to register
  104632. */
  104633. static RegisterTopRootEvents(windowElement: Window, events: {
  104634. name: string;
  104635. handler: Nullable<(e: FocusEvent) => any>;
  104636. }[]): void;
  104637. /**
  104638. * Function used to unregister events from window level
  104639. * @param windowElement defines the Window object to use
  104640. * @param events defines the events to unregister
  104641. */
  104642. static UnregisterTopRootEvents(windowElement: Window, events: {
  104643. name: string;
  104644. handler: Nullable<(e: FocusEvent) => any>;
  104645. }[]): void;
  104646. /**
  104647. * @ignore
  104648. */
  104649. static _ScreenshotCanvas: HTMLCanvasElement;
  104650. /**
  104651. * Dumps the current bound framebuffer
  104652. * @param width defines the rendering width
  104653. * @param height defines the rendering height
  104654. * @param engine defines the hosting engine
  104655. * @param successCallback defines the callback triggered once the data are available
  104656. * @param mimeType defines the mime type of the result
  104657. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  104658. */
  104659. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  104660. /**
  104661. * Converts the canvas data to blob.
  104662. * This acts as a polyfill for browsers not supporting the to blob function.
  104663. * @param canvas Defines the canvas to extract the data from
  104664. * @param successCallback Defines the callback triggered once the data are available
  104665. * @param mimeType Defines the mime type of the result
  104666. */
  104667. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  104668. /**
  104669. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  104670. * @param successCallback defines the callback triggered once the data are available
  104671. * @param mimeType defines the mime type of the result
  104672. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  104673. */
  104674. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  104675. /**
  104676. * Downloads a blob in the browser
  104677. * @param blob defines the blob to download
  104678. * @param fileName defines the name of the downloaded file
  104679. */
  104680. static Download(blob: Blob, fileName: string): void;
  104681. /**
  104682. * Captures a screenshot of the current rendering
  104683. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104684. * @param engine defines the rendering engine
  104685. * @param camera defines the source camera
  104686. * @param size This parameter can be set to a single number or to an object with the
  104687. * following (optional) properties: precision, width, height. If a single number is passed,
  104688. * it will be used for both width and height. If an object is passed, the screenshot size
  104689. * will be derived from the parameters. The precision property is a multiplier allowing
  104690. * rendering at a higher or lower resolution
  104691. * @param successCallback defines the callback receives a single parameter which contains the
  104692. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  104693. * src parameter of an <img> to display it
  104694. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  104695. * Check your browser for supported MIME types
  104696. */
  104697. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  104698. /**
  104699. * Captures a screenshot of the current rendering
  104700. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104701. * @param engine defines the rendering engine
  104702. * @param camera defines the source camera
  104703. * @param size This parameter can be set to a single number or to an object with the
  104704. * following (optional) properties: precision, width, height. If a single number is passed,
  104705. * it will be used for both width and height. If an object is passed, the screenshot size
  104706. * will be derived from the parameters. The precision property is a multiplier allowing
  104707. * rendering at a higher or lower resolution
  104708. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  104709. * Check your browser for supported MIME types
  104710. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  104711. * to the src parameter of an <img> to display it
  104712. */
  104713. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  104714. /**
  104715. * Generates an image screenshot from the specified camera.
  104716. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104717. * @param engine The engine to use for rendering
  104718. * @param camera The camera to use for rendering
  104719. * @param size This parameter can be set to a single number or to an object with the
  104720. * following (optional) properties: precision, width, height. If a single number is passed,
  104721. * it will be used for both width and height. If an object is passed, the screenshot size
  104722. * will be derived from the parameters. The precision property is a multiplier allowing
  104723. * rendering at a higher or lower resolution
  104724. * @param successCallback The callback receives a single parameter which contains the
  104725. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  104726. * src parameter of an <img> to display it
  104727. * @param mimeType The MIME type of the screenshot image (default: image/png).
  104728. * Check your browser for supported MIME types
  104729. * @param samples Texture samples (default: 1)
  104730. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  104731. * @param fileName A name for for the downloaded file.
  104732. */
  104733. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  104734. /**
  104735. * Generates an image screenshot from the specified camera.
  104736. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  104737. * @param engine The engine to use for rendering
  104738. * @param camera The camera to use for rendering
  104739. * @param size This parameter can be set to a single number or to an object with the
  104740. * following (optional) properties: precision, width, height. If a single number is passed,
  104741. * it will be used for both width and height. If an object is passed, the screenshot size
  104742. * will be derived from the parameters. The precision property is a multiplier allowing
  104743. * rendering at a higher or lower resolution
  104744. * @param mimeType The MIME type of the screenshot image (default: image/png).
  104745. * Check your browser for supported MIME types
  104746. * @param samples Texture samples (default: 1)
  104747. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  104748. * @param fileName A name for for the downloaded file.
  104749. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  104750. * to the src parameter of an <img> to display it
  104751. */
  104752. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  104753. /**
  104754. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  104755. * Be aware Math.random() could cause collisions, but:
  104756. * "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"
  104757. * @returns a pseudo random id
  104758. */
  104759. static RandomId(): string;
  104760. /**
  104761. * Test if the given uri is a base64 string
  104762. * @param uri The uri to test
  104763. * @return True if the uri is a base64 string or false otherwise
  104764. */
  104765. static IsBase64(uri: string): boolean;
  104766. /**
  104767. * Decode the given base64 uri.
  104768. * @param uri The uri to decode
  104769. * @return The decoded base64 data.
  104770. */
  104771. static DecodeBase64(uri: string): ArrayBuffer;
  104772. /**
  104773. * Gets the absolute url.
  104774. * @param url the input url
  104775. * @return the absolute url
  104776. */
  104777. static GetAbsoluteUrl(url: string): string;
  104778. /**
  104779. * No log
  104780. */
  104781. static readonly NoneLogLevel: number;
  104782. /**
  104783. * Only message logs
  104784. */
  104785. static readonly MessageLogLevel: number;
  104786. /**
  104787. * Only warning logs
  104788. */
  104789. static readonly WarningLogLevel: number;
  104790. /**
  104791. * Only error logs
  104792. */
  104793. static readonly ErrorLogLevel: number;
  104794. /**
  104795. * All logs
  104796. */
  104797. static readonly AllLogLevel: number;
  104798. /**
  104799. * Gets a value indicating the number of loading errors
  104800. * @ignorenaming
  104801. */
  104802. static get errorsCount(): number;
  104803. /**
  104804. * Callback called when a new log is added
  104805. */
  104806. static OnNewCacheEntry: (entry: string) => void;
  104807. /**
  104808. * Log a message to the console
  104809. * @param message defines the message to log
  104810. */
  104811. static Log(message: string): void;
  104812. /**
  104813. * Write a warning message to the console
  104814. * @param message defines the message to log
  104815. */
  104816. static Warn(message: string): void;
  104817. /**
  104818. * Write an error message to the console
  104819. * @param message defines the message to log
  104820. */
  104821. static Error(message: string): void;
  104822. /**
  104823. * Gets current log cache (list of logs)
  104824. */
  104825. static get LogCache(): string;
  104826. /**
  104827. * Clears the log cache
  104828. */
  104829. static ClearLogCache(): void;
  104830. /**
  104831. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  104832. */
  104833. static set LogLevels(level: number);
  104834. /**
  104835. * Checks if the window object exists
  104836. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  104837. */
  104838. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  104839. /**
  104840. * No performance log
  104841. */
  104842. static readonly PerformanceNoneLogLevel: number;
  104843. /**
  104844. * Use user marks to log performance
  104845. */
  104846. static readonly PerformanceUserMarkLogLevel: number;
  104847. /**
  104848. * Log performance to the console
  104849. */
  104850. static readonly PerformanceConsoleLogLevel: number;
  104851. private static _performance;
  104852. /**
  104853. * Sets the current performance log level
  104854. */
  104855. static set PerformanceLogLevel(level: number);
  104856. private static _StartPerformanceCounterDisabled;
  104857. private static _EndPerformanceCounterDisabled;
  104858. private static _StartUserMark;
  104859. private static _EndUserMark;
  104860. private static _StartPerformanceConsole;
  104861. private static _EndPerformanceConsole;
  104862. /**
  104863. * Starts a performance counter
  104864. */
  104865. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  104866. /**
  104867. * Ends a specific performance coutner
  104868. */
  104869. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  104870. /**
  104871. * Gets either window.performance.now() if supported or Date.now() else
  104872. */
  104873. static get Now(): number;
  104874. /**
  104875. * This method will return the name of the class used to create the instance of the given object.
  104876. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  104877. * @param object the object to get the class name from
  104878. * @param isType defines if the object is actually a type
  104879. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  104880. */
  104881. static GetClassName(object: any, isType?: boolean): string;
  104882. /**
  104883. * Gets the first element of an array satisfying a given predicate
  104884. * @param array defines the array to browse
  104885. * @param predicate defines the predicate to use
  104886. * @returns null if not found or the element
  104887. */
  104888. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  104889. /**
  104890. * This method will return the name of the full name of the class, including its owning module (if any).
  104891. * 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).
  104892. * @param object the object to get the class name from
  104893. * @param isType defines if the object is actually a type
  104894. * @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.
  104895. * @ignorenaming
  104896. */
  104897. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  104898. /**
  104899. * Returns a promise that resolves after the given amount of time.
  104900. * @param delay Number of milliseconds to delay
  104901. * @returns Promise that resolves after the given amount of time
  104902. */
  104903. static DelayAsync(delay: number): Promise<void>;
  104904. }
  104905. /**
  104906. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  104907. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  104908. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  104909. * @param name The name of the class, case should be preserved
  104910. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  104911. */
  104912. export function className(name: string, module?: string): (target: Object) => void;
  104913. /**
  104914. * An implementation of a loop for asynchronous functions.
  104915. */
  104916. export class AsyncLoop {
  104917. /**
  104918. * Defines the number of iterations for the loop
  104919. */
  104920. iterations: number;
  104921. /**
  104922. * Defines the current index of the loop.
  104923. */
  104924. index: number;
  104925. private _done;
  104926. private _fn;
  104927. private _successCallback;
  104928. /**
  104929. * Constructor.
  104930. * @param iterations the number of iterations.
  104931. * @param func the function to run each iteration
  104932. * @param successCallback the callback that will be called upon succesful execution
  104933. * @param offset starting offset.
  104934. */
  104935. constructor(
  104936. /**
  104937. * Defines the number of iterations for the loop
  104938. */
  104939. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  104940. /**
  104941. * Execute the next iteration. Must be called after the last iteration was finished.
  104942. */
  104943. executeNext(): void;
  104944. /**
  104945. * Break the loop and run the success callback.
  104946. */
  104947. breakLoop(): void;
  104948. /**
  104949. * Create and run an async loop.
  104950. * @param iterations the number of iterations.
  104951. * @param fn the function to run each iteration
  104952. * @param successCallback the callback that will be called upon succesful execution
  104953. * @param offset starting offset.
  104954. * @returns the created async loop object
  104955. */
  104956. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  104957. /**
  104958. * A for-loop that will run a given number of iterations synchronous and the rest async.
  104959. * @param iterations total number of iterations
  104960. * @param syncedIterations number of synchronous iterations in each async iteration.
  104961. * @param fn the function to call each iteration.
  104962. * @param callback a success call back that will be called when iterating stops.
  104963. * @param breakFunction a break condition (optional)
  104964. * @param timeout timeout settings for the setTimeout function. default - 0.
  104965. * @returns the created async loop object
  104966. */
  104967. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  104968. }
  104969. }
  104970. declare module BABYLON {
  104971. /**
  104972. * This class implement a typical dictionary using a string as key and the generic type T as value.
  104973. * The underlying implementation relies on an associative array to ensure the best performances.
  104974. * The value can be anything including 'null' but except 'undefined'
  104975. */
  104976. export class StringDictionary<T> {
  104977. /**
  104978. * This will clear this dictionary and copy the content from the 'source' one.
  104979. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  104980. * @param source the dictionary to take the content from and copy to this dictionary
  104981. */
  104982. copyFrom(source: StringDictionary<T>): void;
  104983. /**
  104984. * Get a value based from its key
  104985. * @param key the given key to get the matching value from
  104986. * @return the value if found, otherwise undefined is returned
  104987. */
  104988. get(key: string): T | undefined;
  104989. /**
  104990. * Get a value from its key or add it if it doesn't exist.
  104991. * This method will ensure you that a given key/data will be present in the dictionary.
  104992. * @param key the given key to get the matching value from
  104993. * @param factory the factory that will create the value if the key is not present in the dictionary.
  104994. * The factory will only be invoked if there's no data for the given key.
  104995. * @return the value corresponding to the key.
  104996. */
  104997. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  104998. /**
  104999. * Get a value from its key if present in the dictionary otherwise add it
  105000. * @param key the key to get the value from
  105001. * @param val if there's no such key/value pair in the dictionary add it with this value
  105002. * @return the value corresponding to the key
  105003. */
  105004. getOrAdd(key: string, val: T): T;
  105005. /**
  105006. * Check if there's a given key in the dictionary
  105007. * @param key the key to check for
  105008. * @return true if the key is present, false otherwise
  105009. */
  105010. contains(key: string): boolean;
  105011. /**
  105012. * Add a new key and its corresponding value
  105013. * @param key the key to add
  105014. * @param value the value corresponding to the key
  105015. * @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
  105016. */
  105017. add(key: string, value: T): boolean;
  105018. /**
  105019. * Update a specific value associated to a key
  105020. * @param key defines the key to use
  105021. * @param value defines the value to store
  105022. * @returns true if the value was updated (or false if the key was not found)
  105023. */
  105024. set(key: string, value: T): boolean;
  105025. /**
  105026. * Get the element of the given key and remove it from the dictionary
  105027. * @param key defines the key to search
  105028. * @returns the value associated with the key or null if not found
  105029. */
  105030. getAndRemove(key: string): Nullable<T>;
  105031. /**
  105032. * Remove a key/value from the dictionary.
  105033. * @param key the key to remove
  105034. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  105035. */
  105036. remove(key: string): boolean;
  105037. /**
  105038. * Clear the whole content of the dictionary
  105039. */
  105040. clear(): void;
  105041. /**
  105042. * Gets the current count
  105043. */
  105044. get count(): number;
  105045. /**
  105046. * Execute a callback on each key/val of the dictionary.
  105047. * Note that you can remove any element in this dictionary in the callback implementation
  105048. * @param callback the callback to execute on a given key/value pair
  105049. */
  105050. forEach(callback: (key: string, val: T) => void): void;
  105051. /**
  105052. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  105053. * If the callback returns null or undefined the method will iterate to the next key/value pair
  105054. * Note that you can remove any element in this dictionary in the callback implementation
  105055. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  105056. * @returns the first item
  105057. */
  105058. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  105059. private _count;
  105060. private _data;
  105061. }
  105062. }
  105063. declare module BABYLON {
  105064. /** @hidden */
  105065. export interface ICollisionCoordinator {
  105066. createCollider(): Collider;
  105067. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  105068. init(scene: Scene): void;
  105069. }
  105070. /** @hidden */
  105071. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  105072. private _scene;
  105073. private _scaledPosition;
  105074. private _scaledVelocity;
  105075. private _finalPosition;
  105076. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  105077. createCollider(): Collider;
  105078. init(scene: Scene): void;
  105079. private _collideWithWorld;
  105080. }
  105081. }
  105082. declare module BABYLON {
  105083. /**
  105084. * Class used to manage all inputs for the scene.
  105085. */
  105086. export class InputManager {
  105087. /** The distance in pixel that you have to move to prevent some events */
  105088. static DragMovementThreshold: number;
  105089. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  105090. static LongPressDelay: number;
  105091. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  105092. static DoubleClickDelay: number;
  105093. /** If you need to check double click without raising a single click at first click, enable this flag */
  105094. static ExclusiveDoubleClickMode: boolean;
  105095. private _wheelEventName;
  105096. private _onPointerMove;
  105097. private _onPointerDown;
  105098. private _onPointerUp;
  105099. private _initClickEvent;
  105100. private _initActionManager;
  105101. private _delayedSimpleClick;
  105102. private _delayedSimpleClickTimeout;
  105103. private _previousDelayedSimpleClickTimeout;
  105104. private _meshPickProceed;
  105105. private _previousButtonPressed;
  105106. private _currentPickResult;
  105107. private _previousPickResult;
  105108. private _totalPointersPressed;
  105109. private _doubleClickOccured;
  105110. private _pointerOverMesh;
  105111. private _pickedDownMesh;
  105112. private _pickedUpMesh;
  105113. private _pointerX;
  105114. private _pointerY;
  105115. private _unTranslatedPointerX;
  105116. private _unTranslatedPointerY;
  105117. private _startingPointerPosition;
  105118. private _previousStartingPointerPosition;
  105119. private _startingPointerTime;
  105120. private _previousStartingPointerTime;
  105121. private _pointerCaptures;
  105122. private _onKeyDown;
  105123. private _onKeyUp;
  105124. private _onCanvasFocusObserver;
  105125. private _onCanvasBlurObserver;
  105126. private _scene;
  105127. /**
  105128. * Creates a new InputManager
  105129. * @param scene defines the hosting scene
  105130. */
  105131. constructor(scene: Scene);
  105132. /**
  105133. * Gets the mesh that is currently under the pointer
  105134. */
  105135. get meshUnderPointer(): Nullable<AbstractMesh>;
  105136. /**
  105137. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  105138. */
  105139. get unTranslatedPointer(): Vector2;
  105140. /**
  105141. * Gets or sets the current on-screen X position of the pointer
  105142. */
  105143. get pointerX(): number;
  105144. set pointerX(value: number);
  105145. /**
  105146. * Gets or sets the current on-screen Y position of the pointer
  105147. */
  105148. get pointerY(): number;
  105149. set pointerY(value: number);
  105150. private _updatePointerPosition;
  105151. private _processPointerMove;
  105152. private _setRayOnPointerInfo;
  105153. private _checkPrePointerObservable;
  105154. /**
  105155. * Use this method to simulate a pointer move on a mesh
  105156. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105157. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105158. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105159. */
  105160. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  105161. /**
  105162. * Use this method to simulate a pointer down on a mesh
  105163. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105164. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105165. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105166. */
  105167. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  105168. private _processPointerDown;
  105169. /** @hidden */
  105170. _isPointerSwiping(): boolean;
  105171. /**
  105172. * Use this method to simulate a pointer up on a mesh
  105173. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105174. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105175. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105176. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  105177. */
  105178. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  105179. private _processPointerUp;
  105180. /**
  105181. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  105182. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  105183. * @returns true if the pointer was captured
  105184. */
  105185. isPointerCaptured(pointerId?: number): boolean;
  105186. /**
  105187. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  105188. * @param attachUp defines if you want to attach events to pointerup
  105189. * @param attachDown defines if you want to attach events to pointerdown
  105190. * @param attachMove defines if you want to attach events to pointermove
  105191. */
  105192. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  105193. /**
  105194. * Detaches all event handlers
  105195. */
  105196. detachControl(): void;
  105197. /**
  105198. * Force the value of meshUnderPointer
  105199. * @param mesh defines the mesh to use
  105200. */
  105201. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  105202. /**
  105203. * Gets the mesh under the pointer
  105204. * @returns a Mesh or null if no mesh is under the pointer
  105205. */
  105206. getPointerOverMesh(): Nullable<AbstractMesh>;
  105207. }
  105208. }
  105209. declare module BABYLON {
  105210. /**
  105211. * Helper class used to generate session unique ID
  105212. */
  105213. export class UniqueIdGenerator {
  105214. private static _UniqueIdCounter;
  105215. /**
  105216. * Gets an unique (relatively to the current scene) Id
  105217. */
  105218. static get UniqueId(): number;
  105219. }
  105220. }
  105221. declare module BABYLON {
  105222. /**
  105223. * This class defines the direct association between an animation and a target
  105224. */
  105225. export class TargetedAnimation {
  105226. /**
  105227. * Animation to perform
  105228. */
  105229. animation: Animation;
  105230. /**
  105231. * Target to animate
  105232. */
  105233. target: any;
  105234. /**
  105235. * Serialize the object
  105236. * @returns the JSON object representing the current entity
  105237. */
  105238. serialize(): any;
  105239. }
  105240. /**
  105241. * Use this class to create coordinated animations on multiple targets
  105242. */
  105243. export class AnimationGroup implements IDisposable {
  105244. /** The name of the animation group */
  105245. name: string;
  105246. private _scene;
  105247. private _targetedAnimations;
  105248. private _animatables;
  105249. private _from;
  105250. private _to;
  105251. private _isStarted;
  105252. private _isPaused;
  105253. private _speedRatio;
  105254. private _loopAnimation;
  105255. /**
  105256. * Gets or sets the unique id of the node
  105257. */
  105258. uniqueId: number;
  105259. /**
  105260. * This observable will notify when one animation have ended
  105261. */
  105262. onAnimationEndObservable: Observable<TargetedAnimation>;
  105263. /**
  105264. * Observer raised when one animation loops
  105265. */
  105266. onAnimationLoopObservable: Observable<TargetedAnimation>;
  105267. /**
  105268. * Observer raised when all animations have looped
  105269. */
  105270. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  105271. /**
  105272. * This observable will notify when all animations have ended.
  105273. */
  105274. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  105275. /**
  105276. * This observable will notify when all animations have paused.
  105277. */
  105278. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  105279. /**
  105280. * This observable will notify when all animations are playing.
  105281. */
  105282. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  105283. /**
  105284. * Gets the first frame
  105285. */
  105286. get from(): number;
  105287. /**
  105288. * Gets the last frame
  105289. */
  105290. get to(): number;
  105291. /**
  105292. * Define if the animations are started
  105293. */
  105294. get isStarted(): boolean;
  105295. /**
  105296. * Gets a value indicating that the current group is playing
  105297. */
  105298. get isPlaying(): boolean;
  105299. /**
  105300. * Gets or sets the speed ratio to use for all animations
  105301. */
  105302. get speedRatio(): number;
  105303. /**
  105304. * Gets or sets the speed ratio to use for all animations
  105305. */
  105306. set speedRatio(value: number);
  105307. /**
  105308. * Gets or sets if all animations should loop or not
  105309. */
  105310. get loopAnimation(): boolean;
  105311. set loopAnimation(value: boolean);
  105312. /**
  105313. * Gets the targeted animations for this animation group
  105314. */
  105315. get targetedAnimations(): Array<TargetedAnimation>;
  105316. /**
  105317. * returning the list of animatables controlled by this animation group.
  105318. */
  105319. get animatables(): Array<Animatable>;
  105320. /**
  105321. * Instantiates a new Animation Group.
  105322. * This helps managing several animations at once.
  105323. * @see http://doc.babylonjs.com/how_to/group
  105324. * @param name Defines the name of the group
  105325. * @param scene Defines the scene the group belongs to
  105326. */
  105327. constructor(
  105328. /** The name of the animation group */
  105329. name: string, scene?: Nullable<Scene>);
  105330. /**
  105331. * Add an animation (with its target) in the group
  105332. * @param animation defines the animation we want to add
  105333. * @param target defines the target of the animation
  105334. * @returns the TargetedAnimation object
  105335. */
  105336. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  105337. /**
  105338. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  105339. * It can add constant keys at begin or end
  105340. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  105341. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  105342. * @returns the animation group
  105343. */
  105344. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  105345. private _animationLoopCount;
  105346. private _animationLoopFlags;
  105347. private _processLoop;
  105348. /**
  105349. * Start all animations on given targets
  105350. * @param loop defines if animations must loop
  105351. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  105352. * @param from defines the from key (optional)
  105353. * @param to defines the to key (optional)
  105354. * @returns the current animation group
  105355. */
  105356. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  105357. /**
  105358. * Pause all animations
  105359. * @returns the animation group
  105360. */
  105361. pause(): AnimationGroup;
  105362. /**
  105363. * Play all animations to initial state
  105364. * This function will start() the animations if they were not started or will restart() them if they were paused
  105365. * @param loop defines if animations must loop
  105366. * @returns the animation group
  105367. */
  105368. play(loop?: boolean): AnimationGroup;
  105369. /**
  105370. * Reset all animations to initial state
  105371. * @returns the animation group
  105372. */
  105373. reset(): AnimationGroup;
  105374. /**
  105375. * Restart animations from key 0
  105376. * @returns the animation group
  105377. */
  105378. restart(): AnimationGroup;
  105379. /**
  105380. * Stop all animations
  105381. * @returns the animation group
  105382. */
  105383. stop(): AnimationGroup;
  105384. /**
  105385. * Set animation weight for all animatables
  105386. * @param weight defines the weight to use
  105387. * @return the animationGroup
  105388. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  105389. */
  105390. setWeightForAllAnimatables(weight: number): AnimationGroup;
  105391. /**
  105392. * Synchronize and normalize all animatables with a source animatable
  105393. * @param root defines the root animatable to synchronize with
  105394. * @return the animationGroup
  105395. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  105396. */
  105397. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  105398. /**
  105399. * Goes to a specific frame in this animation group
  105400. * @param frame the frame number to go to
  105401. * @return the animationGroup
  105402. */
  105403. goToFrame(frame: number): AnimationGroup;
  105404. /**
  105405. * Dispose all associated resources
  105406. */
  105407. dispose(): void;
  105408. private _checkAnimationGroupEnded;
  105409. /**
  105410. * Clone the current animation group and returns a copy
  105411. * @param newName defines the name of the new group
  105412. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  105413. * @returns the new aniamtion group
  105414. */
  105415. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  105416. /**
  105417. * Serializes the animationGroup to an object
  105418. * @returns Serialized object
  105419. */
  105420. serialize(): any;
  105421. /**
  105422. * Returns a new AnimationGroup object parsed from the source provided.
  105423. * @param parsedAnimationGroup defines the source
  105424. * @param scene defines the scene that will receive the animationGroup
  105425. * @returns a new AnimationGroup
  105426. */
  105427. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  105428. /**
  105429. * Returns the string "AnimationGroup"
  105430. * @returns "AnimationGroup"
  105431. */
  105432. getClassName(): string;
  105433. /**
  105434. * Creates a detailled string about the object
  105435. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  105436. * @returns a string representing the object
  105437. */
  105438. toString(fullDetails?: boolean): string;
  105439. }
  105440. }
  105441. declare module BABYLON {
  105442. /**
  105443. * Define an interface for all classes that will hold resources
  105444. */
  105445. export interface IDisposable {
  105446. /**
  105447. * Releases all held resources
  105448. */
  105449. dispose(): void;
  105450. }
  105451. /** Interface defining initialization parameters for Scene class */
  105452. export interface SceneOptions {
  105453. /**
  105454. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  105455. * It will improve performance when the number of geometries becomes important.
  105456. */
  105457. useGeometryUniqueIdsMap?: boolean;
  105458. /**
  105459. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  105460. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  105461. */
  105462. useMaterialMeshMap?: boolean;
  105463. /**
  105464. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  105465. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  105466. */
  105467. useClonedMeshMap?: boolean;
  105468. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  105469. virtual?: boolean;
  105470. }
  105471. /**
  105472. * Represents a scene to be rendered by the engine.
  105473. * @see http://doc.babylonjs.com/features/scene
  105474. */
  105475. export class Scene extends AbstractScene implements IAnimatable {
  105476. /** The fog is deactivated */
  105477. static readonly FOGMODE_NONE: number;
  105478. /** The fog density is following an exponential function */
  105479. static readonly FOGMODE_EXP: number;
  105480. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  105481. static readonly FOGMODE_EXP2: number;
  105482. /** The fog density is following a linear function. */
  105483. static readonly FOGMODE_LINEAR: number;
  105484. /**
  105485. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  105486. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105487. */
  105488. static MinDeltaTime: number;
  105489. /**
  105490. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  105491. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105492. */
  105493. static MaxDeltaTime: number;
  105494. /**
  105495. * Factory used to create the default material.
  105496. * @param name The name of the material to create
  105497. * @param scene The scene to create the material for
  105498. * @returns The default material
  105499. */
  105500. static DefaultMaterialFactory(scene: Scene): Material;
  105501. /**
  105502. * Factory used to create the a collision coordinator.
  105503. * @returns The collision coordinator
  105504. */
  105505. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  105506. /** @hidden */
  105507. _inputManager: InputManager;
  105508. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  105509. cameraToUseForPointers: Nullable<Camera>;
  105510. /** @hidden */
  105511. readonly _isScene: boolean;
  105512. /**
  105513. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  105514. */
  105515. autoClear: boolean;
  105516. /**
  105517. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  105518. */
  105519. autoClearDepthAndStencil: boolean;
  105520. /**
  105521. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  105522. */
  105523. clearColor: Color4;
  105524. /**
  105525. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  105526. */
  105527. ambientColor: Color3;
  105528. /**
  105529. * This is use to store the default BRDF lookup for PBR materials in your scene.
  105530. * It should only be one of the following (if not the default embedded one):
  105531. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  105532. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  105533. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  105534. * The material properties need to be setup according to the type of texture in use.
  105535. */
  105536. environmentBRDFTexture: BaseTexture;
  105537. /** @hidden */
  105538. protected _environmentTexture: Nullable<BaseTexture>;
  105539. /**
  105540. * Texture used in all pbr material as the reflection texture.
  105541. * As in the majority of the scene they are the same (exception for multi room and so on),
  105542. * this is easier to reference from here than from all the materials.
  105543. */
  105544. get environmentTexture(): Nullable<BaseTexture>;
  105545. /**
  105546. * Texture used in all pbr material as the reflection texture.
  105547. * As in the majority of the scene they are the same (exception for multi room and so on),
  105548. * this is easier to set here than in all the materials.
  105549. */
  105550. set environmentTexture(value: Nullable<BaseTexture>);
  105551. /** @hidden */
  105552. protected _environmentIntensity: number;
  105553. /**
  105554. * Intensity of the environment in all pbr material.
  105555. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  105556. * As in the majority of the scene they are the same (exception for multi room and so on),
  105557. * this is easier to reference from here than from all the materials.
  105558. */
  105559. get environmentIntensity(): number;
  105560. /**
  105561. * Intensity of the environment in all pbr material.
  105562. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  105563. * As in the majority of the scene they are the same (exception for multi room and so on),
  105564. * this is easier to set here than in all the materials.
  105565. */
  105566. set environmentIntensity(value: number);
  105567. /** @hidden */
  105568. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105569. /**
  105570. * Default image processing configuration used either in the rendering
  105571. * Forward main pass or through the imageProcessingPostProcess if present.
  105572. * As in the majority of the scene they are the same (exception for multi camera),
  105573. * this is easier to reference from here than from all the materials and post process.
  105574. *
  105575. * No setter as we it is a shared configuration, you can set the values instead.
  105576. */
  105577. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  105578. private _forceWireframe;
  105579. /**
  105580. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  105581. */
  105582. set forceWireframe(value: boolean);
  105583. get forceWireframe(): boolean;
  105584. private _skipFrustumClipping;
  105585. /**
  105586. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  105587. */
  105588. set skipFrustumClipping(value: boolean);
  105589. get skipFrustumClipping(): boolean;
  105590. private _forcePointsCloud;
  105591. /**
  105592. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  105593. */
  105594. set forcePointsCloud(value: boolean);
  105595. get forcePointsCloud(): boolean;
  105596. /**
  105597. * Gets or sets the active clipplane 1
  105598. */
  105599. clipPlane: Nullable<Plane>;
  105600. /**
  105601. * Gets or sets the active clipplane 2
  105602. */
  105603. clipPlane2: Nullable<Plane>;
  105604. /**
  105605. * Gets or sets the active clipplane 3
  105606. */
  105607. clipPlane3: Nullable<Plane>;
  105608. /**
  105609. * Gets or sets the active clipplane 4
  105610. */
  105611. clipPlane4: Nullable<Plane>;
  105612. /**
  105613. * Gets or sets the active clipplane 5
  105614. */
  105615. clipPlane5: Nullable<Plane>;
  105616. /**
  105617. * Gets or sets the active clipplane 6
  105618. */
  105619. clipPlane6: Nullable<Plane>;
  105620. /**
  105621. * Gets or sets a boolean indicating if animations are enabled
  105622. */
  105623. animationsEnabled: boolean;
  105624. private _animationPropertiesOverride;
  105625. /**
  105626. * Gets or sets the animation properties override
  105627. */
  105628. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  105629. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  105630. /**
  105631. * Gets or sets a boolean indicating if a constant deltatime has to be used
  105632. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  105633. */
  105634. useConstantAnimationDeltaTime: boolean;
  105635. /**
  105636. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  105637. * Please note that it requires to run a ray cast through the scene on every frame
  105638. */
  105639. constantlyUpdateMeshUnderPointer: boolean;
  105640. /**
  105641. * Defines the HTML cursor to use when hovering over interactive elements
  105642. */
  105643. hoverCursor: string;
  105644. /**
  105645. * Defines the HTML default cursor to use (empty by default)
  105646. */
  105647. defaultCursor: string;
  105648. /**
  105649. * Defines wether cursors are handled by the scene.
  105650. */
  105651. doNotHandleCursors: boolean;
  105652. /**
  105653. * This is used to call preventDefault() on pointer down
  105654. * in order to block unwanted artifacts like system double clicks
  105655. */
  105656. preventDefaultOnPointerDown: boolean;
  105657. /**
  105658. * This is used to call preventDefault() on pointer up
  105659. * in order to block unwanted artifacts like system double clicks
  105660. */
  105661. preventDefaultOnPointerUp: boolean;
  105662. /**
  105663. * Gets or sets user defined metadata
  105664. */
  105665. metadata: any;
  105666. /**
  105667. * For internal use only. Please do not use.
  105668. */
  105669. reservedDataStore: any;
  105670. /**
  105671. * Gets the name of the plugin used to load this scene (null by default)
  105672. */
  105673. loadingPluginName: string;
  105674. /**
  105675. * Use this array to add regular expressions used to disable offline support for specific urls
  105676. */
  105677. disableOfflineSupportExceptionRules: RegExp[];
  105678. /**
  105679. * An event triggered when the scene is disposed.
  105680. */
  105681. onDisposeObservable: Observable<Scene>;
  105682. private _onDisposeObserver;
  105683. /** Sets a function to be executed when this scene is disposed. */
  105684. set onDispose(callback: () => void);
  105685. /**
  105686. * An event triggered before rendering the scene (right after animations and physics)
  105687. */
  105688. onBeforeRenderObservable: Observable<Scene>;
  105689. private _onBeforeRenderObserver;
  105690. /** Sets a function to be executed before rendering this scene */
  105691. set beforeRender(callback: Nullable<() => void>);
  105692. /**
  105693. * An event triggered after rendering the scene
  105694. */
  105695. onAfterRenderObservable: Observable<Scene>;
  105696. /**
  105697. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  105698. */
  105699. onAfterRenderCameraObservable: Observable<Camera>;
  105700. private _onAfterRenderObserver;
  105701. /** Sets a function to be executed after rendering this scene */
  105702. set afterRender(callback: Nullable<() => void>);
  105703. /**
  105704. * An event triggered before animating the scene
  105705. */
  105706. onBeforeAnimationsObservable: Observable<Scene>;
  105707. /**
  105708. * An event triggered after animations processing
  105709. */
  105710. onAfterAnimationsObservable: Observable<Scene>;
  105711. /**
  105712. * An event triggered before draw calls are ready to be sent
  105713. */
  105714. onBeforeDrawPhaseObservable: Observable<Scene>;
  105715. /**
  105716. * An event triggered after draw calls have been sent
  105717. */
  105718. onAfterDrawPhaseObservable: Observable<Scene>;
  105719. /**
  105720. * An event triggered when the scene is ready
  105721. */
  105722. onReadyObservable: Observable<Scene>;
  105723. /**
  105724. * An event triggered before rendering a camera
  105725. */
  105726. onBeforeCameraRenderObservable: Observable<Camera>;
  105727. private _onBeforeCameraRenderObserver;
  105728. /** Sets a function to be executed before rendering a camera*/
  105729. set beforeCameraRender(callback: () => void);
  105730. /**
  105731. * An event triggered after rendering a camera
  105732. */
  105733. onAfterCameraRenderObservable: Observable<Camera>;
  105734. private _onAfterCameraRenderObserver;
  105735. /** Sets a function to be executed after rendering a camera*/
  105736. set afterCameraRender(callback: () => void);
  105737. /**
  105738. * An event triggered when active meshes evaluation is about to start
  105739. */
  105740. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  105741. /**
  105742. * An event triggered when active meshes evaluation is done
  105743. */
  105744. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  105745. /**
  105746. * An event triggered when particles rendering is about to start
  105747. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  105748. */
  105749. onBeforeParticlesRenderingObservable: Observable<Scene>;
  105750. /**
  105751. * An event triggered when particles rendering is done
  105752. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  105753. */
  105754. onAfterParticlesRenderingObservable: Observable<Scene>;
  105755. /**
  105756. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  105757. */
  105758. onDataLoadedObservable: Observable<Scene>;
  105759. /**
  105760. * An event triggered when a camera is created
  105761. */
  105762. onNewCameraAddedObservable: Observable<Camera>;
  105763. /**
  105764. * An event triggered when a camera is removed
  105765. */
  105766. onCameraRemovedObservable: Observable<Camera>;
  105767. /**
  105768. * An event triggered when a light is created
  105769. */
  105770. onNewLightAddedObservable: Observable<Light>;
  105771. /**
  105772. * An event triggered when a light is removed
  105773. */
  105774. onLightRemovedObservable: Observable<Light>;
  105775. /**
  105776. * An event triggered when a geometry is created
  105777. */
  105778. onNewGeometryAddedObservable: Observable<Geometry>;
  105779. /**
  105780. * An event triggered when a geometry is removed
  105781. */
  105782. onGeometryRemovedObservable: Observable<Geometry>;
  105783. /**
  105784. * An event triggered when a transform node is created
  105785. */
  105786. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  105787. /**
  105788. * An event triggered when a transform node is removed
  105789. */
  105790. onTransformNodeRemovedObservable: Observable<TransformNode>;
  105791. /**
  105792. * An event triggered when a mesh is created
  105793. */
  105794. onNewMeshAddedObservable: Observable<AbstractMesh>;
  105795. /**
  105796. * An event triggered when a mesh is removed
  105797. */
  105798. onMeshRemovedObservable: Observable<AbstractMesh>;
  105799. /**
  105800. * An event triggered when a skeleton is created
  105801. */
  105802. onNewSkeletonAddedObservable: Observable<Skeleton>;
  105803. /**
  105804. * An event triggered when a skeleton is removed
  105805. */
  105806. onSkeletonRemovedObservable: Observable<Skeleton>;
  105807. /**
  105808. * An event triggered when a material is created
  105809. */
  105810. onNewMaterialAddedObservable: Observable<Material>;
  105811. /**
  105812. * An event triggered when a material is removed
  105813. */
  105814. onMaterialRemovedObservable: Observable<Material>;
  105815. /**
  105816. * An event triggered when a texture is created
  105817. */
  105818. onNewTextureAddedObservable: Observable<BaseTexture>;
  105819. /**
  105820. * An event triggered when a texture is removed
  105821. */
  105822. onTextureRemovedObservable: Observable<BaseTexture>;
  105823. /**
  105824. * An event triggered when render targets are about to be rendered
  105825. * Can happen multiple times per frame.
  105826. */
  105827. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  105828. /**
  105829. * An event triggered when render targets were rendered.
  105830. * Can happen multiple times per frame.
  105831. */
  105832. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  105833. /**
  105834. * An event triggered before calculating deterministic simulation step
  105835. */
  105836. onBeforeStepObservable: Observable<Scene>;
  105837. /**
  105838. * An event triggered after calculating deterministic simulation step
  105839. */
  105840. onAfterStepObservable: Observable<Scene>;
  105841. /**
  105842. * An event triggered when the activeCamera property is updated
  105843. */
  105844. onActiveCameraChanged: Observable<Scene>;
  105845. /**
  105846. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  105847. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  105848. * 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)
  105849. */
  105850. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  105851. /**
  105852. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  105853. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  105854. * 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)
  105855. */
  105856. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  105857. /**
  105858. * This Observable will when a mesh has been imported into the scene.
  105859. */
  105860. onMeshImportedObservable: Observable<AbstractMesh>;
  105861. /**
  105862. * This Observable will when an animation file has been imported into the scene.
  105863. */
  105864. onAnimationFileImportedObservable: Observable<Scene>;
  105865. /**
  105866. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  105867. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  105868. */
  105869. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  105870. /** @hidden */
  105871. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  105872. /**
  105873. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  105874. */
  105875. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  105876. /**
  105877. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  105878. */
  105879. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  105880. /**
  105881. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  105882. */
  105883. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  105884. /** Callback called when a pointer move is detected */
  105885. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  105886. /** Callback called when a pointer down is detected */
  105887. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  105888. /** Callback called when a pointer up is detected */
  105889. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  105890. /** Callback called when a pointer pick is detected */
  105891. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  105892. /**
  105893. * 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).
  105894. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  105895. */
  105896. onPrePointerObservable: Observable<PointerInfoPre>;
  105897. /**
  105898. * Observable event triggered each time an input event is received from the rendering canvas
  105899. */
  105900. onPointerObservable: Observable<PointerInfo>;
  105901. /**
  105902. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  105903. */
  105904. get unTranslatedPointer(): Vector2;
  105905. /**
  105906. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  105907. */
  105908. static get DragMovementThreshold(): number;
  105909. static set DragMovementThreshold(value: number);
  105910. /**
  105911. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  105912. */
  105913. static get LongPressDelay(): number;
  105914. static set LongPressDelay(value: number);
  105915. /**
  105916. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  105917. */
  105918. static get DoubleClickDelay(): number;
  105919. static set DoubleClickDelay(value: number);
  105920. /** If you need to check double click without raising a single click at first click, enable this flag */
  105921. static get ExclusiveDoubleClickMode(): boolean;
  105922. static set ExclusiveDoubleClickMode(value: boolean);
  105923. /** @hidden */
  105924. _mirroredCameraPosition: Nullable<Vector3>;
  105925. /**
  105926. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  105927. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  105928. */
  105929. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  105930. /**
  105931. * Observable event triggered each time an keyboard event is received from the hosting window
  105932. */
  105933. onKeyboardObservable: Observable<KeyboardInfo>;
  105934. private _useRightHandedSystem;
  105935. /**
  105936. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  105937. */
  105938. set useRightHandedSystem(value: boolean);
  105939. get useRightHandedSystem(): boolean;
  105940. private _timeAccumulator;
  105941. private _currentStepId;
  105942. private _currentInternalStep;
  105943. /**
  105944. * Sets the step Id used by deterministic lock step
  105945. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105946. * @param newStepId defines the step Id
  105947. */
  105948. setStepId(newStepId: number): void;
  105949. /**
  105950. * Gets the step Id used by deterministic lock step
  105951. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105952. * @returns the step Id
  105953. */
  105954. getStepId(): number;
  105955. /**
  105956. * Gets the internal step used by deterministic lock step
  105957. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105958. * @returns the internal step
  105959. */
  105960. getInternalStep(): number;
  105961. private _fogEnabled;
  105962. /**
  105963. * Gets or sets a boolean indicating if fog is enabled on this scene
  105964. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105965. * (Default is true)
  105966. */
  105967. set fogEnabled(value: boolean);
  105968. get fogEnabled(): boolean;
  105969. private _fogMode;
  105970. /**
  105971. * Gets or sets the fog mode to use
  105972. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105973. * | mode | value |
  105974. * | --- | --- |
  105975. * | FOGMODE_NONE | 0 |
  105976. * | FOGMODE_EXP | 1 |
  105977. * | FOGMODE_EXP2 | 2 |
  105978. * | FOGMODE_LINEAR | 3 |
  105979. */
  105980. set fogMode(value: number);
  105981. get fogMode(): number;
  105982. /**
  105983. * Gets or sets the fog color to use
  105984. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105985. * (Default is Color3(0.2, 0.2, 0.3))
  105986. */
  105987. fogColor: Color3;
  105988. /**
  105989. * Gets or sets the fog density to use
  105990. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105991. * (Default is 0.1)
  105992. */
  105993. fogDensity: number;
  105994. /**
  105995. * Gets or sets the fog start distance to use
  105996. * @see http://doc.babylonjs.com/babylon101/environment#fog
  105997. * (Default is 0)
  105998. */
  105999. fogStart: number;
  106000. /**
  106001. * Gets or sets the fog end distance to use
  106002. * @see http://doc.babylonjs.com/babylon101/environment#fog
  106003. * (Default is 1000)
  106004. */
  106005. fogEnd: number;
  106006. private _shadowsEnabled;
  106007. /**
  106008. * Gets or sets a boolean indicating if shadows are enabled on this scene
  106009. */
  106010. set shadowsEnabled(value: boolean);
  106011. get shadowsEnabled(): boolean;
  106012. private _lightsEnabled;
  106013. /**
  106014. * Gets or sets a boolean indicating if lights are enabled on this scene
  106015. */
  106016. set lightsEnabled(value: boolean);
  106017. get lightsEnabled(): boolean;
  106018. /** All of the active cameras added to this scene. */
  106019. activeCameras: Camera[];
  106020. /** @hidden */
  106021. _activeCamera: Nullable<Camera>;
  106022. /** Gets or sets the current active camera */
  106023. get activeCamera(): Nullable<Camera>;
  106024. set activeCamera(value: Nullable<Camera>);
  106025. private _defaultMaterial;
  106026. /** The default material used on meshes when no material is affected */
  106027. get defaultMaterial(): Material;
  106028. /** The default material used on meshes when no material is affected */
  106029. set defaultMaterial(value: Material);
  106030. private _texturesEnabled;
  106031. /**
  106032. * Gets or sets a boolean indicating if textures are enabled on this scene
  106033. */
  106034. set texturesEnabled(value: boolean);
  106035. get texturesEnabled(): boolean;
  106036. /**
  106037. * Gets or sets a boolean indicating if particles are enabled on this scene
  106038. */
  106039. particlesEnabled: boolean;
  106040. /**
  106041. * Gets or sets a boolean indicating if sprites are enabled on this scene
  106042. */
  106043. spritesEnabled: boolean;
  106044. private _skeletonsEnabled;
  106045. /**
  106046. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  106047. */
  106048. set skeletonsEnabled(value: boolean);
  106049. get skeletonsEnabled(): boolean;
  106050. /**
  106051. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  106052. */
  106053. lensFlaresEnabled: boolean;
  106054. /**
  106055. * Gets or sets a boolean indicating if collisions are enabled on this scene
  106056. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  106057. */
  106058. collisionsEnabled: boolean;
  106059. private _collisionCoordinator;
  106060. /** @hidden */
  106061. get collisionCoordinator(): ICollisionCoordinator;
  106062. /**
  106063. * Defines the gravity applied to this scene (used only for collisions)
  106064. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  106065. */
  106066. gravity: Vector3;
  106067. /**
  106068. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  106069. */
  106070. postProcessesEnabled: boolean;
  106071. /**
  106072. * The list of postprocesses added to the scene
  106073. */
  106074. postProcesses: PostProcess[];
  106075. /**
  106076. * Gets the current postprocess manager
  106077. */
  106078. postProcessManager: PostProcessManager;
  106079. /**
  106080. * Gets or sets a boolean indicating if render targets are enabled on this scene
  106081. */
  106082. renderTargetsEnabled: boolean;
  106083. /**
  106084. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  106085. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  106086. */
  106087. dumpNextRenderTargets: boolean;
  106088. /**
  106089. * The list of user defined render targets added to the scene
  106090. */
  106091. customRenderTargets: RenderTargetTexture[];
  106092. /**
  106093. * Defines if texture loading must be delayed
  106094. * If true, textures will only be loaded when they need to be rendered
  106095. */
  106096. useDelayedTextureLoading: boolean;
  106097. /**
  106098. * Gets the list of meshes imported to the scene through SceneLoader
  106099. */
  106100. importedMeshesFiles: String[];
  106101. /**
  106102. * Gets or sets a boolean indicating if probes are enabled on this scene
  106103. */
  106104. probesEnabled: boolean;
  106105. /**
  106106. * Gets or sets the current offline provider to use to store scene data
  106107. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  106108. */
  106109. offlineProvider: IOfflineProvider;
  106110. /**
  106111. * Gets or sets the action manager associated with the scene
  106112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  106113. */
  106114. actionManager: AbstractActionManager;
  106115. private _meshesForIntersections;
  106116. /**
  106117. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  106118. */
  106119. proceduralTexturesEnabled: boolean;
  106120. private _engine;
  106121. private _totalVertices;
  106122. /** @hidden */
  106123. _activeIndices: PerfCounter;
  106124. /** @hidden */
  106125. _activeParticles: PerfCounter;
  106126. /** @hidden */
  106127. _activeBones: PerfCounter;
  106128. private _animationRatio;
  106129. /** @hidden */
  106130. _animationTimeLast: number;
  106131. /** @hidden */
  106132. _animationTime: number;
  106133. /**
  106134. * Gets or sets a general scale for animation speed
  106135. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  106136. */
  106137. animationTimeScale: number;
  106138. /** @hidden */
  106139. _cachedMaterial: Nullable<Material>;
  106140. /** @hidden */
  106141. _cachedEffect: Nullable<Effect>;
  106142. /** @hidden */
  106143. _cachedVisibility: Nullable<number>;
  106144. private _renderId;
  106145. private _frameId;
  106146. private _executeWhenReadyTimeoutId;
  106147. private _intermediateRendering;
  106148. private _viewUpdateFlag;
  106149. private _projectionUpdateFlag;
  106150. /** @hidden */
  106151. _toBeDisposed: Nullable<IDisposable>[];
  106152. private _activeRequests;
  106153. /** @hidden */
  106154. _pendingData: any[];
  106155. private _isDisposed;
  106156. /**
  106157. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  106158. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  106159. */
  106160. dispatchAllSubMeshesOfActiveMeshes: boolean;
  106161. private _activeMeshes;
  106162. private _processedMaterials;
  106163. private _renderTargets;
  106164. /** @hidden */
  106165. _activeParticleSystems: SmartArray<IParticleSystem>;
  106166. private _activeSkeletons;
  106167. private _softwareSkinnedMeshes;
  106168. private _renderingManager;
  106169. /** @hidden */
  106170. _activeAnimatables: Animatable[];
  106171. private _transformMatrix;
  106172. private _sceneUbo;
  106173. /** @hidden */
  106174. _viewMatrix: Matrix;
  106175. private _projectionMatrix;
  106176. /** @hidden */
  106177. _forcedViewPosition: Nullable<Vector3>;
  106178. /** @hidden */
  106179. _frustumPlanes: Plane[];
  106180. /**
  106181. * Gets the list of frustum planes (built from the active camera)
  106182. */
  106183. get frustumPlanes(): Plane[];
  106184. /**
  106185. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  106186. * This is useful if there are more lights that the maximum simulteanous authorized
  106187. */
  106188. requireLightSorting: boolean;
  106189. /** @hidden */
  106190. readonly useMaterialMeshMap: boolean;
  106191. /** @hidden */
  106192. readonly useClonedMeshMap: boolean;
  106193. private _externalData;
  106194. private _uid;
  106195. /**
  106196. * @hidden
  106197. * Backing store of defined scene components.
  106198. */
  106199. _components: ISceneComponent[];
  106200. /**
  106201. * @hidden
  106202. * Backing store of defined scene components.
  106203. */
  106204. _serializableComponents: ISceneSerializableComponent[];
  106205. /**
  106206. * List of components to register on the next registration step.
  106207. */
  106208. private _transientComponents;
  106209. /**
  106210. * Registers the transient components if needed.
  106211. */
  106212. private _registerTransientComponents;
  106213. /**
  106214. * @hidden
  106215. * Add a component to the scene.
  106216. * Note that the ccomponent could be registered on th next frame if this is called after
  106217. * the register component stage.
  106218. * @param component Defines the component to add to the scene
  106219. */
  106220. _addComponent(component: ISceneComponent): void;
  106221. /**
  106222. * @hidden
  106223. * Gets a component from the scene.
  106224. * @param name defines the name of the component to retrieve
  106225. * @returns the component or null if not present
  106226. */
  106227. _getComponent(name: string): Nullable<ISceneComponent>;
  106228. /**
  106229. * @hidden
  106230. * Defines the actions happening before camera updates.
  106231. */
  106232. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  106233. /**
  106234. * @hidden
  106235. * Defines the actions happening before clear the canvas.
  106236. */
  106237. _beforeClearStage: Stage<SimpleStageAction>;
  106238. /**
  106239. * @hidden
  106240. * Defines the actions when collecting render targets for the frame.
  106241. */
  106242. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  106243. /**
  106244. * @hidden
  106245. * Defines the actions happening for one camera in the frame.
  106246. */
  106247. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  106248. /**
  106249. * @hidden
  106250. * Defines the actions happening during the per mesh ready checks.
  106251. */
  106252. _isReadyForMeshStage: Stage<MeshStageAction>;
  106253. /**
  106254. * @hidden
  106255. * Defines the actions happening before evaluate active mesh checks.
  106256. */
  106257. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  106258. /**
  106259. * @hidden
  106260. * Defines the actions happening during the evaluate sub mesh checks.
  106261. */
  106262. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  106263. /**
  106264. * @hidden
  106265. * Defines the actions happening during the active mesh stage.
  106266. */
  106267. _activeMeshStage: Stage<ActiveMeshStageAction>;
  106268. /**
  106269. * @hidden
  106270. * Defines the actions happening during the per camera render target step.
  106271. */
  106272. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  106273. /**
  106274. * @hidden
  106275. * Defines the actions happening just before the active camera is drawing.
  106276. */
  106277. _beforeCameraDrawStage: Stage<CameraStageAction>;
  106278. /**
  106279. * @hidden
  106280. * Defines the actions happening just before a render target is drawing.
  106281. */
  106282. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  106283. /**
  106284. * @hidden
  106285. * Defines the actions happening just before a rendering group is drawing.
  106286. */
  106287. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  106288. /**
  106289. * @hidden
  106290. * Defines the actions happening just before a mesh is drawing.
  106291. */
  106292. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  106293. /**
  106294. * @hidden
  106295. * Defines the actions happening just after a mesh has been drawn.
  106296. */
  106297. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  106298. /**
  106299. * @hidden
  106300. * Defines the actions happening just after a rendering group has been drawn.
  106301. */
  106302. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  106303. /**
  106304. * @hidden
  106305. * Defines the actions happening just after the active camera has been drawn.
  106306. */
  106307. _afterCameraDrawStage: Stage<CameraStageAction>;
  106308. /**
  106309. * @hidden
  106310. * Defines the actions happening just after a render target has been drawn.
  106311. */
  106312. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  106313. /**
  106314. * @hidden
  106315. * Defines the actions happening just after rendering all cameras and computing intersections.
  106316. */
  106317. _afterRenderStage: Stage<SimpleStageAction>;
  106318. /**
  106319. * @hidden
  106320. * Defines the actions happening when a pointer move event happens.
  106321. */
  106322. _pointerMoveStage: Stage<PointerMoveStageAction>;
  106323. /**
  106324. * @hidden
  106325. * Defines the actions happening when a pointer down event happens.
  106326. */
  106327. _pointerDownStage: Stage<PointerUpDownStageAction>;
  106328. /**
  106329. * @hidden
  106330. * Defines the actions happening when a pointer up event happens.
  106331. */
  106332. _pointerUpStage: Stage<PointerUpDownStageAction>;
  106333. /**
  106334. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  106335. */
  106336. private geometriesByUniqueId;
  106337. /**
  106338. * Creates a new Scene
  106339. * @param engine defines the engine to use to render this scene
  106340. * @param options defines the scene options
  106341. */
  106342. constructor(engine: Engine, options?: SceneOptions);
  106343. /**
  106344. * Gets a string idenfifying the name of the class
  106345. * @returns "Scene" string
  106346. */
  106347. getClassName(): string;
  106348. private _defaultMeshCandidates;
  106349. /**
  106350. * @hidden
  106351. */
  106352. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  106353. private _defaultSubMeshCandidates;
  106354. /**
  106355. * @hidden
  106356. */
  106357. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  106358. /**
  106359. * Sets the default candidate providers for the scene.
  106360. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  106361. * and getCollidingSubMeshCandidates to their default function
  106362. */
  106363. setDefaultCandidateProviders(): void;
  106364. /**
  106365. * Gets the mesh that is currently under the pointer
  106366. */
  106367. get meshUnderPointer(): Nullable<AbstractMesh>;
  106368. /**
  106369. * Gets or sets the current on-screen X position of the pointer
  106370. */
  106371. get pointerX(): number;
  106372. set pointerX(value: number);
  106373. /**
  106374. * Gets or sets the current on-screen Y position of the pointer
  106375. */
  106376. get pointerY(): number;
  106377. set pointerY(value: number);
  106378. /**
  106379. * Gets the cached material (ie. the latest rendered one)
  106380. * @returns the cached material
  106381. */
  106382. getCachedMaterial(): Nullable<Material>;
  106383. /**
  106384. * Gets the cached effect (ie. the latest rendered one)
  106385. * @returns the cached effect
  106386. */
  106387. getCachedEffect(): Nullable<Effect>;
  106388. /**
  106389. * Gets the cached visibility state (ie. the latest rendered one)
  106390. * @returns the cached visibility state
  106391. */
  106392. getCachedVisibility(): Nullable<number>;
  106393. /**
  106394. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  106395. * @param material defines the current material
  106396. * @param effect defines the current effect
  106397. * @param visibility defines the current visibility state
  106398. * @returns true if one parameter is not cached
  106399. */
  106400. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  106401. /**
  106402. * Gets the engine associated with the scene
  106403. * @returns an Engine
  106404. */
  106405. getEngine(): Engine;
  106406. /**
  106407. * Gets the total number of vertices rendered per frame
  106408. * @returns the total number of vertices rendered per frame
  106409. */
  106410. getTotalVertices(): number;
  106411. /**
  106412. * Gets the performance counter for total vertices
  106413. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  106414. */
  106415. get totalVerticesPerfCounter(): PerfCounter;
  106416. /**
  106417. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  106418. * @returns the total number of active indices rendered per frame
  106419. */
  106420. getActiveIndices(): number;
  106421. /**
  106422. * Gets the performance counter for active indices
  106423. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  106424. */
  106425. get totalActiveIndicesPerfCounter(): PerfCounter;
  106426. /**
  106427. * Gets the total number of active particles rendered per frame
  106428. * @returns the total number of active particles rendered per frame
  106429. */
  106430. getActiveParticles(): number;
  106431. /**
  106432. * Gets the performance counter for active particles
  106433. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  106434. */
  106435. get activeParticlesPerfCounter(): PerfCounter;
  106436. /**
  106437. * Gets the total number of active bones rendered per frame
  106438. * @returns the total number of active bones rendered per frame
  106439. */
  106440. getActiveBones(): number;
  106441. /**
  106442. * Gets the performance counter for active bones
  106443. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  106444. */
  106445. get activeBonesPerfCounter(): PerfCounter;
  106446. /**
  106447. * Gets the array of active meshes
  106448. * @returns an array of AbstractMesh
  106449. */
  106450. getActiveMeshes(): SmartArray<AbstractMesh>;
  106451. /**
  106452. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  106453. * @returns a number
  106454. */
  106455. getAnimationRatio(): number;
  106456. /**
  106457. * Gets an unique Id for the current render phase
  106458. * @returns a number
  106459. */
  106460. getRenderId(): number;
  106461. /**
  106462. * Gets an unique Id for the current frame
  106463. * @returns a number
  106464. */
  106465. getFrameId(): number;
  106466. /** Call this function if you want to manually increment the render Id*/
  106467. incrementRenderId(): void;
  106468. private _createUbo;
  106469. /**
  106470. * Use this method to simulate a pointer move on a mesh
  106471. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  106472. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  106473. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  106474. * @returns the current scene
  106475. */
  106476. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  106477. /**
  106478. * Use this method to simulate a pointer down on a mesh
  106479. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  106480. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  106481. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  106482. * @returns the current scene
  106483. */
  106484. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  106485. /**
  106486. * Use this method to simulate a pointer up on a mesh
  106487. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  106488. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  106489. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  106490. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  106491. * @returns the current scene
  106492. */
  106493. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  106494. /**
  106495. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  106496. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  106497. * @returns true if the pointer was captured
  106498. */
  106499. isPointerCaptured(pointerId?: number): boolean;
  106500. /**
  106501. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  106502. * @param attachUp defines if you want to attach events to pointerup
  106503. * @param attachDown defines if you want to attach events to pointerdown
  106504. * @param attachMove defines if you want to attach events to pointermove
  106505. */
  106506. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  106507. /** Detaches all event handlers*/
  106508. detachControl(): void;
  106509. /**
  106510. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  106511. * Delay loaded resources are not taking in account
  106512. * @return true if all required resources are ready
  106513. */
  106514. isReady(): boolean;
  106515. /** Resets all cached information relative to material (including effect and visibility) */
  106516. resetCachedMaterial(): void;
  106517. /**
  106518. * Registers a function to be called before every frame render
  106519. * @param func defines the function to register
  106520. */
  106521. registerBeforeRender(func: () => void): void;
  106522. /**
  106523. * Unregisters a function called before every frame render
  106524. * @param func defines the function to unregister
  106525. */
  106526. unregisterBeforeRender(func: () => void): void;
  106527. /**
  106528. * Registers a function to be called after every frame render
  106529. * @param func defines the function to register
  106530. */
  106531. registerAfterRender(func: () => void): void;
  106532. /**
  106533. * Unregisters a function called after every frame render
  106534. * @param func defines the function to unregister
  106535. */
  106536. unregisterAfterRender(func: () => void): void;
  106537. private _executeOnceBeforeRender;
  106538. /**
  106539. * The provided function will run before render once and will be disposed afterwards.
  106540. * A timeout delay can be provided so that the function will be executed in N ms.
  106541. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  106542. * @param func The function to be executed.
  106543. * @param timeout optional delay in ms
  106544. */
  106545. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  106546. /** @hidden */
  106547. _addPendingData(data: any): void;
  106548. /** @hidden */
  106549. _removePendingData(data: any): void;
  106550. /**
  106551. * Returns the number of items waiting to be loaded
  106552. * @returns the number of items waiting to be loaded
  106553. */
  106554. getWaitingItemsCount(): number;
  106555. /**
  106556. * Returns a boolean indicating if the scene is still loading data
  106557. */
  106558. get isLoading(): boolean;
  106559. /**
  106560. * Registers a function to be executed when the scene is ready
  106561. * @param {Function} func - the function to be executed
  106562. */
  106563. executeWhenReady(func: () => void): void;
  106564. /**
  106565. * Returns a promise that resolves when the scene is ready
  106566. * @returns A promise that resolves when the scene is ready
  106567. */
  106568. whenReadyAsync(): Promise<void>;
  106569. /** @hidden */
  106570. _checkIsReady(): void;
  106571. /**
  106572. * Gets all animatable attached to the scene
  106573. */
  106574. get animatables(): Animatable[];
  106575. /**
  106576. * Resets the last animation time frame.
  106577. * Useful to override when animations start running when loading a scene for the first time.
  106578. */
  106579. resetLastAnimationTimeFrame(): void;
  106580. /**
  106581. * Gets the current view matrix
  106582. * @returns a Matrix
  106583. */
  106584. getViewMatrix(): Matrix;
  106585. /**
  106586. * Gets the current projection matrix
  106587. * @returns a Matrix
  106588. */
  106589. getProjectionMatrix(): Matrix;
  106590. /**
  106591. * Gets the current transform matrix
  106592. * @returns a Matrix made of View * Projection
  106593. */
  106594. getTransformMatrix(): Matrix;
  106595. /**
  106596. * Sets the current transform matrix
  106597. * @param viewL defines the View matrix to use
  106598. * @param projectionL defines the Projection matrix to use
  106599. * @param viewR defines the right View matrix to use (if provided)
  106600. * @param projectionR defines the right Projection matrix to use (if provided)
  106601. */
  106602. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  106603. /**
  106604. * Gets the uniform buffer used to store scene data
  106605. * @returns a UniformBuffer
  106606. */
  106607. getSceneUniformBuffer(): UniformBuffer;
  106608. /**
  106609. * Gets an unique (relatively to the current scene) Id
  106610. * @returns an unique number for the scene
  106611. */
  106612. getUniqueId(): number;
  106613. /**
  106614. * Add a mesh to the list of scene's meshes
  106615. * @param newMesh defines the mesh to add
  106616. * @param recursive if all child meshes should also be added to the scene
  106617. */
  106618. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  106619. /**
  106620. * Remove a mesh for the list of scene's meshes
  106621. * @param toRemove defines the mesh to remove
  106622. * @param recursive if all child meshes should also be removed from the scene
  106623. * @returns the index where the mesh was in the mesh list
  106624. */
  106625. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  106626. /**
  106627. * Add a transform node to the list of scene's transform nodes
  106628. * @param newTransformNode defines the transform node to add
  106629. */
  106630. addTransformNode(newTransformNode: TransformNode): void;
  106631. /**
  106632. * Remove a transform node for the list of scene's transform nodes
  106633. * @param toRemove defines the transform node to remove
  106634. * @returns the index where the transform node was in the transform node list
  106635. */
  106636. removeTransformNode(toRemove: TransformNode): number;
  106637. /**
  106638. * Remove a skeleton for the list of scene's skeletons
  106639. * @param toRemove defines the skeleton to remove
  106640. * @returns the index where the skeleton was in the skeleton list
  106641. */
  106642. removeSkeleton(toRemove: Skeleton): number;
  106643. /**
  106644. * Remove a morph target for the list of scene's morph targets
  106645. * @param toRemove defines the morph target to remove
  106646. * @returns the index where the morph target was in the morph target list
  106647. */
  106648. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  106649. /**
  106650. * Remove a light for the list of scene's lights
  106651. * @param toRemove defines the light to remove
  106652. * @returns the index where the light was in the light list
  106653. */
  106654. removeLight(toRemove: Light): number;
  106655. /**
  106656. * Remove a camera for the list of scene's cameras
  106657. * @param toRemove defines the camera to remove
  106658. * @returns the index where the camera was in the camera list
  106659. */
  106660. removeCamera(toRemove: Camera): number;
  106661. /**
  106662. * Remove a particle system for the list of scene's particle systems
  106663. * @param toRemove defines the particle system to remove
  106664. * @returns the index where the particle system was in the particle system list
  106665. */
  106666. removeParticleSystem(toRemove: IParticleSystem): number;
  106667. /**
  106668. * Remove a animation for the list of scene's animations
  106669. * @param toRemove defines the animation to remove
  106670. * @returns the index where the animation was in the animation list
  106671. */
  106672. removeAnimation(toRemove: Animation): number;
  106673. /**
  106674. * Will stop the animation of the given target
  106675. * @param target - the target
  106676. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  106677. * @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)
  106678. */
  106679. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  106680. /**
  106681. * Removes the given animation group from this scene.
  106682. * @param toRemove The animation group to remove
  106683. * @returns The index of the removed animation group
  106684. */
  106685. removeAnimationGroup(toRemove: AnimationGroup): number;
  106686. /**
  106687. * Removes the given multi-material from this scene.
  106688. * @param toRemove The multi-material to remove
  106689. * @returns The index of the removed multi-material
  106690. */
  106691. removeMultiMaterial(toRemove: MultiMaterial): number;
  106692. /**
  106693. * Removes the given material from this scene.
  106694. * @param toRemove The material to remove
  106695. * @returns The index of the removed material
  106696. */
  106697. removeMaterial(toRemove: Material): number;
  106698. /**
  106699. * Removes the given action manager from this scene.
  106700. * @param toRemove The action manager to remove
  106701. * @returns The index of the removed action manager
  106702. */
  106703. removeActionManager(toRemove: AbstractActionManager): number;
  106704. /**
  106705. * Removes the given texture from this scene.
  106706. * @param toRemove The texture to remove
  106707. * @returns The index of the removed texture
  106708. */
  106709. removeTexture(toRemove: BaseTexture): number;
  106710. /**
  106711. * Adds the given light to this scene
  106712. * @param newLight The light to add
  106713. */
  106714. addLight(newLight: Light): void;
  106715. /**
  106716. * Sorts the list list based on light priorities
  106717. */
  106718. sortLightsByPriority(): void;
  106719. /**
  106720. * Adds the given camera to this scene
  106721. * @param newCamera The camera to add
  106722. */
  106723. addCamera(newCamera: Camera): void;
  106724. /**
  106725. * Adds the given skeleton to this scene
  106726. * @param newSkeleton The skeleton to add
  106727. */
  106728. addSkeleton(newSkeleton: Skeleton): void;
  106729. /**
  106730. * Adds the given particle system to this scene
  106731. * @param newParticleSystem The particle system to add
  106732. */
  106733. addParticleSystem(newParticleSystem: IParticleSystem): void;
  106734. /**
  106735. * Adds the given animation to this scene
  106736. * @param newAnimation The animation to add
  106737. */
  106738. addAnimation(newAnimation: Animation): void;
  106739. /**
  106740. * Adds the given animation group to this scene.
  106741. * @param newAnimationGroup The animation group to add
  106742. */
  106743. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  106744. /**
  106745. * Adds the given multi-material to this scene
  106746. * @param newMultiMaterial The multi-material to add
  106747. */
  106748. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  106749. /**
  106750. * Adds the given material to this scene
  106751. * @param newMaterial The material to add
  106752. */
  106753. addMaterial(newMaterial: Material): void;
  106754. /**
  106755. * Adds the given morph target to this scene
  106756. * @param newMorphTargetManager The morph target to add
  106757. */
  106758. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  106759. /**
  106760. * Adds the given geometry to this scene
  106761. * @param newGeometry The geometry to add
  106762. */
  106763. addGeometry(newGeometry: Geometry): void;
  106764. /**
  106765. * Adds the given action manager to this scene
  106766. * @param newActionManager The action manager to add
  106767. */
  106768. addActionManager(newActionManager: AbstractActionManager): void;
  106769. /**
  106770. * Adds the given texture to this scene.
  106771. * @param newTexture The texture to add
  106772. */
  106773. addTexture(newTexture: BaseTexture): void;
  106774. /**
  106775. * Switch active camera
  106776. * @param newCamera defines the new active camera
  106777. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  106778. */
  106779. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  106780. /**
  106781. * sets the active camera of the scene using its ID
  106782. * @param id defines the camera's ID
  106783. * @return the new active camera or null if none found.
  106784. */
  106785. setActiveCameraByID(id: string): Nullable<Camera>;
  106786. /**
  106787. * sets the active camera of the scene using its name
  106788. * @param name defines the camera's name
  106789. * @returns the new active camera or null if none found.
  106790. */
  106791. setActiveCameraByName(name: string): Nullable<Camera>;
  106792. /**
  106793. * get an animation group using its name
  106794. * @param name defines the material's name
  106795. * @return the animation group or null if none found.
  106796. */
  106797. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  106798. /**
  106799. * Get a material using its unique id
  106800. * @param uniqueId defines the material's unique id
  106801. * @return the material or null if none found.
  106802. */
  106803. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  106804. /**
  106805. * get a material using its id
  106806. * @param id defines the material's ID
  106807. * @return the material or null if none found.
  106808. */
  106809. getMaterialByID(id: string): Nullable<Material>;
  106810. /**
  106811. * Gets a the last added material using a given id
  106812. * @param id defines the material's ID
  106813. * @return the last material with the given id or null if none found.
  106814. */
  106815. getLastMaterialByID(id: string): Nullable<Material>;
  106816. /**
  106817. * Gets a material using its name
  106818. * @param name defines the material's name
  106819. * @return the material or null if none found.
  106820. */
  106821. getMaterialByName(name: string): Nullable<Material>;
  106822. /**
  106823. * Get a texture using its unique id
  106824. * @param uniqueId defines the texture's unique id
  106825. * @return the texture or null if none found.
  106826. */
  106827. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  106828. /**
  106829. * Gets a camera using its id
  106830. * @param id defines the id to look for
  106831. * @returns the camera or null if not found
  106832. */
  106833. getCameraByID(id: string): Nullable<Camera>;
  106834. /**
  106835. * Gets a camera using its unique id
  106836. * @param uniqueId defines the unique id to look for
  106837. * @returns the camera or null if not found
  106838. */
  106839. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  106840. /**
  106841. * Gets a camera using its name
  106842. * @param name defines the camera's name
  106843. * @return the camera or null if none found.
  106844. */
  106845. getCameraByName(name: string): Nullable<Camera>;
  106846. /**
  106847. * Gets a bone using its id
  106848. * @param id defines the bone's id
  106849. * @return the bone or null if not found
  106850. */
  106851. getBoneByID(id: string): Nullable<Bone>;
  106852. /**
  106853. * Gets a bone using its id
  106854. * @param name defines the bone's name
  106855. * @return the bone or null if not found
  106856. */
  106857. getBoneByName(name: string): Nullable<Bone>;
  106858. /**
  106859. * Gets a light node using its name
  106860. * @param name defines the the light's name
  106861. * @return the light or null if none found.
  106862. */
  106863. getLightByName(name: string): Nullable<Light>;
  106864. /**
  106865. * Gets a light node using its id
  106866. * @param id defines the light's id
  106867. * @return the light or null if none found.
  106868. */
  106869. getLightByID(id: string): Nullable<Light>;
  106870. /**
  106871. * Gets a light node using its scene-generated unique ID
  106872. * @param uniqueId defines the light's unique id
  106873. * @return the light or null if none found.
  106874. */
  106875. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  106876. /**
  106877. * Gets a particle system by id
  106878. * @param id defines the particle system id
  106879. * @return the corresponding system or null if none found
  106880. */
  106881. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  106882. /**
  106883. * Gets a geometry using its ID
  106884. * @param id defines the geometry's id
  106885. * @return the geometry or null if none found.
  106886. */
  106887. getGeometryByID(id: string): Nullable<Geometry>;
  106888. private _getGeometryByUniqueID;
  106889. /**
  106890. * Add a new geometry to this scene
  106891. * @param geometry defines the geometry to be added to the scene.
  106892. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  106893. * @return a boolean defining if the geometry was added or not
  106894. */
  106895. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  106896. /**
  106897. * Removes an existing geometry
  106898. * @param geometry defines the geometry to be removed from the scene
  106899. * @return a boolean defining if the geometry was removed or not
  106900. */
  106901. removeGeometry(geometry: Geometry): boolean;
  106902. /**
  106903. * Gets the list of geometries attached to the scene
  106904. * @returns an array of Geometry
  106905. */
  106906. getGeometries(): Geometry[];
  106907. /**
  106908. * Gets the first added mesh found of a given ID
  106909. * @param id defines the id to search for
  106910. * @return the mesh found or null if not found at all
  106911. */
  106912. getMeshByID(id: string): Nullable<AbstractMesh>;
  106913. /**
  106914. * Gets a list of meshes using their id
  106915. * @param id defines the id to search for
  106916. * @returns a list of meshes
  106917. */
  106918. getMeshesByID(id: string): Array<AbstractMesh>;
  106919. /**
  106920. * Gets the first added transform node found of a given ID
  106921. * @param id defines the id to search for
  106922. * @return the found transform node or null if not found at all.
  106923. */
  106924. getTransformNodeByID(id: string): Nullable<TransformNode>;
  106925. /**
  106926. * Gets a transform node with its auto-generated unique id
  106927. * @param uniqueId efines the unique id to search for
  106928. * @return the found transform node or null if not found at all.
  106929. */
  106930. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  106931. /**
  106932. * Gets a list of transform nodes using their id
  106933. * @param id defines the id to search for
  106934. * @returns a list of transform nodes
  106935. */
  106936. getTransformNodesByID(id: string): Array<TransformNode>;
  106937. /**
  106938. * Gets a mesh with its auto-generated unique id
  106939. * @param uniqueId defines the unique id to search for
  106940. * @return the found mesh or null if not found at all.
  106941. */
  106942. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  106943. /**
  106944. * Gets a the last added mesh using a given id
  106945. * @param id defines the id to search for
  106946. * @return the found mesh or null if not found at all.
  106947. */
  106948. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  106949. /**
  106950. * Gets a the last added node (Mesh, Camera, Light) using a given id
  106951. * @param id defines the id to search for
  106952. * @return the found node or null if not found at all
  106953. */
  106954. getLastEntryByID(id: string): Nullable<Node>;
  106955. /**
  106956. * Gets a node (Mesh, Camera, Light) using a given id
  106957. * @param id defines the id to search for
  106958. * @return the found node or null if not found at all
  106959. */
  106960. getNodeByID(id: string): Nullable<Node>;
  106961. /**
  106962. * Gets a node (Mesh, Camera, Light) using a given name
  106963. * @param name defines the name to search for
  106964. * @return the found node or null if not found at all.
  106965. */
  106966. getNodeByName(name: string): Nullable<Node>;
  106967. /**
  106968. * Gets a mesh using a given name
  106969. * @param name defines the name to search for
  106970. * @return the found mesh or null if not found at all.
  106971. */
  106972. getMeshByName(name: string): Nullable<AbstractMesh>;
  106973. /**
  106974. * Gets a transform node using a given name
  106975. * @param name defines the name to search for
  106976. * @return the found transform node or null if not found at all.
  106977. */
  106978. getTransformNodeByName(name: string): Nullable<TransformNode>;
  106979. /**
  106980. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  106981. * @param id defines the id to search for
  106982. * @return the found skeleton or null if not found at all.
  106983. */
  106984. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  106985. /**
  106986. * Gets a skeleton using a given auto generated unique id
  106987. * @param uniqueId defines the unique id to search for
  106988. * @return the found skeleton or null if not found at all.
  106989. */
  106990. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  106991. /**
  106992. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  106993. * @param id defines the id to search for
  106994. * @return the found skeleton or null if not found at all.
  106995. */
  106996. getSkeletonById(id: string): Nullable<Skeleton>;
  106997. /**
  106998. * Gets a skeleton using a given name
  106999. * @param name defines the name to search for
  107000. * @return the found skeleton or null if not found at all.
  107001. */
  107002. getSkeletonByName(name: string): Nullable<Skeleton>;
  107003. /**
  107004. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  107005. * @param id defines the id to search for
  107006. * @return the found morph target manager or null if not found at all.
  107007. */
  107008. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  107009. /**
  107010. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  107011. * @param id defines the id to search for
  107012. * @return the found morph target or null if not found at all.
  107013. */
  107014. getMorphTargetById(id: string): Nullable<MorphTarget>;
  107015. /**
  107016. * Gets a boolean indicating if the given mesh is active
  107017. * @param mesh defines the mesh to look for
  107018. * @returns true if the mesh is in the active list
  107019. */
  107020. isActiveMesh(mesh: AbstractMesh): boolean;
  107021. /**
  107022. * Return a unique id as a string which can serve as an identifier for the scene
  107023. */
  107024. get uid(): string;
  107025. /**
  107026. * Add an externaly attached data from its key.
  107027. * This method call will fail and return false, if such key already exists.
  107028. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  107029. * @param key the unique key that identifies the data
  107030. * @param data the data object to associate to the key for this Engine instance
  107031. * @return true if no such key were already present and the data was added successfully, false otherwise
  107032. */
  107033. addExternalData<T>(key: string, data: T): boolean;
  107034. /**
  107035. * Get an externaly attached data from its key
  107036. * @param key the unique key that identifies the data
  107037. * @return the associated data, if present (can be null), or undefined if not present
  107038. */
  107039. getExternalData<T>(key: string): Nullable<T>;
  107040. /**
  107041. * Get an externaly attached data from its key, create it using a factory if it's not already present
  107042. * @param key the unique key that identifies the data
  107043. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  107044. * @return the associated data, can be null if the factory returned null.
  107045. */
  107046. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  107047. /**
  107048. * Remove an externaly attached data from the Engine instance
  107049. * @param key the unique key that identifies the data
  107050. * @return true if the data was successfully removed, false if it doesn't exist
  107051. */
  107052. removeExternalData(key: string): boolean;
  107053. private _evaluateSubMesh;
  107054. /**
  107055. * Clear the processed materials smart array preventing retention point in material dispose.
  107056. */
  107057. freeProcessedMaterials(): void;
  107058. private _preventFreeActiveMeshesAndRenderingGroups;
  107059. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  107060. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  107061. * when disposing several meshes in a row or a hierarchy of meshes.
  107062. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  107063. */
  107064. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  107065. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  107066. /**
  107067. * Clear the active meshes smart array preventing retention point in mesh dispose.
  107068. */
  107069. freeActiveMeshes(): void;
  107070. /**
  107071. * Clear the info related to rendering groups preventing retention points during dispose.
  107072. */
  107073. freeRenderingGroups(): void;
  107074. /** @hidden */
  107075. _isInIntermediateRendering(): boolean;
  107076. /**
  107077. * Lambda returning the list of potentially active meshes.
  107078. */
  107079. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  107080. /**
  107081. * Lambda returning the list of potentially active sub meshes.
  107082. */
  107083. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  107084. /**
  107085. * Lambda returning the list of potentially intersecting sub meshes.
  107086. */
  107087. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  107088. /**
  107089. * Lambda returning the list of potentially colliding sub meshes.
  107090. */
  107091. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  107092. private _activeMeshesFrozen;
  107093. private _skipEvaluateActiveMeshesCompletely;
  107094. /**
  107095. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  107096. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  107097. * @returns the current scene
  107098. */
  107099. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  107100. /**
  107101. * Use this function to restart evaluating active meshes on every frame
  107102. * @returns the current scene
  107103. */
  107104. unfreezeActiveMeshes(): Scene;
  107105. private _evaluateActiveMeshes;
  107106. private _activeMesh;
  107107. /**
  107108. * Update the transform matrix to update from the current active camera
  107109. * @param force defines a boolean used to force the update even if cache is up to date
  107110. */
  107111. updateTransformMatrix(force?: boolean): void;
  107112. private _bindFrameBuffer;
  107113. /** @hidden */
  107114. _allowPostProcessClearColor: boolean;
  107115. /** @hidden */
  107116. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  107117. private _processSubCameras;
  107118. private _checkIntersections;
  107119. /** @hidden */
  107120. _advancePhysicsEngineStep(step: number): void;
  107121. /**
  107122. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  107123. */
  107124. getDeterministicFrameTime: () => number;
  107125. /** @hidden */
  107126. _animate(): void;
  107127. /** Execute all animations (for a frame) */
  107128. animate(): void;
  107129. /**
  107130. * Render the scene
  107131. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  107132. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  107133. */
  107134. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  107135. /**
  107136. * Freeze all materials
  107137. * A frozen material will not be updatable but should be faster to render
  107138. */
  107139. freezeMaterials(): void;
  107140. /**
  107141. * Unfreeze all materials
  107142. * A frozen material will not be updatable but should be faster to render
  107143. */
  107144. unfreezeMaterials(): void;
  107145. /**
  107146. * Releases all held ressources
  107147. */
  107148. dispose(): void;
  107149. /**
  107150. * Gets if the scene is already disposed
  107151. */
  107152. get isDisposed(): boolean;
  107153. /**
  107154. * Call this function to reduce memory footprint of the scene.
  107155. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  107156. */
  107157. clearCachedVertexData(): void;
  107158. /**
  107159. * This function will remove the local cached buffer data from texture.
  107160. * It will save memory but will prevent the texture from being rebuilt
  107161. */
  107162. cleanCachedTextureBuffer(): void;
  107163. /**
  107164. * Get the world extend vectors with an optional filter
  107165. *
  107166. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  107167. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  107168. */
  107169. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  107170. min: Vector3;
  107171. max: Vector3;
  107172. };
  107173. /**
  107174. * Creates a ray that can be used to pick in the scene
  107175. * @param x defines the x coordinate of the origin (on-screen)
  107176. * @param y defines the y coordinate of the origin (on-screen)
  107177. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  107178. * @param camera defines the camera to use for the picking
  107179. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  107180. * @returns a Ray
  107181. */
  107182. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  107183. /**
  107184. * Creates a ray that can be used to pick in the scene
  107185. * @param x defines the x coordinate of the origin (on-screen)
  107186. * @param y defines the y coordinate of the origin (on-screen)
  107187. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  107188. * @param result defines the ray where to store the picking ray
  107189. * @param camera defines the camera to use for the picking
  107190. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  107191. * @returns the current scene
  107192. */
  107193. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  107194. /**
  107195. * Creates a ray that can be used to pick in the scene
  107196. * @param x defines the x coordinate of the origin (on-screen)
  107197. * @param y defines the y coordinate of the origin (on-screen)
  107198. * @param camera defines the camera to use for the picking
  107199. * @returns a Ray
  107200. */
  107201. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  107202. /**
  107203. * Creates a ray that can be used to pick in the scene
  107204. * @param x defines the x coordinate of the origin (on-screen)
  107205. * @param y defines the y coordinate of the origin (on-screen)
  107206. * @param result defines the ray where to store the picking ray
  107207. * @param camera defines the camera to use for the picking
  107208. * @returns the current scene
  107209. */
  107210. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  107211. /** Launch a ray to try to pick a mesh in the scene
  107212. * @param x position on screen
  107213. * @param y position on screen
  107214. * @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
  107215. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  107216. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  107217. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107218. * @returns a PickingInfo
  107219. */
  107220. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  107221. /** Use the given ray to pick a mesh in the scene
  107222. * @param ray The ray to use to pick meshes
  107223. * @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
  107224. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  107225. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107226. * @returns a PickingInfo
  107227. */
  107228. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  107229. /**
  107230. * Launch a ray to try to pick a mesh in the scene
  107231. * @param x X position on screen
  107232. * @param y Y position on screen
  107233. * @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
  107234. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  107235. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107236. * @returns an array of PickingInfo
  107237. */
  107238. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  107239. /**
  107240. * Launch a ray to try to pick a mesh in the scene
  107241. * @param ray Ray to use
  107242. * @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
  107243. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107244. * @returns an array of PickingInfo
  107245. */
  107246. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  107247. /**
  107248. * Force the value of meshUnderPointer
  107249. * @param mesh defines the mesh to use
  107250. */
  107251. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  107252. /**
  107253. * Gets the mesh under the pointer
  107254. * @returns a Mesh or null if no mesh is under the pointer
  107255. */
  107256. getPointerOverMesh(): Nullable<AbstractMesh>;
  107257. /** @hidden */
  107258. _rebuildGeometries(): void;
  107259. /** @hidden */
  107260. _rebuildTextures(): void;
  107261. private _getByTags;
  107262. /**
  107263. * Get a list of meshes by tags
  107264. * @param tagsQuery defines the tags query to use
  107265. * @param forEach defines a predicate used to filter results
  107266. * @returns an array of Mesh
  107267. */
  107268. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  107269. /**
  107270. * Get a list of cameras by tags
  107271. * @param tagsQuery defines the tags query to use
  107272. * @param forEach defines a predicate used to filter results
  107273. * @returns an array of Camera
  107274. */
  107275. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  107276. /**
  107277. * Get a list of lights by tags
  107278. * @param tagsQuery defines the tags query to use
  107279. * @param forEach defines a predicate used to filter results
  107280. * @returns an array of Light
  107281. */
  107282. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  107283. /**
  107284. * Get a list of materials by tags
  107285. * @param tagsQuery defines the tags query to use
  107286. * @param forEach defines a predicate used to filter results
  107287. * @returns an array of Material
  107288. */
  107289. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  107290. /**
  107291. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  107292. * This allowed control for front to back rendering or reversly depending of the special needs.
  107293. *
  107294. * @param renderingGroupId The rendering group id corresponding to its index
  107295. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  107296. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  107297. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  107298. */
  107299. 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;
  107300. /**
  107301. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  107302. *
  107303. * @param renderingGroupId The rendering group id corresponding to its index
  107304. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  107305. * @param depth Automatically clears depth between groups if true and autoClear is true.
  107306. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  107307. */
  107308. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  107309. /**
  107310. * Gets the current auto clear configuration for one rendering group of the rendering
  107311. * manager.
  107312. * @param index the rendering group index to get the information for
  107313. * @returns The auto clear setup for the requested rendering group
  107314. */
  107315. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  107316. private _blockMaterialDirtyMechanism;
  107317. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  107318. get blockMaterialDirtyMechanism(): boolean;
  107319. set blockMaterialDirtyMechanism(value: boolean);
  107320. /**
  107321. * Will flag all materials as dirty to trigger new shader compilation
  107322. * @param flag defines the flag used to specify which material part must be marked as dirty
  107323. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  107324. */
  107325. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  107326. /** @hidden */
  107327. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  107328. /** @hidden */
  107329. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  107330. /** @hidden */
  107331. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  107332. /** @hidden */
  107333. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  107334. /** @hidden */
  107335. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  107336. /** @hidden */
  107337. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  107338. }
  107339. }
  107340. declare module BABYLON {
  107341. /**
  107342. * Set of assets to keep when moving a scene into an asset container.
  107343. */
  107344. export class KeepAssets extends AbstractScene {
  107345. }
  107346. /**
  107347. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  107348. */
  107349. export class InstantiatedEntries {
  107350. /**
  107351. * List of new root nodes (eg. nodes with no parent)
  107352. */
  107353. rootNodes: TransformNode[];
  107354. /**
  107355. * List of new skeletons
  107356. */
  107357. skeletons: Skeleton[];
  107358. /**
  107359. * List of new animation groups
  107360. */
  107361. animationGroups: AnimationGroup[];
  107362. }
  107363. /**
  107364. * Container with a set of assets that can be added or removed from a scene.
  107365. */
  107366. export class AssetContainer extends AbstractScene {
  107367. /**
  107368. * The scene the AssetContainer belongs to.
  107369. */
  107370. scene: Scene;
  107371. /**
  107372. * Instantiates an AssetContainer.
  107373. * @param scene The scene the AssetContainer belongs to.
  107374. */
  107375. constructor(scene: Scene);
  107376. /**
  107377. * Instantiate or clone all meshes and add the new ones to the scene.
  107378. * Skeletons and animation groups will all be cloned
  107379. * @param nameFunction defines an optional function used to get new names for clones
  107380. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  107381. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  107382. */
  107383. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  107384. /**
  107385. * Adds all the assets from the container to the scene.
  107386. */
  107387. addAllToScene(): void;
  107388. /**
  107389. * Removes all the assets in the container from the scene
  107390. */
  107391. removeAllFromScene(): void;
  107392. /**
  107393. * Disposes all the assets in the container
  107394. */
  107395. dispose(): void;
  107396. private _moveAssets;
  107397. /**
  107398. * Removes all the assets contained in the scene and adds them to the container.
  107399. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  107400. */
  107401. moveAllFromScene(keepAssets?: KeepAssets): void;
  107402. /**
  107403. * 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.
  107404. * @returns the root mesh
  107405. */
  107406. createRootMesh(): Mesh;
  107407. /**
  107408. * Merge animations from this asset container into a scene
  107409. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  107410. * @param animatables set of animatables to retarget to a node from the scene
  107411. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  107412. */
  107413. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  107414. }
  107415. }
  107416. declare module BABYLON {
  107417. /**
  107418. * Defines how the parser contract is defined.
  107419. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  107420. */
  107421. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  107422. /**
  107423. * Defines how the individual parser contract is defined.
  107424. * These parser can parse an individual asset
  107425. */
  107426. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  107427. /**
  107428. * Base class of the scene acting as a container for the different elements composing a scene.
  107429. * This class is dynamically extended by the different components of the scene increasing
  107430. * flexibility and reducing coupling
  107431. */
  107432. export abstract class AbstractScene {
  107433. /**
  107434. * Stores the list of available parsers in the application.
  107435. */
  107436. private static _BabylonFileParsers;
  107437. /**
  107438. * Stores the list of available individual parsers in the application.
  107439. */
  107440. private static _IndividualBabylonFileParsers;
  107441. /**
  107442. * Adds a parser in the list of available ones
  107443. * @param name Defines the name of the parser
  107444. * @param parser Defines the parser to add
  107445. */
  107446. static AddParser(name: string, parser: BabylonFileParser): void;
  107447. /**
  107448. * Gets a general parser from the list of avaialble ones
  107449. * @param name Defines the name of the parser
  107450. * @returns the requested parser or null
  107451. */
  107452. static GetParser(name: string): Nullable<BabylonFileParser>;
  107453. /**
  107454. * Adds n individual parser in the list of available ones
  107455. * @param name Defines the name of the parser
  107456. * @param parser Defines the parser to add
  107457. */
  107458. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  107459. /**
  107460. * Gets an individual parser from the list of avaialble ones
  107461. * @param name Defines the name of the parser
  107462. * @returns the requested parser or null
  107463. */
  107464. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  107465. /**
  107466. * Parser json data and populate both a scene and its associated container object
  107467. * @param jsonData Defines the data to parse
  107468. * @param scene Defines the scene to parse the data for
  107469. * @param container Defines the container attached to the parsing sequence
  107470. * @param rootUrl Defines the root url of the data
  107471. */
  107472. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  107473. /**
  107474. * Gets the list of root nodes (ie. nodes with no parent)
  107475. */
  107476. rootNodes: Node[];
  107477. /** All of the cameras added to this scene
  107478. * @see http://doc.babylonjs.com/babylon101/cameras
  107479. */
  107480. cameras: Camera[];
  107481. /**
  107482. * All of the lights added to this scene
  107483. * @see http://doc.babylonjs.com/babylon101/lights
  107484. */
  107485. lights: Light[];
  107486. /**
  107487. * All of the (abstract) meshes added to this scene
  107488. */
  107489. meshes: AbstractMesh[];
  107490. /**
  107491. * The list of skeletons added to the scene
  107492. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  107493. */
  107494. skeletons: Skeleton[];
  107495. /**
  107496. * All of the particle systems added to this scene
  107497. * @see http://doc.babylonjs.com/babylon101/particles
  107498. */
  107499. particleSystems: IParticleSystem[];
  107500. /**
  107501. * Gets a list of Animations associated with the scene
  107502. */
  107503. animations: Animation[];
  107504. /**
  107505. * All of the animation groups added to this scene
  107506. * @see http://doc.babylonjs.com/how_to/group
  107507. */
  107508. animationGroups: AnimationGroup[];
  107509. /**
  107510. * All of the multi-materials added to this scene
  107511. * @see http://doc.babylonjs.com/how_to/multi_materials
  107512. */
  107513. multiMaterials: MultiMaterial[];
  107514. /**
  107515. * All of the materials added to this scene
  107516. * In the context of a Scene, it is not supposed to be modified manually.
  107517. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  107518. * Note also that the order of the Material within the array is not significant and might change.
  107519. * @see http://doc.babylonjs.com/babylon101/materials
  107520. */
  107521. materials: Material[];
  107522. /**
  107523. * The list of morph target managers added to the scene
  107524. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  107525. */
  107526. morphTargetManagers: MorphTargetManager[];
  107527. /**
  107528. * The list of geometries used in the scene.
  107529. */
  107530. geometries: Geometry[];
  107531. /**
  107532. * All of the tranform nodes added to this scene
  107533. * In the context of a Scene, it is not supposed to be modified manually.
  107534. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  107535. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  107536. * @see http://doc.babylonjs.com/how_to/transformnode
  107537. */
  107538. transformNodes: TransformNode[];
  107539. /**
  107540. * ActionManagers available on the scene.
  107541. */
  107542. actionManagers: AbstractActionManager[];
  107543. /**
  107544. * Textures to keep.
  107545. */
  107546. textures: BaseTexture[];
  107547. /**
  107548. * Environment texture for the scene
  107549. */
  107550. environmentTexture: Nullable<BaseTexture>;
  107551. /**
  107552. * @returns all meshes, lights, cameras, transformNodes and bones
  107553. */
  107554. getNodes(): Array<Node>;
  107555. }
  107556. }
  107557. declare module BABYLON {
  107558. /**
  107559. * Interface used to define options for Sound class
  107560. */
  107561. export interface ISoundOptions {
  107562. /**
  107563. * Does the sound autoplay once loaded.
  107564. */
  107565. autoplay?: boolean;
  107566. /**
  107567. * Does the sound loop after it finishes playing once.
  107568. */
  107569. loop?: boolean;
  107570. /**
  107571. * Sound's volume
  107572. */
  107573. volume?: number;
  107574. /**
  107575. * Is it a spatial sound?
  107576. */
  107577. spatialSound?: boolean;
  107578. /**
  107579. * Maximum distance to hear that sound
  107580. */
  107581. maxDistance?: number;
  107582. /**
  107583. * Uses user defined attenuation function
  107584. */
  107585. useCustomAttenuation?: boolean;
  107586. /**
  107587. * Define the roll off factor of spatial sounds.
  107588. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107589. */
  107590. rolloffFactor?: number;
  107591. /**
  107592. * Define the reference distance the sound should be heard perfectly.
  107593. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107594. */
  107595. refDistance?: number;
  107596. /**
  107597. * Define the distance attenuation model the sound will follow.
  107598. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107599. */
  107600. distanceModel?: string;
  107601. /**
  107602. * Defines the playback speed (1 by default)
  107603. */
  107604. playbackRate?: number;
  107605. /**
  107606. * Defines if the sound is from a streaming source
  107607. */
  107608. streaming?: boolean;
  107609. /**
  107610. * Defines an optional length (in seconds) inside the sound file
  107611. */
  107612. length?: number;
  107613. /**
  107614. * Defines an optional offset (in seconds) inside the sound file
  107615. */
  107616. offset?: number;
  107617. /**
  107618. * If true, URLs will not be required to state the audio file codec to use.
  107619. */
  107620. skipCodecCheck?: boolean;
  107621. }
  107622. /**
  107623. * Defines a sound that can be played in the application.
  107624. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  107625. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107626. */
  107627. export class Sound {
  107628. /**
  107629. * The name of the sound in the scene.
  107630. */
  107631. name: string;
  107632. /**
  107633. * Does the sound autoplay once loaded.
  107634. */
  107635. autoplay: boolean;
  107636. /**
  107637. * Does the sound loop after it finishes playing once.
  107638. */
  107639. loop: boolean;
  107640. /**
  107641. * Does the sound use a custom attenuation curve to simulate the falloff
  107642. * happening when the source gets further away from the camera.
  107643. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  107644. */
  107645. useCustomAttenuation: boolean;
  107646. /**
  107647. * The sound track id this sound belongs to.
  107648. */
  107649. soundTrackId: number;
  107650. /**
  107651. * Is this sound currently played.
  107652. */
  107653. isPlaying: boolean;
  107654. /**
  107655. * Is this sound currently paused.
  107656. */
  107657. isPaused: boolean;
  107658. /**
  107659. * Does this sound enables spatial sound.
  107660. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107661. */
  107662. spatialSound: boolean;
  107663. /**
  107664. * Define the reference distance the sound should be heard perfectly.
  107665. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107666. */
  107667. refDistance: number;
  107668. /**
  107669. * Define the roll off factor of spatial sounds.
  107670. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107671. */
  107672. rolloffFactor: number;
  107673. /**
  107674. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  107675. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107676. */
  107677. maxDistance: number;
  107678. /**
  107679. * Define the distance attenuation model the sound will follow.
  107680. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107681. */
  107682. distanceModel: string;
  107683. /**
  107684. * @hidden
  107685. * Back Compat
  107686. **/
  107687. onended: () => any;
  107688. /**
  107689. * Observable event when the current playing sound finishes.
  107690. */
  107691. onEndedObservable: Observable<Sound>;
  107692. private _panningModel;
  107693. private _playbackRate;
  107694. private _streaming;
  107695. private _startTime;
  107696. private _startOffset;
  107697. private _position;
  107698. /** @hidden */
  107699. _positionInEmitterSpace: boolean;
  107700. private _localDirection;
  107701. private _volume;
  107702. private _isReadyToPlay;
  107703. private _isDirectional;
  107704. private _readyToPlayCallback;
  107705. private _audioBuffer;
  107706. private _soundSource;
  107707. private _streamingSource;
  107708. private _soundPanner;
  107709. private _soundGain;
  107710. private _inputAudioNode;
  107711. private _outputAudioNode;
  107712. private _coneInnerAngle;
  107713. private _coneOuterAngle;
  107714. private _coneOuterGain;
  107715. private _scene;
  107716. private _connectedTransformNode;
  107717. private _customAttenuationFunction;
  107718. private _registerFunc;
  107719. private _isOutputConnected;
  107720. private _htmlAudioElement;
  107721. private _urlType;
  107722. private _length?;
  107723. private _offset?;
  107724. /** @hidden */
  107725. static _SceneComponentInitialization: (scene: Scene) => void;
  107726. /**
  107727. * Create a sound and attach it to a scene
  107728. * @param name Name of your sound
  107729. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  107730. * @param scene defines the scene the sound belongs to
  107731. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  107732. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  107733. */
  107734. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  107735. /**
  107736. * Release the sound and its associated resources
  107737. */
  107738. dispose(): void;
  107739. /**
  107740. * Gets if the sounds is ready to be played or not.
  107741. * @returns true if ready, otherwise false
  107742. */
  107743. isReady(): boolean;
  107744. private _soundLoaded;
  107745. /**
  107746. * Sets the data of the sound from an audiobuffer
  107747. * @param audioBuffer The audioBuffer containing the data
  107748. */
  107749. setAudioBuffer(audioBuffer: AudioBuffer): void;
  107750. /**
  107751. * Updates the current sounds options such as maxdistance, loop...
  107752. * @param options A JSON object containing values named as the object properties
  107753. */
  107754. updateOptions(options: ISoundOptions): void;
  107755. private _createSpatialParameters;
  107756. private _updateSpatialParameters;
  107757. /**
  107758. * Switch the panning model to HRTF:
  107759. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  107760. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107761. */
  107762. switchPanningModelToHRTF(): void;
  107763. /**
  107764. * Switch the panning model to Equal Power:
  107765. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  107766. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  107767. */
  107768. switchPanningModelToEqualPower(): void;
  107769. private _switchPanningModel;
  107770. /**
  107771. * Connect this sound to a sound track audio node like gain...
  107772. * @param soundTrackAudioNode the sound track audio node to connect to
  107773. */
  107774. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  107775. /**
  107776. * Transform this sound into a directional source
  107777. * @param coneInnerAngle Size of the inner cone in degree
  107778. * @param coneOuterAngle Size of the outer cone in degree
  107779. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  107780. */
  107781. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  107782. /**
  107783. * Gets or sets the inner angle for the directional cone.
  107784. */
  107785. get directionalConeInnerAngle(): number;
  107786. /**
  107787. * Gets or sets the inner angle for the directional cone.
  107788. */
  107789. set directionalConeInnerAngle(value: number);
  107790. /**
  107791. * Gets or sets the outer angle for the directional cone.
  107792. */
  107793. get directionalConeOuterAngle(): number;
  107794. /**
  107795. * Gets or sets the outer angle for the directional cone.
  107796. */
  107797. set directionalConeOuterAngle(value: number);
  107798. /**
  107799. * Sets the position of the emitter if spatial sound is enabled
  107800. * @param newPosition Defines the new posisiton
  107801. */
  107802. setPosition(newPosition: Vector3): void;
  107803. /**
  107804. * Sets the local direction of the emitter if spatial sound is enabled
  107805. * @param newLocalDirection Defines the new local direction
  107806. */
  107807. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  107808. private _updateDirection;
  107809. /** @hidden */
  107810. updateDistanceFromListener(): void;
  107811. /**
  107812. * Sets a new custom attenuation function for the sound.
  107813. * @param callback Defines the function used for the attenuation
  107814. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  107815. */
  107816. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  107817. /**
  107818. * Play the sound
  107819. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  107820. * @param offset (optional) Start the sound at a specific time in seconds
  107821. * @param length (optional) Sound duration (in seconds)
  107822. */
  107823. play(time?: number, offset?: number, length?: number): void;
  107824. private _onended;
  107825. /**
  107826. * Stop the sound
  107827. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  107828. */
  107829. stop(time?: number): void;
  107830. /**
  107831. * Put the sound in pause
  107832. */
  107833. pause(): void;
  107834. /**
  107835. * Sets a dedicated volume for this sounds
  107836. * @param newVolume Define the new volume of the sound
  107837. * @param time Define time for gradual change to new volume
  107838. */
  107839. setVolume(newVolume: number, time?: number): void;
  107840. /**
  107841. * Set the sound play back rate
  107842. * @param newPlaybackRate Define the playback rate the sound should be played at
  107843. */
  107844. setPlaybackRate(newPlaybackRate: number): void;
  107845. /**
  107846. * Gets the volume of the sound.
  107847. * @returns the volume of the sound
  107848. */
  107849. getVolume(): number;
  107850. /**
  107851. * Attach the sound to a dedicated mesh
  107852. * @param transformNode The transform node to connect the sound with
  107853. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  107854. */
  107855. attachToMesh(transformNode: TransformNode): void;
  107856. /**
  107857. * Detach the sound from the previously attached mesh
  107858. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  107859. */
  107860. detachFromMesh(): void;
  107861. private _onRegisterAfterWorldMatrixUpdate;
  107862. /**
  107863. * Clone the current sound in the scene.
  107864. * @returns the new sound clone
  107865. */
  107866. clone(): Nullable<Sound>;
  107867. /**
  107868. * Gets the current underlying audio buffer containing the data
  107869. * @returns the audio buffer
  107870. */
  107871. getAudioBuffer(): Nullable<AudioBuffer>;
  107872. /**
  107873. * Serializes the Sound in a JSON representation
  107874. * @returns the JSON representation of the sound
  107875. */
  107876. serialize(): any;
  107877. /**
  107878. * Parse a JSON representation of a sound to innstantiate in a given scene
  107879. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  107880. * @param scene Define the scene the new parsed sound should be created in
  107881. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  107882. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  107883. * @returns the newly parsed sound
  107884. */
  107885. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  107886. }
  107887. }
  107888. declare module BABYLON {
  107889. /**
  107890. * This defines an action helpful to play a defined sound on a triggered action.
  107891. */
  107892. export class PlaySoundAction extends Action {
  107893. private _sound;
  107894. /**
  107895. * Instantiate the action
  107896. * @param triggerOptions defines the trigger options
  107897. * @param sound defines the sound to play
  107898. * @param condition defines the trigger related conditions
  107899. */
  107900. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  107901. /** @hidden */
  107902. _prepare(): void;
  107903. /**
  107904. * Execute the action and play the sound.
  107905. */
  107906. execute(): void;
  107907. /**
  107908. * Serializes the actions and its related information.
  107909. * @param parent defines the object to serialize in
  107910. * @returns the serialized object
  107911. */
  107912. serialize(parent: any): any;
  107913. }
  107914. /**
  107915. * This defines an action helpful to stop a defined sound on a triggered action.
  107916. */
  107917. export class StopSoundAction extends Action {
  107918. private _sound;
  107919. /**
  107920. * Instantiate the action
  107921. * @param triggerOptions defines the trigger options
  107922. * @param sound defines the sound to stop
  107923. * @param condition defines the trigger related conditions
  107924. */
  107925. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  107926. /** @hidden */
  107927. _prepare(): void;
  107928. /**
  107929. * Execute the action and stop the sound.
  107930. */
  107931. execute(): void;
  107932. /**
  107933. * Serializes the actions and its related information.
  107934. * @param parent defines the object to serialize in
  107935. * @returns the serialized object
  107936. */
  107937. serialize(parent: any): any;
  107938. }
  107939. }
  107940. declare module BABYLON {
  107941. /**
  107942. * This defines an action responsible to change the value of a property
  107943. * by interpolating between its current value and the newly set one once triggered.
  107944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  107945. */
  107946. export class InterpolateValueAction extends Action {
  107947. /**
  107948. * Defines the path of the property where the value should be interpolated
  107949. */
  107950. propertyPath: string;
  107951. /**
  107952. * Defines the target value at the end of the interpolation.
  107953. */
  107954. value: any;
  107955. /**
  107956. * Defines the time it will take for the property to interpolate to the value.
  107957. */
  107958. duration: number;
  107959. /**
  107960. * Defines if the other scene animations should be stopped when the action has been triggered
  107961. */
  107962. stopOtherAnimations?: boolean;
  107963. /**
  107964. * Defines a callback raised once the interpolation animation has been done.
  107965. */
  107966. onInterpolationDone?: () => void;
  107967. /**
  107968. * Observable triggered once the interpolation animation has been done.
  107969. */
  107970. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  107971. private _target;
  107972. private _effectiveTarget;
  107973. private _property;
  107974. /**
  107975. * Instantiate the action
  107976. * @param triggerOptions defines the trigger options
  107977. * @param target defines the object containing the value to interpolate
  107978. * @param propertyPath defines the path to the property in the target object
  107979. * @param value defines the target value at the end of the interpolation
  107980. * @param duration deines the time it will take for the property to interpolate to the value.
  107981. * @param condition defines the trigger related conditions
  107982. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  107983. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  107984. */
  107985. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  107986. /** @hidden */
  107987. _prepare(): void;
  107988. /**
  107989. * Execute the action starts the value interpolation.
  107990. */
  107991. execute(): void;
  107992. /**
  107993. * Serializes the actions and its related information.
  107994. * @param parent defines the object to serialize in
  107995. * @returns the serialized object
  107996. */
  107997. serialize(parent: any): any;
  107998. }
  107999. }
  108000. declare module BABYLON {
  108001. /**
  108002. * Options allowed during the creation of a sound track.
  108003. */
  108004. export interface ISoundTrackOptions {
  108005. /**
  108006. * The volume the sound track should take during creation
  108007. */
  108008. volume?: number;
  108009. /**
  108010. * Define if the sound track is the main sound track of the scene
  108011. */
  108012. mainTrack?: boolean;
  108013. }
  108014. /**
  108015. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  108016. * It will be also used in a future release to apply effects on a specific track.
  108017. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  108018. */
  108019. export class SoundTrack {
  108020. /**
  108021. * The unique identifier of the sound track in the scene.
  108022. */
  108023. id: number;
  108024. /**
  108025. * The list of sounds included in the sound track.
  108026. */
  108027. soundCollection: Array<Sound>;
  108028. private _outputAudioNode;
  108029. private _scene;
  108030. private _connectedAnalyser;
  108031. private _options;
  108032. private _isInitialized;
  108033. /**
  108034. * Creates a new sound track.
  108035. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  108036. * @param scene Define the scene the sound track belongs to
  108037. * @param options
  108038. */
  108039. constructor(scene: Scene, options?: ISoundTrackOptions);
  108040. private _initializeSoundTrackAudioGraph;
  108041. /**
  108042. * Release the sound track and its associated resources
  108043. */
  108044. dispose(): void;
  108045. /**
  108046. * Adds a sound to this sound track
  108047. * @param sound define the cound to add
  108048. * @ignoreNaming
  108049. */
  108050. AddSound(sound: Sound): void;
  108051. /**
  108052. * Removes a sound to this sound track
  108053. * @param sound define the cound to remove
  108054. * @ignoreNaming
  108055. */
  108056. RemoveSound(sound: Sound): void;
  108057. /**
  108058. * Set a global volume for the full sound track.
  108059. * @param newVolume Define the new volume of the sound track
  108060. */
  108061. setVolume(newVolume: number): void;
  108062. /**
  108063. * Switch the panning model to HRTF:
  108064. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  108065. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108066. */
  108067. switchPanningModelToHRTF(): void;
  108068. /**
  108069. * Switch the panning model to Equal Power:
  108070. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  108071. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108072. */
  108073. switchPanningModelToEqualPower(): void;
  108074. /**
  108075. * Connect the sound track to an audio analyser allowing some amazing
  108076. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  108077. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  108078. * @param analyser The analyser to connect to the engine
  108079. */
  108080. connectToAnalyser(analyser: Analyser): void;
  108081. }
  108082. }
  108083. declare module BABYLON {
  108084. interface AbstractScene {
  108085. /**
  108086. * The list of sounds used in the scene.
  108087. */
  108088. sounds: Nullable<Array<Sound>>;
  108089. }
  108090. interface Scene {
  108091. /**
  108092. * @hidden
  108093. * Backing field
  108094. */
  108095. _mainSoundTrack: SoundTrack;
  108096. /**
  108097. * The main sound track played by the scene.
  108098. * It cotains your primary collection of sounds.
  108099. */
  108100. mainSoundTrack: SoundTrack;
  108101. /**
  108102. * The list of sound tracks added to the scene
  108103. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108104. */
  108105. soundTracks: Nullable<Array<SoundTrack>>;
  108106. /**
  108107. * Gets a sound using a given name
  108108. * @param name defines the name to search for
  108109. * @return the found sound or null if not found at all.
  108110. */
  108111. getSoundByName(name: string): Nullable<Sound>;
  108112. /**
  108113. * Gets or sets if audio support is enabled
  108114. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108115. */
  108116. audioEnabled: boolean;
  108117. /**
  108118. * Gets or sets if audio will be output to headphones
  108119. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108120. */
  108121. headphone: boolean;
  108122. /**
  108123. * Gets or sets custom audio listener position provider
  108124. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108125. */
  108126. audioListenerPositionProvider: Nullable<() => Vector3>;
  108127. /**
  108128. * Gets or sets a refresh rate when using 3D audio positioning
  108129. */
  108130. audioPositioningRefreshRate: number;
  108131. }
  108132. /**
  108133. * Defines the sound scene component responsible to manage any sounds
  108134. * in a given scene.
  108135. */
  108136. export class AudioSceneComponent implements ISceneSerializableComponent {
  108137. /**
  108138. * The component name helpfull to identify the component in the list of scene components.
  108139. */
  108140. readonly name: string;
  108141. /**
  108142. * The scene the component belongs to.
  108143. */
  108144. scene: Scene;
  108145. private _audioEnabled;
  108146. /**
  108147. * Gets whether audio is enabled or not.
  108148. * Please use related enable/disable method to switch state.
  108149. */
  108150. get audioEnabled(): boolean;
  108151. private _headphone;
  108152. /**
  108153. * Gets whether audio is outputing to headphone or not.
  108154. * Please use the according Switch methods to change output.
  108155. */
  108156. get headphone(): boolean;
  108157. /**
  108158. * Gets or sets a refresh rate when using 3D audio positioning
  108159. */
  108160. audioPositioningRefreshRate: number;
  108161. private _audioListenerPositionProvider;
  108162. /**
  108163. * Gets the current audio listener position provider
  108164. */
  108165. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  108166. /**
  108167. * Sets a custom listener position for all sounds in the scene
  108168. * By default, this is the position of the first active camera
  108169. */
  108170. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  108171. /**
  108172. * Creates a new instance of the component for the given scene
  108173. * @param scene Defines the scene to register the component in
  108174. */
  108175. constructor(scene: Scene);
  108176. /**
  108177. * Registers the component in a given scene
  108178. */
  108179. register(): void;
  108180. /**
  108181. * Rebuilds the elements related to this component in case of
  108182. * context lost for instance.
  108183. */
  108184. rebuild(): void;
  108185. /**
  108186. * Serializes the component data to the specified json object
  108187. * @param serializationObject The object to serialize to
  108188. */
  108189. serialize(serializationObject: any): void;
  108190. /**
  108191. * Adds all the elements from the container to the scene
  108192. * @param container the container holding the elements
  108193. */
  108194. addFromContainer(container: AbstractScene): void;
  108195. /**
  108196. * Removes all the elements in the container from the scene
  108197. * @param container contains the elements to remove
  108198. * @param dispose if the removed element should be disposed (default: false)
  108199. */
  108200. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  108201. /**
  108202. * Disposes the component and the associated ressources.
  108203. */
  108204. dispose(): void;
  108205. /**
  108206. * Disables audio in the associated scene.
  108207. */
  108208. disableAudio(): void;
  108209. /**
  108210. * Enables audio in the associated scene.
  108211. */
  108212. enableAudio(): void;
  108213. /**
  108214. * Switch audio to headphone output.
  108215. */
  108216. switchAudioModeForHeadphones(): void;
  108217. /**
  108218. * Switch audio to normal speakers.
  108219. */
  108220. switchAudioModeForNormalSpeakers(): void;
  108221. private _cachedCameraDirection;
  108222. private _cachedCameraPosition;
  108223. private _lastCheck;
  108224. private _afterRender;
  108225. }
  108226. }
  108227. declare module BABYLON {
  108228. /**
  108229. * Wraps one or more Sound objects and selects one with random weight for playback.
  108230. */
  108231. export class WeightedSound {
  108232. /** When true a Sound will be selected and played when the current playing Sound completes. */
  108233. loop: boolean;
  108234. private _coneInnerAngle;
  108235. private _coneOuterAngle;
  108236. private _volume;
  108237. /** A Sound is currently playing. */
  108238. isPlaying: boolean;
  108239. /** A Sound is currently paused. */
  108240. isPaused: boolean;
  108241. private _sounds;
  108242. private _weights;
  108243. private _currentIndex?;
  108244. /**
  108245. * Creates a new WeightedSound from the list of sounds given.
  108246. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  108247. * @param sounds Array of Sounds that will be selected from.
  108248. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  108249. */
  108250. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  108251. /**
  108252. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  108253. */
  108254. get directionalConeInnerAngle(): number;
  108255. /**
  108256. * The size of cone in degress for a directional sound in which there will be no attenuation.
  108257. */
  108258. set directionalConeInnerAngle(value: number);
  108259. /**
  108260. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  108261. * Listener angles between innerAngle and outerAngle will falloff linearly.
  108262. */
  108263. get directionalConeOuterAngle(): number;
  108264. /**
  108265. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  108266. * Listener angles between innerAngle and outerAngle will falloff linearly.
  108267. */
  108268. set directionalConeOuterAngle(value: number);
  108269. /**
  108270. * Playback volume.
  108271. */
  108272. get volume(): number;
  108273. /**
  108274. * Playback volume.
  108275. */
  108276. set volume(value: number);
  108277. private _onended;
  108278. /**
  108279. * Suspend playback
  108280. */
  108281. pause(): void;
  108282. /**
  108283. * Stop playback
  108284. */
  108285. stop(): void;
  108286. /**
  108287. * Start playback.
  108288. * @param startOffset Position the clip head at a specific time in seconds.
  108289. */
  108290. play(startOffset?: number): void;
  108291. }
  108292. }
  108293. declare module BABYLON {
  108294. /**
  108295. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  108296. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  108297. */
  108298. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  108299. /**
  108300. * Gets the name of the behavior.
  108301. */
  108302. get name(): string;
  108303. /**
  108304. * The easing function used by animations
  108305. */
  108306. static EasingFunction: BackEase;
  108307. /**
  108308. * The easing mode used by animations
  108309. */
  108310. static EasingMode: number;
  108311. /**
  108312. * The duration of the animation, in milliseconds
  108313. */
  108314. transitionDuration: number;
  108315. /**
  108316. * Length of the distance animated by the transition when lower radius is reached
  108317. */
  108318. lowerRadiusTransitionRange: number;
  108319. /**
  108320. * Length of the distance animated by the transition when upper radius is reached
  108321. */
  108322. upperRadiusTransitionRange: number;
  108323. private _autoTransitionRange;
  108324. /**
  108325. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  108326. */
  108327. get autoTransitionRange(): boolean;
  108328. /**
  108329. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  108330. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  108331. */
  108332. set autoTransitionRange(value: boolean);
  108333. private _attachedCamera;
  108334. private _onAfterCheckInputsObserver;
  108335. private _onMeshTargetChangedObserver;
  108336. /**
  108337. * Initializes the behavior.
  108338. */
  108339. init(): void;
  108340. /**
  108341. * Attaches the behavior to its arc rotate camera.
  108342. * @param camera Defines the camera to attach the behavior to
  108343. */
  108344. attach(camera: ArcRotateCamera): void;
  108345. /**
  108346. * Detaches the behavior from its current arc rotate camera.
  108347. */
  108348. detach(): void;
  108349. private _radiusIsAnimating;
  108350. private _radiusBounceTransition;
  108351. private _animatables;
  108352. private _cachedWheelPrecision;
  108353. /**
  108354. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  108355. * @param radiusLimit The limit to check against.
  108356. * @return Bool to indicate if at limit.
  108357. */
  108358. private _isRadiusAtLimit;
  108359. /**
  108360. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  108361. * @param radiusDelta The delta by which to animate to. Can be negative.
  108362. */
  108363. private _applyBoundRadiusAnimation;
  108364. /**
  108365. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  108366. */
  108367. protected _clearAnimationLocks(): void;
  108368. /**
  108369. * Stops and removes all animations that have been applied to the camera
  108370. */
  108371. stopAllAnimations(): void;
  108372. }
  108373. }
  108374. declare module BABYLON {
  108375. /**
  108376. * 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.
  108377. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  108378. */
  108379. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  108380. /**
  108381. * Gets the name of the behavior.
  108382. */
  108383. get name(): string;
  108384. private _mode;
  108385. private _radiusScale;
  108386. private _positionScale;
  108387. private _defaultElevation;
  108388. private _elevationReturnTime;
  108389. private _elevationReturnWaitTime;
  108390. private _zoomStopsAnimation;
  108391. private _framingTime;
  108392. /**
  108393. * The easing function used by animations
  108394. */
  108395. static EasingFunction: ExponentialEase;
  108396. /**
  108397. * The easing mode used by animations
  108398. */
  108399. static EasingMode: number;
  108400. /**
  108401. * Sets the current mode used by the behavior
  108402. */
  108403. set mode(mode: number);
  108404. /**
  108405. * Gets current mode used by the behavior.
  108406. */
  108407. get mode(): number;
  108408. /**
  108409. * Sets the scale applied to the radius (1 by default)
  108410. */
  108411. set radiusScale(radius: number);
  108412. /**
  108413. * Gets the scale applied to the radius
  108414. */
  108415. get radiusScale(): number;
  108416. /**
  108417. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  108418. */
  108419. set positionScale(scale: number);
  108420. /**
  108421. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  108422. */
  108423. get positionScale(): number;
  108424. /**
  108425. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  108426. * behaviour is triggered, in radians.
  108427. */
  108428. set defaultElevation(elevation: number);
  108429. /**
  108430. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  108431. * behaviour is triggered, in radians.
  108432. */
  108433. get defaultElevation(): number;
  108434. /**
  108435. * Sets the time (in milliseconds) taken to return to the default beta position.
  108436. * Negative value indicates camera should not return to default.
  108437. */
  108438. set elevationReturnTime(speed: number);
  108439. /**
  108440. * Gets the time (in milliseconds) taken to return to the default beta position.
  108441. * Negative value indicates camera should not return to default.
  108442. */
  108443. get elevationReturnTime(): number;
  108444. /**
  108445. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  108446. */
  108447. set elevationReturnWaitTime(time: number);
  108448. /**
  108449. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  108450. */
  108451. get elevationReturnWaitTime(): number;
  108452. /**
  108453. * Sets the flag that indicates if user zooming should stop animation.
  108454. */
  108455. set zoomStopsAnimation(flag: boolean);
  108456. /**
  108457. * Gets the flag that indicates if user zooming should stop animation.
  108458. */
  108459. get zoomStopsAnimation(): boolean;
  108460. /**
  108461. * Sets the transition time when framing the mesh, in milliseconds
  108462. */
  108463. set framingTime(time: number);
  108464. /**
  108465. * Gets the transition time when framing the mesh, in milliseconds
  108466. */
  108467. get framingTime(): number;
  108468. /**
  108469. * Define if the behavior should automatically change the configured
  108470. * camera limits and sensibilities.
  108471. */
  108472. autoCorrectCameraLimitsAndSensibility: boolean;
  108473. private _onPrePointerObservableObserver;
  108474. private _onAfterCheckInputsObserver;
  108475. private _onMeshTargetChangedObserver;
  108476. private _attachedCamera;
  108477. private _isPointerDown;
  108478. private _lastInteractionTime;
  108479. /**
  108480. * Initializes the behavior.
  108481. */
  108482. init(): void;
  108483. /**
  108484. * Attaches the behavior to its arc rotate camera.
  108485. * @param camera Defines the camera to attach the behavior to
  108486. */
  108487. attach(camera: ArcRotateCamera): void;
  108488. /**
  108489. * Detaches the behavior from its current arc rotate camera.
  108490. */
  108491. detach(): void;
  108492. private _animatables;
  108493. private _betaIsAnimating;
  108494. private _betaTransition;
  108495. private _radiusTransition;
  108496. private _vectorTransition;
  108497. /**
  108498. * Targets the given mesh and updates zoom level accordingly.
  108499. * @param mesh The mesh to target.
  108500. * @param radius Optional. If a cached radius position already exists, overrides default.
  108501. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  108502. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  108503. * @param onAnimationEnd Callback triggered at the end of the framing animation
  108504. */
  108505. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  108506. /**
  108507. * Targets the given mesh with its children and updates zoom level accordingly.
  108508. * @param mesh The mesh to target.
  108509. * @param radius Optional. If a cached radius position already exists, overrides default.
  108510. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  108511. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  108512. * @param onAnimationEnd Callback triggered at the end of the framing animation
  108513. */
  108514. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  108515. /**
  108516. * Targets the given meshes with their children and updates zoom level accordingly.
  108517. * @param meshes The mesh to target.
  108518. * @param radius Optional. If a cached radius position already exists, overrides default.
  108519. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  108520. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  108521. * @param onAnimationEnd Callback triggered at the end of the framing animation
  108522. */
  108523. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  108524. /**
  108525. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  108526. * @param minimumWorld Determines the smaller position of the bounding box extend
  108527. * @param maximumWorld Determines the bigger position of the bounding box extend
  108528. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  108529. * @param onAnimationEnd Callback triggered at the end of the framing animation
  108530. */
  108531. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  108532. /**
  108533. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  108534. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  108535. * frustum width.
  108536. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  108537. * to fully enclose the mesh in the viewing frustum.
  108538. */
  108539. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  108540. /**
  108541. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  108542. * is automatically returned to its default position (expected to be above ground plane).
  108543. */
  108544. private _maintainCameraAboveGround;
  108545. /**
  108546. * Returns the frustum slope based on the canvas ratio and camera FOV
  108547. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  108548. */
  108549. private _getFrustumSlope;
  108550. /**
  108551. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  108552. */
  108553. private _clearAnimationLocks;
  108554. /**
  108555. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  108556. */
  108557. private _applyUserInteraction;
  108558. /**
  108559. * Stops and removes all animations that have been applied to the camera
  108560. */
  108561. stopAllAnimations(): void;
  108562. /**
  108563. * Gets a value indicating if the user is moving the camera
  108564. */
  108565. get isUserIsMoving(): boolean;
  108566. /**
  108567. * The camera can move all the way towards the mesh.
  108568. */
  108569. static IgnoreBoundsSizeMode: number;
  108570. /**
  108571. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  108572. */
  108573. static FitFrustumSidesMode: number;
  108574. }
  108575. }
  108576. declare module BABYLON {
  108577. /**
  108578. * Base class for Camera Pointer Inputs.
  108579. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  108580. * for example usage.
  108581. */
  108582. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  108583. /**
  108584. * Defines the camera the input is attached to.
  108585. */
  108586. abstract camera: Camera;
  108587. /**
  108588. * Whether keyboard modifier keys are pressed at time of last mouse event.
  108589. */
  108590. protected _altKey: boolean;
  108591. protected _ctrlKey: boolean;
  108592. protected _metaKey: boolean;
  108593. protected _shiftKey: boolean;
  108594. /**
  108595. * Which mouse buttons were pressed at time of last mouse event.
  108596. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  108597. */
  108598. protected _buttonsPressed: number;
  108599. /**
  108600. * Defines the buttons associated with the input to handle camera move.
  108601. */
  108602. buttons: number[];
  108603. /**
  108604. * Attach the input controls to a specific dom element to get the input from.
  108605. * @param element Defines the element the controls should be listened from
  108606. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108607. */
  108608. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108609. /**
  108610. * Detach the current controls from the specified dom element.
  108611. * @param element Defines the element to stop listening the inputs from
  108612. */
  108613. detachControl(element: Nullable<HTMLElement>): void;
  108614. /**
  108615. * Gets the class name of the current input.
  108616. * @returns the class name
  108617. */
  108618. getClassName(): string;
  108619. /**
  108620. * Get the friendly name associated with the input class.
  108621. * @returns the input friendly name
  108622. */
  108623. getSimpleName(): string;
  108624. /**
  108625. * Called on pointer POINTERDOUBLETAP event.
  108626. * Override this method to provide functionality on POINTERDOUBLETAP event.
  108627. */
  108628. protected onDoubleTap(type: string): void;
  108629. /**
  108630. * Called on pointer POINTERMOVE event if only a single touch is active.
  108631. * Override this method to provide functionality.
  108632. */
  108633. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  108634. /**
  108635. * Called on pointer POINTERMOVE event if multiple touches are active.
  108636. * Override this method to provide functionality.
  108637. */
  108638. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  108639. /**
  108640. * Called on JS contextmenu event.
  108641. * Override this method to provide functionality.
  108642. */
  108643. protected onContextMenu(evt: PointerEvent): void;
  108644. /**
  108645. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  108646. * press.
  108647. * Override this method to provide functionality.
  108648. */
  108649. protected onButtonDown(evt: PointerEvent): void;
  108650. /**
  108651. * Called each time a new POINTERUP event occurs. Ie, for each button
  108652. * release.
  108653. * Override this method to provide functionality.
  108654. */
  108655. protected onButtonUp(evt: PointerEvent): void;
  108656. /**
  108657. * Called when window becomes inactive.
  108658. * Override this method to provide functionality.
  108659. */
  108660. protected onLostFocus(): void;
  108661. private _pointerInput;
  108662. private _observer;
  108663. private _onLostFocus;
  108664. private pointA;
  108665. private pointB;
  108666. }
  108667. }
  108668. declare module BABYLON {
  108669. /**
  108670. * Manage the pointers inputs to control an arc rotate camera.
  108671. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108672. */
  108673. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  108674. /**
  108675. * Defines the camera the input is attached to.
  108676. */
  108677. camera: ArcRotateCamera;
  108678. /**
  108679. * Gets the class name of the current input.
  108680. * @returns the class name
  108681. */
  108682. getClassName(): string;
  108683. /**
  108684. * Defines the buttons associated with the input to handle camera move.
  108685. */
  108686. buttons: number[];
  108687. /**
  108688. * Defines the pointer angular sensibility along the X axis or how fast is
  108689. * the camera rotating.
  108690. */
  108691. angularSensibilityX: number;
  108692. /**
  108693. * Defines the pointer angular sensibility along the Y axis or how fast is
  108694. * the camera rotating.
  108695. */
  108696. angularSensibilityY: number;
  108697. /**
  108698. * Defines the pointer pinch precision or how fast is the camera zooming.
  108699. */
  108700. pinchPrecision: number;
  108701. /**
  108702. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  108703. * from 0.
  108704. * It defines the percentage of current camera.radius to use as delta when
  108705. * pinch zoom is used.
  108706. */
  108707. pinchDeltaPercentage: number;
  108708. /**
  108709. * Defines the pointer panning sensibility or how fast is the camera moving.
  108710. */
  108711. panningSensibility: number;
  108712. /**
  108713. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  108714. */
  108715. multiTouchPanning: boolean;
  108716. /**
  108717. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  108718. * zoom (pinch) through multitouch.
  108719. */
  108720. multiTouchPanAndZoom: boolean;
  108721. /**
  108722. * Revers pinch action direction.
  108723. */
  108724. pinchInwards: boolean;
  108725. private _isPanClick;
  108726. private _twoFingerActivityCount;
  108727. private _isPinching;
  108728. /**
  108729. * Called on pointer POINTERMOVE event if only a single touch is active.
  108730. */
  108731. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  108732. /**
  108733. * Called on pointer POINTERDOUBLETAP event.
  108734. */
  108735. protected onDoubleTap(type: string): void;
  108736. /**
  108737. * Called on pointer POINTERMOVE event if multiple touches are active.
  108738. */
  108739. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  108740. /**
  108741. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  108742. * press.
  108743. */
  108744. protected onButtonDown(evt: PointerEvent): void;
  108745. /**
  108746. * Called each time a new POINTERUP event occurs. Ie, for each button
  108747. * release.
  108748. */
  108749. protected onButtonUp(evt: PointerEvent): void;
  108750. /**
  108751. * Called when window becomes inactive.
  108752. */
  108753. protected onLostFocus(): void;
  108754. }
  108755. }
  108756. declare module BABYLON {
  108757. /**
  108758. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  108759. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108760. */
  108761. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  108762. /**
  108763. * Defines the camera the input is attached to.
  108764. */
  108765. camera: ArcRotateCamera;
  108766. /**
  108767. * Defines the list of key codes associated with the up action (increase alpha)
  108768. */
  108769. keysUp: number[];
  108770. /**
  108771. * Defines the list of key codes associated with the down action (decrease alpha)
  108772. */
  108773. keysDown: number[];
  108774. /**
  108775. * Defines the list of key codes associated with the left action (increase beta)
  108776. */
  108777. keysLeft: number[];
  108778. /**
  108779. * Defines the list of key codes associated with the right action (decrease beta)
  108780. */
  108781. keysRight: number[];
  108782. /**
  108783. * Defines the list of key codes associated with the reset action.
  108784. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  108785. */
  108786. keysReset: number[];
  108787. /**
  108788. * Defines the panning sensibility of the inputs.
  108789. * (How fast is the camera paning)
  108790. */
  108791. panningSensibility: number;
  108792. /**
  108793. * Defines the zooming sensibility of the inputs.
  108794. * (How fast is the camera zooming)
  108795. */
  108796. zoomingSensibility: number;
  108797. /**
  108798. * Defines wether maintaining the alt key down switch the movement mode from
  108799. * orientation to zoom.
  108800. */
  108801. useAltToZoom: boolean;
  108802. /**
  108803. * Rotation speed of the camera
  108804. */
  108805. angularSpeed: number;
  108806. private _keys;
  108807. private _ctrlPressed;
  108808. private _altPressed;
  108809. private _onCanvasBlurObserver;
  108810. private _onKeyboardObserver;
  108811. private _engine;
  108812. private _scene;
  108813. /**
  108814. * Attach the input controls to a specific dom element to get the input from.
  108815. * @param element Defines the element the controls should be listened from
  108816. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108817. */
  108818. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108819. /**
  108820. * Detach the current controls from the specified dom element.
  108821. * @param element Defines the element to stop listening the inputs from
  108822. */
  108823. detachControl(element: Nullable<HTMLElement>): void;
  108824. /**
  108825. * Update the current camera state depending on the inputs that have been used this frame.
  108826. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  108827. */
  108828. checkInputs(): void;
  108829. /**
  108830. * Gets the class name of the current intput.
  108831. * @returns the class name
  108832. */
  108833. getClassName(): string;
  108834. /**
  108835. * Get the friendly name associated with the input class.
  108836. * @returns the input friendly name
  108837. */
  108838. getSimpleName(): string;
  108839. }
  108840. }
  108841. declare module BABYLON {
  108842. /**
  108843. * Manage the mouse wheel inputs to control an arc rotate camera.
  108844. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108845. */
  108846. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  108847. /**
  108848. * Defines the camera the input is attached to.
  108849. */
  108850. camera: ArcRotateCamera;
  108851. /**
  108852. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  108853. */
  108854. wheelPrecision: number;
  108855. /**
  108856. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  108857. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  108858. */
  108859. wheelDeltaPercentage: number;
  108860. private _wheel;
  108861. private _observer;
  108862. private computeDeltaFromMouseWheelLegacyEvent;
  108863. /**
  108864. * Attach the input controls to a specific dom element to get the input from.
  108865. * @param element Defines the element the controls should be listened from
  108866. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  108867. */
  108868. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  108869. /**
  108870. * Detach the current controls from the specified dom element.
  108871. * @param element Defines the element to stop listening the inputs from
  108872. */
  108873. detachControl(element: Nullable<HTMLElement>): void;
  108874. /**
  108875. * Gets the class name of the current intput.
  108876. * @returns the class name
  108877. */
  108878. getClassName(): string;
  108879. /**
  108880. * Get the friendly name associated with the input class.
  108881. * @returns the input friendly name
  108882. */
  108883. getSimpleName(): string;
  108884. }
  108885. }
  108886. declare module BABYLON {
  108887. /**
  108888. * Default Inputs manager for the ArcRotateCamera.
  108889. * It groups all the default supported inputs for ease of use.
  108890. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  108891. */
  108892. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  108893. /**
  108894. * Instantiates a new ArcRotateCameraInputsManager.
  108895. * @param camera Defines the camera the inputs belong to
  108896. */
  108897. constructor(camera: ArcRotateCamera);
  108898. /**
  108899. * Add mouse wheel input support to the input manager.
  108900. * @returns the current input manager
  108901. */
  108902. addMouseWheel(): ArcRotateCameraInputsManager;
  108903. /**
  108904. * Add pointers input support to the input manager.
  108905. * @returns the current input manager
  108906. */
  108907. addPointers(): ArcRotateCameraInputsManager;
  108908. /**
  108909. * Add keyboard input support to the input manager.
  108910. * @returns the current input manager
  108911. */
  108912. addKeyboard(): ArcRotateCameraInputsManager;
  108913. }
  108914. }
  108915. declare module BABYLON {
  108916. /**
  108917. * This represents an orbital type of camera.
  108918. *
  108919. * 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.
  108920. * 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.
  108921. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  108922. */
  108923. export class ArcRotateCamera extends TargetCamera {
  108924. /**
  108925. * Defines the rotation angle of the camera along the longitudinal axis.
  108926. */
  108927. alpha: number;
  108928. /**
  108929. * Defines the rotation angle of the camera along the latitudinal axis.
  108930. */
  108931. beta: number;
  108932. /**
  108933. * Defines the radius of the camera from it s target point.
  108934. */
  108935. radius: number;
  108936. protected _target: Vector3;
  108937. protected _targetHost: Nullable<AbstractMesh>;
  108938. /**
  108939. * Defines the target point of the camera.
  108940. * The camera looks towards it form the radius distance.
  108941. */
  108942. get target(): Vector3;
  108943. set target(value: Vector3);
  108944. /**
  108945. * Define the current local position of the camera in the scene
  108946. */
  108947. get position(): Vector3;
  108948. set position(newPosition: Vector3);
  108949. protected _upVector: Vector3;
  108950. protected _upToYMatrix: Matrix;
  108951. protected _YToUpMatrix: Matrix;
  108952. /**
  108953. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  108954. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  108955. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  108956. */
  108957. set upVector(vec: Vector3);
  108958. get upVector(): Vector3;
  108959. /**
  108960. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  108961. */
  108962. setMatUp(): void;
  108963. /**
  108964. * Current inertia value on the longitudinal axis.
  108965. * The bigger this number the longer it will take for the camera to stop.
  108966. */
  108967. inertialAlphaOffset: number;
  108968. /**
  108969. * Current inertia value on the latitudinal axis.
  108970. * The bigger this number the longer it will take for the camera to stop.
  108971. */
  108972. inertialBetaOffset: number;
  108973. /**
  108974. * Current inertia value on the radius axis.
  108975. * The bigger this number the longer it will take for the camera to stop.
  108976. */
  108977. inertialRadiusOffset: number;
  108978. /**
  108979. * Minimum allowed angle on the longitudinal axis.
  108980. * This can help limiting how the Camera is able to move in the scene.
  108981. */
  108982. lowerAlphaLimit: Nullable<number>;
  108983. /**
  108984. * Maximum allowed angle on the longitudinal axis.
  108985. * This can help limiting how the Camera is able to move in the scene.
  108986. */
  108987. upperAlphaLimit: Nullable<number>;
  108988. /**
  108989. * Minimum allowed angle on the latitudinal axis.
  108990. * This can help limiting how the Camera is able to move in the scene.
  108991. */
  108992. lowerBetaLimit: number;
  108993. /**
  108994. * Maximum allowed angle on the latitudinal axis.
  108995. * This can help limiting how the Camera is able to move in the scene.
  108996. */
  108997. upperBetaLimit: number;
  108998. /**
  108999. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  109000. * This can help limiting how the Camera is able to move in the scene.
  109001. */
  109002. lowerRadiusLimit: Nullable<number>;
  109003. /**
  109004. * Maximum allowed distance of the camera to the target (The camera can not get further).
  109005. * This can help limiting how the Camera is able to move in the scene.
  109006. */
  109007. upperRadiusLimit: Nullable<number>;
  109008. /**
  109009. * Defines the current inertia value used during panning of the camera along the X axis.
  109010. */
  109011. inertialPanningX: number;
  109012. /**
  109013. * Defines the current inertia value used during panning of the camera along the Y axis.
  109014. */
  109015. inertialPanningY: number;
  109016. /**
  109017. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  109018. * Basically if your fingers moves away from more than this distance you will be considered
  109019. * in pinch mode.
  109020. */
  109021. pinchToPanMaxDistance: number;
  109022. /**
  109023. * Defines the maximum distance the camera can pan.
  109024. * This could help keeping the cammera always in your scene.
  109025. */
  109026. panningDistanceLimit: Nullable<number>;
  109027. /**
  109028. * Defines the target of the camera before paning.
  109029. */
  109030. panningOriginTarget: Vector3;
  109031. /**
  109032. * Defines the value of the inertia used during panning.
  109033. * 0 would mean stop inertia and one would mean no decelleration at all.
  109034. */
  109035. panningInertia: number;
  109036. /**
  109037. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  109038. */
  109039. get angularSensibilityX(): number;
  109040. set angularSensibilityX(value: number);
  109041. /**
  109042. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  109043. */
  109044. get angularSensibilityY(): number;
  109045. set angularSensibilityY(value: number);
  109046. /**
  109047. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  109048. */
  109049. get pinchPrecision(): number;
  109050. set pinchPrecision(value: number);
  109051. /**
  109052. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  109053. * It will be used instead of pinchDeltaPrecision if different from 0.
  109054. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  109055. */
  109056. get pinchDeltaPercentage(): number;
  109057. set pinchDeltaPercentage(value: number);
  109058. /**
  109059. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  109060. */
  109061. get panningSensibility(): number;
  109062. set panningSensibility(value: number);
  109063. /**
  109064. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  109065. */
  109066. get keysUp(): number[];
  109067. set keysUp(value: number[]);
  109068. /**
  109069. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  109070. */
  109071. get keysDown(): number[];
  109072. set keysDown(value: number[]);
  109073. /**
  109074. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  109075. */
  109076. get keysLeft(): number[];
  109077. set keysLeft(value: number[]);
  109078. /**
  109079. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  109080. */
  109081. get keysRight(): number[];
  109082. set keysRight(value: number[]);
  109083. /**
  109084. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  109085. */
  109086. get wheelPrecision(): number;
  109087. set wheelPrecision(value: number);
  109088. /**
  109089. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  109090. * It will be used instead of pinchDeltaPrecision if different from 0.
  109091. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  109092. */
  109093. get wheelDeltaPercentage(): number;
  109094. set wheelDeltaPercentage(value: number);
  109095. /**
  109096. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  109097. */
  109098. zoomOnFactor: number;
  109099. /**
  109100. * Defines a screen offset for the camera position.
  109101. */
  109102. targetScreenOffset: Vector2;
  109103. /**
  109104. * Allows the camera to be completely reversed.
  109105. * If false the camera can not arrive upside down.
  109106. */
  109107. allowUpsideDown: boolean;
  109108. /**
  109109. * Define if double tap/click is used to restore the previously saved state of the camera.
  109110. */
  109111. useInputToRestoreState: boolean;
  109112. /** @hidden */
  109113. _viewMatrix: Matrix;
  109114. /** @hidden */
  109115. _useCtrlForPanning: boolean;
  109116. /** @hidden */
  109117. _panningMouseButton: number;
  109118. /**
  109119. * Defines the input associated to the camera.
  109120. */
  109121. inputs: ArcRotateCameraInputsManager;
  109122. /** @hidden */
  109123. _reset: () => void;
  109124. /**
  109125. * Defines the allowed panning axis.
  109126. */
  109127. panningAxis: Vector3;
  109128. protected _localDirection: Vector3;
  109129. protected _transformedDirection: Vector3;
  109130. private _bouncingBehavior;
  109131. /**
  109132. * Gets the bouncing behavior of the camera if it has been enabled.
  109133. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  109134. */
  109135. get bouncingBehavior(): Nullable<BouncingBehavior>;
  109136. /**
  109137. * Defines if the bouncing behavior of the camera is enabled on the camera.
  109138. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  109139. */
  109140. get useBouncingBehavior(): boolean;
  109141. set useBouncingBehavior(value: boolean);
  109142. private _framingBehavior;
  109143. /**
  109144. * Gets the framing behavior of the camera if it has been enabled.
  109145. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  109146. */
  109147. get framingBehavior(): Nullable<FramingBehavior>;
  109148. /**
  109149. * Defines if the framing behavior of the camera is enabled on the camera.
  109150. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  109151. */
  109152. get useFramingBehavior(): boolean;
  109153. set useFramingBehavior(value: boolean);
  109154. private _autoRotationBehavior;
  109155. /**
  109156. * Gets the auto rotation behavior of the camera if it has been enabled.
  109157. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  109158. */
  109159. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  109160. /**
  109161. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  109162. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  109163. */
  109164. get useAutoRotationBehavior(): boolean;
  109165. set useAutoRotationBehavior(value: boolean);
  109166. /**
  109167. * Observable triggered when the mesh target has been changed on the camera.
  109168. */
  109169. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  109170. /**
  109171. * Event raised when the camera is colliding with a mesh.
  109172. */
  109173. onCollide: (collidedMesh: AbstractMesh) => void;
  109174. /**
  109175. * Defines whether the camera should check collision with the objects oh the scene.
  109176. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  109177. */
  109178. checkCollisions: boolean;
  109179. /**
  109180. * Defines the collision radius of the camera.
  109181. * This simulates a sphere around the camera.
  109182. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  109183. */
  109184. collisionRadius: Vector3;
  109185. protected _collider: Collider;
  109186. protected _previousPosition: Vector3;
  109187. protected _collisionVelocity: Vector3;
  109188. protected _newPosition: Vector3;
  109189. protected _previousAlpha: number;
  109190. protected _previousBeta: number;
  109191. protected _previousRadius: number;
  109192. protected _collisionTriggered: boolean;
  109193. protected _targetBoundingCenter: Nullable<Vector3>;
  109194. private _computationVector;
  109195. /**
  109196. * Instantiates a new ArcRotateCamera in a given scene
  109197. * @param name Defines the name of the camera
  109198. * @param alpha Defines the camera rotation along the logitudinal axis
  109199. * @param beta Defines the camera rotation along the latitudinal axis
  109200. * @param radius Defines the camera distance from its target
  109201. * @param target Defines the camera target
  109202. * @param scene Defines the scene the camera belongs to
  109203. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  109204. */
  109205. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  109206. /** @hidden */
  109207. _initCache(): void;
  109208. /** @hidden */
  109209. _updateCache(ignoreParentClass?: boolean): void;
  109210. protected _getTargetPosition(): Vector3;
  109211. private _storedAlpha;
  109212. private _storedBeta;
  109213. private _storedRadius;
  109214. private _storedTarget;
  109215. private _storedTargetScreenOffset;
  109216. /**
  109217. * Stores the current state of the camera (alpha, beta, radius and target)
  109218. * @returns the camera itself
  109219. */
  109220. storeState(): Camera;
  109221. /**
  109222. * @hidden
  109223. * Restored camera state. You must call storeState() first
  109224. */
  109225. _restoreStateValues(): boolean;
  109226. /** @hidden */
  109227. _isSynchronizedViewMatrix(): boolean;
  109228. /**
  109229. * Attached controls to the current camera.
  109230. * @param element Defines the element the controls should be listened from
  109231. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109232. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  109233. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  109234. */
  109235. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  109236. /**
  109237. * Detach the current controls from the camera.
  109238. * The camera will stop reacting to inputs.
  109239. * @param element Defines the element to stop listening the inputs from
  109240. */
  109241. detachControl(element: HTMLElement): void;
  109242. /** @hidden */
  109243. _checkInputs(): void;
  109244. protected _checkLimits(): void;
  109245. /**
  109246. * Rebuilds angles (alpha, beta) and radius from the give position and target
  109247. */
  109248. rebuildAnglesAndRadius(): void;
  109249. /**
  109250. * Use a position to define the current camera related information like alpha, beta and radius
  109251. * @param position Defines the position to set the camera at
  109252. */
  109253. setPosition(position: Vector3): void;
  109254. /**
  109255. * Defines the target the camera should look at.
  109256. * This will automatically adapt alpha beta and radius to fit within the new target.
  109257. * @param target Defines the new target as a Vector or a mesh
  109258. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  109259. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  109260. */
  109261. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  109262. /** @hidden */
  109263. _getViewMatrix(): Matrix;
  109264. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  109265. /**
  109266. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  109267. * @param meshes Defines the mesh to zoom on
  109268. * @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)
  109269. */
  109270. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  109271. /**
  109272. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  109273. * The target will be changed but the radius
  109274. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  109275. * @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)
  109276. */
  109277. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  109278. min: Vector3;
  109279. max: Vector3;
  109280. distance: number;
  109281. }, doNotUpdateMaxZ?: boolean): void;
  109282. /**
  109283. * @override
  109284. * Override Camera.createRigCamera
  109285. */
  109286. createRigCamera(name: string, cameraIndex: number): Camera;
  109287. /**
  109288. * @hidden
  109289. * @override
  109290. * Override Camera._updateRigCameras
  109291. */
  109292. _updateRigCameras(): void;
  109293. /**
  109294. * Destroy the camera and release the current resources hold by it.
  109295. */
  109296. dispose(): void;
  109297. /**
  109298. * Gets the current object class name.
  109299. * @return the class name
  109300. */
  109301. getClassName(): string;
  109302. }
  109303. }
  109304. declare module BABYLON {
  109305. /**
  109306. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  109307. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  109308. */
  109309. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  109310. /**
  109311. * Gets the name of the behavior.
  109312. */
  109313. get name(): string;
  109314. private _zoomStopsAnimation;
  109315. private _idleRotationSpeed;
  109316. private _idleRotationWaitTime;
  109317. private _idleRotationSpinupTime;
  109318. /**
  109319. * Sets the flag that indicates if user zooming should stop animation.
  109320. */
  109321. set zoomStopsAnimation(flag: boolean);
  109322. /**
  109323. * Gets the flag that indicates if user zooming should stop animation.
  109324. */
  109325. get zoomStopsAnimation(): boolean;
  109326. /**
  109327. * Sets the default speed at which the camera rotates around the model.
  109328. */
  109329. set idleRotationSpeed(speed: number);
  109330. /**
  109331. * Gets the default speed at which the camera rotates around the model.
  109332. */
  109333. get idleRotationSpeed(): number;
  109334. /**
  109335. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  109336. */
  109337. set idleRotationWaitTime(time: number);
  109338. /**
  109339. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  109340. */
  109341. get idleRotationWaitTime(): number;
  109342. /**
  109343. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  109344. */
  109345. set idleRotationSpinupTime(time: number);
  109346. /**
  109347. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  109348. */
  109349. get idleRotationSpinupTime(): number;
  109350. /**
  109351. * Gets a value indicating if the camera is currently rotating because of this behavior
  109352. */
  109353. get rotationInProgress(): boolean;
  109354. private _onPrePointerObservableObserver;
  109355. private _onAfterCheckInputsObserver;
  109356. private _attachedCamera;
  109357. private _isPointerDown;
  109358. private _lastFrameTime;
  109359. private _lastInteractionTime;
  109360. private _cameraRotationSpeed;
  109361. /**
  109362. * Initializes the behavior.
  109363. */
  109364. init(): void;
  109365. /**
  109366. * Attaches the behavior to its arc rotate camera.
  109367. * @param camera Defines the camera to attach the behavior to
  109368. */
  109369. attach(camera: ArcRotateCamera): void;
  109370. /**
  109371. * Detaches the behavior from its current arc rotate camera.
  109372. */
  109373. detach(): void;
  109374. /**
  109375. * Returns true if user is scrolling.
  109376. * @return true if user is scrolling.
  109377. */
  109378. private _userIsZooming;
  109379. private _lastFrameRadius;
  109380. private _shouldAnimationStopForInteraction;
  109381. /**
  109382. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  109383. */
  109384. private _applyUserInteraction;
  109385. private _userIsMoving;
  109386. }
  109387. }
  109388. declare module BABYLON {
  109389. /**
  109390. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  109391. */
  109392. export class AttachToBoxBehavior implements Behavior<Mesh> {
  109393. private ui;
  109394. /**
  109395. * The name of the behavior
  109396. */
  109397. name: string;
  109398. /**
  109399. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  109400. */
  109401. distanceAwayFromFace: number;
  109402. /**
  109403. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  109404. */
  109405. distanceAwayFromBottomOfFace: number;
  109406. private _faceVectors;
  109407. private _target;
  109408. private _scene;
  109409. private _onRenderObserver;
  109410. private _tmpMatrix;
  109411. private _tmpVector;
  109412. /**
  109413. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  109414. * @param ui The transform node that should be attched to the mesh
  109415. */
  109416. constructor(ui: TransformNode);
  109417. /**
  109418. * Initializes the behavior
  109419. */
  109420. init(): void;
  109421. private _closestFace;
  109422. private _zeroVector;
  109423. private _lookAtTmpMatrix;
  109424. private _lookAtToRef;
  109425. /**
  109426. * Attaches the AttachToBoxBehavior to the passed in mesh
  109427. * @param target The mesh that the specified node will be attached to
  109428. */
  109429. attach(target: Mesh): void;
  109430. /**
  109431. * Detaches the behavior from the mesh
  109432. */
  109433. detach(): void;
  109434. }
  109435. }
  109436. declare module BABYLON {
  109437. /**
  109438. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  109439. */
  109440. export class FadeInOutBehavior implements Behavior<Mesh> {
  109441. /**
  109442. * Time in milliseconds to delay before fading in (Default: 0)
  109443. */
  109444. delay: number;
  109445. /**
  109446. * Time in milliseconds for the mesh to fade in (Default: 300)
  109447. */
  109448. fadeInTime: number;
  109449. private _millisecondsPerFrame;
  109450. private _hovered;
  109451. private _hoverValue;
  109452. private _ownerNode;
  109453. /**
  109454. * Instatiates the FadeInOutBehavior
  109455. */
  109456. constructor();
  109457. /**
  109458. * The name of the behavior
  109459. */
  109460. get name(): string;
  109461. /**
  109462. * Initializes the behavior
  109463. */
  109464. init(): void;
  109465. /**
  109466. * Attaches the fade behavior on the passed in mesh
  109467. * @param ownerNode The mesh that will be faded in/out once attached
  109468. */
  109469. attach(ownerNode: Mesh): void;
  109470. /**
  109471. * Detaches the behavior from the mesh
  109472. */
  109473. detach(): void;
  109474. /**
  109475. * Triggers the mesh to begin fading in or out
  109476. * @param value if the object should fade in or out (true to fade in)
  109477. */
  109478. fadeIn(value: boolean): void;
  109479. private _update;
  109480. private _setAllVisibility;
  109481. }
  109482. }
  109483. declare module BABYLON {
  109484. /**
  109485. * Class containing a set of static utilities functions for managing Pivots
  109486. * @hidden
  109487. */
  109488. export class PivotTools {
  109489. private static _PivotCached;
  109490. private static _OldPivotPoint;
  109491. private static _PivotTranslation;
  109492. private static _PivotTmpVector;
  109493. /** @hidden */
  109494. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  109495. /** @hidden */
  109496. static _RestorePivotPoint(mesh: AbstractMesh): void;
  109497. }
  109498. }
  109499. declare module BABYLON {
  109500. /**
  109501. * Class containing static functions to help procedurally build meshes
  109502. */
  109503. export class PlaneBuilder {
  109504. /**
  109505. * Creates a plane mesh
  109506. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  109507. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  109508. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  109509. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109510. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109512. * @param name defines the name of the mesh
  109513. * @param options defines the options used to create the mesh
  109514. * @param scene defines the hosting scene
  109515. * @returns the plane mesh
  109516. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  109517. */
  109518. static CreatePlane(name: string, options: {
  109519. size?: number;
  109520. width?: number;
  109521. height?: number;
  109522. sideOrientation?: number;
  109523. frontUVs?: Vector4;
  109524. backUVs?: Vector4;
  109525. updatable?: boolean;
  109526. sourcePlane?: Plane;
  109527. }, scene?: Nullable<Scene>): Mesh;
  109528. }
  109529. }
  109530. declare module BABYLON {
  109531. /**
  109532. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  109533. */
  109534. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  109535. private static _AnyMouseID;
  109536. /**
  109537. * Abstract mesh the behavior is set on
  109538. */
  109539. attachedNode: AbstractMesh;
  109540. private _dragPlane;
  109541. private _scene;
  109542. private _pointerObserver;
  109543. private _beforeRenderObserver;
  109544. private static _planeScene;
  109545. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  109546. /**
  109547. * 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)
  109548. */
  109549. maxDragAngle: number;
  109550. /**
  109551. * @hidden
  109552. */
  109553. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  109554. /**
  109555. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  109556. */
  109557. currentDraggingPointerID: number;
  109558. /**
  109559. * The last position where the pointer hit the drag plane in world space
  109560. */
  109561. lastDragPosition: Vector3;
  109562. /**
  109563. * If the behavior is currently in a dragging state
  109564. */
  109565. dragging: boolean;
  109566. /**
  109567. * 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)
  109568. */
  109569. dragDeltaRatio: number;
  109570. /**
  109571. * If the drag plane orientation should be updated during the dragging (Default: true)
  109572. */
  109573. updateDragPlane: boolean;
  109574. private _debugMode;
  109575. private _moving;
  109576. /**
  109577. * Fires each time the attached mesh is dragged with the pointer
  109578. * * delta between last drag position and current drag position in world space
  109579. * * dragDistance along the drag axis
  109580. * * dragPlaneNormal normal of the current drag plane used during the drag
  109581. * * dragPlanePoint in world space where the drag intersects the drag plane
  109582. */
  109583. onDragObservable: Observable<{
  109584. delta: Vector3;
  109585. dragPlanePoint: Vector3;
  109586. dragPlaneNormal: Vector3;
  109587. dragDistance: number;
  109588. pointerId: number;
  109589. }>;
  109590. /**
  109591. * Fires each time a drag begins (eg. mouse down on mesh)
  109592. */
  109593. onDragStartObservable: Observable<{
  109594. dragPlanePoint: Vector3;
  109595. pointerId: number;
  109596. }>;
  109597. /**
  109598. * Fires each time a drag ends (eg. mouse release after drag)
  109599. */
  109600. onDragEndObservable: Observable<{
  109601. dragPlanePoint: Vector3;
  109602. pointerId: number;
  109603. }>;
  109604. /**
  109605. * If the attached mesh should be moved when dragged
  109606. */
  109607. moveAttached: boolean;
  109608. /**
  109609. * If the drag behavior will react to drag events (Default: true)
  109610. */
  109611. enabled: boolean;
  109612. /**
  109613. * If pointer events should start and release the drag (Default: true)
  109614. */
  109615. startAndReleaseDragOnPointerEvents: boolean;
  109616. /**
  109617. * If camera controls should be detached during the drag
  109618. */
  109619. detachCameraControls: boolean;
  109620. /**
  109621. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  109622. */
  109623. useObjectOrientationForDragging: boolean;
  109624. private _options;
  109625. /**
  109626. * Gets the options used by the behavior
  109627. */
  109628. get options(): {
  109629. dragAxis?: Vector3;
  109630. dragPlaneNormal?: Vector3;
  109631. };
  109632. /**
  109633. * Sets the options used by the behavior
  109634. */
  109635. set options(options: {
  109636. dragAxis?: Vector3;
  109637. dragPlaneNormal?: Vector3;
  109638. });
  109639. /**
  109640. * Creates a pointer drag behavior that can be attached to a mesh
  109641. * @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)
  109642. */
  109643. constructor(options?: {
  109644. dragAxis?: Vector3;
  109645. dragPlaneNormal?: Vector3;
  109646. });
  109647. /**
  109648. * Predicate to determine if it is valid to move the object to a new position when it is moved
  109649. */
  109650. validateDrag: (targetPosition: Vector3) => boolean;
  109651. /**
  109652. * The name of the behavior
  109653. */
  109654. get name(): string;
  109655. /**
  109656. * Initializes the behavior
  109657. */
  109658. init(): void;
  109659. private _tmpVector;
  109660. private _alternatePickedPoint;
  109661. private _worldDragAxis;
  109662. private _targetPosition;
  109663. private _attachedElement;
  109664. /**
  109665. * Attaches the drag behavior the passed in mesh
  109666. * @param ownerNode The mesh that will be dragged around once attached
  109667. * @param predicate Predicate to use for pick filtering
  109668. */
  109669. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  109670. /**
  109671. * Force relase the drag action by code.
  109672. */
  109673. releaseDrag(): void;
  109674. private _startDragRay;
  109675. private _lastPointerRay;
  109676. /**
  109677. * Simulates the start of a pointer drag event on the behavior
  109678. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  109679. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  109680. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  109681. */
  109682. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  109683. private _startDrag;
  109684. private _dragDelta;
  109685. private _moveDrag;
  109686. private _pickWithRayOnDragPlane;
  109687. private _pointA;
  109688. private _pointB;
  109689. private _pointC;
  109690. private _lineA;
  109691. private _lineB;
  109692. private _localAxis;
  109693. private _lookAt;
  109694. private _updateDragPlanePosition;
  109695. /**
  109696. * Detaches the behavior from the mesh
  109697. */
  109698. detach(): void;
  109699. }
  109700. }
  109701. declare module BABYLON {
  109702. /**
  109703. * A behavior that when attached to a mesh will allow the mesh to be scaled
  109704. */
  109705. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  109706. private _dragBehaviorA;
  109707. private _dragBehaviorB;
  109708. private _startDistance;
  109709. private _initialScale;
  109710. private _targetScale;
  109711. private _ownerNode;
  109712. private _sceneRenderObserver;
  109713. /**
  109714. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  109715. */
  109716. constructor();
  109717. /**
  109718. * The name of the behavior
  109719. */
  109720. get name(): string;
  109721. /**
  109722. * Initializes the behavior
  109723. */
  109724. init(): void;
  109725. private _getCurrentDistance;
  109726. /**
  109727. * Attaches the scale behavior the passed in mesh
  109728. * @param ownerNode The mesh that will be scaled around once attached
  109729. */
  109730. attach(ownerNode: Mesh): void;
  109731. /**
  109732. * Detaches the behavior from the mesh
  109733. */
  109734. detach(): void;
  109735. }
  109736. }
  109737. declare module BABYLON {
  109738. /**
  109739. * 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
  109740. */
  109741. export class SixDofDragBehavior implements Behavior<Mesh> {
  109742. private static _virtualScene;
  109743. private _ownerNode;
  109744. private _sceneRenderObserver;
  109745. private _scene;
  109746. private _targetPosition;
  109747. private _virtualOriginMesh;
  109748. private _virtualDragMesh;
  109749. private _pointerObserver;
  109750. private _moving;
  109751. private _startingOrientation;
  109752. /**
  109753. * 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)
  109754. */
  109755. private zDragFactor;
  109756. /**
  109757. * If the object should rotate to face the drag origin
  109758. */
  109759. rotateDraggedObject: boolean;
  109760. /**
  109761. * If the behavior is currently in a dragging state
  109762. */
  109763. dragging: boolean;
  109764. /**
  109765. * 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)
  109766. */
  109767. dragDeltaRatio: number;
  109768. /**
  109769. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  109770. */
  109771. currentDraggingPointerID: number;
  109772. /**
  109773. * If camera controls should be detached during the drag
  109774. */
  109775. detachCameraControls: boolean;
  109776. /**
  109777. * Fires each time a drag starts
  109778. */
  109779. onDragStartObservable: Observable<{}>;
  109780. /**
  109781. * Fires each time a drag ends (eg. mouse release after drag)
  109782. */
  109783. onDragEndObservable: Observable<{}>;
  109784. /**
  109785. * 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
  109786. */
  109787. constructor();
  109788. /**
  109789. * The name of the behavior
  109790. */
  109791. get name(): string;
  109792. /**
  109793. * Initializes the behavior
  109794. */
  109795. init(): void;
  109796. /**
  109797. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  109798. */
  109799. private get _pointerCamera();
  109800. /**
  109801. * Attaches the scale behavior the passed in mesh
  109802. * @param ownerNode The mesh that will be scaled around once attached
  109803. */
  109804. attach(ownerNode: Mesh): void;
  109805. /**
  109806. * Detaches the behavior from the mesh
  109807. */
  109808. detach(): void;
  109809. }
  109810. }
  109811. declare module BABYLON {
  109812. /**
  109813. * Class used to apply inverse kinematics to bones
  109814. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  109815. */
  109816. export class BoneIKController {
  109817. private static _tmpVecs;
  109818. private static _tmpQuat;
  109819. private static _tmpMats;
  109820. /**
  109821. * Gets or sets the target mesh
  109822. */
  109823. targetMesh: AbstractMesh;
  109824. /** Gets or sets the mesh used as pole */
  109825. poleTargetMesh: AbstractMesh;
  109826. /**
  109827. * Gets or sets the bone used as pole
  109828. */
  109829. poleTargetBone: Nullable<Bone>;
  109830. /**
  109831. * Gets or sets the target position
  109832. */
  109833. targetPosition: Vector3;
  109834. /**
  109835. * Gets or sets the pole target position
  109836. */
  109837. poleTargetPosition: Vector3;
  109838. /**
  109839. * Gets or sets the pole target local offset
  109840. */
  109841. poleTargetLocalOffset: Vector3;
  109842. /**
  109843. * Gets or sets the pole angle
  109844. */
  109845. poleAngle: number;
  109846. /**
  109847. * Gets or sets the mesh associated with the controller
  109848. */
  109849. mesh: AbstractMesh;
  109850. /**
  109851. * 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)
  109852. */
  109853. slerpAmount: number;
  109854. private _bone1Quat;
  109855. private _bone1Mat;
  109856. private _bone2Ang;
  109857. private _bone1;
  109858. private _bone2;
  109859. private _bone1Length;
  109860. private _bone2Length;
  109861. private _maxAngle;
  109862. private _maxReach;
  109863. private _rightHandedSystem;
  109864. private _bendAxis;
  109865. private _slerping;
  109866. private _adjustRoll;
  109867. /**
  109868. * Gets or sets maximum allowed angle
  109869. */
  109870. get maxAngle(): number;
  109871. set maxAngle(value: number);
  109872. /**
  109873. * Creates a new BoneIKController
  109874. * @param mesh defines the mesh to control
  109875. * @param bone defines the bone to control
  109876. * @param options defines options to set up the controller
  109877. */
  109878. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  109879. targetMesh?: AbstractMesh;
  109880. poleTargetMesh?: AbstractMesh;
  109881. poleTargetBone?: Bone;
  109882. poleTargetLocalOffset?: Vector3;
  109883. poleAngle?: number;
  109884. bendAxis?: Vector3;
  109885. maxAngle?: number;
  109886. slerpAmount?: number;
  109887. });
  109888. private _setMaxAngle;
  109889. /**
  109890. * Force the controller to update the bones
  109891. */
  109892. update(): void;
  109893. }
  109894. }
  109895. declare module BABYLON {
  109896. /**
  109897. * Class used to make a bone look toward a point in space
  109898. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  109899. */
  109900. export class BoneLookController {
  109901. private static _tmpVecs;
  109902. private static _tmpQuat;
  109903. private static _tmpMats;
  109904. /**
  109905. * The target Vector3 that the bone will look at
  109906. */
  109907. target: Vector3;
  109908. /**
  109909. * The mesh that the bone is attached to
  109910. */
  109911. mesh: AbstractMesh;
  109912. /**
  109913. * The bone that will be looking to the target
  109914. */
  109915. bone: Bone;
  109916. /**
  109917. * The up axis of the coordinate system that is used when the bone is rotated
  109918. */
  109919. upAxis: Vector3;
  109920. /**
  109921. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  109922. */
  109923. upAxisSpace: Space;
  109924. /**
  109925. * Used to make an adjustment to the yaw of the bone
  109926. */
  109927. adjustYaw: number;
  109928. /**
  109929. * Used to make an adjustment to the pitch of the bone
  109930. */
  109931. adjustPitch: number;
  109932. /**
  109933. * Used to make an adjustment to the roll of the bone
  109934. */
  109935. adjustRoll: number;
  109936. /**
  109937. * 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)
  109938. */
  109939. slerpAmount: number;
  109940. private _minYaw;
  109941. private _maxYaw;
  109942. private _minPitch;
  109943. private _maxPitch;
  109944. private _minYawSin;
  109945. private _minYawCos;
  109946. private _maxYawSin;
  109947. private _maxYawCos;
  109948. private _midYawConstraint;
  109949. private _minPitchTan;
  109950. private _maxPitchTan;
  109951. private _boneQuat;
  109952. private _slerping;
  109953. private _transformYawPitch;
  109954. private _transformYawPitchInv;
  109955. private _firstFrameSkipped;
  109956. private _yawRange;
  109957. private _fowardAxis;
  109958. /**
  109959. * Gets or sets the minimum yaw angle that the bone can look to
  109960. */
  109961. get minYaw(): number;
  109962. set minYaw(value: number);
  109963. /**
  109964. * Gets or sets the maximum yaw angle that the bone can look to
  109965. */
  109966. get maxYaw(): number;
  109967. set maxYaw(value: number);
  109968. /**
  109969. * Gets or sets the minimum pitch angle that the bone can look to
  109970. */
  109971. get minPitch(): number;
  109972. set minPitch(value: number);
  109973. /**
  109974. * Gets or sets the maximum pitch angle that the bone can look to
  109975. */
  109976. get maxPitch(): number;
  109977. set maxPitch(value: number);
  109978. /**
  109979. * Create a BoneLookController
  109980. * @param mesh the mesh that the bone belongs to
  109981. * @param bone the bone that will be looking to the target
  109982. * @param target the target Vector3 to look at
  109983. * @param options optional settings:
  109984. * * maxYaw: the maximum angle the bone will yaw to
  109985. * * minYaw: the minimum angle the bone will yaw to
  109986. * * maxPitch: the maximum angle the bone will pitch to
  109987. * * minPitch: the minimum angle the bone will yaw to
  109988. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  109989. * * upAxis: the up axis of the coordinate system
  109990. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  109991. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  109992. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  109993. * * adjustYaw: used to make an adjustment to the yaw of the bone
  109994. * * adjustPitch: used to make an adjustment to the pitch of the bone
  109995. * * adjustRoll: used to make an adjustment to the roll of the bone
  109996. **/
  109997. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  109998. maxYaw?: number;
  109999. minYaw?: number;
  110000. maxPitch?: number;
  110001. minPitch?: number;
  110002. slerpAmount?: number;
  110003. upAxis?: Vector3;
  110004. upAxisSpace?: Space;
  110005. yawAxis?: Vector3;
  110006. pitchAxis?: Vector3;
  110007. adjustYaw?: number;
  110008. adjustPitch?: number;
  110009. adjustRoll?: number;
  110010. });
  110011. /**
  110012. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  110013. */
  110014. update(): void;
  110015. private _getAngleDiff;
  110016. private _getAngleBetween;
  110017. private _isAngleBetween;
  110018. }
  110019. }
  110020. declare module BABYLON {
  110021. /**
  110022. * Manage the gamepad inputs to control an arc rotate camera.
  110023. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110024. */
  110025. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  110026. /**
  110027. * Defines the camera the input is attached to.
  110028. */
  110029. camera: ArcRotateCamera;
  110030. /**
  110031. * Defines the gamepad the input is gathering event from.
  110032. */
  110033. gamepad: Nullable<Gamepad>;
  110034. /**
  110035. * Defines the gamepad rotation sensiblity.
  110036. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  110037. */
  110038. gamepadRotationSensibility: number;
  110039. /**
  110040. * Defines the gamepad move sensiblity.
  110041. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  110042. */
  110043. gamepadMoveSensibility: number;
  110044. private _yAxisScale;
  110045. /**
  110046. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  110047. */
  110048. get invertYAxis(): boolean;
  110049. set invertYAxis(value: boolean);
  110050. private _onGamepadConnectedObserver;
  110051. private _onGamepadDisconnectedObserver;
  110052. /**
  110053. * Attach the input controls to a specific dom element to get the input from.
  110054. * @param element Defines the element the controls should be listened from
  110055. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110056. */
  110057. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110058. /**
  110059. * Detach the current controls from the specified dom element.
  110060. * @param element Defines the element to stop listening the inputs from
  110061. */
  110062. detachControl(element: Nullable<HTMLElement>): void;
  110063. /**
  110064. * Update the current camera state depending on the inputs that have been used this frame.
  110065. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110066. */
  110067. checkInputs(): void;
  110068. /**
  110069. * Gets the class name of the current intput.
  110070. * @returns the class name
  110071. */
  110072. getClassName(): string;
  110073. /**
  110074. * Get the friendly name associated with the input class.
  110075. * @returns the input friendly name
  110076. */
  110077. getSimpleName(): string;
  110078. }
  110079. }
  110080. declare module BABYLON {
  110081. interface ArcRotateCameraInputsManager {
  110082. /**
  110083. * Add orientation input support to the input manager.
  110084. * @returns the current input manager
  110085. */
  110086. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  110087. }
  110088. /**
  110089. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  110090. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110091. */
  110092. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  110093. /**
  110094. * Defines the camera the input is attached to.
  110095. */
  110096. camera: ArcRotateCamera;
  110097. /**
  110098. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  110099. */
  110100. alphaCorrection: number;
  110101. /**
  110102. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  110103. */
  110104. gammaCorrection: number;
  110105. private _alpha;
  110106. private _gamma;
  110107. private _dirty;
  110108. private _deviceOrientationHandler;
  110109. /**
  110110. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  110111. */
  110112. constructor();
  110113. /**
  110114. * Attach the input controls to a specific dom element to get the input from.
  110115. * @param element Defines the element the controls should be listened from
  110116. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110117. */
  110118. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110119. /** @hidden */
  110120. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  110121. /**
  110122. * Update the current camera state depending on the inputs that have been used this frame.
  110123. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110124. */
  110125. checkInputs(): void;
  110126. /**
  110127. * Detach the current controls from the specified dom element.
  110128. * @param element Defines the element to stop listening the inputs from
  110129. */
  110130. detachControl(element: Nullable<HTMLElement>): void;
  110131. /**
  110132. * Gets the class name of the current intput.
  110133. * @returns the class name
  110134. */
  110135. getClassName(): string;
  110136. /**
  110137. * Get the friendly name associated with the input class.
  110138. * @returns the input friendly name
  110139. */
  110140. getSimpleName(): string;
  110141. }
  110142. }
  110143. declare module BABYLON {
  110144. /**
  110145. * Listen to mouse events to control the camera.
  110146. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110147. */
  110148. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  110149. /**
  110150. * Defines the camera the input is attached to.
  110151. */
  110152. camera: FlyCamera;
  110153. /**
  110154. * Defines if touch is enabled. (Default is true.)
  110155. */
  110156. touchEnabled: boolean;
  110157. /**
  110158. * Defines the buttons associated with the input to handle camera rotation.
  110159. */
  110160. buttons: number[];
  110161. /**
  110162. * Assign buttons for Yaw control.
  110163. */
  110164. buttonsYaw: number[];
  110165. /**
  110166. * Assign buttons for Pitch control.
  110167. */
  110168. buttonsPitch: number[];
  110169. /**
  110170. * Assign buttons for Roll control.
  110171. */
  110172. buttonsRoll: number[];
  110173. /**
  110174. * Detect if any button is being pressed while mouse is moved.
  110175. * -1 = Mouse locked.
  110176. * 0 = Left button.
  110177. * 1 = Middle Button.
  110178. * 2 = Right Button.
  110179. */
  110180. activeButton: number;
  110181. /**
  110182. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  110183. * Higher values reduce its sensitivity.
  110184. */
  110185. angularSensibility: number;
  110186. private _mousemoveCallback;
  110187. private _observer;
  110188. private _rollObserver;
  110189. private previousPosition;
  110190. private noPreventDefault;
  110191. private element;
  110192. /**
  110193. * Listen to mouse events to control the camera.
  110194. * @param touchEnabled Define if touch is enabled. (Default is true.)
  110195. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110196. */
  110197. constructor(touchEnabled?: boolean);
  110198. /**
  110199. * Attach the mouse control to the HTML DOM element.
  110200. * @param element Defines the element that listens to the input events.
  110201. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  110202. */
  110203. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110204. /**
  110205. * Detach the current controls from the specified dom element.
  110206. * @param element Defines the element to stop listening the inputs from
  110207. */
  110208. detachControl(element: Nullable<HTMLElement>): void;
  110209. /**
  110210. * Gets the class name of the current input.
  110211. * @returns the class name.
  110212. */
  110213. getClassName(): string;
  110214. /**
  110215. * Get the friendly name associated with the input class.
  110216. * @returns the input's friendly name.
  110217. */
  110218. getSimpleName(): string;
  110219. private _pointerInput;
  110220. private _onMouseMove;
  110221. /**
  110222. * Rotate camera by mouse offset.
  110223. */
  110224. private rotateCamera;
  110225. }
  110226. }
  110227. declare module BABYLON {
  110228. /**
  110229. * Default Inputs manager for the FlyCamera.
  110230. * It groups all the default supported inputs for ease of use.
  110231. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110232. */
  110233. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  110234. /**
  110235. * Instantiates a new FlyCameraInputsManager.
  110236. * @param camera Defines the camera the inputs belong to.
  110237. */
  110238. constructor(camera: FlyCamera);
  110239. /**
  110240. * Add keyboard input support to the input manager.
  110241. * @returns the new FlyCameraKeyboardMoveInput().
  110242. */
  110243. addKeyboard(): FlyCameraInputsManager;
  110244. /**
  110245. * Add mouse input support to the input manager.
  110246. * @param touchEnabled Enable touch screen support.
  110247. * @returns the new FlyCameraMouseInput().
  110248. */
  110249. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  110250. }
  110251. }
  110252. declare module BABYLON {
  110253. /**
  110254. * This is a flying camera, designed for 3D movement and rotation in all directions,
  110255. * such as in a 3D Space Shooter or a Flight Simulator.
  110256. */
  110257. export class FlyCamera extends TargetCamera {
  110258. /**
  110259. * Define the collision ellipsoid of the camera.
  110260. * This is helpful for simulating a camera body, like a player's body.
  110261. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  110262. */
  110263. ellipsoid: Vector3;
  110264. /**
  110265. * Define an offset for the position of the ellipsoid around the camera.
  110266. * This can be helpful if the camera is attached away from the player's body center,
  110267. * such as at its head.
  110268. */
  110269. ellipsoidOffset: Vector3;
  110270. /**
  110271. * Enable or disable collisions of the camera with the rest of the scene objects.
  110272. */
  110273. checkCollisions: boolean;
  110274. /**
  110275. * Enable or disable gravity on the camera.
  110276. */
  110277. applyGravity: boolean;
  110278. /**
  110279. * Define the current direction the camera is moving to.
  110280. */
  110281. cameraDirection: Vector3;
  110282. /**
  110283. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  110284. * This overrides and empties cameraRotation.
  110285. */
  110286. rotationQuaternion: Quaternion;
  110287. /**
  110288. * Track Roll to maintain the wanted Rolling when looking around.
  110289. */
  110290. _trackRoll: number;
  110291. /**
  110292. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  110293. */
  110294. rollCorrect: number;
  110295. /**
  110296. * Mimic a banked turn, Rolling the camera when Yawing.
  110297. * It's recommended to use rollCorrect = 10 for faster banking correction.
  110298. */
  110299. bankedTurn: boolean;
  110300. /**
  110301. * Limit in radians for how much Roll banking will add. (Default: 90°)
  110302. */
  110303. bankedTurnLimit: number;
  110304. /**
  110305. * Value of 0 disables the banked Roll.
  110306. * Value of 1 is equal to the Yaw angle in radians.
  110307. */
  110308. bankedTurnMultiplier: number;
  110309. /**
  110310. * The inputs manager loads all the input sources, such as keyboard and mouse.
  110311. */
  110312. inputs: FlyCameraInputsManager;
  110313. /**
  110314. * Gets the input sensibility for mouse input.
  110315. * Higher values reduce sensitivity.
  110316. */
  110317. get angularSensibility(): number;
  110318. /**
  110319. * Sets the input sensibility for a mouse input.
  110320. * Higher values reduce sensitivity.
  110321. */
  110322. set angularSensibility(value: number);
  110323. /**
  110324. * Get the keys for camera movement forward.
  110325. */
  110326. get keysForward(): number[];
  110327. /**
  110328. * Set the keys for camera movement forward.
  110329. */
  110330. set keysForward(value: number[]);
  110331. /**
  110332. * Get the keys for camera movement backward.
  110333. */
  110334. get keysBackward(): number[];
  110335. set keysBackward(value: number[]);
  110336. /**
  110337. * Get the keys for camera movement up.
  110338. */
  110339. get keysUp(): number[];
  110340. /**
  110341. * Set the keys for camera movement up.
  110342. */
  110343. set keysUp(value: number[]);
  110344. /**
  110345. * Get the keys for camera movement down.
  110346. */
  110347. get keysDown(): number[];
  110348. /**
  110349. * Set the keys for camera movement down.
  110350. */
  110351. set keysDown(value: number[]);
  110352. /**
  110353. * Get the keys for camera movement left.
  110354. */
  110355. get keysLeft(): number[];
  110356. /**
  110357. * Set the keys for camera movement left.
  110358. */
  110359. set keysLeft(value: number[]);
  110360. /**
  110361. * Set the keys for camera movement right.
  110362. */
  110363. get keysRight(): number[];
  110364. /**
  110365. * Set the keys for camera movement right.
  110366. */
  110367. set keysRight(value: number[]);
  110368. /**
  110369. * Event raised when the camera collides with a mesh in the scene.
  110370. */
  110371. onCollide: (collidedMesh: AbstractMesh) => void;
  110372. private _collider;
  110373. private _needMoveForGravity;
  110374. private _oldPosition;
  110375. private _diffPosition;
  110376. private _newPosition;
  110377. /** @hidden */
  110378. _localDirection: Vector3;
  110379. /** @hidden */
  110380. _transformedDirection: Vector3;
  110381. /**
  110382. * Instantiates a FlyCamera.
  110383. * This is a flying camera, designed for 3D movement and rotation in all directions,
  110384. * such as in a 3D Space Shooter or a Flight Simulator.
  110385. * @param name Define the name of the camera in the scene.
  110386. * @param position Define the starting position of the camera in the scene.
  110387. * @param scene Define the scene the camera belongs to.
  110388. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  110389. */
  110390. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  110391. /**
  110392. * Attach a control to the HTML DOM element.
  110393. * @param element Defines the element that listens to the input events.
  110394. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  110395. */
  110396. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110397. /**
  110398. * Detach a control from the HTML DOM element.
  110399. * The camera will stop reacting to that input.
  110400. * @param element Defines the element that listens to the input events.
  110401. */
  110402. detachControl(element: HTMLElement): void;
  110403. private _collisionMask;
  110404. /**
  110405. * Get the mask that the camera ignores in collision events.
  110406. */
  110407. get collisionMask(): number;
  110408. /**
  110409. * Set the mask that the camera ignores in collision events.
  110410. */
  110411. set collisionMask(mask: number);
  110412. /** @hidden */
  110413. _collideWithWorld(displacement: Vector3): void;
  110414. /** @hidden */
  110415. private _onCollisionPositionChange;
  110416. /** @hidden */
  110417. _checkInputs(): void;
  110418. /** @hidden */
  110419. _decideIfNeedsToMove(): boolean;
  110420. /** @hidden */
  110421. _updatePosition(): void;
  110422. /**
  110423. * Restore the Roll to its target value at the rate specified.
  110424. * @param rate - Higher means slower restoring.
  110425. * @hidden
  110426. */
  110427. restoreRoll(rate: number): void;
  110428. /**
  110429. * Destroy the camera and release the current resources held by it.
  110430. */
  110431. dispose(): void;
  110432. /**
  110433. * Get the current object class name.
  110434. * @returns the class name.
  110435. */
  110436. getClassName(): string;
  110437. }
  110438. }
  110439. declare module BABYLON {
  110440. /**
  110441. * Listen to keyboard events to control the camera.
  110442. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110443. */
  110444. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  110445. /**
  110446. * Defines the camera the input is attached to.
  110447. */
  110448. camera: FlyCamera;
  110449. /**
  110450. * The list of keyboard keys used to control the forward move of the camera.
  110451. */
  110452. keysForward: number[];
  110453. /**
  110454. * The list of keyboard keys used to control the backward move of the camera.
  110455. */
  110456. keysBackward: number[];
  110457. /**
  110458. * The list of keyboard keys used to control the forward move of the camera.
  110459. */
  110460. keysUp: number[];
  110461. /**
  110462. * The list of keyboard keys used to control the backward move of the camera.
  110463. */
  110464. keysDown: number[];
  110465. /**
  110466. * The list of keyboard keys used to control the right strafe move of the camera.
  110467. */
  110468. keysRight: number[];
  110469. /**
  110470. * The list of keyboard keys used to control the left strafe move of the camera.
  110471. */
  110472. keysLeft: number[];
  110473. private _keys;
  110474. private _onCanvasBlurObserver;
  110475. private _onKeyboardObserver;
  110476. private _engine;
  110477. private _scene;
  110478. /**
  110479. * Attach the input controls to a specific dom element to get the input from.
  110480. * @param element Defines the element the controls should be listened from
  110481. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110482. */
  110483. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110484. /**
  110485. * Detach the current controls from the specified dom element.
  110486. * @param element Defines the element to stop listening the inputs from
  110487. */
  110488. detachControl(element: Nullable<HTMLElement>): void;
  110489. /**
  110490. * Gets the class name of the current intput.
  110491. * @returns the class name
  110492. */
  110493. getClassName(): string;
  110494. /** @hidden */
  110495. _onLostFocus(e: FocusEvent): void;
  110496. /**
  110497. * Get the friendly name associated with the input class.
  110498. * @returns the input friendly name
  110499. */
  110500. getSimpleName(): string;
  110501. /**
  110502. * Update the current camera state depending on the inputs that have been used this frame.
  110503. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110504. */
  110505. checkInputs(): void;
  110506. }
  110507. }
  110508. declare module BABYLON {
  110509. /**
  110510. * Manage the mouse wheel inputs to control a follow camera.
  110511. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110512. */
  110513. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  110514. /**
  110515. * Defines the camera the input is attached to.
  110516. */
  110517. camera: FollowCamera;
  110518. /**
  110519. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  110520. */
  110521. axisControlRadius: boolean;
  110522. /**
  110523. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  110524. */
  110525. axisControlHeight: boolean;
  110526. /**
  110527. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  110528. */
  110529. axisControlRotation: boolean;
  110530. /**
  110531. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  110532. * relation to mouseWheel events.
  110533. */
  110534. wheelPrecision: number;
  110535. /**
  110536. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  110537. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  110538. */
  110539. wheelDeltaPercentage: number;
  110540. private _wheel;
  110541. private _observer;
  110542. /**
  110543. * Attach the input controls to a specific dom element to get the input from.
  110544. * @param element Defines the element the controls should be listened from
  110545. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110546. */
  110547. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110548. /**
  110549. * Detach the current controls from the specified dom element.
  110550. * @param element Defines the element to stop listening the inputs from
  110551. */
  110552. detachControl(element: Nullable<HTMLElement>): void;
  110553. /**
  110554. * Gets the class name of the current intput.
  110555. * @returns the class name
  110556. */
  110557. getClassName(): string;
  110558. /**
  110559. * Get the friendly name associated with the input class.
  110560. * @returns the input friendly name
  110561. */
  110562. getSimpleName(): string;
  110563. }
  110564. }
  110565. declare module BABYLON {
  110566. /**
  110567. * Manage the pointers inputs to control an follow camera.
  110568. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110569. */
  110570. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  110571. /**
  110572. * Defines the camera the input is attached to.
  110573. */
  110574. camera: FollowCamera;
  110575. /**
  110576. * Gets the class name of the current input.
  110577. * @returns the class name
  110578. */
  110579. getClassName(): string;
  110580. /**
  110581. * Defines the pointer angular sensibility along the X axis or how fast is
  110582. * the camera rotating.
  110583. * A negative number will reverse the axis direction.
  110584. */
  110585. angularSensibilityX: number;
  110586. /**
  110587. * Defines the pointer angular sensibility along the Y axis or how fast is
  110588. * the camera rotating.
  110589. * A negative number will reverse the axis direction.
  110590. */
  110591. angularSensibilityY: number;
  110592. /**
  110593. * Defines the pointer pinch precision or how fast is the camera zooming.
  110594. * A negative number will reverse the axis direction.
  110595. */
  110596. pinchPrecision: number;
  110597. /**
  110598. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  110599. * from 0.
  110600. * It defines the percentage of current camera.radius to use as delta when
  110601. * pinch zoom is used.
  110602. */
  110603. pinchDeltaPercentage: number;
  110604. /**
  110605. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  110606. */
  110607. axisXControlRadius: boolean;
  110608. /**
  110609. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  110610. */
  110611. axisXControlHeight: boolean;
  110612. /**
  110613. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  110614. */
  110615. axisXControlRotation: boolean;
  110616. /**
  110617. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  110618. */
  110619. axisYControlRadius: boolean;
  110620. /**
  110621. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  110622. */
  110623. axisYControlHeight: boolean;
  110624. /**
  110625. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  110626. */
  110627. axisYControlRotation: boolean;
  110628. /**
  110629. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  110630. */
  110631. axisPinchControlRadius: boolean;
  110632. /**
  110633. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  110634. */
  110635. axisPinchControlHeight: boolean;
  110636. /**
  110637. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  110638. */
  110639. axisPinchControlRotation: boolean;
  110640. /**
  110641. * Log error messages if basic misconfiguration has occurred.
  110642. */
  110643. warningEnable: boolean;
  110644. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  110645. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  110646. private _warningCounter;
  110647. private _warning;
  110648. }
  110649. }
  110650. declare module BABYLON {
  110651. /**
  110652. * Default Inputs manager for the FollowCamera.
  110653. * It groups all the default supported inputs for ease of use.
  110654. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110655. */
  110656. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  110657. /**
  110658. * Instantiates a new FollowCameraInputsManager.
  110659. * @param camera Defines the camera the inputs belong to
  110660. */
  110661. constructor(camera: FollowCamera);
  110662. /**
  110663. * Add keyboard input support to the input manager.
  110664. * @returns the current input manager
  110665. */
  110666. addKeyboard(): FollowCameraInputsManager;
  110667. /**
  110668. * Add mouse wheel input support to the input manager.
  110669. * @returns the current input manager
  110670. */
  110671. addMouseWheel(): FollowCameraInputsManager;
  110672. /**
  110673. * Add pointers input support to the input manager.
  110674. * @returns the current input manager
  110675. */
  110676. addPointers(): FollowCameraInputsManager;
  110677. /**
  110678. * Add orientation input support to the input manager.
  110679. * @returns the current input manager
  110680. */
  110681. addVRDeviceOrientation(): FollowCameraInputsManager;
  110682. }
  110683. }
  110684. declare module BABYLON {
  110685. /**
  110686. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  110687. * an arc rotate version arcFollowCamera are available.
  110688. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  110689. */
  110690. export class FollowCamera extends TargetCamera {
  110691. /**
  110692. * Distance the follow camera should follow an object at
  110693. */
  110694. radius: number;
  110695. /**
  110696. * Minimum allowed distance of the camera to the axis of rotation
  110697. * (The camera can not get closer).
  110698. * This can help limiting how the Camera is able to move in the scene.
  110699. */
  110700. lowerRadiusLimit: Nullable<number>;
  110701. /**
  110702. * Maximum allowed distance of the camera to the axis of rotation
  110703. * (The camera can not get further).
  110704. * This can help limiting how the Camera is able to move in the scene.
  110705. */
  110706. upperRadiusLimit: Nullable<number>;
  110707. /**
  110708. * Define a rotation offset between the camera and the object it follows
  110709. */
  110710. rotationOffset: number;
  110711. /**
  110712. * Minimum allowed angle to camera position relative to target object.
  110713. * This can help limiting how the Camera is able to move in the scene.
  110714. */
  110715. lowerRotationOffsetLimit: Nullable<number>;
  110716. /**
  110717. * Maximum allowed angle to camera position relative to target object.
  110718. * This can help limiting how the Camera is able to move in the scene.
  110719. */
  110720. upperRotationOffsetLimit: Nullable<number>;
  110721. /**
  110722. * Define a height offset between the camera and the object it follows.
  110723. * It can help following an object from the top (like a car chaing a plane)
  110724. */
  110725. heightOffset: number;
  110726. /**
  110727. * Minimum allowed height of camera position relative to target object.
  110728. * This can help limiting how the Camera is able to move in the scene.
  110729. */
  110730. lowerHeightOffsetLimit: Nullable<number>;
  110731. /**
  110732. * Maximum allowed height of camera position relative to target object.
  110733. * This can help limiting how the Camera is able to move in the scene.
  110734. */
  110735. upperHeightOffsetLimit: Nullable<number>;
  110736. /**
  110737. * Define how fast the camera can accelerate to follow it s target.
  110738. */
  110739. cameraAcceleration: number;
  110740. /**
  110741. * Define the speed limit of the camera following an object.
  110742. */
  110743. maxCameraSpeed: number;
  110744. /**
  110745. * Define the target of the camera.
  110746. */
  110747. lockedTarget: Nullable<AbstractMesh>;
  110748. /**
  110749. * Defines the input associated with the camera.
  110750. */
  110751. inputs: FollowCameraInputsManager;
  110752. /**
  110753. * Instantiates the follow camera.
  110754. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  110755. * @param name Define the name of the camera in the scene
  110756. * @param position Define the position of the camera
  110757. * @param scene Define the scene the camera belong to
  110758. * @param lockedTarget Define the target of the camera
  110759. */
  110760. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  110761. private _follow;
  110762. /**
  110763. * Attached controls to the current camera.
  110764. * @param element Defines the element the controls should be listened from
  110765. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110766. */
  110767. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110768. /**
  110769. * Detach the current controls from the camera.
  110770. * The camera will stop reacting to inputs.
  110771. * @param element Defines the element to stop listening the inputs from
  110772. */
  110773. detachControl(element: HTMLElement): void;
  110774. /** @hidden */
  110775. _checkInputs(): void;
  110776. private _checkLimits;
  110777. /**
  110778. * Gets the camera class name.
  110779. * @returns the class name
  110780. */
  110781. getClassName(): string;
  110782. }
  110783. /**
  110784. * Arc Rotate version of the follow camera.
  110785. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  110786. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  110787. */
  110788. export class ArcFollowCamera extends TargetCamera {
  110789. /** The longitudinal angle of the camera */
  110790. alpha: number;
  110791. /** The latitudinal angle of the camera */
  110792. beta: number;
  110793. /** The radius of the camera from its target */
  110794. radius: number;
  110795. /** Define the camera target (the messh it should follow) */
  110796. target: Nullable<AbstractMesh>;
  110797. private _cartesianCoordinates;
  110798. /**
  110799. * Instantiates a new ArcFollowCamera
  110800. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  110801. * @param name Define the name of the camera
  110802. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  110803. * @param beta Define the rotation angle of the camera around the elevation axis
  110804. * @param radius Define the radius of the camera from its target point
  110805. * @param target Define the target of the camera
  110806. * @param scene Define the scene the camera belongs to
  110807. */
  110808. constructor(name: string,
  110809. /** The longitudinal angle of the camera */
  110810. alpha: number,
  110811. /** The latitudinal angle of the camera */
  110812. beta: number,
  110813. /** The radius of the camera from its target */
  110814. radius: number,
  110815. /** Define the camera target (the messh it should follow) */
  110816. target: Nullable<AbstractMesh>, scene: Scene);
  110817. private _follow;
  110818. /** @hidden */
  110819. _checkInputs(): void;
  110820. /**
  110821. * Returns the class name of the object.
  110822. * It is mostly used internally for serialization purposes.
  110823. */
  110824. getClassName(): string;
  110825. }
  110826. }
  110827. declare module BABYLON {
  110828. /**
  110829. * Manage the keyboard inputs to control the movement of a follow camera.
  110830. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110831. */
  110832. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  110833. /**
  110834. * Defines the camera the input is attached to.
  110835. */
  110836. camera: FollowCamera;
  110837. /**
  110838. * Defines the list of key codes associated with the up action (increase heightOffset)
  110839. */
  110840. keysHeightOffsetIncr: number[];
  110841. /**
  110842. * Defines the list of key codes associated with the down action (decrease heightOffset)
  110843. */
  110844. keysHeightOffsetDecr: number[];
  110845. /**
  110846. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  110847. */
  110848. keysHeightOffsetModifierAlt: boolean;
  110849. /**
  110850. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  110851. */
  110852. keysHeightOffsetModifierCtrl: boolean;
  110853. /**
  110854. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  110855. */
  110856. keysHeightOffsetModifierShift: boolean;
  110857. /**
  110858. * Defines the list of key codes associated with the left action (increase rotationOffset)
  110859. */
  110860. keysRotationOffsetIncr: number[];
  110861. /**
  110862. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  110863. */
  110864. keysRotationOffsetDecr: number[];
  110865. /**
  110866. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  110867. */
  110868. keysRotationOffsetModifierAlt: boolean;
  110869. /**
  110870. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  110871. */
  110872. keysRotationOffsetModifierCtrl: boolean;
  110873. /**
  110874. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  110875. */
  110876. keysRotationOffsetModifierShift: boolean;
  110877. /**
  110878. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  110879. */
  110880. keysRadiusIncr: number[];
  110881. /**
  110882. * Defines the list of key codes associated with the zoom-out action (increase radius)
  110883. */
  110884. keysRadiusDecr: number[];
  110885. /**
  110886. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  110887. */
  110888. keysRadiusModifierAlt: boolean;
  110889. /**
  110890. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  110891. */
  110892. keysRadiusModifierCtrl: boolean;
  110893. /**
  110894. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  110895. */
  110896. keysRadiusModifierShift: boolean;
  110897. /**
  110898. * Defines the rate of change of heightOffset.
  110899. */
  110900. heightSensibility: number;
  110901. /**
  110902. * Defines the rate of change of rotationOffset.
  110903. */
  110904. rotationSensibility: number;
  110905. /**
  110906. * Defines the rate of change of radius.
  110907. */
  110908. radiusSensibility: number;
  110909. private _keys;
  110910. private _ctrlPressed;
  110911. private _altPressed;
  110912. private _shiftPressed;
  110913. private _onCanvasBlurObserver;
  110914. private _onKeyboardObserver;
  110915. private _engine;
  110916. private _scene;
  110917. /**
  110918. * Attach the input controls to a specific dom element to get the input from.
  110919. * @param element Defines the element the controls should be listened from
  110920. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110921. */
  110922. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110923. /**
  110924. * Detach the current controls from the specified dom element.
  110925. * @param element Defines the element to stop listening the inputs from
  110926. */
  110927. detachControl(element: Nullable<HTMLElement>): void;
  110928. /**
  110929. * Update the current camera state depending on the inputs that have been used this frame.
  110930. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110931. */
  110932. checkInputs(): void;
  110933. /**
  110934. * Gets the class name of the current input.
  110935. * @returns the class name
  110936. */
  110937. getClassName(): string;
  110938. /**
  110939. * Get the friendly name associated with the input class.
  110940. * @returns the input friendly name
  110941. */
  110942. getSimpleName(): string;
  110943. /**
  110944. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  110945. * allow modification of the heightOffset value.
  110946. */
  110947. private _modifierHeightOffset;
  110948. /**
  110949. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  110950. * allow modification of the rotationOffset value.
  110951. */
  110952. private _modifierRotationOffset;
  110953. /**
  110954. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  110955. * allow modification of the radius value.
  110956. */
  110957. private _modifierRadius;
  110958. }
  110959. }
  110960. declare module BABYLON {
  110961. interface FreeCameraInputsManager {
  110962. /**
  110963. * @hidden
  110964. */
  110965. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  110966. /**
  110967. * Add orientation input support to the input manager.
  110968. * @returns the current input manager
  110969. */
  110970. addDeviceOrientation(): FreeCameraInputsManager;
  110971. }
  110972. /**
  110973. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  110974. * Screen rotation is taken into account.
  110975. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110976. */
  110977. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  110978. private _camera;
  110979. private _screenOrientationAngle;
  110980. private _constantTranform;
  110981. private _screenQuaternion;
  110982. private _alpha;
  110983. private _beta;
  110984. private _gamma;
  110985. /**
  110986. * Can be used to detect if a device orientation sensor is available on a device
  110987. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  110988. * @returns a promise that will resolve on orientation change
  110989. */
  110990. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  110991. /**
  110992. * @hidden
  110993. */
  110994. _onDeviceOrientationChangedObservable: Observable<void>;
  110995. /**
  110996. * Instantiates a new input
  110997. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110998. */
  110999. constructor();
  111000. /**
  111001. * Define the camera controlled by the input.
  111002. */
  111003. get camera(): FreeCamera;
  111004. set camera(camera: FreeCamera);
  111005. /**
  111006. * Attach the input controls to a specific dom element to get the input from.
  111007. * @param element Defines the element the controls should be listened from
  111008. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111009. */
  111010. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111011. private _orientationChanged;
  111012. private _deviceOrientation;
  111013. /**
  111014. * Detach the current controls from the specified dom element.
  111015. * @param element Defines the element to stop listening the inputs from
  111016. */
  111017. detachControl(element: Nullable<HTMLElement>): void;
  111018. /**
  111019. * Update the current camera state depending on the inputs that have been used this frame.
  111020. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111021. */
  111022. checkInputs(): void;
  111023. /**
  111024. * Gets the class name of the current intput.
  111025. * @returns the class name
  111026. */
  111027. getClassName(): string;
  111028. /**
  111029. * Get the friendly name associated with the input class.
  111030. * @returns the input friendly name
  111031. */
  111032. getSimpleName(): string;
  111033. }
  111034. }
  111035. declare module BABYLON {
  111036. /**
  111037. * Manage the gamepad inputs to control a free camera.
  111038. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111039. */
  111040. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  111041. /**
  111042. * Define the camera the input is attached to.
  111043. */
  111044. camera: FreeCamera;
  111045. /**
  111046. * Define the Gamepad controlling the input
  111047. */
  111048. gamepad: Nullable<Gamepad>;
  111049. /**
  111050. * Defines the gamepad rotation sensiblity.
  111051. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  111052. */
  111053. gamepadAngularSensibility: number;
  111054. /**
  111055. * Defines the gamepad move sensiblity.
  111056. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  111057. */
  111058. gamepadMoveSensibility: number;
  111059. private _yAxisScale;
  111060. /**
  111061. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  111062. */
  111063. get invertYAxis(): boolean;
  111064. set invertYAxis(value: boolean);
  111065. private _onGamepadConnectedObserver;
  111066. private _onGamepadDisconnectedObserver;
  111067. private _cameraTransform;
  111068. private _deltaTransform;
  111069. private _vector3;
  111070. private _vector2;
  111071. /**
  111072. * Attach the input controls to a specific dom element to get the input from.
  111073. * @param element Defines the element the controls should be listened from
  111074. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111075. */
  111076. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111077. /**
  111078. * Detach the current controls from the specified dom element.
  111079. * @param element Defines the element to stop listening the inputs from
  111080. */
  111081. detachControl(element: Nullable<HTMLElement>): void;
  111082. /**
  111083. * Update the current camera state depending on the inputs that have been used this frame.
  111084. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111085. */
  111086. checkInputs(): void;
  111087. /**
  111088. * Gets the class name of the current intput.
  111089. * @returns the class name
  111090. */
  111091. getClassName(): string;
  111092. /**
  111093. * Get the friendly name associated with the input class.
  111094. * @returns the input friendly name
  111095. */
  111096. getSimpleName(): string;
  111097. }
  111098. }
  111099. declare module BABYLON {
  111100. /**
  111101. * Defines the potential axis of a Joystick
  111102. */
  111103. export enum JoystickAxis {
  111104. /** X axis */
  111105. X = 0,
  111106. /** Y axis */
  111107. Y = 1,
  111108. /** Z axis */
  111109. Z = 2
  111110. }
  111111. /**
  111112. * Class used to define virtual joystick (used in touch mode)
  111113. */
  111114. export class VirtualJoystick {
  111115. /**
  111116. * Gets or sets a boolean indicating that left and right values must be inverted
  111117. */
  111118. reverseLeftRight: boolean;
  111119. /**
  111120. * Gets or sets a boolean indicating that up and down values must be inverted
  111121. */
  111122. reverseUpDown: boolean;
  111123. /**
  111124. * Gets the offset value for the position (ie. the change of the position value)
  111125. */
  111126. deltaPosition: Vector3;
  111127. /**
  111128. * Gets a boolean indicating if the virtual joystick was pressed
  111129. */
  111130. pressed: boolean;
  111131. /**
  111132. * Canvas the virtual joystick will render onto, default z-index of this is 5
  111133. */
  111134. static Canvas: Nullable<HTMLCanvasElement>;
  111135. private static _globalJoystickIndex;
  111136. private static vjCanvasContext;
  111137. private static vjCanvasWidth;
  111138. private static vjCanvasHeight;
  111139. private static halfWidth;
  111140. private _action;
  111141. private _axisTargetedByLeftAndRight;
  111142. private _axisTargetedByUpAndDown;
  111143. private _joystickSensibility;
  111144. private _inversedSensibility;
  111145. private _joystickPointerID;
  111146. private _joystickColor;
  111147. private _joystickPointerPos;
  111148. private _joystickPreviousPointerPos;
  111149. private _joystickPointerStartPos;
  111150. private _deltaJoystickVector;
  111151. private _leftJoystick;
  111152. private _touches;
  111153. private _onPointerDownHandlerRef;
  111154. private _onPointerMoveHandlerRef;
  111155. private _onPointerUpHandlerRef;
  111156. private _onResize;
  111157. /**
  111158. * Creates a new virtual joystick
  111159. * @param leftJoystick defines that the joystick is for left hand (false by default)
  111160. */
  111161. constructor(leftJoystick?: boolean);
  111162. /**
  111163. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  111164. * @param newJoystickSensibility defines the new sensibility
  111165. */
  111166. setJoystickSensibility(newJoystickSensibility: number): void;
  111167. private _onPointerDown;
  111168. private _onPointerMove;
  111169. private _onPointerUp;
  111170. /**
  111171. * Change the color of the virtual joystick
  111172. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  111173. */
  111174. setJoystickColor(newColor: string): void;
  111175. /**
  111176. * Defines a callback to call when the joystick is touched
  111177. * @param action defines the callback
  111178. */
  111179. setActionOnTouch(action: () => any): void;
  111180. /**
  111181. * Defines which axis you'd like to control for left & right
  111182. * @param axis defines the axis to use
  111183. */
  111184. setAxisForLeftRight(axis: JoystickAxis): void;
  111185. /**
  111186. * Defines which axis you'd like to control for up & down
  111187. * @param axis defines the axis to use
  111188. */
  111189. setAxisForUpDown(axis: JoystickAxis): void;
  111190. private _drawVirtualJoystick;
  111191. /**
  111192. * Release internal HTML canvas
  111193. */
  111194. releaseCanvas(): void;
  111195. }
  111196. }
  111197. declare module BABYLON {
  111198. interface FreeCameraInputsManager {
  111199. /**
  111200. * Add virtual joystick input support to the input manager.
  111201. * @returns the current input manager
  111202. */
  111203. addVirtualJoystick(): FreeCameraInputsManager;
  111204. }
  111205. /**
  111206. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  111207. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111208. */
  111209. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  111210. /**
  111211. * Defines the camera the input is attached to.
  111212. */
  111213. camera: FreeCamera;
  111214. private _leftjoystick;
  111215. private _rightjoystick;
  111216. /**
  111217. * Gets the left stick of the virtual joystick.
  111218. * @returns The virtual Joystick
  111219. */
  111220. getLeftJoystick(): VirtualJoystick;
  111221. /**
  111222. * Gets the right stick of the virtual joystick.
  111223. * @returns The virtual Joystick
  111224. */
  111225. getRightJoystick(): VirtualJoystick;
  111226. /**
  111227. * Update the current camera state depending on the inputs that have been used this frame.
  111228. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111229. */
  111230. checkInputs(): void;
  111231. /**
  111232. * Attach the input controls to a specific dom element to get the input from.
  111233. * @param element Defines the element the controls should be listened from
  111234. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111235. */
  111236. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111237. /**
  111238. * Detach the current controls from the specified dom element.
  111239. * @param element Defines the element to stop listening the inputs from
  111240. */
  111241. detachControl(element: Nullable<HTMLElement>): void;
  111242. /**
  111243. * Gets the class name of the current intput.
  111244. * @returns the class name
  111245. */
  111246. getClassName(): string;
  111247. /**
  111248. * Get the friendly name associated with the input class.
  111249. * @returns the input friendly name
  111250. */
  111251. getSimpleName(): string;
  111252. }
  111253. }
  111254. declare module BABYLON {
  111255. /**
  111256. * This represents a FPS type of camera controlled by touch.
  111257. * This is like a universal camera minus the Gamepad controls.
  111258. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111259. */
  111260. export class TouchCamera extends FreeCamera {
  111261. /**
  111262. * Defines the touch sensibility for rotation.
  111263. * The higher the faster.
  111264. */
  111265. get touchAngularSensibility(): number;
  111266. set touchAngularSensibility(value: number);
  111267. /**
  111268. * Defines the touch sensibility for move.
  111269. * The higher the faster.
  111270. */
  111271. get touchMoveSensibility(): number;
  111272. set touchMoveSensibility(value: number);
  111273. /**
  111274. * Instantiates a new touch camera.
  111275. * This represents a FPS type of camera controlled by touch.
  111276. * This is like a universal camera minus the Gamepad controls.
  111277. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111278. * @param name Define the name of the camera in the scene
  111279. * @param position Define the start position of the camera in the scene
  111280. * @param scene Define the scene the camera belongs to
  111281. */
  111282. constructor(name: string, position: Vector3, scene: Scene);
  111283. /**
  111284. * Gets the current object class name.
  111285. * @return the class name
  111286. */
  111287. getClassName(): string;
  111288. /** @hidden */
  111289. _setupInputs(): void;
  111290. }
  111291. }
  111292. declare module BABYLON {
  111293. /**
  111294. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  111295. * being tilted forward or back and left or right.
  111296. */
  111297. export class DeviceOrientationCamera extends FreeCamera {
  111298. private _initialQuaternion;
  111299. private _quaternionCache;
  111300. private _tmpDragQuaternion;
  111301. private _disablePointerInputWhenUsingDeviceOrientation;
  111302. /**
  111303. * Creates a new device orientation camera
  111304. * @param name The name of the camera
  111305. * @param position The start position camera
  111306. * @param scene The scene the camera belongs to
  111307. */
  111308. constructor(name: string, position: Vector3, scene: Scene);
  111309. /**
  111310. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  111311. */
  111312. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  111313. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  111314. private _dragFactor;
  111315. /**
  111316. * Enabled turning on the y axis when the orientation sensor is active
  111317. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  111318. */
  111319. enableHorizontalDragging(dragFactor?: number): void;
  111320. /**
  111321. * Gets the current instance class name ("DeviceOrientationCamera").
  111322. * This helps avoiding instanceof at run time.
  111323. * @returns the class name
  111324. */
  111325. getClassName(): string;
  111326. /**
  111327. * @hidden
  111328. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  111329. */
  111330. _checkInputs(): void;
  111331. /**
  111332. * Reset the camera to its default orientation on the specified axis only.
  111333. * @param axis The axis to reset
  111334. */
  111335. resetToCurrentRotation(axis?: Axis): void;
  111336. }
  111337. }
  111338. declare module BABYLON {
  111339. /**
  111340. * Defines supported buttons for XBox360 compatible gamepads
  111341. */
  111342. export enum Xbox360Button {
  111343. /** A */
  111344. A = 0,
  111345. /** B */
  111346. B = 1,
  111347. /** X */
  111348. X = 2,
  111349. /** Y */
  111350. Y = 3,
  111351. /** Start */
  111352. Start = 4,
  111353. /** Back */
  111354. Back = 5,
  111355. /** Left button */
  111356. LB = 6,
  111357. /** Right button */
  111358. RB = 7,
  111359. /** Left stick */
  111360. LeftStick = 8,
  111361. /** Right stick */
  111362. RightStick = 9
  111363. }
  111364. /** Defines values for XBox360 DPad */
  111365. export enum Xbox360Dpad {
  111366. /** Up */
  111367. Up = 0,
  111368. /** Down */
  111369. Down = 1,
  111370. /** Left */
  111371. Left = 2,
  111372. /** Right */
  111373. Right = 3
  111374. }
  111375. /**
  111376. * Defines a XBox360 gamepad
  111377. */
  111378. export class Xbox360Pad extends Gamepad {
  111379. private _leftTrigger;
  111380. private _rightTrigger;
  111381. private _onlefttriggerchanged;
  111382. private _onrighttriggerchanged;
  111383. private _onbuttondown;
  111384. private _onbuttonup;
  111385. private _ondpaddown;
  111386. private _ondpadup;
  111387. /** Observable raised when a button is pressed */
  111388. onButtonDownObservable: Observable<Xbox360Button>;
  111389. /** Observable raised when a button is released */
  111390. onButtonUpObservable: Observable<Xbox360Button>;
  111391. /** Observable raised when a pad is pressed */
  111392. onPadDownObservable: Observable<Xbox360Dpad>;
  111393. /** Observable raised when a pad is released */
  111394. onPadUpObservable: Observable<Xbox360Dpad>;
  111395. private _buttonA;
  111396. private _buttonB;
  111397. private _buttonX;
  111398. private _buttonY;
  111399. private _buttonBack;
  111400. private _buttonStart;
  111401. private _buttonLB;
  111402. private _buttonRB;
  111403. private _buttonLeftStick;
  111404. private _buttonRightStick;
  111405. private _dPadUp;
  111406. private _dPadDown;
  111407. private _dPadLeft;
  111408. private _dPadRight;
  111409. private _isXboxOnePad;
  111410. /**
  111411. * Creates a new XBox360 gamepad object
  111412. * @param id defines the id of this gamepad
  111413. * @param index defines its index
  111414. * @param gamepad defines the internal HTML gamepad object
  111415. * @param xboxOne defines if it is a XBox One gamepad
  111416. */
  111417. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  111418. /**
  111419. * Defines the callback to call when left trigger is pressed
  111420. * @param callback defines the callback to use
  111421. */
  111422. onlefttriggerchanged(callback: (value: number) => void): void;
  111423. /**
  111424. * Defines the callback to call when right trigger is pressed
  111425. * @param callback defines the callback to use
  111426. */
  111427. onrighttriggerchanged(callback: (value: number) => void): void;
  111428. /**
  111429. * Gets the left trigger value
  111430. */
  111431. get leftTrigger(): number;
  111432. /**
  111433. * Sets the left trigger value
  111434. */
  111435. set leftTrigger(newValue: number);
  111436. /**
  111437. * Gets the right trigger value
  111438. */
  111439. get rightTrigger(): number;
  111440. /**
  111441. * Sets the right trigger value
  111442. */
  111443. set rightTrigger(newValue: number);
  111444. /**
  111445. * Defines the callback to call when a button is pressed
  111446. * @param callback defines the callback to use
  111447. */
  111448. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  111449. /**
  111450. * Defines the callback to call when a button is released
  111451. * @param callback defines the callback to use
  111452. */
  111453. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  111454. /**
  111455. * Defines the callback to call when a pad is pressed
  111456. * @param callback defines the callback to use
  111457. */
  111458. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  111459. /**
  111460. * Defines the callback to call when a pad is released
  111461. * @param callback defines the callback to use
  111462. */
  111463. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  111464. private _setButtonValue;
  111465. private _setDPadValue;
  111466. /**
  111467. * Gets the value of the `A` button
  111468. */
  111469. get buttonA(): number;
  111470. /**
  111471. * Sets the value of the `A` button
  111472. */
  111473. set buttonA(value: number);
  111474. /**
  111475. * Gets the value of the `B` button
  111476. */
  111477. get buttonB(): number;
  111478. /**
  111479. * Sets the value of the `B` button
  111480. */
  111481. set buttonB(value: number);
  111482. /**
  111483. * Gets the value of the `X` button
  111484. */
  111485. get buttonX(): number;
  111486. /**
  111487. * Sets the value of the `X` button
  111488. */
  111489. set buttonX(value: number);
  111490. /**
  111491. * Gets the value of the `Y` button
  111492. */
  111493. get buttonY(): number;
  111494. /**
  111495. * Sets the value of the `Y` button
  111496. */
  111497. set buttonY(value: number);
  111498. /**
  111499. * Gets the value of the `Start` button
  111500. */
  111501. get buttonStart(): number;
  111502. /**
  111503. * Sets the value of the `Start` button
  111504. */
  111505. set buttonStart(value: number);
  111506. /**
  111507. * Gets the value of the `Back` button
  111508. */
  111509. get buttonBack(): number;
  111510. /**
  111511. * Sets the value of the `Back` button
  111512. */
  111513. set buttonBack(value: number);
  111514. /**
  111515. * Gets the value of the `Left` button
  111516. */
  111517. get buttonLB(): number;
  111518. /**
  111519. * Sets the value of the `Left` button
  111520. */
  111521. set buttonLB(value: number);
  111522. /**
  111523. * Gets the value of the `Right` button
  111524. */
  111525. get buttonRB(): number;
  111526. /**
  111527. * Sets the value of the `Right` button
  111528. */
  111529. set buttonRB(value: number);
  111530. /**
  111531. * Gets the value of the Left joystick
  111532. */
  111533. get buttonLeftStick(): number;
  111534. /**
  111535. * Sets the value of the Left joystick
  111536. */
  111537. set buttonLeftStick(value: number);
  111538. /**
  111539. * Gets the value of the Right joystick
  111540. */
  111541. get buttonRightStick(): number;
  111542. /**
  111543. * Sets the value of the Right joystick
  111544. */
  111545. set buttonRightStick(value: number);
  111546. /**
  111547. * Gets the value of D-pad up
  111548. */
  111549. get dPadUp(): number;
  111550. /**
  111551. * Sets the value of D-pad up
  111552. */
  111553. set dPadUp(value: number);
  111554. /**
  111555. * Gets the value of D-pad down
  111556. */
  111557. get dPadDown(): number;
  111558. /**
  111559. * Sets the value of D-pad down
  111560. */
  111561. set dPadDown(value: number);
  111562. /**
  111563. * Gets the value of D-pad left
  111564. */
  111565. get dPadLeft(): number;
  111566. /**
  111567. * Sets the value of D-pad left
  111568. */
  111569. set dPadLeft(value: number);
  111570. /**
  111571. * Gets the value of D-pad right
  111572. */
  111573. get dPadRight(): number;
  111574. /**
  111575. * Sets the value of D-pad right
  111576. */
  111577. set dPadRight(value: number);
  111578. /**
  111579. * Force the gamepad to synchronize with device values
  111580. */
  111581. update(): void;
  111582. /**
  111583. * Disposes the gamepad
  111584. */
  111585. dispose(): void;
  111586. }
  111587. }
  111588. declare module BABYLON {
  111589. /**
  111590. * Defines supported buttons for DualShock compatible gamepads
  111591. */
  111592. export enum DualShockButton {
  111593. /** Cross */
  111594. Cross = 0,
  111595. /** Circle */
  111596. Circle = 1,
  111597. /** Square */
  111598. Square = 2,
  111599. /** Triangle */
  111600. Triangle = 3,
  111601. /** Options */
  111602. Options = 4,
  111603. /** Share */
  111604. Share = 5,
  111605. /** L1 */
  111606. L1 = 6,
  111607. /** R1 */
  111608. R1 = 7,
  111609. /** Left stick */
  111610. LeftStick = 8,
  111611. /** Right stick */
  111612. RightStick = 9
  111613. }
  111614. /** Defines values for DualShock DPad */
  111615. export enum DualShockDpad {
  111616. /** Up */
  111617. Up = 0,
  111618. /** Down */
  111619. Down = 1,
  111620. /** Left */
  111621. Left = 2,
  111622. /** Right */
  111623. Right = 3
  111624. }
  111625. /**
  111626. * Defines a DualShock gamepad
  111627. */
  111628. export class DualShockPad extends Gamepad {
  111629. private _leftTrigger;
  111630. private _rightTrigger;
  111631. private _onlefttriggerchanged;
  111632. private _onrighttriggerchanged;
  111633. private _onbuttondown;
  111634. private _onbuttonup;
  111635. private _ondpaddown;
  111636. private _ondpadup;
  111637. /** Observable raised when a button is pressed */
  111638. onButtonDownObservable: Observable<DualShockButton>;
  111639. /** Observable raised when a button is released */
  111640. onButtonUpObservable: Observable<DualShockButton>;
  111641. /** Observable raised when a pad is pressed */
  111642. onPadDownObservable: Observable<DualShockDpad>;
  111643. /** Observable raised when a pad is released */
  111644. onPadUpObservable: Observable<DualShockDpad>;
  111645. private _buttonCross;
  111646. private _buttonCircle;
  111647. private _buttonSquare;
  111648. private _buttonTriangle;
  111649. private _buttonShare;
  111650. private _buttonOptions;
  111651. private _buttonL1;
  111652. private _buttonR1;
  111653. private _buttonLeftStick;
  111654. private _buttonRightStick;
  111655. private _dPadUp;
  111656. private _dPadDown;
  111657. private _dPadLeft;
  111658. private _dPadRight;
  111659. /**
  111660. * Creates a new DualShock gamepad object
  111661. * @param id defines the id of this gamepad
  111662. * @param index defines its index
  111663. * @param gamepad defines the internal HTML gamepad object
  111664. */
  111665. constructor(id: string, index: number, gamepad: any);
  111666. /**
  111667. * Defines the callback to call when left trigger is pressed
  111668. * @param callback defines the callback to use
  111669. */
  111670. onlefttriggerchanged(callback: (value: number) => void): void;
  111671. /**
  111672. * Defines the callback to call when right trigger is pressed
  111673. * @param callback defines the callback to use
  111674. */
  111675. onrighttriggerchanged(callback: (value: number) => void): void;
  111676. /**
  111677. * Gets the left trigger value
  111678. */
  111679. get leftTrigger(): number;
  111680. /**
  111681. * Sets the left trigger value
  111682. */
  111683. set leftTrigger(newValue: number);
  111684. /**
  111685. * Gets the right trigger value
  111686. */
  111687. get rightTrigger(): number;
  111688. /**
  111689. * Sets the right trigger value
  111690. */
  111691. set rightTrigger(newValue: number);
  111692. /**
  111693. * Defines the callback to call when a button is pressed
  111694. * @param callback defines the callback to use
  111695. */
  111696. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  111697. /**
  111698. * Defines the callback to call when a button is released
  111699. * @param callback defines the callback to use
  111700. */
  111701. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  111702. /**
  111703. * Defines the callback to call when a pad is pressed
  111704. * @param callback defines the callback to use
  111705. */
  111706. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  111707. /**
  111708. * Defines the callback to call when a pad is released
  111709. * @param callback defines the callback to use
  111710. */
  111711. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  111712. private _setButtonValue;
  111713. private _setDPadValue;
  111714. /**
  111715. * Gets the value of the `Cross` button
  111716. */
  111717. get buttonCross(): number;
  111718. /**
  111719. * Sets the value of the `Cross` button
  111720. */
  111721. set buttonCross(value: number);
  111722. /**
  111723. * Gets the value of the `Circle` button
  111724. */
  111725. get buttonCircle(): number;
  111726. /**
  111727. * Sets the value of the `Circle` button
  111728. */
  111729. set buttonCircle(value: number);
  111730. /**
  111731. * Gets the value of the `Square` button
  111732. */
  111733. get buttonSquare(): number;
  111734. /**
  111735. * Sets the value of the `Square` button
  111736. */
  111737. set buttonSquare(value: number);
  111738. /**
  111739. * Gets the value of the `Triangle` button
  111740. */
  111741. get buttonTriangle(): number;
  111742. /**
  111743. * Sets the value of the `Triangle` button
  111744. */
  111745. set buttonTriangle(value: number);
  111746. /**
  111747. * Gets the value of the `Options` button
  111748. */
  111749. get buttonOptions(): number;
  111750. /**
  111751. * Sets the value of the `Options` button
  111752. */
  111753. set buttonOptions(value: number);
  111754. /**
  111755. * Gets the value of the `Share` button
  111756. */
  111757. get buttonShare(): number;
  111758. /**
  111759. * Sets the value of the `Share` button
  111760. */
  111761. set buttonShare(value: number);
  111762. /**
  111763. * Gets the value of the `L1` button
  111764. */
  111765. get buttonL1(): number;
  111766. /**
  111767. * Sets the value of the `L1` button
  111768. */
  111769. set buttonL1(value: number);
  111770. /**
  111771. * Gets the value of the `R1` button
  111772. */
  111773. get buttonR1(): number;
  111774. /**
  111775. * Sets the value of the `R1` button
  111776. */
  111777. set buttonR1(value: number);
  111778. /**
  111779. * Gets the value of the Left joystick
  111780. */
  111781. get buttonLeftStick(): number;
  111782. /**
  111783. * Sets the value of the Left joystick
  111784. */
  111785. set buttonLeftStick(value: number);
  111786. /**
  111787. * Gets the value of the Right joystick
  111788. */
  111789. get buttonRightStick(): number;
  111790. /**
  111791. * Sets the value of the Right joystick
  111792. */
  111793. set buttonRightStick(value: number);
  111794. /**
  111795. * Gets the value of D-pad up
  111796. */
  111797. get dPadUp(): number;
  111798. /**
  111799. * Sets the value of D-pad up
  111800. */
  111801. set dPadUp(value: number);
  111802. /**
  111803. * Gets the value of D-pad down
  111804. */
  111805. get dPadDown(): number;
  111806. /**
  111807. * Sets the value of D-pad down
  111808. */
  111809. set dPadDown(value: number);
  111810. /**
  111811. * Gets the value of D-pad left
  111812. */
  111813. get dPadLeft(): number;
  111814. /**
  111815. * Sets the value of D-pad left
  111816. */
  111817. set dPadLeft(value: number);
  111818. /**
  111819. * Gets the value of D-pad right
  111820. */
  111821. get dPadRight(): number;
  111822. /**
  111823. * Sets the value of D-pad right
  111824. */
  111825. set dPadRight(value: number);
  111826. /**
  111827. * Force the gamepad to synchronize with device values
  111828. */
  111829. update(): void;
  111830. /**
  111831. * Disposes the gamepad
  111832. */
  111833. dispose(): void;
  111834. }
  111835. }
  111836. declare module BABYLON {
  111837. /**
  111838. * Manager for handling gamepads
  111839. */
  111840. export class GamepadManager {
  111841. private _scene?;
  111842. private _babylonGamepads;
  111843. private _oneGamepadConnected;
  111844. /** @hidden */
  111845. _isMonitoring: boolean;
  111846. private _gamepadEventSupported;
  111847. private _gamepadSupport?;
  111848. /**
  111849. * observable to be triggered when the gamepad controller has been connected
  111850. */
  111851. onGamepadConnectedObservable: Observable<Gamepad>;
  111852. /**
  111853. * observable to be triggered when the gamepad controller has been disconnected
  111854. */
  111855. onGamepadDisconnectedObservable: Observable<Gamepad>;
  111856. private _onGamepadConnectedEvent;
  111857. private _onGamepadDisconnectedEvent;
  111858. /**
  111859. * Initializes the gamepad manager
  111860. * @param _scene BabylonJS scene
  111861. */
  111862. constructor(_scene?: Scene | undefined);
  111863. /**
  111864. * The gamepads in the game pad manager
  111865. */
  111866. get gamepads(): Gamepad[];
  111867. /**
  111868. * Get the gamepad controllers based on type
  111869. * @param type The type of gamepad controller
  111870. * @returns Nullable gamepad
  111871. */
  111872. getGamepadByType(type?: number): Nullable<Gamepad>;
  111873. /**
  111874. * Disposes the gamepad manager
  111875. */
  111876. dispose(): void;
  111877. private _addNewGamepad;
  111878. private _startMonitoringGamepads;
  111879. private _stopMonitoringGamepads;
  111880. /** @hidden */
  111881. _checkGamepadsStatus(): void;
  111882. private _updateGamepadObjects;
  111883. }
  111884. }
  111885. declare module BABYLON {
  111886. interface Scene {
  111887. /** @hidden */
  111888. _gamepadManager: Nullable<GamepadManager>;
  111889. /**
  111890. * Gets the gamepad manager associated with the scene
  111891. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  111892. */
  111893. gamepadManager: GamepadManager;
  111894. }
  111895. /**
  111896. * Interface representing a free camera inputs manager
  111897. */
  111898. interface FreeCameraInputsManager {
  111899. /**
  111900. * Adds gamepad input support to the FreeCameraInputsManager.
  111901. * @returns the FreeCameraInputsManager
  111902. */
  111903. addGamepad(): FreeCameraInputsManager;
  111904. }
  111905. /**
  111906. * Interface representing an arc rotate camera inputs manager
  111907. */
  111908. interface ArcRotateCameraInputsManager {
  111909. /**
  111910. * Adds gamepad input support to the ArcRotateCamera InputManager.
  111911. * @returns the camera inputs manager
  111912. */
  111913. addGamepad(): ArcRotateCameraInputsManager;
  111914. }
  111915. /**
  111916. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  111917. */
  111918. export class GamepadSystemSceneComponent implements ISceneComponent {
  111919. /**
  111920. * The component name helpfull to identify the component in the list of scene components.
  111921. */
  111922. readonly name: string;
  111923. /**
  111924. * The scene the component belongs to.
  111925. */
  111926. scene: Scene;
  111927. /**
  111928. * Creates a new instance of the component for the given scene
  111929. * @param scene Defines the scene to register the component in
  111930. */
  111931. constructor(scene: Scene);
  111932. /**
  111933. * Registers the component in a given scene
  111934. */
  111935. register(): void;
  111936. /**
  111937. * Rebuilds the elements related to this component in case of
  111938. * context lost for instance.
  111939. */
  111940. rebuild(): void;
  111941. /**
  111942. * Disposes the component and the associated ressources
  111943. */
  111944. dispose(): void;
  111945. private _beforeCameraUpdate;
  111946. }
  111947. }
  111948. declare module BABYLON {
  111949. /**
  111950. * 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,
  111951. * which still works and will still be found in many Playgrounds.
  111952. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111953. */
  111954. export class UniversalCamera extends TouchCamera {
  111955. /**
  111956. * Defines the gamepad rotation sensiblity.
  111957. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  111958. */
  111959. get gamepadAngularSensibility(): number;
  111960. set gamepadAngularSensibility(value: number);
  111961. /**
  111962. * Defines the gamepad move sensiblity.
  111963. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  111964. */
  111965. get gamepadMoveSensibility(): number;
  111966. set gamepadMoveSensibility(value: number);
  111967. /**
  111968. * 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,
  111969. * which still works and will still be found in many Playgrounds.
  111970. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111971. * @param name Define the name of the camera in the scene
  111972. * @param position Define the start position of the camera in the scene
  111973. * @param scene Define the scene the camera belongs to
  111974. */
  111975. constructor(name: string, position: Vector3, scene: Scene);
  111976. /**
  111977. * Gets the current object class name.
  111978. * @return the class name
  111979. */
  111980. getClassName(): string;
  111981. }
  111982. }
  111983. declare module BABYLON {
  111984. /**
  111985. * This represents a FPS type of camera. This is only here for back compat purpose.
  111986. * Please use the UniversalCamera instead as both are identical.
  111987. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111988. */
  111989. export class GamepadCamera extends UniversalCamera {
  111990. /**
  111991. * Instantiates a new Gamepad Camera
  111992. * This represents a FPS type of camera. This is only here for back compat purpose.
  111993. * Please use the UniversalCamera instead as both are identical.
  111994. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  111995. * @param name Define the name of the camera in the scene
  111996. * @param position Define the start position of the camera in the scene
  111997. * @param scene Define the scene the camera belongs to
  111998. */
  111999. constructor(name: string, position: Vector3, scene: Scene);
  112000. /**
  112001. * Gets the current object class name.
  112002. * @return the class name
  112003. */
  112004. getClassName(): string;
  112005. }
  112006. }
  112007. declare module BABYLON {
  112008. /** @hidden */
  112009. export var passPixelShader: {
  112010. name: string;
  112011. shader: string;
  112012. };
  112013. }
  112014. declare module BABYLON {
  112015. /** @hidden */
  112016. export var passCubePixelShader: {
  112017. name: string;
  112018. shader: string;
  112019. };
  112020. }
  112021. declare module BABYLON {
  112022. /**
  112023. * PassPostProcess which produces an output the same as it's input
  112024. */
  112025. export class PassPostProcess extends PostProcess {
  112026. /**
  112027. * Creates the PassPostProcess
  112028. * @param name The name of the effect.
  112029. * @param options The required width/height ratio to downsize to before computing the render pass.
  112030. * @param camera The camera to apply the render pass to.
  112031. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112032. * @param engine The engine which the post process will be applied. (default: current engine)
  112033. * @param reusable If the post process can be reused on the same frame. (default: false)
  112034. * @param textureType The type of texture to be used when performing the post processing.
  112035. * @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)
  112036. */
  112037. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112038. }
  112039. /**
  112040. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  112041. */
  112042. export class PassCubePostProcess extends PostProcess {
  112043. private _face;
  112044. /**
  112045. * Gets or sets the cube face to display.
  112046. * * 0 is +X
  112047. * * 1 is -X
  112048. * * 2 is +Y
  112049. * * 3 is -Y
  112050. * * 4 is +Z
  112051. * * 5 is -Z
  112052. */
  112053. get face(): number;
  112054. set face(value: number);
  112055. /**
  112056. * Creates the PassCubePostProcess
  112057. * @param name The name of the effect.
  112058. * @param options The required width/height ratio to downsize to before computing the render pass.
  112059. * @param camera The camera to apply the render pass to.
  112060. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112061. * @param engine The engine which the post process will be applied. (default: current engine)
  112062. * @param reusable If the post process can be reused on the same frame. (default: false)
  112063. * @param textureType The type of texture to be used when performing the post processing.
  112064. * @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)
  112065. */
  112066. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112067. }
  112068. }
  112069. declare module BABYLON {
  112070. /** @hidden */
  112071. export var anaglyphPixelShader: {
  112072. name: string;
  112073. shader: string;
  112074. };
  112075. }
  112076. declare module BABYLON {
  112077. /**
  112078. * Postprocess used to generate anaglyphic rendering
  112079. */
  112080. export class AnaglyphPostProcess extends PostProcess {
  112081. private _passedProcess;
  112082. /**
  112083. * Creates a new AnaglyphPostProcess
  112084. * @param name defines postprocess name
  112085. * @param options defines creation options or target ratio scale
  112086. * @param rigCameras defines cameras using this postprocess
  112087. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  112088. * @param engine defines hosting engine
  112089. * @param reusable defines if the postprocess will be reused multiple times per frame
  112090. */
  112091. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  112092. }
  112093. }
  112094. declare module BABYLON {
  112095. /**
  112096. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  112097. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112098. */
  112099. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  112100. /**
  112101. * Creates a new AnaglyphArcRotateCamera
  112102. * @param name defines camera name
  112103. * @param alpha defines alpha angle (in radians)
  112104. * @param beta defines beta angle (in radians)
  112105. * @param radius defines radius
  112106. * @param target defines camera target
  112107. * @param interaxialDistance defines distance between each color axis
  112108. * @param scene defines the hosting scene
  112109. */
  112110. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  112111. /**
  112112. * Gets camera class name
  112113. * @returns AnaglyphArcRotateCamera
  112114. */
  112115. getClassName(): string;
  112116. }
  112117. }
  112118. declare module BABYLON {
  112119. /**
  112120. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  112121. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112122. */
  112123. export class AnaglyphFreeCamera extends FreeCamera {
  112124. /**
  112125. * Creates a new AnaglyphFreeCamera
  112126. * @param name defines camera name
  112127. * @param position defines initial position
  112128. * @param interaxialDistance defines distance between each color axis
  112129. * @param scene defines the hosting scene
  112130. */
  112131. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  112132. /**
  112133. * Gets camera class name
  112134. * @returns AnaglyphFreeCamera
  112135. */
  112136. getClassName(): string;
  112137. }
  112138. }
  112139. declare module BABYLON {
  112140. /**
  112141. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  112142. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112143. */
  112144. export class AnaglyphGamepadCamera extends GamepadCamera {
  112145. /**
  112146. * Creates a new AnaglyphGamepadCamera
  112147. * @param name defines camera name
  112148. * @param position defines initial position
  112149. * @param interaxialDistance defines distance between each color axis
  112150. * @param scene defines the hosting scene
  112151. */
  112152. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  112153. /**
  112154. * Gets camera class name
  112155. * @returns AnaglyphGamepadCamera
  112156. */
  112157. getClassName(): string;
  112158. }
  112159. }
  112160. declare module BABYLON {
  112161. /**
  112162. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  112163. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112164. */
  112165. export class AnaglyphUniversalCamera extends UniversalCamera {
  112166. /**
  112167. * Creates a new AnaglyphUniversalCamera
  112168. * @param name defines camera name
  112169. * @param position defines initial position
  112170. * @param interaxialDistance defines distance between each color axis
  112171. * @param scene defines the hosting scene
  112172. */
  112173. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  112174. /**
  112175. * Gets camera class name
  112176. * @returns AnaglyphUniversalCamera
  112177. */
  112178. getClassName(): string;
  112179. }
  112180. }
  112181. declare module BABYLON {
  112182. /** @hidden */
  112183. export var stereoscopicInterlacePixelShader: {
  112184. name: string;
  112185. shader: string;
  112186. };
  112187. }
  112188. declare module BABYLON {
  112189. /**
  112190. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  112191. */
  112192. export class StereoscopicInterlacePostProcess extends PostProcess {
  112193. private _stepSize;
  112194. private _passedProcess;
  112195. /**
  112196. * Initializes a StereoscopicInterlacePostProcess
  112197. * @param name The name of the effect.
  112198. * @param rigCameras The rig cameras to be appled to the post process
  112199. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  112200. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112201. * @param engine The engine which the post process will be applied. (default: current engine)
  112202. * @param reusable If the post process can be reused on the same frame. (default: false)
  112203. */
  112204. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112205. }
  112206. }
  112207. declare module BABYLON {
  112208. /**
  112209. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  112210. * @see http://doc.babylonjs.com/features/cameras
  112211. */
  112212. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  112213. /**
  112214. * Creates a new StereoscopicArcRotateCamera
  112215. * @param name defines camera name
  112216. * @param alpha defines alpha angle (in radians)
  112217. * @param beta defines beta angle (in radians)
  112218. * @param radius defines radius
  112219. * @param target defines camera target
  112220. * @param interaxialDistance defines distance between each color axis
  112221. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112222. * @param scene defines the hosting scene
  112223. */
  112224. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112225. /**
  112226. * Gets camera class name
  112227. * @returns StereoscopicArcRotateCamera
  112228. */
  112229. getClassName(): string;
  112230. }
  112231. }
  112232. declare module BABYLON {
  112233. /**
  112234. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  112235. * @see http://doc.babylonjs.com/features/cameras
  112236. */
  112237. export class StereoscopicFreeCamera extends FreeCamera {
  112238. /**
  112239. * Creates a new StereoscopicFreeCamera
  112240. * @param name defines camera name
  112241. * @param position defines initial position
  112242. * @param interaxialDistance defines distance between each color axis
  112243. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112244. * @param scene defines the hosting scene
  112245. */
  112246. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112247. /**
  112248. * Gets camera class name
  112249. * @returns StereoscopicFreeCamera
  112250. */
  112251. getClassName(): string;
  112252. }
  112253. }
  112254. declare module BABYLON {
  112255. /**
  112256. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  112257. * @see http://doc.babylonjs.com/features/cameras
  112258. */
  112259. export class StereoscopicGamepadCamera extends GamepadCamera {
  112260. /**
  112261. * Creates a new StereoscopicGamepadCamera
  112262. * @param name defines camera name
  112263. * @param position defines initial position
  112264. * @param interaxialDistance defines distance between each color axis
  112265. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112266. * @param scene defines the hosting scene
  112267. */
  112268. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112269. /**
  112270. * Gets camera class name
  112271. * @returns StereoscopicGamepadCamera
  112272. */
  112273. getClassName(): string;
  112274. }
  112275. }
  112276. declare module BABYLON {
  112277. /**
  112278. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  112279. * @see http://doc.babylonjs.com/features/cameras
  112280. */
  112281. export class StereoscopicUniversalCamera extends UniversalCamera {
  112282. /**
  112283. * Creates a new StereoscopicUniversalCamera
  112284. * @param name defines camera name
  112285. * @param position defines initial position
  112286. * @param interaxialDistance defines distance between each color axis
  112287. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112288. * @param scene defines the hosting scene
  112289. */
  112290. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112291. /**
  112292. * Gets camera class name
  112293. * @returns StereoscopicUniversalCamera
  112294. */
  112295. getClassName(): string;
  112296. }
  112297. }
  112298. declare module BABYLON {
  112299. /**
  112300. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  112301. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  112302. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  112303. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  112304. */
  112305. export class VirtualJoysticksCamera extends FreeCamera {
  112306. /**
  112307. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  112308. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  112309. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  112310. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  112311. * @param name Define the name of the camera in the scene
  112312. * @param position Define the start position of the camera in the scene
  112313. * @param scene Define the scene the camera belongs to
  112314. */
  112315. constructor(name: string, position: Vector3, scene: Scene);
  112316. /**
  112317. * Gets the current object class name.
  112318. * @return the class name
  112319. */
  112320. getClassName(): string;
  112321. }
  112322. }
  112323. declare module BABYLON {
  112324. /**
  112325. * This represents all the required metrics to create a VR camera.
  112326. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  112327. */
  112328. export class VRCameraMetrics {
  112329. /**
  112330. * Define the horizontal resolution off the screen.
  112331. */
  112332. hResolution: number;
  112333. /**
  112334. * Define the vertical resolution off the screen.
  112335. */
  112336. vResolution: number;
  112337. /**
  112338. * Define the horizontal screen size.
  112339. */
  112340. hScreenSize: number;
  112341. /**
  112342. * Define the vertical screen size.
  112343. */
  112344. vScreenSize: number;
  112345. /**
  112346. * Define the vertical screen center position.
  112347. */
  112348. vScreenCenter: number;
  112349. /**
  112350. * Define the distance of the eyes to the screen.
  112351. */
  112352. eyeToScreenDistance: number;
  112353. /**
  112354. * Define the distance between both lenses
  112355. */
  112356. lensSeparationDistance: number;
  112357. /**
  112358. * Define the distance between both viewer's eyes.
  112359. */
  112360. interpupillaryDistance: number;
  112361. /**
  112362. * Define the distortion factor of the VR postprocess.
  112363. * Please, touch with care.
  112364. */
  112365. distortionK: number[];
  112366. /**
  112367. * Define the chromatic aberration correction factors for the VR post process.
  112368. */
  112369. chromaAbCorrection: number[];
  112370. /**
  112371. * Define the scale factor of the post process.
  112372. * The smaller the better but the slower.
  112373. */
  112374. postProcessScaleFactor: number;
  112375. /**
  112376. * Define an offset for the lens center.
  112377. */
  112378. lensCenterOffset: number;
  112379. /**
  112380. * Define if the current vr camera should compensate the distortion of the lense or not.
  112381. */
  112382. compensateDistortion: boolean;
  112383. /**
  112384. * Defines if multiview should be enabled when rendering (Default: false)
  112385. */
  112386. multiviewEnabled: boolean;
  112387. /**
  112388. * Gets the rendering aspect ratio based on the provided resolutions.
  112389. */
  112390. get aspectRatio(): number;
  112391. /**
  112392. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  112393. */
  112394. get aspectRatioFov(): number;
  112395. /**
  112396. * @hidden
  112397. */
  112398. get leftHMatrix(): Matrix;
  112399. /**
  112400. * @hidden
  112401. */
  112402. get rightHMatrix(): Matrix;
  112403. /**
  112404. * @hidden
  112405. */
  112406. get leftPreViewMatrix(): Matrix;
  112407. /**
  112408. * @hidden
  112409. */
  112410. get rightPreViewMatrix(): Matrix;
  112411. /**
  112412. * Get the default VRMetrics based on the most generic setup.
  112413. * @returns the default vr metrics
  112414. */
  112415. static GetDefault(): VRCameraMetrics;
  112416. }
  112417. }
  112418. declare module BABYLON {
  112419. /** @hidden */
  112420. export var vrDistortionCorrectionPixelShader: {
  112421. name: string;
  112422. shader: string;
  112423. };
  112424. }
  112425. declare module BABYLON {
  112426. /**
  112427. * VRDistortionCorrectionPostProcess used for mobile VR
  112428. */
  112429. export class VRDistortionCorrectionPostProcess extends PostProcess {
  112430. private _isRightEye;
  112431. private _distortionFactors;
  112432. private _postProcessScaleFactor;
  112433. private _lensCenterOffset;
  112434. private _scaleIn;
  112435. private _scaleFactor;
  112436. private _lensCenter;
  112437. /**
  112438. * Initializes the VRDistortionCorrectionPostProcess
  112439. * @param name The name of the effect.
  112440. * @param camera The camera to apply the render pass to.
  112441. * @param isRightEye If this is for the right eye distortion
  112442. * @param vrMetrics All the required metrics for the VR camera
  112443. */
  112444. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  112445. }
  112446. }
  112447. declare module BABYLON {
  112448. /**
  112449. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  112450. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  112451. */
  112452. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  112453. /**
  112454. * Creates a new VRDeviceOrientationArcRotateCamera
  112455. * @param name defines camera name
  112456. * @param alpha defines the camera rotation along the logitudinal axis
  112457. * @param beta defines the camera rotation along the latitudinal axis
  112458. * @param radius defines the camera distance from its target
  112459. * @param target defines the camera target
  112460. * @param scene defines the scene the camera belongs to
  112461. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  112462. * @param vrCameraMetrics defines the vr metrics associated to the camera
  112463. */
  112464. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  112465. /**
  112466. * Gets camera class name
  112467. * @returns VRDeviceOrientationArcRotateCamera
  112468. */
  112469. getClassName(): string;
  112470. }
  112471. }
  112472. declare module BABYLON {
  112473. /**
  112474. * Camera used to simulate VR rendering (based on FreeCamera)
  112475. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  112476. */
  112477. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  112478. /**
  112479. * Creates a new VRDeviceOrientationFreeCamera
  112480. * @param name defines camera name
  112481. * @param position defines the start position of the camera
  112482. * @param scene defines the scene the camera belongs to
  112483. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  112484. * @param vrCameraMetrics defines the vr metrics associated to the camera
  112485. */
  112486. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  112487. /**
  112488. * Gets camera class name
  112489. * @returns VRDeviceOrientationFreeCamera
  112490. */
  112491. getClassName(): string;
  112492. }
  112493. }
  112494. declare module BABYLON {
  112495. /**
  112496. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  112497. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  112498. */
  112499. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  112500. /**
  112501. * Creates a new VRDeviceOrientationGamepadCamera
  112502. * @param name defines camera name
  112503. * @param position defines the start position of the camera
  112504. * @param scene defines the scene the camera belongs to
  112505. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  112506. * @param vrCameraMetrics defines the vr metrics associated to the camera
  112507. */
  112508. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  112509. /**
  112510. * Gets camera class name
  112511. * @returns VRDeviceOrientationGamepadCamera
  112512. */
  112513. getClassName(): string;
  112514. }
  112515. }
  112516. declare module BABYLON {
  112517. /** @hidden */
  112518. export var imageProcessingPixelShader: {
  112519. name: string;
  112520. shader: string;
  112521. };
  112522. }
  112523. declare module BABYLON {
  112524. /**
  112525. * ImageProcessingPostProcess
  112526. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  112527. */
  112528. export class ImageProcessingPostProcess extends PostProcess {
  112529. /**
  112530. * Default configuration related to image processing available in the PBR Material.
  112531. */
  112532. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  112533. /**
  112534. * Gets the image processing configuration used either in this material.
  112535. */
  112536. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  112537. /**
  112538. * Sets the Default image processing configuration used either in the this material.
  112539. *
  112540. * If sets to null, the scene one is in use.
  112541. */
  112542. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  112543. /**
  112544. * Keep track of the image processing observer to allow dispose and replace.
  112545. */
  112546. private _imageProcessingObserver;
  112547. /**
  112548. * Attaches a new image processing configuration to the PBR Material.
  112549. * @param configuration
  112550. */
  112551. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  112552. /**
  112553. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  112554. */
  112555. get colorCurves(): Nullable<ColorCurves>;
  112556. /**
  112557. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  112558. */
  112559. set colorCurves(value: Nullable<ColorCurves>);
  112560. /**
  112561. * Gets wether the color curves effect is enabled.
  112562. */
  112563. get colorCurvesEnabled(): boolean;
  112564. /**
  112565. * Sets wether the color curves effect is enabled.
  112566. */
  112567. set colorCurvesEnabled(value: boolean);
  112568. /**
  112569. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  112570. */
  112571. get colorGradingTexture(): Nullable<BaseTexture>;
  112572. /**
  112573. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  112574. */
  112575. set colorGradingTexture(value: Nullable<BaseTexture>);
  112576. /**
  112577. * Gets wether the color grading effect is enabled.
  112578. */
  112579. get colorGradingEnabled(): boolean;
  112580. /**
  112581. * Gets wether the color grading effect is enabled.
  112582. */
  112583. set colorGradingEnabled(value: boolean);
  112584. /**
  112585. * Gets exposure used in the effect.
  112586. */
  112587. get exposure(): number;
  112588. /**
  112589. * Sets exposure used in the effect.
  112590. */
  112591. set exposure(value: number);
  112592. /**
  112593. * Gets wether tonemapping is enabled or not.
  112594. */
  112595. get toneMappingEnabled(): boolean;
  112596. /**
  112597. * Sets wether tonemapping is enabled or not
  112598. */
  112599. set toneMappingEnabled(value: boolean);
  112600. /**
  112601. * Gets the type of tone mapping effect.
  112602. */
  112603. get toneMappingType(): number;
  112604. /**
  112605. * Sets the type of tone mapping effect.
  112606. */
  112607. set toneMappingType(value: number);
  112608. /**
  112609. * Gets contrast used in the effect.
  112610. */
  112611. get contrast(): number;
  112612. /**
  112613. * Sets contrast used in the effect.
  112614. */
  112615. set contrast(value: number);
  112616. /**
  112617. * Gets Vignette stretch size.
  112618. */
  112619. get vignetteStretch(): number;
  112620. /**
  112621. * Sets Vignette stretch size.
  112622. */
  112623. set vignetteStretch(value: number);
  112624. /**
  112625. * Gets Vignette centre X Offset.
  112626. */
  112627. get vignetteCentreX(): number;
  112628. /**
  112629. * Sets Vignette centre X Offset.
  112630. */
  112631. set vignetteCentreX(value: number);
  112632. /**
  112633. * Gets Vignette centre Y Offset.
  112634. */
  112635. get vignetteCentreY(): number;
  112636. /**
  112637. * Sets Vignette centre Y Offset.
  112638. */
  112639. set vignetteCentreY(value: number);
  112640. /**
  112641. * Gets Vignette weight or intensity of the vignette effect.
  112642. */
  112643. get vignetteWeight(): number;
  112644. /**
  112645. * Sets Vignette weight or intensity of the vignette effect.
  112646. */
  112647. set vignetteWeight(value: number);
  112648. /**
  112649. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  112650. * if vignetteEnabled is set to true.
  112651. */
  112652. get vignetteColor(): Color4;
  112653. /**
  112654. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  112655. * if vignetteEnabled is set to true.
  112656. */
  112657. set vignetteColor(value: Color4);
  112658. /**
  112659. * Gets Camera field of view used by the Vignette effect.
  112660. */
  112661. get vignetteCameraFov(): number;
  112662. /**
  112663. * Sets Camera field of view used by the Vignette effect.
  112664. */
  112665. set vignetteCameraFov(value: number);
  112666. /**
  112667. * Gets the vignette blend mode allowing different kind of effect.
  112668. */
  112669. get vignetteBlendMode(): number;
  112670. /**
  112671. * Sets the vignette blend mode allowing different kind of effect.
  112672. */
  112673. set vignetteBlendMode(value: number);
  112674. /**
  112675. * Gets wether the vignette effect is enabled.
  112676. */
  112677. get vignetteEnabled(): boolean;
  112678. /**
  112679. * Sets wether the vignette effect is enabled.
  112680. */
  112681. set vignetteEnabled(value: boolean);
  112682. private _fromLinearSpace;
  112683. /**
  112684. * Gets wether the input of the processing is in Gamma or Linear Space.
  112685. */
  112686. get fromLinearSpace(): boolean;
  112687. /**
  112688. * Sets wether the input of the processing is in Gamma or Linear Space.
  112689. */
  112690. set fromLinearSpace(value: boolean);
  112691. /**
  112692. * Defines cache preventing GC.
  112693. */
  112694. private _defines;
  112695. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  112696. /**
  112697. * "ImageProcessingPostProcess"
  112698. * @returns "ImageProcessingPostProcess"
  112699. */
  112700. getClassName(): string;
  112701. protected _updateParameters(): void;
  112702. dispose(camera?: Camera): void;
  112703. }
  112704. }
  112705. declare module BABYLON {
  112706. /**
  112707. * Class containing static functions to help procedurally build meshes
  112708. */
  112709. export class GroundBuilder {
  112710. /**
  112711. * Creates a ground mesh
  112712. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  112713. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  112714. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112715. * @param name defines the name of the mesh
  112716. * @param options defines the options used to create the mesh
  112717. * @param scene defines the hosting scene
  112718. * @returns the ground mesh
  112719. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  112720. */
  112721. static CreateGround(name: string, options: {
  112722. width?: number;
  112723. height?: number;
  112724. subdivisions?: number;
  112725. subdivisionsX?: number;
  112726. subdivisionsY?: number;
  112727. updatable?: boolean;
  112728. }, scene: any): Mesh;
  112729. /**
  112730. * Creates a tiled ground mesh
  112731. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  112732. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  112733. * * 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
  112734. * * 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
  112735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112736. * @param name defines the name of the mesh
  112737. * @param options defines the options used to create the mesh
  112738. * @param scene defines the hosting scene
  112739. * @returns the tiled ground mesh
  112740. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  112741. */
  112742. static CreateTiledGround(name: string, options: {
  112743. xmin: number;
  112744. zmin: number;
  112745. xmax: number;
  112746. zmax: number;
  112747. subdivisions?: {
  112748. w: number;
  112749. h: number;
  112750. };
  112751. precision?: {
  112752. w: number;
  112753. h: number;
  112754. };
  112755. updatable?: boolean;
  112756. }, scene?: Nullable<Scene>): Mesh;
  112757. /**
  112758. * Creates a ground mesh from a height map
  112759. * * The parameter `url` sets the URL of the height map image resource.
  112760. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  112761. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  112762. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  112763. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  112764. * * 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.
  112765. * * 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).
  112766. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  112767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112768. * @param name defines the name of the mesh
  112769. * @param url defines the url to the height map
  112770. * @param options defines the options used to create the mesh
  112771. * @param scene defines the hosting scene
  112772. * @returns the ground mesh
  112773. * @see https://doc.babylonjs.com/babylon101/height_map
  112774. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  112775. */
  112776. static CreateGroundFromHeightMap(name: string, url: string, options: {
  112777. width?: number;
  112778. height?: number;
  112779. subdivisions?: number;
  112780. minHeight?: number;
  112781. maxHeight?: number;
  112782. colorFilter?: Color3;
  112783. alphaFilter?: number;
  112784. updatable?: boolean;
  112785. onReady?: (mesh: GroundMesh) => void;
  112786. }, scene?: Nullable<Scene>): GroundMesh;
  112787. }
  112788. }
  112789. declare module BABYLON {
  112790. /**
  112791. * Class containing static functions to help procedurally build meshes
  112792. */
  112793. export class TorusBuilder {
  112794. /**
  112795. * Creates a torus mesh
  112796. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  112797. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  112798. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  112799. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112800. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112801. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112802. * @param name defines the name of the mesh
  112803. * @param options defines the options used to create the mesh
  112804. * @param scene defines the hosting scene
  112805. * @returns the torus mesh
  112806. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  112807. */
  112808. static CreateTorus(name: string, options: {
  112809. diameter?: number;
  112810. thickness?: number;
  112811. tessellation?: number;
  112812. updatable?: boolean;
  112813. sideOrientation?: number;
  112814. frontUVs?: Vector4;
  112815. backUVs?: Vector4;
  112816. }, scene: any): Mesh;
  112817. }
  112818. }
  112819. declare module BABYLON {
  112820. /**
  112821. * Class containing static functions to help procedurally build meshes
  112822. */
  112823. export class CylinderBuilder {
  112824. /**
  112825. * Creates a cylinder or a cone mesh
  112826. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  112827. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  112828. * * 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.
  112829. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  112830. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  112831. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  112832. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  112833. * * 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).
  112834. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  112835. * * 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).
  112836. * * 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
  112837. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  112838. * * 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
  112839. * * 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.
  112840. * * If `enclose` is false, a ring surface is one element.
  112841. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  112842. * * 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
  112843. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112844. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112845. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  112846. * @param name defines the name of the mesh
  112847. * @param options defines the options used to create the mesh
  112848. * @param scene defines the hosting scene
  112849. * @returns the cylinder mesh
  112850. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  112851. */
  112852. static CreateCylinder(name: string, options: {
  112853. height?: number;
  112854. diameterTop?: number;
  112855. diameterBottom?: number;
  112856. diameter?: number;
  112857. tessellation?: number;
  112858. subdivisions?: number;
  112859. arc?: number;
  112860. faceColors?: Color4[];
  112861. faceUV?: Vector4[];
  112862. updatable?: boolean;
  112863. hasRings?: boolean;
  112864. enclose?: boolean;
  112865. cap?: number;
  112866. sideOrientation?: number;
  112867. frontUVs?: Vector4;
  112868. backUVs?: Vector4;
  112869. }, scene: any): Mesh;
  112870. }
  112871. }
  112872. declare module BABYLON {
  112873. /**
  112874. * States of the webXR experience
  112875. */
  112876. export enum WebXRState {
  112877. /**
  112878. * Transitioning to being in XR mode
  112879. */
  112880. ENTERING_XR = 0,
  112881. /**
  112882. * Transitioning to non XR mode
  112883. */
  112884. EXITING_XR = 1,
  112885. /**
  112886. * In XR mode and presenting
  112887. */
  112888. IN_XR = 2,
  112889. /**
  112890. * Not entered XR mode
  112891. */
  112892. NOT_IN_XR = 3
  112893. }
  112894. /**
  112895. * Abstraction of the XR render target
  112896. */
  112897. export interface WebXRRenderTarget extends IDisposable {
  112898. /**
  112899. * xrpresent context of the canvas which can be used to display/mirror xr content
  112900. */
  112901. canvasContext: WebGLRenderingContext;
  112902. /**
  112903. * xr layer for the canvas
  112904. */
  112905. xrLayer: Nullable<XRWebGLLayer>;
  112906. /**
  112907. * Initializes the xr layer for the session
  112908. * @param xrSession xr session
  112909. * @returns a promise that will resolve once the XR Layer has been created
  112910. */
  112911. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  112912. }
  112913. }
  112914. declare module BABYLON {
  112915. /**
  112916. * COnfiguration object for WebXR output canvas
  112917. */
  112918. export class WebXRManagedOutputCanvasOptions {
  112919. /**
  112920. * Options for this XR Layer output
  112921. */
  112922. canvasOptions: XRWebGLLayerOptions;
  112923. /**
  112924. * CSS styling for a newly created canvas (if not provided)
  112925. */
  112926. newCanvasCssStyle?: string;
  112927. /**
  112928. * Get the default values of the configuration object
  112929. * @returns default values of this configuration object
  112930. */
  112931. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  112932. }
  112933. /**
  112934. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  112935. */
  112936. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  112937. private configuration;
  112938. private _engine;
  112939. private _canvas;
  112940. /**
  112941. * xrpresent context of the canvas which can be used to display/mirror xr content
  112942. */
  112943. canvasContext: WebGLRenderingContext;
  112944. /**
  112945. * xr layer for the canvas
  112946. */
  112947. xrLayer: Nullable<XRWebGLLayer>;
  112948. /**
  112949. * Initializes the xr layer for the session
  112950. * @param xrSession xr session
  112951. * @returns a promise that will resolve once the XR Layer has been created
  112952. */
  112953. initializeXRLayerAsync(xrSession: any): any;
  112954. /**
  112955. * Initializes the canvas to be added/removed upon entering/exiting xr
  112956. * @param engine the Babylon engine
  112957. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  112958. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  112959. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  112960. */
  112961. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  112962. /**
  112963. * Disposes of the object
  112964. */
  112965. dispose(): void;
  112966. private _setManagedOutputCanvas;
  112967. private _addCanvas;
  112968. private _removeCanvas;
  112969. }
  112970. }
  112971. declare module BABYLON {
  112972. /**
  112973. * Manages an XRSession to work with Babylon's engine
  112974. * @see https://doc.babylonjs.com/how_to/webxr
  112975. */
  112976. export class WebXRSessionManager implements IDisposable {
  112977. /** The scene which the session should be created for */
  112978. scene: Scene;
  112979. /**
  112980. * Fires every time a new xrFrame arrives which can be used to update the camera
  112981. */
  112982. onXRFrameObservable: Observable<XRFrame>;
  112983. /**
  112984. * Fires when the xr session is ended either by the device or manually done
  112985. */
  112986. onXRSessionEnded: Observable<any>;
  112987. /**
  112988. * Fires when the xr session is ended either by the device or manually done
  112989. */
  112990. onXRSessionInit: Observable<XRSession>;
  112991. /**
  112992. * Underlying xr session
  112993. */
  112994. session: XRSession;
  112995. /**
  112996. * Type of reference space used when creating the session
  112997. */
  112998. referenceSpace: XRReferenceSpace;
  112999. /**
  113000. * Current XR frame
  113001. */
  113002. currentFrame: Nullable<XRFrame>;
  113003. /** WebXR timestamp updated every frame */
  113004. currentTimestamp: number;
  113005. private _xrNavigator;
  113006. private baseLayer;
  113007. private _rttProvider;
  113008. private _sessionEnded;
  113009. /**
  113010. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  113011. * @param scene The scene which the session should be created for
  113012. */
  113013. constructor(
  113014. /** The scene which the session should be created for */
  113015. scene: Scene);
  113016. /**
  113017. * Initializes the manager
  113018. * After initialization enterXR can be called to start an XR session
  113019. * @returns Promise which resolves after it is initialized
  113020. */
  113021. initializeAsync(): Promise<void>;
  113022. /**
  113023. * Initializes an xr session
  113024. * @param xrSessionMode mode to initialize
  113025. * @param optionalFeatures defines optional values to pass to the session builder
  113026. * @returns a promise which will resolve once the session has been initialized
  113027. */
  113028. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  113029. /**
  113030. * Sets the reference space on the xr session
  113031. * @param referenceSpace space to set
  113032. * @returns a promise that will resolve once the reference space has been set
  113033. */
  113034. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  113035. /**
  113036. * Updates the render state of the session
  113037. * @param state state to set
  113038. * @returns a promise that resolves once the render state has been updated
  113039. */
  113040. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  113041. /**
  113042. * Starts rendering to the xr layer
  113043. * @returns a promise that will resolve once rendering has started
  113044. */
  113045. startRenderingToXRAsync(): Promise<void>;
  113046. /**
  113047. * Gets the correct render target texture to be rendered this frame for this eye
  113048. * @param eye the eye for which to get the render target
  113049. * @returns the render target for the specified eye
  113050. */
  113051. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  113052. /**
  113053. * Stops the xrSession and restores the renderloop
  113054. * @returns Promise which resolves after it exits XR
  113055. */
  113056. exitXRAsync(): Promise<void>;
  113057. /**
  113058. * Checks if a session would be supported for the creation options specified
  113059. * @param sessionMode session mode to check if supported eg. immersive-vr
  113060. * @returns true if supported
  113061. */
  113062. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  113063. /**
  113064. * Creates a WebXRRenderTarget object for the XR session
  113065. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  113066. * @param options optional options to provide when creating a new render target
  113067. * @returns a WebXR render target to which the session can render
  113068. */
  113069. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  113070. /**
  113071. * @hidden
  113072. * Converts the render layer of xrSession to a render target
  113073. * @param session session to create render target for
  113074. * @param scene scene the new render target should be created for
  113075. * @param baseLayer the webgl layer to create the render target for
  113076. */
  113077. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  113078. /**
  113079. * Disposes of the session manager
  113080. */
  113081. dispose(): void;
  113082. /**
  113083. * Gets a promise returning true when fullfiled if the given session mode is supported
  113084. * @param sessionMode defines the session to test
  113085. * @returns a promise
  113086. */
  113087. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  113088. }
  113089. }
  113090. declare module BABYLON {
  113091. /**
  113092. * WebXR Camera which holds the views for the xrSession
  113093. * @see https://doc.babylonjs.com/how_to/webxr
  113094. */
  113095. export class WebXRCamera extends FreeCamera {
  113096. /**
  113097. * Is the camera in debug mode. Used when using an emulator
  113098. */
  113099. debugMode: boolean;
  113100. /**
  113101. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  113102. * @param name the name of the camera
  113103. * @param scene the scene to add the camera to
  113104. */
  113105. constructor(name: string, scene: Scene);
  113106. private _updateNumberOfRigCameras;
  113107. /** @hidden */
  113108. _updateForDualEyeDebugging(): void;
  113109. /**
  113110. * Updates the cameras position from the current pose information of the XR session
  113111. * @param xrSessionManager the session containing pose information
  113112. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  113113. */
  113114. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  113115. }
  113116. }
  113117. declare module BABYLON {
  113118. /**
  113119. * Defining the interface required for a (webxr) feature
  113120. */
  113121. export interface IWebXRFeature extends IDisposable {
  113122. /**
  113123. * Attach the feature to the session
  113124. * Will usually be called by the features manager
  113125. *
  113126. * @returns true if successful.
  113127. */
  113128. attach(): boolean;
  113129. /**
  113130. * Detach the feature from the session
  113131. * Will usually be called by the features manager
  113132. *
  113133. * @returns true if successful.
  113134. */
  113135. detach(): boolean;
  113136. }
  113137. /**
  113138. * Defining the constructor of a feature. Used to register the modules.
  113139. */
  113140. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  113141. /**
  113142. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  113143. * It is mainly used in AR sessions.
  113144. *
  113145. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  113146. */
  113147. export class WebXRFeaturesManager implements IDisposable {
  113148. private _xrSessionManager;
  113149. private static readonly _AvailableFeatures;
  113150. /**
  113151. * Used to register a module. After calling this function a developer can use this feature in the scene.
  113152. * Mainly used internally.
  113153. *
  113154. * @param featureName the name of the feature to register
  113155. * @param constructorFunction the function used to construct the module
  113156. * @param version the (babylon) version of the module
  113157. * @param stable is that a stable version of this module
  113158. */
  113159. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  113160. /**
  113161. * Returns a constructor of a specific feature.
  113162. *
  113163. * @param featureName the name of the feature to construct
  113164. * @param version the version of the feature to load
  113165. * @param xrSessionManager the xrSessionManager. Used to construct the module
  113166. * @param options optional options provided to the module.
  113167. * @returns a function that, when called, will return a new instance of this feature
  113168. */
  113169. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  113170. /**
  113171. * Return the latest unstable version of this feature
  113172. * @param featureName the name of the feature to search
  113173. * @returns the version number. if not found will return -1
  113174. */
  113175. static GetLatestVersionOfFeature(featureName: string): number;
  113176. /**
  113177. * Return the latest stable version of this feature
  113178. * @param featureName the name of the feature to search
  113179. * @returns the version number. if not found will return -1
  113180. */
  113181. static GetStableVersionOfFeature(featureName: string): number;
  113182. /**
  113183. * Can be used to return the list of features currently registered
  113184. *
  113185. * @returns an Array of available features
  113186. */
  113187. static GetAvailableFeatures(): string[];
  113188. /**
  113189. * Gets the versions available for a specific feature
  113190. * @param featureName the name of the feature
  113191. * @returns an array with the available versions
  113192. */
  113193. static GetAvailableVersions(featureName: string): string[];
  113194. private _features;
  113195. /**
  113196. * constructs a new features manages.
  113197. *
  113198. * @param _xrSessionManager an instance of WebXRSessionManager
  113199. */
  113200. constructor(_xrSessionManager: WebXRSessionManager);
  113201. /**
  113202. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  113203. *
  113204. * @param featureName the name of the feature to load or the class of the feature
  113205. * @param version optional version to load. if not provided the latest version will be enabled
  113206. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  113207. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  113208. * @returns a new constructed feature or throws an error if feature not found.
  113209. */
  113210. enableFeature(featureName: string | {
  113211. Name: string;
  113212. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  113213. /**
  113214. * Used to disable an already-enabled feature
  113215. * @param featureName the feature to disable
  113216. * @returns true if disable was successful
  113217. */
  113218. disableFeature(featureName: string | {
  113219. Name: string;
  113220. }): boolean;
  113221. /**
  113222. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  113223. * Can be used during a session to start a feature
  113224. * @param featureName the name of feature to attach
  113225. */
  113226. attachFeature(featureName: string): void;
  113227. /**
  113228. * Can be used inside a session or when the session ends to detach a specific feature
  113229. * @param featureName the name of the feature to detach
  113230. */
  113231. detachFeature(featureName: string): void;
  113232. /**
  113233. * Get the list of enabled features
  113234. * @returns an array of enabled features
  113235. */
  113236. getEnabledFeatures(): string[];
  113237. /**
  113238. * get the implementation of an enabled feature.
  113239. * @param featureName the name of the feature to load
  113240. * @returns the feature class, if found
  113241. */
  113242. getEnabledFeature(featureName: string): IWebXRFeature;
  113243. /**
  113244. * dispose this features manager
  113245. */
  113246. dispose(): void;
  113247. }
  113248. }
  113249. declare module BABYLON {
  113250. /**
  113251. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  113252. * @see https://doc.babylonjs.com/how_to/webxr
  113253. */
  113254. export class WebXRExperienceHelper implements IDisposable {
  113255. private scene;
  113256. /**
  113257. * 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
  113258. */
  113259. container: AbstractMesh;
  113260. /**
  113261. * Camera used to render xr content
  113262. */
  113263. camera: WebXRCamera;
  113264. /**
  113265. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  113266. */
  113267. state: WebXRState;
  113268. private _setState;
  113269. private static _TmpVector;
  113270. /**
  113271. * Fires when the state of the experience helper has changed
  113272. */
  113273. onStateChangedObservable: Observable<WebXRState>;
  113274. /** Session manager used to keep track of xr session */
  113275. sessionManager: WebXRSessionManager;
  113276. /** A features manager for this xr session */
  113277. featuresManager: WebXRFeaturesManager;
  113278. private _nonVRCamera;
  113279. private _originalSceneAutoClear;
  113280. private _supported;
  113281. /**
  113282. * Creates the experience helper
  113283. * @param scene the scene to attach the experience helper to
  113284. * @returns a promise for the experience helper
  113285. */
  113286. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  113287. /**
  113288. * Creates a WebXRExperienceHelper
  113289. * @param scene The scene the helper should be created in
  113290. */
  113291. private constructor();
  113292. /**
  113293. * Exits XR mode and returns the scene to its original state
  113294. * @returns promise that resolves after xr mode has exited
  113295. */
  113296. exitXRAsync(): Promise<void>;
  113297. /**
  113298. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  113299. * @param sessionMode options for the XR session
  113300. * @param referenceSpaceType frame of reference of the XR session
  113301. * @param renderTarget the output canvas that will be used to enter XR mode
  113302. * @returns promise that resolves after xr mode has entered
  113303. */
  113304. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  113305. /**
  113306. * Updates the global position of the camera by moving the camera's container
  113307. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  113308. * @param position The desired global position of the camera
  113309. */
  113310. setPositionOfCameraUsingContainer(position: Vector3): void;
  113311. /**
  113312. * Rotates the xr camera by rotating the camera's container around the camera's position
  113313. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  113314. * @param rotation the desired quaternion rotation to apply to the camera
  113315. */
  113316. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  113317. /**
  113318. * Disposes of the experience helper
  113319. */
  113320. dispose(): void;
  113321. }
  113322. }
  113323. declare module BABYLON {
  113324. /**
  113325. * Represents an XR input
  113326. */
  113327. export class WebXRController {
  113328. private scene;
  113329. /** The underlying input source for the controller */
  113330. inputSource: XRInputSource;
  113331. private parentContainer;
  113332. /**
  113333. * 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
  113334. */
  113335. grip?: AbstractMesh;
  113336. /**
  113337. * Pointer which can be used to select objects or attach a visible laser to
  113338. */
  113339. pointer: AbstractMesh;
  113340. private _gamepadMode;
  113341. /**
  113342. * If available, this is the gamepad object related to this controller.
  113343. * Using this object it is possible to get click events and trackpad changes of the
  113344. * webxr controller that is currently being used.
  113345. */
  113346. gamepadController?: WebVRController;
  113347. /**
  113348. * Event that fires when the controller is removed/disposed
  113349. */
  113350. onDisposeObservable: Observable<{}>;
  113351. private _tmpQuaternion;
  113352. private _tmpVector;
  113353. /**
  113354. * Creates the controller
  113355. * @see https://doc.babylonjs.com/how_to/webxr
  113356. * @param scene the scene which the controller should be associated to
  113357. * @param inputSource the underlying input source for the controller
  113358. * @param parentContainer parent that the controller meshes should be children of
  113359. */
  113360. constructor(scene: Scene,
  113361. /** The underlying input source for the controller */
  113362. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  113363. /**
  113364. * Updates the controller pose based on the given XRFrame
  113365. * @param xrFrame xr frame to update the pose with
  113366. * @param referenceSpace reference space to use
  113367. */
  113368. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  113369. /**
  113370. * Gets a world space ray coming from the controller
  113371. * @param result the resulting ray
  113372. */
  113373. getWorldPointerRayToRef(result: Ray): void;
  113374. /**
  113375. * Get the scene associated with this controller
  113376. * @returns the scene object
  113377. */
  113378. getScene(): Scene;
  113379. /**
  113380. * Disposes of the object
  113381. */
  113382. dispose(): void;
  113383. }
  113384. }
  113385. declare module BABYLON {
  113386. /**
  113387. * XR input used to track XR inputs such as controllers/rays
  113388. */
  113389. export class WebXRInput implements IDisposable {
  113390. /**
  113391. * Base experience the input listens to
  113392. */
  113393. baseExperience: WebXRExperienceHelper;
  113394. /**
  113395. * XR controllers being tracked
  113396. */
  113397. controllers: Array<WebXRController>;
  113398. private _frameObserver;
  113399. private _stateObserver;
  113400. /**
  113401. * Event when a controller has been connected/added
  113402. */
  113403. onControllerAddedObservable: Observable<WebXRController>;
  113404. /**
  113405. * Event when a controller has been removed/disconnected
  113406. */
  113407. onControllerRemovedObservable: Observable<WebXRController>;
  113408. /**
  113409. * Initializes the WebXRInput
  113410. * @param baseExperience experience helper which the input should be created for
  113411. */
  113412. constructor(
  113413. /**
  113414. * Base experience the input listens to
  113415. */
  113416. baseExperience: WebXRExperienceHelper);
  113417. private _onInputSourcesChange;
  113418. private _addAndRemoveControllers;
  113419. /**
  113420. * Disposes of the object
  113421. */
  113422. dispose(): void;
  113423. }
  113424. }
  113425. declare module BABYLON {
  113426. /**
  113427. * Class used to represent data loading progression
  113428. */
  113429. export class SceneLoaderProgressEvent {
  113430. /** defines if data length to load can be evaluated */
  113431. readonly lengthComputable: boolean;
  113432. /** defines the loaded data length */
  113433. readonly loaded: number;
  113434. /** defines the data length to load */
  113435. readonly total: number;
  113436. /**
  113437. * Create a new progress event
  113438. * @param lengthComputable defines if data length to load can be evaluated
  113439. * @param loaded defines the loaded data length
  113440. * @param total defines the data length to load
  113441. */
  113442. constructor(
  113443. /** defines if data length to load can be evaluated */
  113444. lengthComputable: boolean,
  113445. /** defines the loaded data length */
  113446. loaded: number,
  113447. /** defines the data length to load */
  113448. total: number);
  113449. /**
  113450. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  113451. * @param event defines the source event
  113452. * @returns a new SceneLoaderProgressEvent
  113453. */
  113454. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  113455. }
  113456. /**
  113457. * Interface used by SceneLoader plugins to define supported file extensions
  113458. */
  113459. export interface ISceneLoaderPluginExtensions {
  113460. /**
  113461. * Defines the list of supported extensions
  113462. */
  113463. [extension: string]: {
  113464. isBinary: boolean;
  113465. };
  113466. }
  113467. /**
  113468. * Interface used by SceneLoader plugin factory
  113469. */
  113470. export interface ISceneLoaderPluginFactory {
  113471. /**
  113472. * Defines the name of the factory
  113473. */
  113474. name: string;
  113475. /**
  113476. * Function called to create a new plugin
  113477. * @return the new plugin
  113478. */
  113479. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  113480. /**
  113481. * The callback that returns true if the data can be directly loaded.
  113482. * @param data string containing the file data
  113483. * @returns if the data can be loaded directly
  113484. */
  113485. canDirectLoad?(data: string): boolean;
  113486. }
  113487. /**
  113488. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  113489. */
  113490. export interface ISceneLoaderPluginBase {
  113491. /**
  113492. * The friendly name of this plugin.
  113493. */
  113494. name: string;
  113495. /**
  113496. * The file extensions supported by this plugin.
  113497. */
  113498. extensions: string | ISceneLoaderPluginExtensions;
  113499. /**
  113500. * The callback called when loading from a url.
  113501. * @param scene scene loading this url
  113502. * @param url url to load
  113503. * @param onSuccess callback called when the file successfully loads
  113504. * @param onProgress callback called while file is loading (if the server supports this mode)
  113505. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  113506. * @param onError callback called when the file fails to load
  113507. * @returns a file request object
  113508. */
  113509. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  113510. /**
  113511. * The callback called when loading from a file object.
  113512. * @param scene scene loading this file
  113513. * @param file defines the file to load
  113514. * @param onSuccess defines the callback to call when data is loaded
  113515. * @param onProgress defines the callback to call during loading process
  113516. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  113517. * @param onError defines the callback to call when an error occurs
  113518. * @returns a file request object
  113519. */
  113520. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  113521. /**
  113522. * The callback that returns true if the data can be directly loaded.
  113523. * @param data string containing the file data
  113524. * @returns if the data can be loaded directly
  113525. */
  113526. canDirectLoad?(data: string): boolean;
  113527. /**
  113528. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  113529. * @param scene scene loading this data
  113530. * @param data string containing the data
  113531. * @returns data to pass to the plugin
  113532. */
  113533. directLoad?(scene: Scene, data: string): any;
  113534. /**
  113535. * The callback that allows custom handling of the root url based on the response url.
  113536. * @param rootUrl the original root url
  113537. * @param responseURL the response url if available
  113538. * @returns the new root url
  113539. */
  113540. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  113541. }
  113542. /**
  113543. * Interface used to define a SceneLoader plugin
  113544. */
  113545. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  113546. /**
  113547. * Import meshes into a scene.
  113548. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  113549. * @param scene The scene to import into
  113550. * @param data The data to import
  113551. * @param rootUrl The root url for scene and resources
  113552. * @param meshes The meshes array to import into
  113553. * @param particleSystems The particle systems array to import into
  113554. * @param skeletons The skeletons array to import into
  113555. * @param onError The callback when import fails
  113556. * @returns True if successful or false otherwise
  113557. */
  113558. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  113559. /**
  113560. * Load into a scene.
  113561. * @param scene The scene to load into
  113562. * @param data The data to import
  113563. * @param rootUrl The root url for scene and resources
  113564. * @param onError The callback when import fails
  113565. * @returns True if successful or false otherwise
  113566. */
  113567. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  113568. /**
  113569. * Load into an asset container.
  113570. * @param scene The scene to load into
  113571. * @param data The data to import
  113572. * @param rootUrl The root url for scene and resources
  113573. * @param onError The callback when import fails
  113574. * @returns The loaded asset container
  113575. */
  113576. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  113577. }
  113578. /**
  113579. * Interface used to define an async SceneLoader plugin
  113580. */
  113581. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  113582. /**
  113583. * Import meshes into a scene.
  113584. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  113585. * @param scene The scene to import into
  113586. * @param data The data to import
  113587. * @param rootUrl The root url for scene and resources
  113588. * @param onProgress The callback when the load progresses
  113589. * @param fileName Defines the name of the file to load
  113590. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  113591. */
  113592. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  113593. meshes: AbstractMesh[];
  113594. particleSystems: IParticleSystem[];
  113595. skeletons: Skeleton[];
  113596. animationGroups: AnimationGroup[];
  113597. }>;
  113598. /**
  113599. * Load into a scene.
  113600. * @param scene The scene to load into
  113601. * @param data The data to import
  113602. * @param rootUrl The root url for scene and resources
  113603. * @param onProgress The callback when the load progresses
  113604. * @param fileName Defines the name of the file to load
  113605. * @returns Nothing
  113606. */
  113607. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  113608. /**
  113609. * Load into an asset container.
  113610. * @param scene The scene to load into
  113611. * @param data The data to import
  113612. * @param rootUrl The root url for scene and resources
  113613. * @param onProgress The callback when the load progresses
  113614. * @param fileName Defines the name of the file to load
  113615. * @returns The loaded asset container
  113616. */
  113617. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  113618. }
  113619. /**
  113620. * Mode that determines how to handle old animation groups before loading new ones.
  113621. */
  113622. export enum SceneLoaderAnimationGroupLoadingMode {
  113623. /**
  113624. * Reset all old animations to initial state then dispose them.
  113625. */
  113626. Clean = 0,
  113627. /**
  113628. * Stop all old animations.
  113629. */
  113630. Stop = 1,
  113631. /**
  113632. * Restart old animations from first frame.
  113633. */
  113634. Sync = 2,
  113635. /**
  113636. * Old animations remains untouched.
  113637. */
  113638. NoSync = 3
  113639. }
  113640. /**
  113641. * Class used to load scene from various file formats using registered plugins
  113642. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  113643. */
  113644. export class SceneLoader {
  113645. /**
  113646. * No logging while loading
  113647. */
  113648. static readonly NO_LOGGING: number;
  113649. /**
  113650. * Minimal logging while loading
  113651. */
  113652. static readonly MINIMAL_LOGGING: number;
  113653. /**
  113654. * Summary logging while loading
  113655. */
  113656. static readonly SUMMARY_LOGGING: number;
  113657. /**
  113658. * Detailled logging while loading
  113659. */
  113660. static readonly DETAILED_LOGGING: number;
  113661. /**
  113662. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  113663. */
  113664. static get ForceFullSceneLoadingForIncremental(): boolean;
  113665. static set ForceFullSceneLoadingForIncremental(value: boolean);
  113666. /**
  113667. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  113668. */
  113669. static get ShowLoadingScreen(): boolean;
  113670. static set ShowLoadingScreen(value: boolean);
  113671. /**
  113672. * Defines the current logging level (while loading the scene)
  113673. * @ignorenaming
  113674. */
  113675. static get loggingLevel(): number;
  113676. static set loggingLevel(value: number);
  113677. /**
  113678. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  113679. */
  113680. static get CleanBoneMatrixWeights(): boolean;
  113681. static set CleanBoneMatrixWeights(value: boolean);
  113682. /**
  113683. * Event raised when a plugin is used to load a scene
  113684. */
  113685. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  113686. private static _registeredPlugins;
  113687. private static _getDefaultPlugin;
  113688. private static _getPluginForExtension;
  113689. private static _getPluginForDirectLoad;
  113690. private static _getPluginForFilename;
  113691. private static _getDirectLoad;
  113692. private static _loadData;
  113693. private static _getFileInfo;
  113694. /**
  113695. * Gets a plugin that can load the given extension
  113696. * @param extension defines the extension to load
  113697. * @returns a plugin or null if none works
  113698. */
  113699. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  113700. /**
  113701. * Gets a boolean indicating that the given extension can be loaded
  113702. * @param extension defines the extension to load
  113703. * @returns true if the extension is supported
  113704. */
  113705. static IsPluginForExtensionAvailable(extension: string): boolean;
  113706. /**
  113707. * Adds a new plugin to the list of registered plugins
  113708. * @param plugin defines the plugin to add
  113709. */
  113710. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  113711. /**
  113712. * Import meshes into a scene
  113713. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  113714. * @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)
  113715. * @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)
  113716. * @param scene the instance of BABYLON.Scene to append to
  113717. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  113718. * @param onProgress a callback with a progress event for each file being loaded
  113719. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113720. * @param pluginExtension the extension used to determine the plugin
  113721. * @returns The loaded plugin
  113722. */
  113723. 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>;
  113724. /**
  113725. * Import meshes into a scene
  113726. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  113727. * @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)
  113728. * @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)
  113729. * @param scene the instance of BABYLON.Scene to append to
  113730. * @param onProgress a callback with a progress event for each file being loaded
  113731. * @param pluginExtension the extension used to determine the plugin
  113732. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  113733. */
  113734. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  113735. meshes: AbstractMesh[];
  113736. particleSystems: IParticleSystem[];
  113737. skeletons: Skeleton[];
  113738. animationGroups: AnimationGroup[];
  113739. }>;
  113740. /**
  113741. * Load a scene
  113742. * @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)
  113743. * @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)
  113744. * @param engine is the instance of BABYLON.Engine to use to create the scene
  113745. * @param onSuccess a callback with the scene when import succeeds
  113746. * @param onProgress a callback with a progress event for each file being loaded
  113747. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113748. * @param pluginExtension the extension used to determine the plugin
  113749. * @returns The loaded plugin
  113750. */
  113751. 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>;
  113752. /**
  113753. * Load a scene
  113754. * @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)
  113755. * @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)
  113756. * @param engine is the instance of BABYLON.Engine to use to create the scene
  113757. * @param onProgress a callback with a progress event for each file being loaded
  113758. * @param pluginExtension the extension used to determine the plugin
  113759. * @returns The loaded scene
  113760. */
  113761. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  113762. /**
  113763. * Append a scene
  113764. * @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)
  113765. * @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)
  113766. * @param scene is the instance of BABYLON.Scene to append to
  113767. * @param onSuccess a callback with the scene when import succeeds
  113768. * @param onProgress a callback with a progress event for each file being loaded
  113769. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113770. * @param pluginExtension the extension used to determine the plugin
  113771. * @returns The loaded plugin
  113772. */
  113773. 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>;
  113774. /**
  113775. * Append a scene
  113776. * @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)
  113777. * @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)
  113778. * @param scene is the instance of BABYLON.Scene to append to
  113779. * @param onProgress a callback with a progress event for each file being loaded
  113780. * @param pluginExtension the extension used to determine the plugin
  113781. * @returns The given scene
  113782. */
  113783. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  113784. /**
  113785. * Load a scene into an asset container
  113786. * @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)
  113787. * @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)
  113788. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  113789. * @param onSuccess a callback with the scene when import succeeds
  113790. * @param onProgress a callback with a progress event for each file being loaded
  113791. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113792. * @param pluginExtension the extension used to determine the plugin
  113793. * @returns The loaded plugin
  113794. */
  113795. 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>;
  113796. /**
  113797. * Load a scene into an asset container
  113798. * @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)
  113799. * @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)
  113800. * @param scene is the instance of Scene to append to
  113801. * @param onProgress a callback with a progress event for each file being loaded
  113802. * @param pluginExtension the extension used to determine the plugin
  113803. * @returns The loaded asset container
  113804. */
  113805. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  113806. /**
  113807. * Import animations from a file into a scene
  113808. * @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)
  113809. * @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)
  113810. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  113811. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  113812. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  113813. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  113814. * @param onSuccess a callback with the scene when import succeeds
  113815. * @param onProgress a callback with a progress event for each file being loaded
  113816. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113817. */
  113818. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  113819. /**
  113820. * Import animations from a file into a scene
  113821. * @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)
  113822. * @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)
  113823. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  113824. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  113825. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  113826. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  113827. * @param onSuccess a callback with the scene when import succeeds
  113828. * @param onProgress a callback with a progress event for each file being loaded
  113829. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  113830. * @returns the updated scene with imported animations
  113831. */
  113832. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  113833. }
  113834. }
  113835. declare module BABYLON {
  113836. /**
  113837. * Generic Controller
  113838. */
  113839. export class GenericController extends WebVRController {
  113840. /**
  113841. * Base Url for the controller model.
  113842. */
  113843. static readonly MODEL_BASE_URL: string;
  113844. /**
  113845. * File name for the controller model.
  113846. */
  113847. static readonly MODEL_FILENAME: string;
  113848. /**
  113849. * Creates a new GenericController from a gamepad
  113850. * @param vrGamepad the gamepad that the controller should be created from
  113851. */
  113852. constructor(vrGamepad: any);
  113853. /**
  113854. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113855. * @param scene scene in which to add meshes
  113856. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113857. */
  113858. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  113859. /**
  113860. * Called once for each button that changed state since the last frame
  113861. * @param buttonIdx Which button index changed
  113862. * @param state New state of the button
  113863. * @param changes Which properties on the state changed since last frame
  113864. */
  113865. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113866. }
  113867. }
  113868. declare module BABYLON {
  113869. /**
  113870. * Defines the WindowsMotionController object that the state of the windows motion controller
  113871. */
  113872. export class WindowsMotionController extends WebVRController {
  113873. /**
  113874. * The base url used to load the left and right controller models
  113875. */
  113876. static MODEL_BASE_URL: string;
  113877. /**
  113878. * The name of the left controller model file
  113879. */
  113880. static MODEL_LEFT_FILENAME: string;
  113881. /**
  113882. * The name of the right controller model file
  113883. */
  113884. static MODEL_RIGHT_FILENAME: string;
  113885. /**
  113886. * The controller name prefix for this controller type
  113887. */
  113888. static readonly GAMEPAD_ID_PREFIX: string;
  113889. /**
  113890. * The controller id pattern for this controller type
  113891. */
  113892. private static readonly GAMEPAD_ID_PATTERN;
  113893. private _loadedMeshInfo;
  113894. protected readonly _mapping: {
  113895. buttons: string[];
  113896. buttonMeshNames: {
  113897. 'trigger': string;
  113898. 'menu': string;
  113899. 'grip': string;
  113900. 'thumbstick': string;
  113901. 'trackpad': string;
  113902. };
  113903. buttonObservableNames: {
  113904. 'trigger': string;
  113905. 'menu': string;
  113906. 'grip': string;
  113907. 'thumbstick': string;
  113908. 'trackpad': string;
  113909. };
  113910. axisMeshNames: string[];
  113911. pointingPoseMeshName: string;
  113912. };
  113913. /**
  113914. * Fired when the trackpad on this controller is clicked
  113915. */
  113916. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  113917. /**
  113918. * Fired when the trackpad on this controller is modified
  113919. */
  113920. onTrackpadValuesChangedObservable: Observable<StickValues>;
  113921. /**
  113922. * The current x and y values of this controller's trackpad
  113923. */
  113924. trackpad: StickValues;
  113925. /**
  113926. * Creates a new WindowsMotionController from a gamepad
  113927. * @param vrGamepad the gamepad that the controller should be created from
  113928. */
  113929. constructor(vrGamepad: any);
  113930. /**
  113931. * Fired when the trigger on this controller is modified
  113932. */
  113933. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113934. /**
  113935. * Fired when the menu button on this controller is modified
  113936. */
  113937. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113938. /**
  113939. * Fired when the grip button on this controller is modified
  113940. */
  113941. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113942. /**
  113943. * Fired when the thumbstick button on this controller is modified
  113944. */
  113945. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113946. /**
  113947. * Fired when the touchpad button on this controller is modified
  113948. */
  113949. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  113950. /**
  113951. * Fired when the touchpad values on this controller are modified
  113952. */
  113953. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  113954. protected _updateTrackpad(): void;
  113955. /**
  113956. * Called once per frame by the engine.
  113957. */
  113958. update(): void;
  113959. /**
  113960. * Called once for each button that changed state since the last frame
  113961. * @param buttonIdx Which button index changed
  113962. * @param state New state of the button
  113963. * @param changes Which properties on the state changed since last frame
  113964. */
  113965. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  113966. /**
  113967. * Moves the buttons on the controller mesh based on their current state
  113968. * @param buttonName the name of the button to move
  113969. * @param buttonValue the value of the button which determines the buttons new position
  113970. */
  113971. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  113972. /**
  113973. * Moves the axis on the controller mesh based on its current state
  113974. * @param axis the index of the axis
  113975. * @param axisValue the value of the axis which determines the meshes new position
  113976. * @hidden
  113977. */
  113978. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  113979. /**
  113980. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  113981. * @param scene scene in which to add meshes
  113982. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  113983. */
  113984. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  113985. /**
  113986. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  113987. * can be transformed by button presses and axes values, based on this._mapping.
  113988. *
  113989. * @param scene scene in which the meshes exist
  113990. * @param meshes list of meshes that make up the controller model to process
  113991. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  113992. */
  113993. private processModel;
  113994. private createMeshInfo;
  113995. /**
  113996. * Gets the ray of the controller in the direction the controller is pointing
  113997. * @param length the length the resulting ray should be
  113998. * @returns a ray in the direction the controller is pointing
  113999. */
  114000. getForwardRay(length?: number): Ray;
  114001. /**
  114002. * Disposes of the controller
  114003. */
  114004. dispose(): void;
  114005. }
  114006. /**
  114007. * This class represents a new windows motion controller in XR.
  114008. */
  114009. export class XRWindowsMotionController extends WindowsMotionController {
  114010. /**
  114011. * Changing the original WIndowsMotionController mapping to fir the new mapping
  114012. */
  114013. protected readonly _mapping: {
  114014. buttons: string[];
  114015. buttonMeshNames: {
  114016. 'trigger': string;
  114017. 'menu': string;
  114018. 'grip': string;
  114019. 'thumbstick': string;
  114020. 'trackpad': string;
  114021. };
  114022. buttonObservableNames: {
  114023. 'trigger': string;
  114024. 'menu': string;
  114025. 'grip': string;
  114026. 'thumbstick': string;
  114027. 'trackpad': string;
  114028. };
  114029. axisMeshNames: string[];
  114030. pointingPoseMeshName: string;
  114031. };
  114032. /**
  114033. * Construct a new XR-Based windows motion controller
  114034. *
  114035. * @param gamepadInfo the gamepad object from the browser
  114036. */
  114037. constructor(gamepadInfo: any);
  114038. /**
  114039. * holds the thumbstick values (X,Y)
  114040. */
  114041. thumbstickValues: StickValues;
  114042. /**
  114043. * Fired when the thumbstick on this controller is clicked
  114044. */
  114045. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  114046. /**
  114047. * Fired when the thumbstick on this controller is modified
  114048. */
  114049. onThumbstickValuesChangedObservable: Observable<StickValues>;
  114050. /**
  114051. * Fired when the touchpad button on this controller is modified
  114052. */
  114053. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  114054. /**
  114055. * Fired when the touchpad values on this controller are modified
  114056. */
  114057. onTrackpadValuesChangedObservable: Observable<StickValues>;
  114058. /**
  114059. * Fired when the thumbstick button on this controller is modified
  114060. * here to prevent breaking changes
  114061. */
  114062. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114063. /**
  114064. * updating the thumbstick(!) and not the trackpad.
  114065. * This is named this way due to the difference between WebVR and XR and to avoid
  114066. * changing the parent class.
  114067. */
  114068. protected _updateTrackpad(): void;
  114069. /**
  114070. * Disposes the class with joy
  114071. */
  114072. dispose(): void;
  114073. }
  114074. }
  114075. declare module BABYLON {
  114076. /**
  114077. * Oculus Touch Controller
  114078. */
  114079. export class OculusTouchController extends WebVRController {
  114080. /**
  114081. * Base Url for the controller model.
  114082. */
  114083. static MODEL_BASE_URL: string;
  114084. /**
  114085. * File name for the left controller model.
  114086. */
  114087. static MODEL_LEFT_FILENAME: string;
  114088. /**
  114089. * File name for the right controller model.
  114090. */
  114091. static MODEL_RIGHT_FILENAME: string;
  114092. /**
  114093. * Base Url for the Quest controller model.
  114094. */
  114095. static QUEST_MODEL_BASE_URL: string;
  114096. /**
  114097. * @hidden
  114098. * If the controllers are running on a device that needs the updated Quest controller models
  114099. */
  114100. static _IsQuest: boolean;
  114101. /**
  114102. * Fired when the secondary trigger on this controller is modified
  114103. */
  114104. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  114105. /**
  114106. * Fired when the thumb rest on this controller is modified
  114107. */
  114108. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  114109. /**
  114110. * Creates a new OculusTouchController from a gamepad
  114111. * @param vrGamepad the gamepad that the controller should be created from
  114112. */
  114113. constructor(vrGamepad: any);
  114114. /**
  114115. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  114116. * @param scene scene in which to add meshes
  114117. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  114118. */
  114119. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  114120. /**
  114121. * Fired when the A button on this controller is modified
  114122. */
  114123. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114124. /**
  114125. * Fired when the B button on this controller is modified
  114126. */
  114127. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114128. /**
  114129. * Fired when the X button on this controller is modified
  114130. */
  114131. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114132. /**
  114133. * Fired when the Y button on this controller is modified
  114134. */
  114135. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114136. /**
  114137. * Called once for each button that changed state since the last frame
  114138. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  114139. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  114140. * 2) secondary trigger (same)
  114141. * 3) A (right) X (left), touch, pressed = value
  114142. * 4) B / Y
  114143. * 5) thumb rest
  114144. * @param buttonIdx Which button index changed
  114145. * @param state New state of the button
  114146. * @param changes Which properties on the state changed since last frame
  114147. */
  114148. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  114149. }
  114150. }
  114151. declare module BABYLON {
  114152. /**
  114153. * Vive Controller
  114154. */
  114155. export class ViveController extends WebVRController {
  114156. /**
  114157. * Base Url for the controller model.
  114158. */
  114159. static MODEL_BASE_URL: string;
  114160. /**
  114161. * File name for the controller model.
  114162. */
  114163. static MODEL_FILENAME: string;
  114164. /**
  114165. * Creates a new ViveController from a gamepad
  114166. * @param vrGamepad the gamepad that the controller should be created from
  114167. */
  114168. constructor(vrGamepad: any);
  114169. /**
  114170. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  114171. * @param scene scene in which to add meshes
  114172. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  114173. */
  114174. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  114175. /**
  114176. * Fired when the left button on this controller is modified
  114177. */
  114178. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114179. /**
  114180. * Fired when the right button on this controller is modified
  114181. */
  114182. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114183. /**
  114184. * Fired when the menu button on this controller is modified
  114185. */
  114186. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  114187. /**
  114188. * Called once for each button that changed state since the last frame
  114189. * Vive mapping:
  114190. * 0: touchpad
  114191. * 1: trigger
  114192. * 2: left AND right buttons
  114193. * 3: menu button
  114194. * @param buttonIdx Which button index changed
  114195. * @param state New state of the button
  114196. * @param changes Which properties on the state changed since last frame
  114197. */
  114198. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  114199. }
  114200. }
  114201. declare module BABYLON {
  114202. /**
  114203. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  114204. */
  114205. export class WebXRControllerModelLoader {
  114206. /**
  114207. * an observable that triggers when a new model (the mesh itself) was initialized.
  114208. * To know when the mesh was loaded use the controller's own modelLoaded() method
  114209. */
  114210. onControllerModelLoaded: Observable<WebXRController>;
  114211. /**
  114212. * Creates the WebXRControllerModelLoader
  114213. * @param input xr input that creates the controllers
  114214. */
  114215. constructor(input: WebXRInput);
  114216. }
  114217. }
  114218. declare module BABYLON {
  114219. /**
  114220. * Handles pointer input automatically for the pointer of XR controllers
  114221. */
  114222. export class WebXRControllerPointerSelection {
  114223. private static _idCounter;
  114224. private _tmpRay;
  114225. /**
  114226. * Creates a WebXRControllerPointerSelection
  114227. * @param input input manager to setup pointer selection
  114228. */
  114229. constructor(input: WebXRInput);
  114230. private _convertNormalToDirectionOfRay;
  114231. private _updatePointerDistance;
  114232. }
  114233. }
  114234. declare module BABYLON {
  114235. /**
  114236. * Enables teleportation
  114237. */
  114238. export class WebXRControllerTeleportation {
  114239. private _teleportationFillColor;
  114240. private _teleportationBorderColor;
  114241. private _tmpRay;
  114242. private _tmpVector;
  114243. /**
  114244. * when set to true (default) teleportation will wait for thumbstick changes.
  114245. * When set to false teleportation will be disabled.
  114246. *
  114247. * If set to false while teleporting results can be unexpected.
  114248. */
  114249. enabled: boolean;
  114250. /**
  114251. * Creates a WebXRControllerTeleportation
  114252. * @param input input manager to add teleportation to
  114253. * @param floorMeshes floormeshes which can be teleported to
  114254. */
  114255. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  114256. }
  114257. }
  114258. declare module BABYLON {
  114259. /**
  114260. * Button which can be used to enter a different mode of XR
  114261. */
  114262. export class WebXREnterExitUIButton {
  114263. /** button element */
  114264. element: HTMLElement;
  114265. /** XR initialization options for the button */
  114266. sessionMode: XRSessionMode;
  114267. /** Reference space type */
  114268. referenceSpaceType: XRReferenceSpaceType;
  114269. /**
  114270. * Creates a WebXREnterExitUIButton
  114271. * @param element button element
  114272. * @param sessionMode XR initialization session mode
  114273. * @param referenceSpaceType the type of reference space to be used
  114274. */
  114275. constructor(
  114276. /** button element */
  114277. element: HTMLElement,
  114278. /** XR initialization options for the button */
  114279. sessionMode: XRSessionMode,
  114280. /** Reference space type */
  114281. referenceSpaceType: XRReferenceSpaceType);
  114282. /**
  114283. * Overwritable function which can be used to update the button's visuals when the state changes
  114284. * @param activeButton the current active button in the UI
  114285. */
  114286. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  114287. }
  114288. /**
  114289. * Options to create the webXR UI
  114290. */
  114291. export class WebXREnterExitUIOptions {
  114292. /**
  114293. * Context to enter xr with
  114294. */
  114295. renderTarget?: Nullable<WebXRRenderTarget>;
  114296. /**
  114297. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  114298. */
  114299. customButtons?: Array<WebXREnterExitUIButton>;
  114300. /**
  114301. * A session mode to use when creating the default button.
  114302. * Default is immersive-vr
  114303. */
  114304. sessionMode?: XRSessionMode;
  114305. /**
  114306. * A reference space type to use when creating the default button.
  114307. * Default is local-floor
  114308. */
  114309. referenceSpaceType?: XRReferenceSpaceType;
  114310. }
  114311. /**
  114312. * UI to allow the user to enter/exit XR mode
  114313. */
  114314. export class WebXREnterExitUI implements IDisposable {
  114315. private scene;
  114316. /** version of the options passed to this UI */
  114317. options: WebXREnterExitUIOptions;
  114318. private _overlay;
  114319. private _buttons;
  114320. private _activeButton;
  114321. /**
  114322. * Fired every time the active button is changed.
  114323. *
  114324. * When xr is entered via a button that launches xr that button will be the callback parameter
  114325. *
  114326. * When exiting xr the callback parameter will be null)
  114327. */
  114328. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  114329. /**
  114330. * Creates UI to allow the user to enter/exit XR mode
  114331. * @param scene the scene to add the ui to
  114332. * @param helper the xr experience helper to enter/exit xr with
  114333. * @param options options to configure the UI
  114334. * @returns the created ui
  114335. */
  114336. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  114337. /**
  114338. *
  114339. * @param scene babylon scene object to use
  114340. * @param options (read-only) version of the options passed to this UI
  114341. */
  114342. private constructor();
  114343. private _updateButtons;
  114344. /**
  114345. * Disposes of the object
  114346. */
  114347. dispose(): void;
  114348. }
  114349. }
  114350. declare module BABYLON {
  114351. /**
  114352. * Options for the default xr helper
  114353. */
  114354. export class WebXRDefaultExperienceOptions {
  114355. /**
  114356. * Floor meshes that should be used for teleporting
  114357. */
  114358. floorMeshes: Array<AbstractMesh>;
  114359. /**
  114360. * Enable or disable default UI to enter XR
  114361. */
  114362. disableDefaultUI?: boolean;
  114363. /**
  114364. * optional configuration for the output canvas
  114365. */
  114366. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  114367. /**
  114368. * optional UI options. This can be used among other to change session mode and reference space type
  114369. */
  114370. uiOptions?: WebXREnterExitUIOptions;
  114371. }
  114372. /**
  114373. * Default experience which provides a similar setup to the previous webVRExperience
  114374. */
  114375. export class WebXRDefaultExperience {
  114376. /**
  114377. * Base experience
  114378. */
  114379. baseExperience: WebXRExperienceHelper;
  114380. /**
  114381. * Input experience extension
  114382. */
  114383. input: WebXRInput;
  114384. /**
  114385. * Loads the controller models
  114386. */
  114387. controllerModelLoader: WebXRControllerModelLoader;
  114388. /**
  114389. * Enables laser pointer and selection
  114390. */
  114391. pointerSelection: WebXRControllerPointerSelection;
  114392. /**
  114393. * Enables teleportation
  114394. */
  114395. teleportation: WebXRControllerTeleportation;
  114396. /**
  114397. * Enables ui for entering/exiting xr
  114398. */
  114399. enterExitUI: WebXREnterExitUI;
  114400. /**
  114401. * Default target xr should render to
  114402. */
  114403. renderTarget: WebXRRenderTarget;
  114404. /**
  114405. * Creates the default xr experience
  114406. * @param scene scene
  114407. * @param options options for basic configuration
  114408. * @returns resulting WebXRDefaultExperience
  114409. */
  114410. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  114411. private constructor();
  114412. /**
  114413. * DIsposes of the experience helper
  114414. */
  114415. dispose(): void;
  114416. }
  114417. }
  114418. declare module BABYLON {
  114419. /**
  114420. * Options to modify the vr teleportation behavior.
  114421. */
  114422. export interface VRTeleportationOptions {
  114423. /**
  114424. * The name of the mesh which should be used as the teleportation floor. (default: null)
  114425. */
  114426. floorMeshName?: string;
  114427. /**
  114428. * A list of meshes to be used as the teleportation floor. (default: empty)
  114429. */
  114430. floorMeshes?: Mesh[];
  114431. /**
  114432. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  114433. */
  114434. teleportationMode?: number;
  114435. /**
  114436. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  114437. */
  114438. teleportationTime?: number;
  114439. /**
  114440. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  114441. */
  114442. teleportationSpeed?: number;
  114443. /**
  114444. * The easing function used in the animation or null for Linear. (default CircleEase)
  114445. */
  114446. easingFunction?: EasingFunction;
  114447. }
  114448. /**
  114449. * Options to modify the vr experience helper's behavior.
  114450. */
  114451. export interface VRExperienceHelperOptions extends WebVROptions {
  114452. /**
  114453. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  114454. */
  114455. createDeviceOrientationCamera?: boolean;
  114456. /**
  114457. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  114458. */
  114459. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  114460. /**
  114461. * Uses the main button on the controller to toggle the laser casted. (default: true)
  114462. */
  114463. laserToggle?: boolean;
  114464. /**
  114465. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  114466. */
  114467. floorMeshes?: Mesh[];
  114468. /**
  114469. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  114470. */
  114471. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  114472. /**
  114473. * Defines if WebXR should be used instead of WebVR (if available)
  114474. */
  114475. useXR?: boolean;
  114476. }
  114477. /**
  114478. * Event containing information after VR has been entered
  114479. */
  114480. export class OnAfterEnteringVRObservableEvent {
  114481. /**
  114482. * If entering vr was successful
  114483. */
  114484. success: boolean;
  114485. }
  114486. /**
  114487. * Helps to quickly add VR support to an existing scene.
  114488. * See http://doc.babylonjs.com/how_to/webvr_helper
  114489. */
  114490. export class VRExperienceHelper {
  114491. /** Options to modify the vr experience helper's behavior. */
  114492. webVROptions: VRExperienceHelperOptions;
  114493. private _scene;
  114494. private _position;
  114495. private _btnVR;
  114496. private _btnVRDisplayed;
  114497. private _webVRsupported;
  114498. private _webVRready;
  114499. private _webVRrequesting;
  114500. private _webVRpresenting;
  114501. private _hasEnteredVR;
  114502. private _fullscreenVRpresenting;
  114503. private _inputElement;
  114504. private _webVRCamera;
  114505. private _vrDeviceOrientationCamera;
  114506. private _deviceOrientationCamera;
  114507. private _existingCamera;
  114508. private _onKeyDown;
  114509. private _onVrDisplayPresentChange;
  114510. private _onVRDisplayChanged;
  114511. private _onVRRequestPresentStart;
  114512. private _onVRRequestPresentComplete;
  114513. /**
  114514. * 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)
  114515. */
  114516. enableGazeEvenWhenNoPointerLock: boolean;
  114517. /**
  114518. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  114519. */
  114520. exitVROnDoubleTap: boolean;
  114521. /**
  114522. * Observable raised right before entering VR.
  114523. */
  114524. onEnteringVRObservable: Observable<VRExperienceHelper>;
  114525. /**
  114526. * Observable raised when entering VR has completed.
  114527. */
  114528. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  114529. /**
  114530. * Observable raised when exiting VR.
  114531. */
  114532. onExitingVRObservable: Observable<VRExperienceHelper>;
  114533. /**
  114534. * Observable raised when controller mesh is loaded.
  114535. */
  114536. onControllerMeshLoadedObservable: Observable<WebVRController>;
  114537. /** Return this.onEnteringVRObservable
  114538. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  114539. */
  114540. get onEnteringVR(): Observable<VRExperienceHelper>;
  114541. /** Return this.onExitingVRObservable
  114542. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  114543. */
  114544. get onExitingVR(): Observable<VRExperienceHelper>;
  114545. /** Return this.onControllerMeshLoadedObservable
  114546. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  114547. */
  114548. get onControllerMeshLoaded(): Observable<WebVRController>;
  114549. private _rayLength;
  114550. private _useCustomVRButton;
  114551. private _teleportationRequested;
  114552. private _teleportActive;
  114553. private _floorMeshName;
  114554. private _floorMeshesCollection;
  114555. private _teleportationMode;
  114556. private _teleportationTime;
  114557. private _teleportationSpeed;
  114558. private _teleportationEasing;
  114559. private _rotationAllowed;
  114560. private _teleportBackwardsVector;
  114561. private _teleportationTarget;
  114562. private _isDefaultTeleportationTarget;
  114563. private _postProcessMove;
  114564. private _teleportationFillColor;
  114565. private _teleportationBorderColor;
  114566. private _rotationAngle;
  114567. private _haloCenter;
  114568. private _cameraGazer;
  114569. private _padSensibilityUp;
  114570. private _padSensibilityDown;
  114571. private _leftController;
  114572. private _rightController;
  114573. private _gazeColor;
  114574. private _laserColor;
  114575. private _pickedLaserColor;
  114576. private _pickedGazeColor;
  114577. /**
  114578. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  114579. */
  114580. onNewMeshSelected: Observable<AbstractMesh>;
  114581. /**
  114582. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  114583. * This observable will provide the mesh and the controller used to select the mesh
  114584. */
  114585. onMeshSelectedWithController: Observable<{
  114586. mesh: AbstractMesh;
  114587. controller: WebVRController;
  114588. }>;
  114589. /**
  114590. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  114591. */
  114592. onNewMeshPicked: Observable<PickingInfo>;
  114593. private _circleEase;
  114594. /**
  114595. * Observable raised before camera teleportation
  114596. */
  114597. onBeforeCameraTeleport: Observable<Vector3>;
  114598. /**
  114599. * Observable raised after camera teleportation
  114600. */
  114601. onAfterCameraTeleport: Observable<Vector3>;
  114602. /**
  114603. * Observable raised when current selected mesh gets unselected
  114604. */
  114605. onSelectedMeshUnselected: Observable<AbstractMesh>;
  114606. private _raySelectionPredicate;
  114607. /**
  114608. * To be optionaly changed by user to define custom ray selection
  114609. */
  114610. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  114611. /**
  114612. * To be optionaly changed by user to define custom selection logic (after ray selection)
  114613. */
  114614. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  114615. /**
  114616. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  114617. */
  114618. teleportationEnabled: boolean;
  114619. private _defaultHeight;
  114620. private _teleportationInitialized;
  114621. private _interactionsEnabled;
  114622. private _interactionsRequested;
  114623. private _displayGaze;
  114624. private _displayLaserPointer;
  114625. /**
  114626. * The mesh used to display where the user is going to teleport.
  114627. */
  114628. get teleportationTarget(): Mesh;
  114629. /**
  114630. * Sets the mesh to be used to display where the user is going to teleport.
  114631. */
  114632. set teleportationTarget(value: Mesh);
  114633. /**
  114634. * 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
  114635. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  114636. * See http://doc.babylonjs.com/resources/baking_transformations
  114637. */
  114638. get gazeTrackerMesh(): Mesh;
  114639. set gazeTrackerMesh(value: Mesh);
  114640. /**
  114641. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  114642. */
  114643. updateGazeTrackerScale: boolean;
  114644. /**
  114645. * If the gaze trackers color should be updated when selecting meshes
  114646. */
  114647. updateGazeTrackerColor: boolean;
  114648. /**
  114649. * If the controller laser color should be updated when selecting meshes
  114650. */
  114651. updateControllerLaserColor: boolean;
  114652. /**
  114653. * The gaze tracking mesh corresponding to the left controller
  114654. */
  114655. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  114656. /**
  114657. * The gaze tracking mesh corresponding to the right controller
  114658. */
  114659. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  114660. /**
  114661. * If the ray of the gaze should be displayed.
  114662. */
  114663. get displayGaze(): boolean;
  114664. /**
  114665. * Sets if the ray of the gaze should be displayed.
  114666. */
  114667. set displayGaze(value: boolean);
  114668. /**
  114669. * If the ray of the LaserPointer should be displayed.
  114670. */
  114671. get displayLaserPointer(): boolean;
  114672. /**
  114673. * Sets if the ray of the LaserPointer should be displayed.
  114674. */
  114675. set displayLaserPointer(value: boolean);
  114676. /**
  114677. * The deviceOrientationCamera used as the camera when not in VR.
  114678. */
  114679. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  114680. /**
  114681. * Based on the current WebVR support, returns the current VR camera used.
  114682. */
  114683. get currentVRCamera(): Nullable<Camera>;
  114684. /**
  114685. * The webVRCamera which is used when in VR.
  114686. */
  114687. get webVRCamera(): WebVRFreeCamera;
  114688. /**
  114689. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  114690. */
  114691. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  114692. /**
  114693. * The html button that is used to trigger entering into VR.
  114694. */
  114695. get vrButton(): Nullable<HTMLButtonElement>;
  114696. private get _teleportationRequestInitiated();
  114697. /**
  114698. * Defines wether or not Pointer lock should be requested when switching to
  114699. * full screen.
  114700. */
  114701. requestPointerLockOnFullScreen: boolean;
  114702. /**
  114703. * If asking to force XR, this will be populated with the default xr experience
  114704. */
  114705. xr: WebXRDefaultExperience;
  114706. /**
  114707. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  114708. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  114709. */
  114710. xrTestDone: boolean;
  114711. /**
  114712. * Instantiates a VRExperienceHelper.
  114713. * Helps to quickly add VR support to an existing scene.
  114714. * @param scene The scene the VRExperienceHelper belongs to.
  114715. * @param webVROptions Options to modify the vr experience helper's behavior.
  114716. */
  114717. constructor(scene: Scene,
  114718. /** Options to modify the vr experience helper's behavior. */
  114719. webVROptions?: VRExperienceHelperOptions);
  114720. private completeVRInit;
  114721. private _onDefaultMeshLoaded;
  114722. private _onResize;
  114723. private _onFullscreenChange;
  114724. /**
  114725. * Gets a value indicating if we are currently in VR mode.
  114726. */
  114727. get isInVRMode(): boolean;
  114728. private onVrDisplayPresentChange;
  114729. private onVRDisplayChanged;
  114730. private moveButtonToBottomRight;
  114731. private displayVRButton;
  114732. private updateButtonVisibility;
  114733. private _cachedAngularSensibility;
  114734. /**
  114735. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  114736. * Otherwise, will use the fullscreen API.
  114737. */
  114738. enterVR(): void;
  114739. /**
  114740. * Attempt to exit VR, or fullscreen.
  114741. */
  114742. exitVR(): void;
  114743. /**
  114744. * The position of the vr experience helper.
  114745. */
  114746. get position(): Vector3;
  114747. /**
  114748. * Sets the position of the vr experience helper.
  114749. */
  114750. set position(value: Vector3);
  114751. /**
  114752. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  114753. */
  114754. enableInteractions(): void;
  114755. private get _noControllerIsActive();
  114756. private beforeRender;
  114757. private _isTeleportationFloor;
  114758. /**
  114759. * Adds a floor mesh to be used for teleportation.
  114760. * @param floorMesh the mesh to be used for teleportation.
  114761. */
  114762. addFloorMesh(floorMesh: Mesh): void;
  114763. /**
  114764. * Removes a floor mesh from being used for teleportation.
  114765. * @param floorMesh the mesh to be removed.
  114766. */
  114767. removeFloorMesh(floorMesh: Mesh): void;
  114768. /**
  114769. * Enables interactions and teleportation using the VR controllers and gaze.
  114770. * @param vrTeleportationOptions options to modify teleportation behavior.
  114771. */
  114772. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  114773. private _onNewGamepadConnected;
  114774. private _tryEnableInteractionOnController;
  114775. private _onNewGamepadDisconnected;
  114776. private _enableInteractionOnController;
  114777. private _checkTeleportWithRay;
  114778. private _checkRotate;
  114779. private _checkTeleportBackwards;
  114780. private _enableTeleportationOnController;
  114781. private _createTeleportationCircles;
  114782. private _displayTeleportationTarget;
  114783. private _hideTeleportationTarget;
  114784. private _rotateCamera;
  114785. private _moveTeleportationSelectorTo;
  114786. private _workingVector;
  114787. private _workingQuaternion;
  114788. private _workingMatrix;
  114789. /**
  114790. * Time Constant Teleportation Mode
  114791. */
  114792. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  114793. /**
  114794. * Speed Constant Teleportation Mode
  114795. */
  114796. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  114797. /**
  114798. * Teleports the users feet to the desired location
  114799. * @param location The location where the user's feet should be placed
  114800. */
  114801. teleportCamera(location: Vector3): void;
  114802. private _convertNormalToDirectionOfRay;
  114803. private _castRayAndSelectObject;
  114804. private _notifySelectedMeshUnselected;
  114805. /**
  114806. * Permanently set new colors for the laser pointer
  114807. * @param color the new laser color
  114808. * @param pickedColor the new laser color when picked mesh detected
  114809. */
  114810. setLaserColor(color: Color3, pickedColor?: Color3): void;
  114811. /**
  114812. * Permanently set new colors for the gaze pointer
  114813. * @param color the new gaze color
  114814. * @param pickedColor the new gaze color when picked mesh detected
  114815. */
  114816. setGazeColor(color: Color3, pickedColor?: Color3): void;
  114817. /**
  114818. * Sets the color of the laser ray from the vr controllers.
  114819. * @param color new color for the ray.
  114820. */
  114821. changeLaserColor(color: Color3): void;
  114822. /**
  114823. * Sets the color of the ray from the vr headsets gaze.
  114824. * @param color new color for the ray.
  114825. */
  114826. changeGazeColor(color: Color3): void;
  114827. /**
  114828. * Exits VR and disposes of the vr experience helper
  114829. */
  114830. dispose(): void;
  114831. /**
  114832. * Gets the name of the VRExperienceHelper class
  114833. * @returns "VRExperienceHelper"
  114834. */
  114835. getClassName(): string;
  114836. }
  114837. }
  114838. declare module BABYLON {
  114839. /**
  114840. * Options used for hit testing
  114841. */
  114842. export interface IWebXRHitTestOptions {
  114843. /**
  114844. * Only test when user interacted with the scene. Default - hit test every frame
  114845. */
  114846. testOnPointerDownOnly?: boolean;
  114847. /**
  114848. * The node to use to transform the local results to world coordinates
  114849. */
  114850. worldParentNode?: TransformNode;
  114851. }
  114852. /**
  114853. * Interface defining the babylon result of raycasting/hit-test
  114854. */
  114855. export interface IWebXRHitResult {
  114856. /**
  114857. * The native hit test result
  114858. */
  114859. xrHitResult: XRHitResult;
  114860. /**
  114861. * Transformation matrix that can be applied to a node that will put it in the hit point location
  114862. */
  114863. transformationMatrix: Matrix;
  114864. }
  114865. /**
  114866. * The currently-working hit-test module.
  114867. * Hit test (or raycasting) is used to interact with the real world.
  114868. * For further information read here - https://github.com/immersive-web/hit-test
  114869. */
  114870. export class WebXRHitTestLegacy implements IWebXRFeature {
  114871. private _xrSessionManager;
  114872. /**
  114873. * options to use when constructing this feature
  114874. */
  114875. readonly options: IWebXRHitTestOptions;
  114876. /**
  114877. * The module's name
  114878. */
  114879. static readonly Name: string;
  114880. /**
  114881. * The (Babylon) version of this module.
  114882. * This is an integer representing the implementation version.
  114883. * This number does not correspond to the webxr specs version
  114884. */
  114885. static readonly Version: number;
  114886. /**
  114887. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  114888. * @param event the (select) event to use to select with
  114889. * @param referenceSpace the reference space to use for this hit test
  114890. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  114891. */
  114892. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  114893. /**
  114894. * execute a hit test with an XR Ray
  114895. *
  114896. * @param xrSession a native xrSession that will execute this hit test
  114897. * @param xrRay the ray (position and direction) to use for raycasting
  114898. * @param referenceSpace native XR reference space to use for the hit-test
  114899. * @param filter filter function that will filter the results
  114900. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  114901. */
  114902. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  114903. /**
  114904. * Triggered when new babylon (transformed) hit test results are available
  114905. */
  114906. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  114907. /**
  114908. * Creates a new instance of the (legacy version) hit test feature
  114909. * @param _xrSessionManager an instance of WebXRSessionManager
  114910. * @param options options to use when constructing this feature
  114911. */
  114912. constructor(_xrSessionManager: WebXRSessionManager,
  114913. /**
  114914. * options to use when constructing this feature
  114915. */
  114916. options?: IWebXRHitTestOptions);
  114917. private _onSelectEnabled;
  114918. private _xrFrameObserver;
  114919. private _attached;
  114920. /**
  114921. * Populated with the last native XR Hit Results
  114922. */
  114923. lastNativeXRHitResults: XRHitResult[];
  114924. /**
  114925. * attach this feature
  114926. * Will usually be called by the features manager
  114927. *
  114928. * @returns true if successful.
  114929. */
  114930. attach(): boolean;
  114931. /**
  114932. * detach this feature.
  114933. * Will usually be called by the features manager
  114934. *
  114935. * @returns true if successful.
  114936. */
  114937. detach(): boolean;
  114938. private _onHitTestResults;
  114939. private _onSelect;
  114940. /**
  114941. * Dispose this feature and all of the resources attached
  114942. */
  114943. dispose(): void;
  114944. }
  114945. }
  114946. declare module BABYLON {
  114947. /**
  114948. * Options used in the plane detector module
  114949. */
  114950. export interface IWebXRPlaneDetectorOptions {
  114951. /**
  114952. * The node to use to transform the local results to world coordinates
  114953. */
  114954. worldParentNode?: TransformNode;
  114955. }
  114956. /**
  114957. * A babylon interface for a webxr plane.
  114958. * A Plane is actually a polygon, built from N points in space
  114959. */
  114960. export interface IWebXRPlane {
  114961. /**
  114962. * a babylon-assigned ID for this polygon
  114963. */
  114964. id: number;
  114965. /**
  114966. * the native xr-plane object
  114967. */
  114968. xrPlane: XRPlane;
  114969. /**
  114970. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  114971. */
  114972. polygonDefinition: Array<Vector3>;
  114973. /**
  114974. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  114975. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  114976. */
  114977. transformationMatrix: Matrix;
  114978. }
  114979. /**
  114980. * The plane detector is used to detect planes in the real world when in AR
  114981. * For more information see https://github.com/immersive-web/real-world-geometry/
  114982. */
  114983. export class WebXRPlaneDetector implements IWebXRFeature {
  114984. private _xrSessionManager;
  114985. private _options;
  114986. /**
  114987. * The module's name
  114988. */
  114989. static readonly Name: string;
  114990. /**
  114991. * The (Babylon) version of this module.
  114992. * This is an integer representing the implementation version.
  114993. * This number does not correspond to the webxr specs version
  114994. */
  114995. static readonly Version: number;
  114996. /**
  114997. * Observers registered here will be executed when a new plane was added to the session
  114998. */
  114999. onPlaneAddedObservable: Observable<IWebXRPlane>;
  115000. /**
  115001. * Observers registered here will be executed when a plane is no longer detected in the session
  115002. */
  115003. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  115004. /**
  115005. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  115006. * This can execute N times every frame
  115007. */
  115008. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  115009. private _enabled;
  115010. private _attached;
  115011. private _detectedPlanes;
  115012. private _lastFrameDetected;
  115013. private _observerTracked;
  115014. /**
  115015. * construct a new Plane Detector
  115016. * @param _xrSessionManager an instance of xr Session manager
  115017. * @param _options configuration to use when constructing this feature
  115018. */
  115019. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  115020. /**
  115021. * attach this feature
  115022. * Will usually be called by the features manager
  115023. *
  115024. * @returns true if successful.
  115025. */
  115026. attach(): boolean;
  115027. /**
  115028. * detach this feature.
  115029. * Will usually be called by the features manager
  115030. *
  115031. * @returns true if successful.
  115032. */
  115033. detach(): boolean;
  115034. /**
  115035. * Dispose this feature and all of the resources attached
  115036. */
  115037. dispose(): void;
  115038. private _updatePlaneWithXRPlane;
  115039. /**
  115040. * avoiding using Array.find for global support.
  115041. * @param xrPlane the plane to find in the array
  115042. */
  115043. private findIndexInPlaneArray;
  115044. }
  115045. }
  115046. declare module BABYLON {
  115047. /**
  115048. * Configuration options of the anchor system
  115049. */
  115050. export interface IWebXRAnchorSystemOptions {
  115051. /**
  115052. * a node that will be used to convert local to world coordinates
  115053. */
  115054. worldParentNode?: TransformNode;
  115055. /**
  115056. * should the anchor system use plane detection.
  115057. * If set to true, the plane-detection feature should be set using setPlaneDetector
  115058. */
  115059. usePlaneDetection?: boolean;
  115060. /**
  115061. * Should a new anchor be added every time a select event is triggered
  115062. */
  115063. addAnchorOnSelect?: boolean;
  115064. }
  115065. /**
  115066. * A babylon container for an XR Anchor
  115067. */
  115068. export interface IWebXRAnchor {
  115069. /**
  115070. * A babylon-assigned ID for this anchor
  115071. */
  115072. id: number;
  115073. /**
  115074. * The native anchor object
  115075. */
  115076. xrAnchor: XRAnchor;
  115077. /**
  115078. * Transformation matrix to apply to an object attached to this anchor
  115079. */
  115080. transformationMatrix: Matrix;
  115081. }
  115082. /**
  115083. * An implementation of the anchor system of WebXR.
  115084. * Note that the current documented implementation is not available in any browser. Future implementations
  115085. * will use the frame to create an anchor and not the session or a detected plane
  115086. * For further information see https://github.com/immersive-web/anchors/
  115087. */
  115088. export class WebXRAnchorSystem implements IWebXRFeature {
  115089. private _xrSessionManager;
  115090. private _options;
  115091. /**
  115092. * The module's name
  115093. */
  115094. static readonly Name: string;
  115095. /**
  115096. * The (Babylon) version of this module.
  115097. * This is an integer representing the implementation version.
  115098. * This number does not correspond to the webxr specs version
  115099. */
  115100. static readonly Version: number;
  115101. /**
  115102. * Observers registered here will be executed when a new anchor was added to the session
  115103. */
  115104. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  115105. /**
  115106. * Observers registered here will be executed when an existing anchor updates
  115107. * This can execute N times every frame
  115108. */
  115109. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  115110. /**
  115111. * Observers registered here will be executed when an anchor was removed from the session
  115112. */
  115113. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  115114. private _planeDetector;
  115115. private _hitTestModule;
  115116. private _enabled;
  115117. private _attached;
  115118. private _trackedAnchors;
  115119. private _lastFrameDetected;
  115120. private _observerTracked;
  115121. /**
  115122. * constructs a new anchor system
  115123. * @param _xrSessionManager an instance of WebXRSessionManager
  115124. * @param _options configuration object for this feature
  115125. */
  115126. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  115127. /**
  115128. * set the plane detector to use in order to create anchors from frames
  115129. * @param planeDetector the plane-detector module to use
  115130. * @param enable enable plane-anchors. default is true
  115131. */
  115132. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  115133. /**
  115134. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  115135. * @param hitTestModule the hit-test module to use.
  115136. */
  115137. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  115138. /**
  115139. * attach this feature
  115140. * Will usually be called by the features manager
  115141. *
  115142. * @returns true if successful.
  115143. */
  115144. attach(): boolean;
  115145. /**
  115146. * detach this feature.
  115147. * Will usually be called by the features manager
  115148. *
  115149. * @returns true if successful.
  115150. */
  115151. detach(): boolean;
  115152. /**
  115153. * Dispose this feature and all of the resources attached
  115154. */
  115155. dispose(): void;
  115156. private _onSelect;
  115157. /**
  115158. * Add anchor at a specific XR point.
  115159. *
  115160. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  115161. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  115162. * @returns a promise the fulfills when the anchor was created
  115163. */
  115164. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  115165. private _updateAnchorWithXRFrame;
  115166. /**
  115167. * avoiding using Array.find for global support.
  115168. * @param xrAnchor the plane to find in the array
  115169. */
  115170. private _findIndexInAnchorArray;
  115171. }
  115172. }
  115173. declare module BABYLON {
  115174. /**
  115175. * Options interface for the background remover plugin
  115176. */
  115177. export interface IWebXRBackgroundRemoverOptions {
  115178. /**
  115179. * don't disable the environment helper
  115180. */
  115181. ignoreEnvironmentHelper?: boolean;
  115182. /**
  115183. * flags to configure the removal of the environment helper.
  115184. * If not set, the entire background will be removed. If set, flags should be set as well.
  115185. */
  115186. environmentHelperRemovalFlags?: {
  115187. /**
  115188. * Should the skybox be removed (default false)
  115189. */
  115190. skyBox?: boolean;
  115191. /**
  115192. * Should the ground be removed (default false)
  115193. */
  115194. ground?: boolean;
  115195. };
  115196. /**
  115197. * Further background meshes to disable when entering AR
  115198. */
  115199. backgroundMeshes?: AbstractMesh[];
  115200. }
  115201. /**
  115202. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  115203. */
  115204. export class WebXRBackgroundRemover implements IWebXRFeature {
  115205. private _xrSessionManager;
  115206. /**
  115207. * read-only options to be used in this module
  115208. */
  115209. readonly options: IWebXRBackgroundRemoverOptions;
  115210. /**
  115211. * The module's name
  115212. */
  115213. static readonly Name: string;
  115214. /**
  115215. * The (Babylon) version of this module.
  115216. * This is an integer representing the implementation version.
  115217. * This number does not correspond to the webxr specs version
  115218. */
  115219. static readonly Version: number;
  115220. /**
  115221. * registered observers will be triggered when the background state changes
  115222. */
  115223. onBackgroundStateChangedObservable: Observable<boolean>;
  115224. /**
  115225. * constructs a new background remover module
  115226. * @param _xrSessionManager the session manager for this module
  115227. * @param options read-only options to be used in this module
  115228. */
  115229. constructor(_xrSessionManager: WebXRSessionManager,
  115230. /**
  115231. * read-only options to be used in this module
  115232. */
  115233. options?: IWebXRBackgroundRemoverOptions);
  115234. /**
  115235. * attach this feature
  115236. * Will usually be called by the features manager
  115237. *
  115238. * @returns true if successful.
  115239. */
  115240. attach(): boolean;
  115241. /**
  115242. * detach this feature.
  115243. * Will usually be called by the features manager
  115244. *
  115245. * @returns true if successful.
  115246. */
  115247. detach(): boolean;
  115248. private _setBackgroundState;
  115249. /**
  115250. * Dispose this feature and all of the resources attached
  115251. */
  115252. dispose(): void;
  115253. }
  115254. }
  115255. declare module BABYLON {
  115256. /**
  115257. * Contains an array of blocks representing the octree
  115258. */
  115259. export interface IOctreeContainer<T> {
  115260. /**
  115261. * Blocks within the octree
  115262. */
  115263. blocks: Array<OctreeBlock<T>>;
  115264. }
  115265. /**
  115266. * Class used to store a cell in an octree
  115267. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115268. */
  115269. export class OctreeBlock<T> {
  115270. /**
  115271. * Gets the content of the current block
  115272. */
  115273. entries: T[];
  115274. /**
  115275. * Gets the list of block children
  115276. */
  115277. blocks: Array<OctreeBlock<T>>;
  115278. private _depth;
  115279. private _maxDepth;
  115280. private _capacity;
  115281. private _minPoint;
  115282. private _maxPoint;
  115283. private _boundingVectors;
  115284. private _creationFunc;
  115285. /**
  115286. * Creates a new block
  115287. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  115288. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  115289. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  115290. * @param depth defines the current depth of this block in the octree
  115291. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  115292. * @param creationFunc defines a callback to call when an element is added to the block
  115293. */
  115294. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  115295. /**
  115296. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  115297. */
  115298. get capacity(): number;
  115299. /**
  115300. * Gets the minimum vector (in world space) of the block's bounding box
  115301. */
  115302. get minPoint(): Vector3;
  115303. /**
  115304. * Gets the maximum vector (in world space) of the block's bounding box
  115305. */
  115306. get maxPoint(): Vector3;
  115307. /**
  115308. * Add a new element to this block
  115309. * @param entry defines the element to add
  115310. */
  115311. addEntry(entry: T): void;
  115312. /**
  115313. * Remove an element from this block
  115314. * @param entry defines the element to remove
  115315. */
  115316. removeEntry(entry: T): void;
  115317. /**
  115318. * Add an array of elements to this block
  115319. * @param entries defines the array of elements to add
  115320. */
  115321. addEntries(entries: T[]): void;
  115322. /**
  115323. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  115324. * @param frustumPlanes defines the frustum planes to test
  115325. * @param selection defines the array to store current content if selection is positive
  115326. * @param allowDuplicate defines if the selection array can contains duplicated entries
  115327. */
  115328. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  115329. /**
  115330. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  115331. * @param sphereCenter defines the bounding sphere center
  115332. * @param sphereRadius defines the bounding sphere radius
  115333. * @param selection defines the array to store current content if selection is positive
  115334. * @param allowDuplicate defines if the selection array can contains duplicated entries
  115335. */
  115336. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  115337. /**
  115338. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  115339. * @param ray defines the ray to test with
  115340. * @param selection defines the array to store current content if selection is positive
  115341. */
  115342. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  115343. /**
  115344. * Subdivide the content into child blocks (this block will then be empty)
  115345. */
  115346. createInnerBlocks(): void;
  115347. /**
  115348. * @hidden
  115349. */
  115350. 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;
  115351. }
  115352. }
  115353. declare module BABYLON {
  115354. /**
  115355. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  115356. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115357. */
  115358. export class Octree<T> {
  115359. /** 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.) */
  115360. maxDepth: number;
  115361. /**
  115362. * Blocks within the octree containing objects
  115363. */
  115364. blocks: Array<OctreeBlock<T>>;
  115365. /**
  115366. * Content stored in the octree
  115367. */
  115368. dynamicContent: T[];
  115369. private _maxBlockCapacity;
  115370. private _selectionContent;
  115371. private _creationFunc;
  115372. /**
  115373. * Creates a octree
  115374. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115375. * @param creationFunc function to be used to instatiate the octree
  115376. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  115377. * @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.)
  115378. */
  115379. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  115380. /** 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.) */
  115381. maxDepth?: number);
  115382. /**
  115383. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  115384. * @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);
  115385. * @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);
  115386. * @param entries meshes to be added to the octree blocks
  115387. */
  115388. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  115389. /**
  115390. * Adds a mesh to the octree
  115391. * @param entry Mesh to add to the octree
  115392. */
  115393. addMesh(entry: T): void;
  115394. /**
  115395. * Remove an element from the octree
  115396. * @param entry defines the element to remove
  115397. */
  115398. removeMesh(entry: T): void;
  115399. /**
  115400. * Selects an array of meshes within the frustum
  115401. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  115402. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  115403. * @returns array of meshes within the frustum
  115404. */
  115405. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  115406. /**
  115407. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  115408. * @param sphereCenter defines the bounding sphere center
  115409. * @param sphereRadius defines the bounding sphere radius
  115410. * @param allowDuplicate defines if the selection array can contains duplicated entries
  115411. * @returns an array of objects that intersect the sphere
  115412. */
  115413. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  115414. /**
  115415. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  115416. * @param ray defines the ray to test with
  115417. * @returns array of intersected objects
  115418. */
  115419. intersectsRay(ray: Ray): SmartArray<T>;
  115420. /**
  115421. * Adds a mesh into the octree block if it intersects the block
  115422. */
  115423. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  115424. /**
  115425. * Adds a submesh into the octree block if it intersects the block
  115426. */
  115427. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  115428. }
  115429. }
  115430. declare module BABYLON {
  115431. interface Scene {
  115432. /**
  115433. * @hidden
  115434. * Backing Filed
  115435. */
  115436. _selectionOctree: Octree<AbstractMesh>;
  115437. /**
  115438. * Gets the octree used to boost mesh selection (picking)
  115439. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115440. */
  115441. selectionOctree: Octree<AbstractMesh>;
  115442. /**
  115443. * Creates or updates the octree used to boost selection (picking)
  115444. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115445. * @param maxCapacity defines the maximum capacity per leaf
  115446. * @param maxDepth defines the maximum depth of the octree
  115447. * @returns an octree of AbstractMesh
  115448. */
  115449. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  115450. }
  115451. interface AbstractMesh {
  115452. /**
  115453. * @hidden
  115454. * Backing Field
  115455. */
  115456. _submeshesOctree: Octree<SubMesh>;
  115457. /**
  115458. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  115459. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  115460. * @param maxCapacity defines the maximum size of each block (64 by default)
  115461. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  115462. * @returns the new octree
  115463. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  115464. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  115465. */
  115466. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  115467. }
  115468. /**
  115469. * Defines the octree scene component responsible to manage any octrees
  115470. * in a given scene.
  115471. */
  115472. export class OctreeSceneComponent {
  115473. /**
  115474. * The component name help to identify the component in the list of scene components.
  115475. */
  115476. readonly name: string;
  115477. /**
  115478. * The scene the component belongs to.
  115479. */
  115480. scene: Scene;
  115481. /**
  115482. * Indicates if the meshes have been checked to make sure they are isEnabled()
  115483. */
  115484. readonly checksIsEnabled: boolean;
  115485. /**
  115486. * Creates a new instance of the component for the given scene
  115487. * @param scene Defines the scene to register the component in
  115488. */
  115489. constructor(scene: Scene);
  115490. /**
  115491. * Registers the component in a given scene
  115492. */
  115493. register(): void;
  115494. /**
  115495. * Return the list of active meshes
  115496. * @returns the list of active meshes
  115497. */
  115498. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  115499. /**
  115500. * Return the list of active sub meshes
  115501. * @param mesh The mesh to get the candidates sub meshes from
  115502. * @returns the list of active sub meshes
  115503. */
  115504. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  115505. private _tempRay;
  115506. /**
  115507. * Return the list of sub meshes intersecting with a given local ray
  115508. * @param mesh defines the mesh to find the submesh for
  115509. * @param localRay defines the ray in local space
  115510. * @returns the list of intersecting sub meshes
  115511. */
  115512. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  115513. /**
  115514. * Return the list of sub meshes colliding with a collider
  115515. * @param mesh defines the mesh to find the submesh for
  115516. * @param collider defines the collider to evaluate the collision against
  115517. * @returns the list of colliding sub meshes
  115518. */
  115519. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  115520. /**
  115521. * Rebuilds the elements related to this component in case of
  115522. * context lost for instance.
  115523. */
  115524. rebuild(): void;
  115525. /**
  115526. * Disposes the component and the associated ressources.
  115527. */
  115528. dispose(): void;
  115529. }
  115530. }
  115531. declare module BABYLON {
  115532. /**
  115533. * Renders a layer on top of an existing scene
  115534. */
  115535. export class UtilityLayerRenderer implements IDisposable {
  115536. /** the original scene that will be rendered on top of */
  115537. originalScene: Scene;
  115538. private _pointerCaptures;
  115539. private _lastPointerEvents;
  115540. private static _DefaultUtilityLayer;
  115541. private static _DefaultKeepDepthUtilityLayer;
  115542. private _sharedGizmoLight;
  115543. private _renderCamera;
  115544. /**
  115545. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  115546. * @returns the camera that is used when rendering the utility layer
  115547. */
  115548. getRenderCamera(): Nullable<Camera>;
  115549. /**
  115550. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  115551. * @param cam the camera that should be used when rendering the utility layer
  115552. */
  115553. setRenderCamera(cam: Nullable<Camera>): void;
  115554. /**
  115555. * @hidden
  115556. * Light which used by gizmos to get light shading
  115557. */
  115558. _getSharedGizmoLight(): HemisphericLight;
  115559. /**
  115560. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  115561. */
  115562. pickUtilitySceneFirst: boolean;
  115563. /**
  115564. * 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)
  115565. */
  115566. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  115567. /**
  115568. * 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)
  115569. */
  115570. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  115571. /**
  115572. * The scene that is rendered on top of the original scene
  115573. */
  115574. utilityLayerScene: Scene;
  115575. /**
  115576. * If the utility layer should automatically be rendered on top of existing scene
  115577. */
  115578. shouldRender: boolean;
  115579. /**
  115580. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  115581. */
  115582. onlyCheckPointerDownEvents: boolean;
  115583. /**
  115584. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  115585. */
  115586. processAllEvents: boolean;
  115587. /**
  115588. * Observable raised when the pointer move from the utility layer scene to the main scene
  115589. */
  115590. onPointerOutObservable: Observable<number>;
  115591. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  115592. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  115593. private _afterRenderObserver;
  115594. private _sceneDisposeObserver;
  115595. private _originalPointerObserver;
  115596. /**
  115597. * Instantiates a UtilityLayerRenderer
  115598. * @param originalScene the original scene that will be rendered on top of
  115599. * @param handleEvents boolean indicating if the utility layer should handle events
  115600. */
  115601. constructor(
  115602. /** the original scene that will be rendered on top of */
  115603. originalScene: Scene, handleEvents?: boolean);
  115604. private _notifyObservers;
  115605. /**
  115606. * Renders the utility layers scene on top of the original scene
  115607. */
  115608. render(): void;
  115609. /**
  115610. * Disposes of the renderer
  115611. */
  115612. dispose(): void;
  115613. private _updateCamera;
  115614. }
  115615. }
  115616. declare module BABYLON {
  115617. /**
  115618. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  115619. */
  115620. export class Gizmo implements IDisposable {
  115621. /** The utility layer the gizmo will be added to */
  115622. gizmoLayer: UtilityLayerRenderer;
  115623. /**
  115624. * The root mesh of the gizmo
  115625. */
  115626. _rootMesh: Mesh;
  115627. private _attachedMesh;
  115628. /**
  115629. * Ratio for the scale of the gizmo (Default: 1)
  115630. */
  115631. scaleRatio: number;
  115632. /**
  115633. * If a custom mesh has been set (Default: false)
  115634. */
  115635. protected _customMeshSet: boolean;
  115636. /**
  115637. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  115638. * * When set, interactions will be enabled
  115639. */
  115640. get attachedMesh(): Nullable<AbstractMesh>;
  115641. set attachedMesh(value: Nullable<AbstractMesh>);
  115642. /**
  115643. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  115644. * @param mesh The mesh to replace the default mesh of the gizmo
  115645. */
  115646. setCustomMesh(mesh: Mesh): void;
  115647. /**
  115648. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  115649. */
  115650. updateGizmoRotationToMatchAttachedMesh: boolean;
  115651. /**
  115652. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  115653. */
  115654. updateGizmoPositionToMatchAttachedMesh: boolean;
  115655. /**
  115656. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  115657. */
  115658. updateScale: boolean;
  115659. protected _interactionsEnabled: boolean;
  115660. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115661. private _beforeRenderObserver;
  115662. private _tempVector;
  115663. /**
  115664. * Creates a gizmo
  115665. * @param gizmoLayer The utility layer the gizmo will be added to
  115666. */
  115667. constructor(
  115668. /** The utility layer the gizmo will be added to */
  115669. gizmoLayer?: UtilityLayerRenderer);
  115670. /**
  115671. * Updates the gizmo to match the attached mesh's position/rotation
  115672. */
  115673. protected _update(): void;
  115674. /**
  115675. * Disposes of the gizmo
  115676. */
  115677. dispose(): void;
  115678. }
  115679. }
  115680. declare module BABYLON {
  115681. /**
  115682. * Single plane drag gizmo
  115683. */
  115684. export class PlaneDragGizmo extends Gizmo {
  115685. /**
  115686. * Drag behavior responsible for the gizmos dragging interactions
  115687. */
  115688. dragBehavior: PointerDragBehavior;
  115689. private _pointerObserver;
  115690. /**
  115691. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115692. */
  115693. snapDistance: number;
  115694. /**
  115695. * Event that fires each time the gizmo snaps to a new location.
  115696. * * snapDistance is the the change in distance
  115697. */
  115698. onSnapObservable: Observable<{
  115699. snapDistance: number;
  115700. }>;
  115701. private _plane;
  115702. private _coloredMaterial;
  115703. private _hoverMaterial;
  115704. private _isEnabled;
  115705. private _parent;
  115706. /** @hidden */
  115707. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  115708. /** @hidden */
  115709. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  115710. /**
  115711. * Creates a PlaneDragGizmo
  115712. * @param gizmoLayer The utility layer the gizmo will be added to
  115713. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  115714. * @param color The color of the gizmo
  115715. */
  115716. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  115717. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115718. /**
  115719. * If the gizmo is enabled
  115720. */
  115721. set isEnabled(value: boolean);
  115722. get isEnabled(): boolean;
  115723. /**
  115724. * Disposes of the gizmo
  115725. */
  115726. dispose(): void;
  115727. }
  115728. }
  115729. declare module BABYLON {
  115730. /**
  115731. * Gizmo that enables dragging a mesh along 3 axis
  115732. */
  115733. export class PositionGizmo extends Gizmo {
  115734. /**
  115735. * Internal gizmo used for interactions on the x axis
  115736. */
  115737. xGizmo: AxisDragGizmo;
  115738. /**
  115739. * Internal gizmo used for interactions on the y axis
  115740. */
  115741. yGizmo: AxisDragGizmo;
  115742. /**
  115743. * Internal gizmo used for interactions on the z axis
  115744. */
  115745. zGizmo: AxisDragGizmo;
  115746. /**
  115747. * Internal gizmo used for interactions on the yz plane
  115748. */
  115749. xPlaneGizmo: PlaneDragGizmo;
  115750. /**
  115751. * Internal gizmo used for interactions on the xz plane
  115752. */
  115753. yPlaneGizmo: PlaneDragGizmo;
  115754. /**
  115755. * Internal gizmo used for interactions on the xy plane
  115756. */
  115757. zPlaneGizmo: PlaneDragGizmo;
  115758. /**
  115759. * private variables
  115760. */
  115761. private _meshAttached;
  115762. private _updateGizmoRotationToMatchAttachedMesh;
  115763. private _snapDistance;
  115764. private _scaleRatio;
  115765. /** Fires an event when any of it's sub gizmos are dragged */
  115766. onDragStartObservable: Observable<unknown>;
  115767. /** Fires an event when any of it's sub gizmos are released from dragging */
  115768. onDragEndObservable: Observable<unknown>;
  115769. /**
  115770. * If set to true, planar drag is enabled
  115771. */
  115772. private _planarGizmoEnabled;
  115773. get attachedMesh(): Nullable<AbstractMesh>;
  115774. set attachedMesh(mesh: Nullable<AbstractMesh>);
  115775. /**
  115776. * Creates a PositionGizmo
  115777. * @param gizmoLayer The utility layer the gizmo will be added to
  115778. */
  115779. constructor(gizmoLayer?: UtilityLayerRenderer);
  115780. /**
  115781. * If the planar drag gizmo is enabled
  115782. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  115783. */
  115784. set planarGizmoEnabled(value: boolean);
  115785. get planarGizmoEnabled(): boolean;
  115786. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  115787. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  115788. /**
  115789. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115790. */
  115791. set snapDistance(value: number);
  115792. get snapDistance(): number;
  115793. /**
  115794. * Ratio for the scale of the gizmo (Default: 1)
  115795. */
  115796. set scaleRatio(value: number);
  115797. get scaleRatio(): number;
  115798. /**
  115799. * Disposes of the gizmo
  115800. */
  115801. dispose(): void;
  115802. /**
  115803. * CustomMeshes are not supported by this gizmo
  115804. * @param mesh The mesh to replace the default mesh of the gizmo
  115805. */
  115806. setCustomMesh(mesh: Mesh): void;
  115807. }
  115808. }
  115809. declare module BABYLON {
  115810. /**
  115811. * Single axis drag gizmo
  115812. */
  115813. export class AxisDragGizmo extends Gizmo {
  115814. /**
  115815. * Drag behavior responsible for the gizmos dragging interactions
  115816. */
  115817. dragBehavior: PointerDragBehavior;
  115818. private _pointerObserver;
  115819. /**
  115820. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  115821. */
  115822. snapDistance: number;
  115823. /**
  115824. * Event that fires each time the gizmo snaps to a new location.
  115825. * * snapDistance is the the change in distance
  115826. */
  115827. onSnapObservable: Observable<{
  115828. snapDistance: number;
  115829. }>;
  115830. private _isEnabled;
  115831. private _parent;
  115832. private _arrow;
  115833. private _coloredMaterial;
  115834. private _hoverMaterial;
  115835. /** @hidden */
  115836. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  115837. /** @hidden */
  115838. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  115839. /**
  115840. * Creates an AxisDragGizmo
  115841. * @param gizmoLayer The utility layer the gizmo will be added to
  115842. * @param dragAxis The axis which the gizmo will be able to drag on
  115843. * @param color The color of the gizmo
  115844. */
  115845. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  115846. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  115847. /**
  115848. * If the gizmo is enabled
  115849. */
  115850. set isEnabled(value: boolean);
  115851. get isEnabled(): boolean;
  115852. /**
  115853. * Disposes of the gizmo
  115854. */
  115855. dispose(): void;
  115856. }
  115857. }
  115858. declare module BABYLON.Debug {
  115859. /**
  115860. * The Axes viewer will show 3 axes in a specific point in space
  115861. */
  115862. export class AxesViewer {
  115863. private _xAxis;
  115864. private _yAxis;
  115865. private _zAxis;
  115866. private _scaleLinesFactor;
  115867. private _instanced;
  115868. /**
  115869. * Gets the hosting scene
  115870. */
  115871. scene: Scene;
  115872. /**
  115873. * Gets or sets a number used to scale line length
  115874. */
  115875. scaleLines: number;
  115876. /** Gets the node hierarchy used to render x-axis */
  115877. get xAxis(): TransformNode;
  115878. /** Gets the node hierarchy used to render y-axis */
  115879. get yAxis(): TransformNode;
  115880. /** Gets the node hierarchy used to render z-axis */
  115881. get zAxis(): TransformNode;
  115882. /**
  115883. * Creates a new AxesViewer
  115884. * @param scene defines the hosting scene
  115885. * @param scaleLines defines a number used to scale line length (1 by default)
  115886. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  115887. * @param xAxis defines the node hierarchy used to render the x-axis
  115888. * @param yAxis defines the node hierarchy used to render the y-axis
  115889. * @param zAxis defines the node hierarchy used to render the z-axis
  115890. */
  115891. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  115892. /**
  115893. * Force the viewer to update
  115894. * @param position defines the position of the viewer
  115895. * @param xaxis defines the x axis of the viewer
  115896. * @param yaxis defines the y axis of the viewer
  115897. * @param zaxis defines the z axis of the viewer
  115898. */
  115899. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  115900. /**
  115901. * Creates an instance of this axes viewer.
  115902. * @returns a new axes viewer with instanced meshes
  115903. */
  115904. createInstance(): AxesViewer;
  115905. /** Releases resources */
  115906. dispose(): void;
  115907. private static _SetRenderingGroupId;
  115908. }
  115909. }
  115910. declare module BABYLON.Debug {
  115911. /**
  115912. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  115913. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  115914. */
  115915. export class BoneAxesViewer extends AxesViewer {
  115916. /**
  115917. * Gets or sets the target mesh where to display the axes viewer
  115918. */
  115919. mesh: Nullable<Mesh>;
  115920. /**
  115921. * Gets or sets the target bone where to display the axes viewer
  115922. */
  115923. bone: Nullable<Bone>;
  115924. /** Gets current position */
  115925. pos: Vector3;
  115926. /** Gets direction of X axis */
  115927. xaxis: Vector3;
  115928. /** Gets direction of Y axis */
  115929. yaxis: Vector3;
  115930. /** Gets direction of Z axis */
  115931. zaxis: Vector3;
  115932. /**
  115933. * Creates a new BoneAxesViewer
  115934. * @param scene defines the hosting scene
  115935. * @param bone defines the target bone
  115936. * @param mesh defines the target mesh
  115937. * @param scaleLines defines a scaling factor for line length (1 by default)
  115938. */
  115939. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  115940. /**
  115941. * Force the viewer to update
  115942. */
  115943. update(): void;
  115944. /** Releases resources */
  115945. dispose(): void;
  115946. }
  115947. }
  115948. declare module BABYLON {
  115949. /**
  115950. * Interface used to define scene explorer extensibility option
  115951. */
  115952. export interface IExplorerExtensibilityOption {
  115953. /**
  115954. * Define the option label
  115955. */
  115956. label: string;
  115957. /**
  115958. * Defines the action to execute on click
  115959. */
  115960. action: (entity: any) => void;
  115961. }
  115962. /**
  115963. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  115964. */
  115965. export interface IExplorerExtensibilityGroup {
  115966. /**
  115967. * Defines a predicate to test if a given type mut be extended
  115968. */
  115969. predicate: (entity: any) => boolean;
  115970. /**
  115971. * Gets the list of options added to a type
  115972. */
  115973. entries: IExplorerExtensibilityOption[];
  115974. }
  115975. /**
  115976. * Interface used to define the options to use to create the Inspector
  115977. */
  115978. export interface IInspectorOptions {
  115979. /**
  115980. * Display in overlay mode (default: false)
  115981. */
  115982. overlay?: boolean;
  115983. /**
  115984. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  115985. */
  115986. globalRoot?: HTMLElement;
  115987. /**
  115988. * Display the Scene explorer
  115989. */
  115990. showExplorer?: boolean;
  115991. /**
  115992. * Display the property inspector
  115993. */
  115994. showInspector?: boolean;
  115995. /**
  115996. * Display in embed mode (both panes on the right)
  115997. */
  115998. embedMode?: boolean;
  115999. /**
  116000. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  116001. */
  116002. handleResize?: boolean;
  116003. /**
  116004. * Allow the panes to popup (default: true)
  116005. */
  116006. enablePopup?: boolean;
  116007. /**
  116008. * Allow the panes to be closed by users (default: true)
  116009. */
  116010. enableClose?: boolean;
  116011. /**
  116012. * Optional list of extensibility entries
  116013. */
  116014. explorerExtensibility?: IExplorerExtensibilityGroup[];
  116015. /**
  116016. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  116017. */
  116018. inspectorURL?: string;
  116019. /**
  116020. * Optional initial tab (default to DebugLayerTab.Properties)
  116021. */
  116022. initialTab?: DebugLayerTab;
  116023. }
  116024. interface Scene {
  116025. /**
  116026. * @hidden
  116027. * Backing field
  116028. */
  116029. _debugLayer: DebugLayer;
  116030. /**
  116031. * Gets the debug layer (aka Inspector) associated with the scene
  116032. * @see http://doc.babylonjs.com/features/playground_debuglayer
  116033. */
  116034. debugLayer: DebugLayer;
  116035. }
  116036. /**
  116037. * Enum of inspector action tab
  116038. */
  116039. export enum DebugLayerTab {
  116040. /**
  116041. * Properties tag (default)
  116042. */
  116043. Properties = 0,
  116044. /**
  116045. * Debug tab
  116046. */
  116047. Debug = 1,
  116048. /**
  116049. * Statistics tab
  116050. */
  116051. Statistics = 2,
  116052. /**
  116053. * Tools tab
  116054. */
  116055. Tools = 3,
  116056. /**
  116057. * Settings tab
  116058. */
  116059. Settings = 4
  116060. }
  116061. /**
  116062. * The debug layer (aka Inspector) is the go to tool in order to better understand
  116063. * what is happening in your scene
  116064. * @see http://doc.babylonjs.com/features/playground_debuglayer
  116065. */
  116066. export class DebugLayer {
  116067. /**
  116068. * Define the url to get the inspector script from.
  116069. * By default it uses the babylonjs CDN.
  116070. * @ignoreNaming
  116071. */
  116072. static InspectorURL: string;
  116073. private _scene;
  116074. private BJSINSPECTOR;
  116075. private _onPropertyChangedObservable?;
  116076. /**
  116077. * Observable triggered when a property is changed through the inspector.
  116078. */
  116079. get onPropertyChangedObservable(): any;
  116080. /**
  116081. * Instantiates a new debug layer.
  116082. * The debug layer (aka Inspector) is the go to tool in order to better understand
  116083. * what is happening in your scene
  116084. * @see http://doc.babylonjs.com/features/playground_debuglayer
  116085. * @param scene Defines the scene to inspect
  116086. */
  116087. constructor(scene: Scene);
  116088. /** Creates the inspector window. */
  116089. private _createInspector;
  116090. /**
  116091. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  116092. * @param entity defines the entity to select
  116093. * @param lineContainerTitle defines the specific block to highlight
  116094. */
  116095. select(entity: any, lineContainerTitle?: string): void;
  116096. /** Get the inspector from bundle or global */
  116097. private _getGlobalInspector;
  116098. /**
  116099. * Get if the inspector is visible or not.
  116100. * @returns true if visible otherwise, false
  116101. */
  116102. isVisible(): boolean;
  116103. /**
  116104. * Hide the inspector and close its window.
  116105. */
  116106. hide(): void;
  116107. /**
  116108. * Launch the debugLayer.
  116109. * @param config Define the configuration of the inspector
  116110. * @return a promise fulfilled when the debug layer is visible
  116111. */
  116112. show(config?: IInspectorOptions): Promise<DebugLayer>;
  116113. }
  116114. }
  116115. declare module BABYLON {
  116116. /**
  116117. * Class containing static functions to help procedurally build meshes
  116118. */
  116119. export class BoxBuilder {
  116120. /**
  116121. * Creates a box mesh
  116122. * * The parameter `size` sets the size (float) of each box side (default 1)
  116123. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  116124. * * 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)
  116125. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  116126. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116127. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116129. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  116130. * @param name defines the name of the mesh
  116131. * @param options defines the options used to create the mesh
  116132. * @param scene defines the hosting scene
  116133. * @returns the box mesh
  116134. */
  116135. static CreateBox(name: string, options: {
  116136. size?: number;
  116137. width?: number;
  116138. height?: number;
  116139. depth?: number;
  116140. faceUV?: Vector4[];
  116141. faceColors?: Color4[];
  116142. sideOrientation?: number;
  116143. frontUVs?: Vector4;
  116144. backUVs?: Vector4;
  116145. wrap?: boolean;
  116146. topBaseAt?: number;
  116147. bottomBaseAt?: number;
  116148. updatable?: boolean;
  116149. }, scene?: Nullable<Scene>): Mesh;
  116150. }
  116151. }
  116152. declare module BABYLON {
  116153. /**
  116154. * Class containing static functions to help procedurally build meshes
  116155. */
  116156. export class SphereBuilder {
  116157. /**
  116158. * Creates a sphere mesh
  116159. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  116160. * * 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`)
  116161. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  116162. * * 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
  116163. * * 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)
  116164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116165. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116167. * @param name defines the name of the mesh
  116168. * @param options defines the options used to create the mesh
  116169. * @param scene defines the hosting scene
  116170. * @returns the sphere mesh
  116171. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  116172. */
  116173. static CreateSphere(name: string, options: {
  116174. segments?: number;
  116175. diameter?: number;
  116176. diameterX?: number;
  116177. diameterY?: number;
  116178. diameterZ?: number;
  116179. arc?: number;
  116180. slice?: number;
  116181. sideOrientation?: number;
  116182. frontUVs?: Vector4;
  116183. backUVs?: Vector4;
  116184. updatable?: boolean;
  116185. }, scene?: Nullable<Scene>): Mesh;
  116186. }
  116187. }
  116188. declare module BABYLON.Debug {
  116189. /**
  116190. * Used to show the physics impostor around the specific mesh
  116191. */
  116192. export class PhysicsViewer {
  116193. /** @hidden */
  116194. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  116195. /** @hidden */
  116196. protected _meshes: Array<Nullable<AbstractMesh>>;
  116197. /** @hidden */
  116198. protected _scene: Nullable<Scene>;
  116199. /** @hidden */
  116200. protected _numMeshes: number;
  116201. /** @hidden */
  116202. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  116203. private _renderFunction;
  116204. private _utilityLayer;
  116205. private _debugBoxMesh;
  116206. private _debugSphereMesh;
  116207. private _debugCylinderMesh;
  116208. private _debugMaterial;
  116209. private _debugMeshMeshes;
  116210. /**
  116211. * Creates a new PhysicsViewer
  116212. * @param scene defines the hosting scene
  116213. */
  116214. constructor(scene: Scene);
  116215. /** @hidden */
  116216. protected _updateDebugMeshes(): void;
  116217. /**
  116218. * Renders a specified physic impostor
  116219. * @param impostor defines the impostor to render
  116220. * @param targetMesh defines the mesh represented by the impostor
  116221. * @returns the new debug mesh used to render the impostor
  116222. */
  116223. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  116224. /**
  116225. * Hides a specified physic impostor
  116226. * @param impostor defines the impostor to hide
  116227. */
  116228. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  116229. private _getDebugMaterial;
  116230. private _getDebugBoxMesh;
  116231. private _getDebugSphereMesh;
  116232. private _getDebugCylinderMesh;
  116233. private _getDebugMeshMesh;
  116234. private _getDebugMesh;
  116235. /** Releases all resources */
  116236. dispose(): void;
  116237. }
  116238. }
  116239. declare module BABYLON {
  116240. /**
  116241. * Class containing static functions to help procedurally build meshes
  116242. */
  116243. export class LinesBuilder {
  116244. /**
  116245. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  116246. * * 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
  116247. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  116248. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  116249. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  116250. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  116251. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  116252. * * 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
  116253. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  116254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116255. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  116256. * @param name defines the name of the new line system
  116257. * @param options defines the options used to create the line system
  116258. * @param scene defines the hosting scene
  116259. * @returns a new line system mesh
  116260. */
  116261. static CreateLineSystem(name: string, options: {
  116262. lines: Vector3[][];
  116263. updatable?: boolean;
  116264. instance?: Nullable<LinesMesh>;
  116265. colors?: Nullable<Color4[][]>;
  116266. useVertexAlpha?: boolean;
  116267. }, scene: Nullable<Scene>): LinesMesh;
  116268. /**
  116269. * Creates a line mesh
  116270. * 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
  116271. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116272. * * The parameter `points` is an array successive Vector3
  116273. * * 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
  116274. * * The optional parameter `colors` is an array of successive Color4, one per line point
  116275. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  116276. * * When updating an instance, remember that only point positions can change, not the number of points
  116277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116278. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  116279. * @param name defines the name of the new line system
  116280. * @param options defines the options used to create the line system
  116281. * @param scene defines the hosting scene
  116282. * @returns a new line mesh
  116283. */
  116284. static CreateLines(name: string, options: {
  116285. points: Vector3[];
  116286. updatable?: boolean;
  116287. instance?: Nullable<LinesMesh>;
  116288. colors?: Color4[];
  116289. useVertexAlpha?: boolean;
  116290. }, scene?: Nullable<Scene>): LinesMesh;
  116291. /**
  116292. * Creates a dashed line mesh
  116293. * * 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
  116294. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  116295. * * The parameter `points` is an array successive Vector3
  116296. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  116297. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  116298. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  116299. * * 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
  116300. * * When updating an instance, remember that only point positions can change, not the number of points
  116301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116302. * @param name defines the name of the mesh
  116303. * @param options defines the options used to create the mesh
  116304. * @param scene defines the hosting scene
  116305. * @returns the dashed line mesh
  116306. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  116307. */
  116308. static CreateDashedLines(name: string, options: {
  116309. points: Vector3[];
  116310. dashSize?: number;
  116311. gapSize?: number;
  116312. dashNb?: number;
  116313. updatable?: boolean;
  116314. instance?: LinesMesh;
  116315. }, scene?: Nullable<Scene>): LinesMesh;
  116316. }
  116317. }
  116318. declare module BABYLON {
  116319. /**
  116320. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  116321. * in order to better appreciate the issue one might have.
  116322. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  116323. */
  116324. export class RayHelper {
  116325. /**
  116326. * Defines the ray we are currently tryin to visualize.
  116327. */
  116328. ray: Nullable<Ray>;
  116329. private _renderPoints;
  116330. private _renderLine;
  116331. private _renderFunction;
  116332. private _scene;
  116333. private _updateToMeshFunction;
  116334. private _attachedToMesh;
  116335. private _meshSpaceDirection;
  116336. private _meshSpaceOrigin;
  116337. /**
  116338. * Helper function to create a colored helper in a scene in one line.
  116339. * @param ray Defines the ray we are currently tryin to visualize
  116340. * @param scene Defines the scene the ray is used in
  116341. * @param color Defines the color we want to see the ray in
  116342. * @returns The newly created ray helper.
  116343. */
  116344. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  116345. /**
  116346. * Instantiate a new ray helper.
  116347. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  116348. * in order to better appreciate the issue one might have.
  116349. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  116350. * @param ray Defines the ray we are currently tryin to visualize
  116351. */
  116352. constructor(ray: Ray);
  116353. /**
  116354. * Shows the ray we are willing to debug.
  116355. * @param scene Defines the scene the ray needs to be rendered in
  116356. * @param color Defines the color the ray needs to be rendered in
  116357. */
  116358. show(scene: Scene, color?: Color3): void;
  116359. /**
  116360. * Hides the ray we are debugging.
  116361. */
  116362. hide(): void;
  116363. private _render;
  116364. /**
  116365. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  116366. * @param mesh Defines the mesh we want the helper attached to
  116367. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  116368. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  116369. * @param length Defines the length of the ray
  116370. */
  116371. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  116372. /**
  116373. * Detach the ray helper from the mesh it has previously been attached to.
  116374. */
  116375. detachFromMesh(): void;
  116376. private _updateToMesh;
  116377. /**
  116378. * Dispose the helper and release its associated resources.
  116379. */
  116380. dispose(): void;
  116381. }
  116382. }
  116383. declare module BABYLON.Debug {
  116384. /**
  116385. * Class used to render a debug view of a given skeleton
  116386. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  116387. */
  116388. export class SkeletonViewer {
  116389. /** defines the skeleton to render */
  116390. skeleton: Skeleton;
  116391. /** defines the mesh attached to the skeleton */
  116392. mesh: AbstractMesh;
  116393. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  116394. autoUpdateBonesMatrices: boolean;
  116395. /** defines the rendering group id to use with the viewer */
  116396. renderingGroupId: number;
  116397. /** Gets or sets the color used to render the skeleton */
  116398. color: Color3;
  116399. private _scene;
  116400. private _debugLines;
  116401. private _debugMesh;
  116402. private _isEnabled;
  116403. private _renderFunction;
  116404. private _utilityLayer;
  116405. /**
  116406. * Returns the mesh used to render the bones
  116407. */
  116408. get debugMesh(): Nullable<LinesMesh>;
  116409. /**
  116410. * Creates a new SkeletonViewer
  116411. * @param skeleton defines the skeleton to render
  116412. * @param mesh defines the mesh attached to the skeleton
  116413. * @param scene defines the hosting scene
  116414. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  116415. * @param renderingGroupId defines the rendering group id to use with the viewer
  116416. */
  116417. constructor(
  116418. /** defines the skeleton to render */
  116419. skeleton: Skeleton,
  116420. /** defines the mesh attached to the skeleton */
  116421. mesh: AbstractMesh, scene: Scene,
  116422. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  116423. autoUpdateBonesMatrices?: boolean,
  116424. /** defines the rendering group id to use with the viewer */
  116425. renderingGroupId?: number);
  116426. /** Gets or sets a boolean indicating if the viewer is enabled */
  116427. set isEnabled(value: boolean);
  116428. get isEnabled(): boolean;
  116429. private _getBonePosition;
  116430. private _getLinesForBonesWithLength;
  116431. private _getLinesForBonesNoLength;
  116432. /** Update the viewer to sync with current skeleton state */
  116433. update(): void;
  116434. /** Release associated resources */
  116435. dispose(): void;
  116436. }
  116437. }
  116438. declare module BABYLON {
  116439. /**
  116440. * Options to create the null engine
  116441. */
  116442. export class NullEngineOptions {
  116443. /**
  116444. * Render width (Default: 512)
  116445. */
  116446. renderWidth: number;
  116447. /**
  116448. * Render height (Default: 256)
  116449. */
  116450. renderHeight: number;
  116451. /**
  116452. * Texture size (Default: 512)
  116453. */
  116454. textureSize: number;
  116455. /**
  116456. * If delta time between frames should be constant
  116457. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116458. */
  116459. deterministicLockstep: boolean;
  116460. /**
  116461. * Maximum about of steps between frames (Default: 4)
  116462. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116463. */
  116464. lockstepMaxSteps: number;
  116465. }
  116466. /**
  116467. * The null engine class provides support for headless version of babylon.js.
  116468. * This can be used in server side scenario or for testing purposes
  116469. */
  116470. export class NullEngine extends Engine {
  116471. private _options;
  116472. /**
  116473. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  116474. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116475. * @returns true if engine is in deterministic lock step mode
  116476. */
  116477. isDeterministicLockStep(): boolean;
  116478. /**
  116479. * Gets the max steps when engine is running in deterministic lock step
  116480. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116481. * @returns the max steps
  116482. */
  116483. getLockstepMaxSteps(): number;
  116484. /**
  116485. * Gets the current hardware scaling level.
  116486. * By default the hardware scaling level is computed from the window device ratio.
  116487. * 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.
  116488. * @returns a number indicating the current hardware scaling level
  116489. */
  116490. getHardwareScalingLevel(): number;
  116491. constructor(options?: NullEngineOptions);
  116492. /**
  116493. * Creates a vertex buffer
  116494. * @param vertices the data for the vertex buffer
  116495. * @returns the new WebGL static buffer
  116496. */
  116497. createVertexBuffer(vertices: FloatArray): DataBuffer;
  116498. /**
  116499. * Creates a new index buffer
  116500. * @param indices defines the content of the index buffer
  116501. * @param updatable defines if the index buffer must be updatable
  116502. * @returns a new webGL buffer
  116503. */
  116504. createIndexBuffer(indices: IndicesArray): DataBuffer;
  116505. /**
  116506. * Clear the current render buffer or the current render target (if any is set up)
  116507. * @param color defines the color to use
  116508. * @param backBuffer defines if the back buffer must be cleared
  116509. * @param depth defines if the depth buffer must be cleared
  116510. * @param stencil defines if the stencil buffer must be cleared
  116511. */
  116512. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  116513. /**
  116514. * Gets the current render width
  116515. * @param useScreen defines if screen size must be used (or the current render target if any)
  116516. * @returns a number defining the current render width
  116517. */
  116518. getRenderWidth(useScreen?: boolean): number;
  116519. /**
  116520. * Gets the current render height
  116521. * @param useScreen defines if screen size must be used (or the current render target if any)
  116522. * @returns a number defining the current render height
  116523. */
  116524. getRenderHeight(useScreen?: boolean): number;
  116525. /**
  116526. * Set the WebGL's viewport
  116527. * @param viewport defines the viewport element to be used
  116528. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  116529. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  116530. */
  116531. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  116532. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  116533. /**
  116534. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  116535. * @param pipelineContext defines the pipeline context to use
  116536. * @param uniformsNames defines the list of uniform names
  116537. * @returns an array of webGL uniform locations
  116538. */
  116539. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  116540. /**
  116541. * Gets the lsit of active attributes for a given webGL program
  116542. * @param pipelineContext defines the pipeline context to use
  116543. * @param attributesNames defines the list of attribute names to get
  116544. * @returns an array of indices indicating the offset of each attribute
  116545. */
  116546. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  116547. /**
  116548. * Binds an effect to the webGL context
  116549. * @param effect defines the effect to bind
  116550. */
  116551. bindSamplers(effect: Effect): void;
  116552. /**
  116553. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  116554. * @param effect defines the effect to activate
  116555. */
  116556. enableEffect(effect: Effect): void;
  116557. /**
  116558. * Set various states to the webGL context
  116559. * @param culling defines backface culling state
  116560. * @param zOffset defines the value to apply to zOffset (0 by default)
  116561. * @param force defines if states must be applied even if cache is up to date
  116562. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  116563. */
  116564. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  116565. /**
  116566. * Set the value of an uniform to an array of int32
  116567. * @param uniform defines the webGL uniform location where to store the value
  116568. * @param array defines the array of int32 to store
  116569. */
  116570. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  116571. /**
  116572. * Set the value of an uniform to an array of int32 (stored as vec2)
  116573. * @param uniform defines the webGL uniform location where to store the value
  116574. * @param array defines the array of int32 to store
  116575. */
  116576. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  116577. /**
  116578. * Set the value of an uniform to an array of int32 (stored as vec3)
  116579. * @param uniform defines the webGL uniform location where to store the value
  116580. * @param array defines the array of int32 to store
  116581. */
  116582. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  116583. /**
  116584. * Set the value of an uniform to an array of int32 (stored as vec4)
  116585. * @param uniform defines the webGL uniform location where to store the value
  116586. * @param array defines the array of int32 to store
  116587. */
  116588. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  116589. /**
  116590. * Set the value of an uniform to an array of float32
  116591. * @param uniform defines the webGL uniform location where to store the value
  116592. * @param array defines the array of float32 to store
  116593. */
  116594. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  116595. /**
  116596. * Set the value of an uniform to an array of float32 (stored as vec2)
  116597. * @param uniform defines the webGL uniform location where to store the value
  116598. * @param array defines the array of float32 to store
  116599. */
  116600. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  116601. /**
  116602. * Set the value of an uniform to an array of float32 (stored as vec3)
  116603. * @param uniform defines the webGL uniform location where to store the value
  116604. * @param array defines the array of float32 to store
  116605. */
  116606. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  116607. /**
  116608. * Set the value of an uniform to an array of float32 (stored as vec4)
  116609. * @param uniform defines the webGL uniform location where to store the value
  116610. * @param array defines the array of float32 to store
  116611. */
  116612. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  116613. /**
  116614. * Set the value of an uniform to an array of number
  116615. * @param uniform defines the webGL uniform location where to store the value
  116616. * @param array defines the array of number to store
  116617. */
  116618. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  116619. /**
  116620. * Set the value of an uniform to an array of number (stored as vec2)
  116621. * @param uniform defines the webGL uniform location where to store the value
  116622. * @param array defines the array of number to store
  116623. */
  116624. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  116625. /**
  116626. * Set the value of an uniform to an array of number (stored as vec3)
  116627. * @param uniform defines the webGL uniform location where to store the value
  116628. * @param array defines the array of number to store
  116629. */
  116630. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  116631. /**
  116632. * Set the value of an uniform to an array of number (stored as vec4)
  116633. * @param uniform defines the webGL uniform location where to store the value
  116634. * @param array defines the array of number to store
  116635. */
  116636. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  116637. /**
  116638. * Set the value of an uniform to an array of float32 (stored as matrices)
  116639. * @param uniform defines the webGL uniform location where to store the value
  116640. * @param matrices defines the array of float32 to store
  116641. */
  116642. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  116643. /**
  116644. * Set the value of an uniform to a matrix (3x3)
  116645. * @param uniform defines the webGL uniform location where to store the value
  116646. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  116647. */
  116648. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  116649. /**
  116650. * Set the value of an uniform to a matrix (2x2)
  116651. * @param uniform defines the webGL uniform location where to store the value
  116652. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  116653. */
  116654. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  116655. /**
  116656. * Set the value of an uniform to a number (float)
  116657. * @param uniform defines the webGL uniform location where to store the value
  116658. * @param value defines the float number to store
  116659. */
  116660. setFloat(uniform: WebGLUniformLocation, value: number): void;
  116661. /**
  116662. * Set the value of an uniform to a vec2
  116663. * @param uniform defines the webGL uniform location where to store the value
  116664. * @param x defines the 1st component of the value
  116665. * @param y defines the 2nd component of the value
  116666. */
  116667. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  116668. /**
  116669. * Set the value of an uniform to a vec3
  116670. * @param uniform defines the webGL uniform location where to store the value
  116671. * @param x defines the 1st component of the value
  116672. * @param y defines the 2nd component of the value
  116673. * @param z defines the 3rd component of the value
  116674. */
  116675. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  116676. /**
  116677. * Set the value of an uniform to a boolean
  116678. * @param uniform defines the webGL uniform location where to store the value
  116679. * @param bool defines the boolean to store
  116680. */
  116681. setBool(uniform: WebGLUniformLocation, bool: number): void;
  116682. /**
  116683. * Set the value of an uniform to a vec4
  116684. * @param uniform defines the webGL uniform location where to store the value
  116685. * @param x defines the 1st component of the value
  116686. * @param y defines the 2nd component of the value
  116687. * @param z defines the 3rd component of the value
  116688. * @param w defines the 4th component of the value
  116689. */
  116690. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  116691. /**
  116692. * Sets the current alpha mode
  116693. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  116694. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  116695. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  116696. */
  116697. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  116698. /**
  116699. * Bind webGl buffers directly to the webGL context
  116700. * @param vertexBuffers defines the vertex buffer to bind
  116701. * @param indexBuffer defines the index buffer to bind
  116702. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  116703. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  116704. * @param effect defines the effect associated with the vertex buffer
  116705. */
  116706. bindBuffers(vertexBuffers: {
  116707. [key: string]: VertexBuffer;
  116708. }, indexBuffer: DataBuffer, effect: Effect): void;
  116709. /**
  116710. * Force the entire cache to be cleared
  116711. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  116712. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  116713. */
  116714. wipeCaches(bruteForce?: boolean): void;
  116715. /**
  116716. * Send a draw order
  116717. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  116718. * @param indexStart defines the starting index
  116719. * @param indexCount defines the number of index to draw
  116720. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116721. */
  116722. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  116723. /**
  116724. * Draw a list of indexed primitives
  116725. * @param fillMode defines the primitive to use
  116726. * @param indexStart defines the starting index
  116727. * @param indexCount defines the number of index to draw
  116728. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116729. */
  116730. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  116731. /**
  116732. * Draw a list of unindexed primitives
  116733. * @param fillMode defines the primitive to use
  116734. * @param verticesStart defines the index of first vertex to draw
  116735. * @param verticesCount defines the count of vertices to draw
  116736. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116737. */
  116738. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116739. /** @hidden */
  116740. _createTexture(): WebGLTexture;
  116741. /** @hidden */
  116742. _releaseTexture(texture: InternalTexture): void;
  116743. /**
  116744. * Usually called from Texture.ts.
  116745. * Passed information to create a WebGLTexture
  116746. * @param urlArg defines a value which contains one of the following:
  116747. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  116748. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  116749. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  116750. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  116751. * @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)
  116752. * @param scene needed for loading to the correct scene
  116753. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  116754. * @param onLoad optional callback to be called upon successful completion
  116755. * @param onError optional callback to be called upon failure
  116756. * @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
  116757. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  116758. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  116759. * @param forcedExtension defines the extension to use to pick the right loader
  116760. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  116761. * @returns a InternalTexture for assignment back into BABYLON.Texture
  116762. */
  116763. 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;
  116764. /**
  116765. * Creates a new render target texture
  116766. * @param size defines the size of the texture
  116767. * @param options defines the options used to create the texture
  116768. * @returns a new render target texture stored in an InternalTexture
  116769. */
  116770. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  116771. /**
  116772. * Update the sampling mode of a given texture
  116773. * @param samplingMode defines the required sampling mode
  116774. * @param texture defines the texture to update
  116775. */
  116776. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  116777. /**
  116778. * Binds the frame buffer to the specified texture.
  116779. * @param texture The texture to render to or null for the default canvas
  116780. * @param faceIndex The face of the texture to render to in case of cube texture
  116781. * @param requiredWidth The width of the target to render to
  116782. * @param requiredHeight The height of the target to render to
  116783. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  116784. * @param depthStencilTexture The depth stencil texture to use to render
  116785. * @param lodLevel defines le lod level to bind to the frame buffer
  116786. */
  116787. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  116788. /**
  116789. * Unbind the current render target texture from the webGL context
  116790. * @param texture defines the render target texture to unbind
  116791. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  116792. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  116793. */
  116794. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  116795. /**
  116796. * Creates a dynamic vertex buffer
  116797. * @param vertices the data for the dynamic vertex buffer
  116798. * @returns the new WebGL dynamic buffer
  116799. */
  116800. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  116801. /**
  116802. * Update the content of a dynamic texture
  116803. * @param texture defines the texture to update
  116804. * @param canvas defines the canvas containing the source
  116805. * @param invertY defines if data must be stored with Y axis inverted
  116806. * @param premulAlpha defines if alpha is stored as premultiplied
  116807. * @param format defines the format of the data
  116808. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  116809. */
  116810. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  116811. /**
  116812. * Gets a boolean indicating if all created effects are ready
  116813. * @returns true if all effects are ready
  116814. */
  116815. areAllEffectsReady(): boolean;
  116816. /**
  116817. * @hidden
  116818. * Get the current error code of the webGL context
  116819. * @returns the error code
  116820. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  116821. */
  116822. getError(): number;
  116823. /** @hidden */
  116824. _getUnpackAlignement(): number;
  116825. /** @hidden */
  116826. _unpackFlipY(value: boolean): void;
  116827. /**
  116828. * Update a dynamic index buffer
  116829. * @param indexBuffer defines the target index buffer
  116830. * @param indices defines the data to update
  116831. * @param offset defines the offset in the target index buffer where update should start
  116832. */
  116833. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  116834. /**
  116835. * Updates a dynamic vertex buffer.
  116836. * @param vertexBuffer the vertex buffer to update
  116837. * @param vertices the data used to update the vertex buffer
  116838. * @param byteOffset the byte offset of the data (optional)
  116839. * @param byteLength the byte length of the data (optional)
  116840. */
  116841. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  116842. /** @hidden */
  116843. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  116844. /** @hidden */
  116845. _bindTexture(channel: number, texture: InternalTexture): void;
  116846. protected _deleteBuffer(buffer: WebGLBuffer): void;
  116847. /**
  116848. * 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
  116849. */
  116850. releaseEffects(): void;
  116851. displayLoadingUI(): void;
  116852. hideLoadingUI(): void;
  116853. /** @hidden */
  116854. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116855. /** @hidden */
  116856. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116857. /** @hidden */
  116858. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116859. /** @hidden */
  116860. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  116861. }
  116862. }
  116863. declare module BABYLON {
  116864. /** @hidden */
  116865. export class _OcclusionDataStorage {
  116866. /** @hidden */
  116867. occlusionInternalRetryCounter: number;
  116868. /** @hidden */
  116869. isOcclusionQueryInProgress: boolean;
  116870. /** @hidden */
  116871. isOccluded: boolean;
  116872. /** @hidden */
  116873. occlusionRetryCount: number;
  116874. /** @hidden */
  116875. occlusionType: number;
  116876. /** @hidden */
  116877. occlusionQueryAlgorithmType: number;
  116878. }
  116879. interface Engine {
  116880. /**
  116881. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  116882. * @return the new query
  116883. */
  116884. createQuery(): WebGLQuery;
  116885. /**
  116886. * Delete and release a webGL query
  116887. * @param query defines the query to delete
  116888. * @return the current engine
  116889. */
  116890. deleteQuery(query: WebGLQuery): Engine;
  116891. /**
  116892. * Check if a given query has resolved and got its value
  116893. * @param query defines the query to check
  116894. * @returns true if the query got its value
  116895. */
  116896. isQueryResultAvailable(query: WebGLQuery): boolean;
  116897. /**
  116898. * Gets the value of a given query
  116899. * @param query defines the query to check
  116900. * @returns the value of the query
  116901. */
  116902. getQueryResult(query: WebGLQuery): number;
  116903. /**
  116904. * Initiates an occlusion query
  116905. * @param algorithmType defines the algorithm to use
  116906. * @param query defines the query to use
  116907. * @returns the current engine
  116908. * @see http://doc.babylonjs.com/features/occlusionquery
  116909. */
  116910. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  116911. /**
  116912. * Ends an occlusion query
  116913. * @see http://doc.babylonjs.com/features/occlusionquery
  116914. * @param algorithmType defines the algorithm to use
  116915. * @returns the current engine
  116916. */
  116917. endOcclusionQuery(algorithmType: number): Engine;
  116918. /**
  116919. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  116920. * Please note that only one query can be issued at a time
  116921. * @returns a time token used to track the time span
  116922. */
  116923. startTimeQuery(): Nullable<_TimeToken>;
  116924. /**
  116925. * Ends a time query
  116926. * @param token defines the token used to measure the time span
  116927. * @returns the time spent (in ns)
  116928. */
  116929. endTimeQuery(token: _TimeToken): int;
  116930. /** @hidden */
  116931. _currentNonTimestampToken: Nullable<_TimeToken>;
  116932. /** @hidden */
  116933. _createTimeQuery(): WebGLQuery;
  116934. /** @hidden */
  116935. _deleteTimeQuery(query: WebGLQuery): void;
  116936. /** @hidden */
  116937. _getGlAlgorithmType(algorithmType: number): number;
  116938. /** @hidden */
  116939. _getTimeQueryResult(query: WebGLQuery): any;
  116940. /** @hidden */
  116941. _getTimeQueryAvailability(query: WebGLQuery): any;
  116942. }
  116943. interface AbstractMesh {
  116944. /**
  116945. * Backing filed
  116946. * @hidden
  116947. */
  116948. __occlusionDataStorage: _OcclusionDataStorage;
  116949. /**
  116950. * Access property
  116951. * @hidden
  116952. */
  116953. _occlusionDataStorage: _OcclusionDataStorage;
  116954. /**
  116955. * 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.
  116956. * The default value is -1 which means don't break the query and wait till the result
  116957. * @see http://doc.babylonjs.com/features/occlusionquery
  116958. */
  116959. occlusionRetryCount: number;
  116960. /**
  116961. * 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:
  116962. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  116963. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  116964. * * 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.
  116965. * @see http://doc.babylonjs.com/features/occlusionquery
  116966. */
  116967. occlusionType: number;
  116968. /**
  116969. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  116970. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  116971. * * 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.
  116972. * @see http://doc.babylonjs.com/features/occlusionquery
  116973. */
  116974. occlusionQueryAlgorithmType: number;
  116975. /**
  116976. * 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
  116977. * @see http://doc.babylonjs.com/features/occlusionquery
  116978. */
  116979. isOccluded: boolean;
  116980. /**
  116981. * Flag to check the progress status of the query
  116982. * @see http://doc.babylonjs.com/features/occlusionquery
  116983. */
  116984. isOcclusionQueryInProgress: boolean;
  116985. }
  116986. }
  116987. declare module BABYLON {
  116988. /** @hidden */
  116989. export var _forceTransformFeedbackToBundle: boolean;
  116990. interface Engine {
  116991. /**
  116992. * Creates a webGL transform feedback object
  116993. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  116994. * @returns the webGL transform feedback object
  116995. */
  116996. createTransformFeedback(): WebGLTransformFeedback;
  116997. /**
  116998. * Delete a webGL transform feedback object
  116999. * @param value defines the webGL transform feedback object to delete
  117000. */
  117001. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  117002. /**
  117003. * Bind a webGL transform feedback object to the webgl context
  117004. * @param value defines the webGL transform feedback object to bind
  117005. */
  117006. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  117007. /**
  117008. * Begins a transform feedback operation
  117009. * @param usePoints defines if points or triangles must be used
  117010. */
  117011. beginTransformFeedback(usePoints: boolean): void;
  117012. /**
  117013. * Ends a transform feedback operation
  117014. */
  117015. endTransformFeedback(): void;
  117016. /**
  117017. * Specify the varyings to use with transform feedback
  117018. * @param program defines the associated webGL program
  117019. * @param value defines the list of strings representing the varying names
  117020. */
  117021. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  117022. /**
  117023. * Bind a webGL buffer for a transform feedback operation
  117024. * @param value defines the webGL buffer to bind
  117025. */
  117026. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  117027. }
  117028. }
  117029. declare module BABYLON {
  117030. /**
  117031. * Creation options of the multi render target texture.
  117032. */
  117033. export interface IMultiRenderTargetOptions {
  117034. /**
  117035. * Define if the texture needs to create mip maps after render.
  117036. */
  117037. generateMipMaps?: boolean;
  117038. /**
  117039. * Define the types of all the draw buffers we want to create
  117040. */
  117041. types?: number[];
  117042. /**
  117043. * Define the sampling modes of all the draw buffers we want to create
  117044. */
  117045. samplingModes?: number[];
  117046. /**
  117047. * Define if a depth buffer is required
  117048. */
  117049. generateDepthBuffer?: boolean;
  117050. /**
  117051. * Define if a stencil buffer is required
  117052. */
  117053. generateStencilBuffer?: boolean;
  117054. /**
  117055. * Define if a depth texture is required instead of a depth buffer
  117056. */
  117057. generateDepthTexture?: boolean;
  117058. /**
  117059. * Define the number of desired draw buffers
  117060. */
  117061. textureCount?: number;
  117062. /**
  117063. * Define if aspect ratio should be adapted to the texture or stay the scene one
  117064. */
  117065. doNotChangeAspectRatio?: boolean;
  117066. /**
  117067. * Define the default type of the buffers we are creating
  117068. */
  117069. defaultType?: number;
  117070. }
  117071. /**
  117072. * A multi render target, like a render target provides the ability to render to a texture.
  117073. * Unlike the render target, it can render to several draw buffers in one draw.
  117074. * This is specially interesting in deferred rendering or for any effects requiring more than
  117075. * just one color from a single pass.
  117076. */
  117077. export class MultiRenderTarget extends RenderTargetTexture {
  117078. private _internalTextures;
  117079. private _textures;
  117080. private _multiRenderTargetOptions;
  117081. /**
  117082. * Get if draw buffers are currently supported by the used hardware and browser.
  117083. */
  117084. get isSupported(): boolean;
  117085. /**
  117086. * Get the list of textures generated by the multi render target.
  117087. */
  117088. get textures(): Texture[];
  117089. /**
  117090. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  117091. */
  117092. get depthTexture(): Texture;
  117093. /**
  117094. * Set the wrapping mode on U of all the textures we are rendering to.
  117095. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  117096. */
  117097. set wrapU(wrap: number);
  117098. /**
  117099. * Set the wrapping mode on V of all the textures we are rendering to.
  117100. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  117101. */
  117102. set wrapV(wrap: number);
  117103. /**
  117104. * Instantiate a new multi render target texture.
  117105. * A multi render target, like a render target provides the ability to render to a texture.
  117106. * Unlike the render target, it can render to several draw buffers in one draw.
  117107. * This is specially interesting in deferred rendering or for any effects requiring more than
  117108. * just one color from a single pass.
  117109. * @param name Define the name of the texture
  117110. * @param size Define the size of the buffers to render to
  117111. * @param count Define the number of target we are rendering into
  117112. * @param scene Define the scene the texture belongs to
  117113. * @param options Define the options used to create the multi render target
  117114. */
  117115. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  117116. /** @hidden */
  117117. _rebuild(): void;
  117118. private _createInternalTextures;
  117119. private _createTextures;
  117120. /**
  117121. * Define the number of samples used if MSAA is enabled.
  117122. */
  117123. get samples(): number;
  117124. set samples(value: number);
  117125. /**
  117126. * Resize all the textures in the multi render target.
  117127. * Be carrefull as it will recreate all the data in the new texture.
  117128. * @param size Define the new size
  117129. */
  117130. resize(size: any): void;
  117131. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  117132. /**
  117133. * Dispose the render targets and their associated resources
  117134. */
  117135. dispose(): void;
  117136. /**
  117137. * Release all the underlying texture used as draw buffers.
  117138. */
  117139. releaseInternalTextures(): void;
  117140. }
  117141. }
  117142. declare module BABYLON {
  117143. interface ThinEngine {
  117144. /**
  117145. * Unbind a list of render target textures from the webGL context
  117146. * This is used only when drawBuffer extension or webGL2 are active
  117147. * @param textures defines the render target textures to unbind
  117148. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  117149. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  117150. */
  117151. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  117152. /**
  117153. * Create a multi render target texture
  117154. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  117155. * @param size defines the size of the texture
  117156. * @param options defines the creation options
  117157. * @returns the cube texture as an InternalTexture
  117158. */
  117159. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  117160. /**
  117161. * Update the sample count for a given multiple render target texture
  117162. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  117163. * @param textures defines the textures to update
  117164. * @param samples defines the sample count to set
  117165. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  117166. */
  117167. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  117168. }
  117169. }
  117170. declare module BABYLON {
  117171. /**
  117172. * Class used to define an additional view for the engine
  117173. * @see https://doc.babylonjs.com/how_to/multi_canvases
  117174. */
  117175. export class EngineView {
  117176. /** Defines the canvas where to render the view */
  117177. target: HTMLCanvasElement;
  117178. /** Defines an optional camera used to render the view (will use active camera else) */
  117179. camera?: Camera;
  117180. }
  117181. interface Engine {
  117182. /**
  117183. * Gets or sets the HTML element to use for attaching events
  117184. */
  117185. inputElement: Nullable<HTMLElement>;
  117186. /**
  117187. * Gets the current engine view
  117188. * @see https://doc.babylonjs.com/how_to/multi_canvases
  117189. */
  117190. activeView: Nullable<EngineView>;
  117191. /** Gets or sets the list of views */
  117192. views: EngineView[];
  117193. /**
  117194. * Register a new child canvas
  117195. * @param canvas defines the canvas to register
  117196. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  117197. * @returns the associated view
  117198. */
  117199. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  117200. /**
  117201. * Remove a registered child canvas
  117202. * @param canvas defines the canvas to remove
  117203. * @returns the current engine
  117204. */
  117205. unRegisterView(canvas: HTMLCanvasElement): Engine;
  117206. }
  117207. }
  117208. declare module BABYLON {
  117209. /**
  117210. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  117211. */
  117212. export interface CubeMapInfo {
  117213. /**
  117214. * The pixel array for the front face.
  117215. * This is stored in format, left to right, up to down format.
  117216. */
  117217. front: Nullable<ArrayBufferView>;
  117218. /**
  117219. * The pixel array for the back face.
  117220. * This is stored in format, left to right, up to down format.
  117221. */
  117222. back: Nullable<ArrayBufferView>;
  117223. /**
  117224. * The pixel array for the left face.
  117225. * This is stored in format, left to right, up to down format.
  117226. */
  117227. left: Nullable<ArrayBufferView>;
  117228. /**
  117229. * The pixel array for the right face.
  117230. * This is stored in format, left to right, up to down format.
  117231. */
  117232. right: Nullable<ArrayBufferView>;
  117233. /**
  117234. * The pixel array for the up face.
  117235. * This is stored in format, left to right, up to down format.
  117236. */
  117237. up: Nullable<ArrayBufferView>;
  117238. /**
  117239. * The pixel array for the down face.
  117240. * This is stored in format, left to right, up to down format.
  117241. */
  117242. down: Nullable<ArrayBufferView>;
  117243. /**
  117244. * The size of the cubemap stored.
  117245. *
  117246. * Each faces will be size * size pixels.
  117247. */
  117248. size: number;
  117249. /**
  117250. * The format of the texture.
  117251. *
  117252. * RGBA, RGB.
  117253. */
  117254. format: number;
  117255. /**
  117256. * The type of the texture data.
  117257. *
  117258. * UNSIGNED_INT, FLOAT.
  117259. */
  117260. type: number;
  117261. /**
  117262. * Specifies whether the texture is in gamma space.
  117263. */
  117264. gammaSpace: boolean;
  117265. }
  117266. /**
  117267. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  117268. */
  117269. export class PanoramaToCubeMapTools {
  117270. private static FACE_FRONT;
  117271. private static FACE_BACK;
  117272. private static FACE_RIGHT;
  117273. private static FACE_LEFT;
  117274. private static FACE_DOWN;
  117275. private static FACE_UP;
  117276. /**
  117277. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  117278. *
  117279. * @param float32Array The source data.
  117280. * @param inputWidth The width of the input panorama.
  117281. * @param inputHeight The height of the input panorama.
  117282. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  117283. * @return The cubemap data
  117284. */
  117285. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  117286. private static CreateCubemapTexture;
  117287. private static CalcProjectionSpherical;
  117288. }
  117289. }
  117290. declare module BABYLON {
  117291. /**
  117292. * Helper class dealing with the extraction of spherical polynomial dataArray
  117293. * from a cube map.
  117294. */
  117295. export class CubeMapToSphericalPolynomialTools {
  117296. private static FileFaces;
  117297. /**
  117298. * Converts a texture to the according Spherical Polynomial data.
  117299. * This extracts the first 3 orders only as they are the only one used in the lighting.
  117300. *
  117301. * @param texture The texture to extract the information from.
  117302. * @return The Spherical Polynomial data.
  117303. */
  117304. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  117305. /**
  117306. * Converts a cubemap to the according Spherical Polynomial data.
  117307. * This extracts the first 3 orders only as they are the only one used in the lighting.
  117308. *
  117309. * @param cubeInfo The Cube map to extract the information from.
  117310. * @return The Spherical Polynomial data.
  117311. */
  117312. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  117313. }
  117314. }
  117315. declare module BABYLON {
  117316. interface BaseTexture {
  117317. /**
  117318. * Get the polynomial representation of the texture data.
  117319. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  117320. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  117321. */
  117322. sphericalPolynomial: Nullable<SphericalPolynomial>;
  117323. }
  117324. }
  117325. declare module BABYLON {
  117326. /** @hidden */
  117327. export var rgbdEncodePixelShader: {
  117328. name: string;
  117329. shader: string;
  117330. };
  117331. }
  117332. declare module BABYLON {
  117333. /** @hidden */
  117334. export var rgbdDecodePixelShader: {
  117335. name: string;
  117336. shader: string;
  117337. };
  117338. }
  117339. declare module BABYLON {
  117340. /**
  117341. * Raw texture data and descriptor sufficient for WebGL texture upload
  117342. */
  117343. export interface EnvironmentTextureInfo {
  117344. /**
  117345. * Version of the environment map
  117346. */
  117347. version: number;
  117348. /**
  117349. * Width of image
  117350. */
  117351. width: number;
  117352. /**
  117353. * Irradiance information stored in the file.
  117354. */
  117355. irradiance: any;
  117356. /**
  117357. * Specular information stored in the file.
  117358. */
  117359. specular: any;
  117360. }
  117361. /**
  117362. * Defines One Image in the file. It requires only the position in the file
  117363. * as well as the length.
  117364. */
  117365. interface BufferImageData {
  117366. /**
  117367. * Length of the image data.
  117368. */
  117369. length: number;
  117370. /**
  117371. * Position of the data from the null terminator delimiting the end of the JSON.
  117372. */
  117373. position: number;
  117374. }
  117375. /**
  117376. * Defines the specular data enclosed in the file.
  117377. * This corresponds to the version 1 of the data.
  117378. */
  117379. export interface EnvironmentTextureSpecularInfoV1 {
  117380. /**
  117381. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  117382. */
  117383. specularDataPosition?: number;
  117384. /**
  117385. * This contains all the images data needed to reconstruct the cubemap.
  117386. */
  117387. mipmaps: Array<BufferImageData>;
  117388. /**
  117389. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  117390. */
  117391. lodGenerationScale: number;
  117392. }
  117393. /**
  117394. * Sets of helpers addressing the serialization and deserialization of environment texture
  117395. * stored in a BabylonJS env file.
  117396. * Those files are usually stored as .env files.
  117397. */
  117398. export class EnvironmentTextureTools {
  117399. /**
  117400. * Magic number identifying the env file.
  117401. */
  117402. private static _MagicBytes;
  117403. /**
  117404. * Gets the environment info from an env file.
  117405. * @param data The array buffer containing the .env bytes.
  117406. * @returns the environment file info (the json header) if successfully parsed.
  117407. */
  117408. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  117409. /**
  117410. * Creates an environment texture from a loaded cube texture.
  117411. * @param texture defines the cube texture to convert in env file
  117412. * @return a promise containing the environment data if succesfull.
  117413. */
  117414. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  117415. /**
  117416. * Creates a JSON representation of the spherical data.
  117417. * @param texture defines the texture containing the polynomials
  117418. * @return the JSON representation of the spherical info
  117419. */
  117420. private static _CreateEnvTextureIrradiance;
  117421. /**
  117422. * Creates the ArrayBufferViews used for initializing environment texture image data.
  117423. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  117424. * @param info parameters that determine what views will be created for accessing the underlying buffer
  117425. * @return the views described by info providing access to the underlying buffer
  117426. */
  117427. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  117428. /**
  117429. * Uploads the texture info contained in the env file to the GPU.
  117430. * @param texture defines the internal texture to upload to
  117431. * @param arrayBuffer defines the buffer cotaining the data to load
  117432. * @param info defines the texture info retrieved through the GetEnvInfo method
  117433. * @returns a promise
  117434. */
  117435. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  117436. private static _OnImageReadyAsync;
  117437. /**
  117438. * Uploads the levels of image data to the GPU.
  117439. * @param texture defines the internal texture to upload to
  117440. * @param imageData defines the array buffer views of image data [mipmap][face]
  117441. * @returns a promise
  117442. */
  117443. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  117444. /**
  117445. * Uploads spherical polynomials information to the texture.
  117446. * @param texture defines the texture we are trying to upload the information to
  117447. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  117448. */
  117449. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  117450. /** @hidden */
  117451. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  117452. }
  117453. }
  117454. declare module BABYLON {
  117455. /**
  117456. * Contains position and normal vectors for a vertex
  117457. */
  117458. export class PositionNormalVertex {
  117459. /** the position of the vertex (defaut: 0,0,0) */
  117460. position: Vector3;
  117461. /** the normal of the vertex (defaut: 0,1,0) */
  117462. normal: Vector3;
  117463. /**
  117464. * Creates a PositionNormalVertex
  117465. * @param position the position of the vertex (defaut: 0,0,0)
  117466. * @param normal the normal of the vertex (defaut: 0,1,0)
  117467. */
  117468. constructor(
  117469. /** the position of the vertex (defaut: 0,0,0) */
  117470. position?: Vector3,
  117471. /** the normal of the vertex (defaut: 0,1,0) */
  117472. normal?: Vector3);
  117473. /**
  117474. * Clones the PositionNormalVertex
  117475. * @returns the cloned PositionNormalVertex
  117476. */
  117477. clone(): PositionNormalVertex;
  117478. }
  117479. /**
  117480. * Contains position, normal and uv vectors for a vertex
  117481. */
  117482. export class PositionNormalTextureVertex {
  117483. /** the position of the vertex (defaut: 0,0,0) */
  117484. position: Vector3;
  117485. /** the normal of the vertex (defaut: 0,1,0) */
  117486. normal: Vector3;
  117487. /** the uv of the vertex (default: 0,0) */
  117488. uv: Vector2;
  117489. /**
  117490. * Creates a PositionNormalTextureVertex
  117491. * @param position the position of the vertex (defaut: 0,0,0)
  117492. * @param normal the normal of the vertex (defaut: 0,1,0)
  117493. * @param uv the uv of the vertex (default: 0,0)
  117494. */
  117495. constructor(
  117496. /** the position of the vertex (defaut: 0,0,0) */
  117497. position?: Vector3,
  117498. /** the normal of the vertex (defaut: 0,1,0) */
  117499. normal?: Vector3,
  117500. /** the uv of the vertex (default: 0,0) */
  117501. uv?: Vector2);
  117502. /**
  117503. * Clones the PositionNormalTextureVertex
  117504. * @returns the cloned PositionNormalTextureVertex
  117505. */
  117506. clone(): PositionNormalTextureVertex;
  117507. }
  117508. }
  117509. declare module BABYLON {
  117510. /** @hidden */
  117511. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  117512. private _genericAttributeLocation;
  117513. private _varyingLocationCount;
  117514. private _varyingLocationMap;
  117515. private _replacements;
  117516. private _textureCount;
  117517. private _uniforms;
  117518. lineProcessor(line: string): string;
  117519. attributeProcessor(attribute: string): string;
  117520. varyingProcessor(varying: string, isFragment: boolean): string;
  117521. uniformProcessor(uniform: string): string;
  117522. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  117523. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  117524. }
  117525. }
  117526. declare module BABYLON {
  117527. /**
  117528. * Container for accessors for natively-stored mesh data buffers.
  117529. */
  117530. class NativeDataBuffer extends DataBuffer {
  117531. /**
  117532. * Accessor value used to identify/retrieve a natively-stored index buffer.
  117533. */
  117534. nativeIndexBuffer?: any;
  117535. /**
  117536. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  117537. */
  117538. nativeVertexBuffer?: any;
  117539. }
  117540. /** @hidden */
  117541. class NativeTexture extends InternalTexture {
  117542. getInternalTexture(): InternalTexture;
  117543. getViewCount(): number;
  117544. }
  117545. /** @hidden */
  117546. export class NativeEngine extends Engine {
  117547. private readonly _native;
  117548. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  117549. private readonly INVALID_HANDLE;
  117550. getHardwareScalingLevel(): number;
  117551. constructor();
  117552. /**
  117553. * Can be used to override the current requestAnimationFrame requester.
  117554. * @hidden
  117555. */
  117556. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  117557. /**
  117558. * Override default engine behavior.
  117559. * @param color
  117560. * @param backBuffer
  117561. * @param depth
  117562. * @param stencil
  117563. */
  117564. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  117565. /**
  117566. * Gets host document
  117567. * @returns the host document object
  117568. */
  117569. getHostDocument(): Nullable<Document>;
  117570. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  117571. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  117572. createVertexBuffer(data: DataArray): NativeDataBuffer;
  117573. recordVertexArrayObject(vertexBuffers: {
  117574. [key: string]: VertexBuffer;
  117575. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  117576. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  117577. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  117578. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  117579. /**
  117580. * Draw a list of indexed primitives
  117581. * @param fillMode defines the primitive to use
  117582. * @param indexStart defines the starting index
  117583. * @param indexCount defines the number of index to draw
  117584. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  117585. */
  117586. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  117587. /**
  117588. * Draw a list of unindexed primitives
  117589. * @param fillMode defines the primitive to use
  117590. * @param verticesStart defines the index of first vertex to draw
  117591. * @param verticesCount defines the count of vertices to draw
  117592. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  117593. */
  117594. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  117595. createPipelineContext(): IPipelineContext;
  117596. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  117597. /** @hidden */
  117598. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  117599. /** @hidden */
  117600. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  117601. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  117602. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  117603. protected _setProgram(program: WebGLProgram): void;
  117604. _releaseEffect(effect: Effect): void;
  117605. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  117606. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  117607. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  117608. bindSamplers(effect: Effect): void;
  117609. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  117610. getRenderWidth(useScreen?: boolean): number;
  117611. getRenderHeight(useScreen?: boolean): number;
  117612. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  117613. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  117614. /**
  117615. * Set the z offset to apply to current rendering
  117616. * @param value defines the offset to apply
  117617. */
  117618. setZOffset(value: number): void;
  117619. /**
  117620. * Gets the current value of the zOffset
  117621. * @returns the current zOffset state
  117622. */
  117623. getZOffset(): number;
  117624. /**
  117625. * Enable or disable depth buffering
  117626. * @param enable defines the state to set
  117627. */
  117628. setDepthBuffer(enable: boolean): void;
  117629. /**
  117630. * Gets a boolean indicating if depth writing is enabled
  117631. * @returns the current depth writing state
  117632. */
  117633. getDepthWrite(): boolean;
  117634. /**
  117635. * Enable or disable depth writing
  117636. * @param enable defines the state to set
  117637. */
  117638. setDepthWrite(enable: boolean): void;
  117639. /**
  117640. * Enable or disable color writing
  117641. * @param enable defines the state to set
  117642. */
  117643. setColorWrite(enable: boolean): void;
  117644. /**
  117645. * Gets a boolean indicating if color writing is enabled
  117646. * @returns the current color writing state
  117647. */
  117648. getColorWrite(): boolean;
  117649. /**
  117650. * Sets alpha constants used by some alpha blending modes
  117651. * @param r defines the red component
  117652. * @param g defines the green component
  117653. * @param b defines the blue component
  117654. * @param a defines the alpha component
  117655. */
  117656. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  117657. /**
  117658. * Sets the current alpha mode
  117659. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  117660. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  117661. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  117662. */
  117663. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  117664. /**
  117665. * Gets the current alpha mode
  117666. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  117667. * @returns the current alpha mode
  117668. */
  117669. getAlphaMode(): number;
  117670. setInt(uniform: WebGLUniformLocation, int: number): void;
  117671. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  117672. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  117673. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  117674. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  117675. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  117676. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  117677. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  117678. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  117679. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  117680. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  117681. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  117682. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  117683. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  117684. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  117685. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  117686. setFloat(uniform: WebGLUniformLocation, value: number): void;
  117687. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  117688. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  117689. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  117690. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  117691. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  117692. wipeCaches(bruteForce?: boolean): void;
  117693. _createTexture(): WebGLTexture;
  117694. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  117695. /**
  117696. * Usually called from BABYLON.Texture.ts.
  117697. * Passed information to create a WebGLTexture
  117698. * @param urlArg defines a value which contains one of the following:
  117699. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  117700. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  117701. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  117702. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  117703. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  117704. * @param scene needed for loading to the correct scene
  117705. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  117706. * @param onLoad optional callback to be called upon successful completion
  117707. * @param onError optional callback to be called upon failure
  117708. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  117709. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  117710. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  117711. * @param forcedExtension defines the extension to use to pick the right loader
  117712. * @returns a InternalTexture for assignment back into BABYLON.Texture
  117713. */
  117714. 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;
  117715. /**
  117716. * Creates a cube texture
  117717. * @param rootUrl defines the url where the files to load is located
  117718. * @param scene defines the current scene
  117719. * @param files defines the list of files to load (1 per face)
  117720. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  117721. * @param onLoad defines an optional callback raised when the texture is loaded
  117722. * @param onError defines an optional callback raised if there is an issue to load the texture
  117723. * @param format defines the format of the data
  117724. * @param forcedExtension defines the extension to use to pick the right loader
  117725. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  117726. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  117727. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  117728. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  117729. * @returns the cube texture as an InternalTexture
  117730. */
  117731. 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;
  117732. private _getSamplingFilter;
  117733. private static _GetNativeTextureFormat;
  117734. createRenderTargetTexture(size: number | {
  117735. width: number;
  117736. height: number;
  117737. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  117738. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  117739. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  117740. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  117741. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  117742. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  117743. /**
  117744. * Updates a dynamic vertex buffer.
  117745. * @param vertexBuffer the vertex buffer to update
  117746. * @param data the data used to update the vertex buffer
  117747. * @param byteOffset the byte offset of the data (optional)
  117748. * @param byteLength the byte length of the data (optional)
  117749. */
  117750. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  117751. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  117752. private _updateAnisotropicLevel;
  117753. private _getAddressMode;
  117754. /** @hidden */
  117755. _bindTexture(channel: number, texture: InternalTexture): void;
  117756. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  117757. releaseEffects(): void;
  117758. /** @hidden */
  117759. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117760. /** @hidden */
  117761. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117762. /** @hidden */
  117763. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117764. /** @hidden */
  117765. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  117766. }
  117767. }
  117768. declare module BABYLON {
  117769. /**
  117770. * Gather the list of clipboard event types as constants.
  117771. */
  117772. export class ClipboardEventTypes {
  117773. /**
  117774. * The clipboard event is fired when a copy command is active (pressed).
  117775. */
  117776. static readonly COPY: number;
  117777. /**
  117778. * The clipboard event is fired when a cut command is active (pressed).
  117779. */
  117780. static readonly CUT: number;
  117781. /**
  117782. * The clipboard event is fired when a paste command is active (pressed).
  117783. */
  117784. static readonly PASTE: number;
  117785. }
  117786. /**
  117787. * This class is used to store clipboard related info for the onClipboardObservable event.
  117788. */
  117789. export class ClipboardInfo {
  117790. /**
  117791. * Defines the type of event (BABYLON.ClipboardEventTypes)
  117792. */
  117793. type: number;
  117794. /**
  117795. * Defines the related dom event
  117796. */
  117797. event: ClipboardEvent;
  117798. /**
  117799. *Creates an instance of ClipboardInfo.
  117800. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  117801. * @param event Defines the related dom event
  117802. */
  117803. constructor(
  117804. /**
  117805. * Defines the type of event (BABYLON.ClipboardEventTypes)
  117806. */
  117807. type: number,
  117808. /**
  117809. * Defines the related dom event
  117810. */
  117811. event: ClipboardEvent);
  117812. /**
  117813. * Get the clipboard event's type from the keycode.
  117814. * @param keyCode Defines the keyCode for the current keyboard event.
  117815. * @return {number}
  117816. */
  117817. static GetTypeFromCharacter(keyCode: number): number;
  117818. }
  117819. }
  117820. declare module BABYLON {
  117821. /**
  117822. * Google Daydream controller
  117823. */
  117824. export class DaydreamController extends WebVRController {
  117825. /**
  117826. * Base Url for the controller model.
  117827. */
  117828. static MODEL_BASE_URL: string;
  117829. /**
  117830. * File name for the controller model.
  117831. */
  117832. static MODEL_FILENAME: string;
  117833. /**
  117834. * Gamepad Id prefix used to identify Daydream Controller.
  117835. */
  117836. static readonly GAMEPAD_ID_PREFIX: string;
  117837. /**
  117838. * Creates a new DaydreamController from a gamepad
  117839. * @param vrGamepad the gamepad that the controller should be created from
  117840. */
  117841. constructor(vrGamepad: any);
  117842. /**
  117843. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  117844. * @param scene scene in which to add meshes
  117845. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  117846. */
  117847. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  117848. /**
  117849. * Called once for each button that changed state since the last frame
  117850. * @param buttonIdx Which button index changed
  117851. * @param state New state of the button
  117852. * @param changes Which properties on the state changed since last frame
  117853. */
  117854. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  117855. }
  117856. }
  117857. declare module BABYLON {
  117858. /**
  117859. * Gear VR Controller
  117860. */
  117861. export class GearVRController extends WebVRController {
  117862. /**
  117863. * Base Url for the controller model.
  117864. */
  117865. static MODEL_BASE_URL: string;
  117866. /**
  117867. * File name for the controller model.
  117868. */
  117869. static MODEL_FILENAME: string;
  117870. /**
  117871. * Gamepad Id prefix used to identify this controller.
  117872. */
  117873. static readonly GAMEPAD_ID_PREFIX: string;
  117874. private readonly _buttonIndexToObservableNameMap;
  117875. /**
  117876. * Creates a new GearVRController from a gamepad
  117877. * @param vrGamepad the gamepad that the controller should be created from
  117878. */
  117879. constructor(vrGamepad: any);
  117880. /**
  117881. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  117882. * @param scene scene in which to add meshes
  117883. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  117884. */
  117885. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  117886. /**
  117887. * Called once for each button that changed state since the last frame
  117888. * @param buttonIdx Which button index changed
  117889. * @param state New state of the button
  117890. * @param changes Which properties on the state changed since last frame
  117891. */
  117892. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  117893. }
  117894. }
  117895. declare module BABYLON {
  117896. /**
  117897. * Class containing static functions to help procedurally build meshes
  117898. */
  117899. export class PolyhedronBuilder {
  117900. /**
  117901. * Creates a polyhedron mesh
  117902. * * 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
  117903. * * The parameter `size` (positive float, default 1) sets the polygon size
  117904. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  117905. * * 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`
  117906. * * 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
  117907. * * 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)`)
  117908. * * 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
  117909. * * 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
  117910. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117911. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117913. * @param name defines the name of the mesh
  117914. * @param options defines the options used to create the mesh
  117915. * @param scene defines the hosting scene
  117916. * @returns the polyhedron mesh
  117917. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  117918. */
  117919. static CreatePolyhedron(name: string, options: {
  117920. type?: number;
  117921. size?: number;
  117922. sizeX?: number;
  117923. sizeY?: number;
  117924. sizeZ?: number;
  117925. custom?: any;
  117926. faceUV?: Vector4[];
  117927. faceColors?: Color4[];
  117928. flat?: boolean;
  117929. updatable?: boolean;
  117930. sideOrientation?: number;
  117931. frontUVs?: Vector4;
  117932. backUVs?: Vector4;
  117933. }, scene?: Nullable<Scene>): Mesh;
  117934. }
  117935. }
  117936. declare module BABYLON {
  117937. /**
  117938. * Gizmo that enables scaling a mesh along 3 axis
  117939. */
  117940. export class ScaleGizmo extends Gizmo {
  117941. /**
  117942. * Internal gizmo used for interactions on the x axis
  117943. */
  117944. xGizmo: AxisScaleGizmo;
  117945. /**
  117946. * Internal gizmo used for interactions on the y axis
  117947. */
  117948. yGizmo: AxisScaleGizmo;
  117949. /**
  117950. * Internal gizmo used for interactions on the z axis
  117951. */
  117952. zGizmo: AxisScaleGizmo;
  117953. /**
  117954. * Internal gizmo used to scale all axis equally
  117955. */
  117956. uniformScaleGizmo: AxisScaleGizmo;
  117957. private _meshAttached;
  117958. private _updateGizmoRotationToMatchAttachedMesh;
  117959. private _snapDistance;
  117960. private _scaleRatio;
  117961. private _uniformScalingMesh;
  117962. private _octahedron;
  117963. private _sensitivity;
  117964. /** Fires an event when any of it's sub gizmos are dragged */
  117965. onDragStartObservable: Observable<unknown>;
  117966. /** Fires an event when any of it's sub gizmos are released from dragging */
  117967. onDragEndObservable: Observable<unknown>;
  117968. get attachedMesh(): Nullable<AbstractMesh>;
  117969. set attachedMesh(mesh: Nullable<AbstractMesh>);
  117970. /**
  117971. * Creates a ScaleGizmo
  117972. * @param gizmoLayer The utility layer the gizmo will be added to
  117973. */
  117974. constructor(gizmoLayer?: UtilityLayerRenderer);
  117975. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  117976. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  117977. /**
  117978. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  117979. */
  117980. set snapDistance(value: number);
  117981. get snapDistance(): number;
  117982. /**
  117983. * Ratio for the scale of the gizmo (Default: 1)
  117984. */
  117985. set scaleRatio(value: number);
  117986. get scaleRatio(): number;
  117987. /**
  117988. * Sensitivity factor for dragging (Default: 1)
  117989. */
  117990. set sensitivity(value: number);
  117991. get sensitivity(): number;
  117992. /**
  117993. * Disposes of the gizmo
  117994. */
  117995. dispose(): void;
  117996. }
  117997. }
  117998. declare module BABYLON {
  117999. /**
  118000. * Single axis scale gizmo
  118001. */
  118002. export class AxisScaleGizmo extends Gizmo {
  118003. /**
  118004. * Drag behavior responsible for the gizmos dragging interactions
  118005. */
  118006. dragBehavior: PointerDragBehavior;
  118007. private _pointerObserver;
  118008. /**
  118009. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118010. */
  118011. snapDistance: number;
  118012. /**
  118013. * Event that fires each time the gizmo snaps to a new location.
  118014. * * snapDistance is the the change in distance
  118015. */
  118016. onSnapObservable: Observable<{
  118017. snapDistance: number;
  118018. }>;
  118019. /**
  118020. * If the scaling operation should be done on all axis (default: false)
  118021. */
  118022. uniformScaling: boolean;
  118023. /**
  118024. * Custom sensitivity value for the drag strength
  118025. */
  118026. sensitivity: number;
  118027. private _isEnabled;
  118028. private _parent;
  118029. private _arrow;
  118030. private _coloredMaterial;
  118031. private _hoverMaterial;
  118032. /**
  118033. * Creates an AxisScaleGizmo
  118034. * @param gizmoLayer The utility layer the gizmo will be added to
  118035. * @param dragAxis The axis which the gizmo will be able to scale on
  118036. * @param color The color of the gizmo
  118037. */
  118038. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  118039. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118040. /**
  118041. * If the gizmo is enabled
  118042. */
  118043. set isEnabled(value: boolean);
  118044. get isEnabled(): boolean;
  118045. /**
  118046. * Disposes of the gizmo
  118047. */
  118048. dispose(): void;
  118049. /**
  118050. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  118051. * @param mesh The mesh to replace the default mesh of the gizmo
  118052. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  118053. */
  118054. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  118055. }
  118056. }
  118057. declare module BABYLON {
  118058. /**
  118059. * Bounding box gizmo
  118060. */
  118061. export class BoundingBoxGizmo extends Gizmo {
  118062. private _lineBoundingBox;
  118063. private _rotateSpheresParent;
  118064. private _scaleBoxesParent;
  118065. private _boundingDimensions;
  118066. private _renderObserver;
  118067. private _pointerObserver;
  118068. private _scaleDragSpeed;
  118069. private _tmpQuaternion;
  118070. private _tmpVector;
  118071. private _tmpRotationMatrix;
  118072. /**
  118073. * 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)
  118074. */
  118075. ignoreChildren: boolean;
  118076. /**
  118077. * 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)
  118078. */
  118079. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  118080. /**
  118081. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  118082. */
  118083. rotationSphereSize: number;
  118084. /**
  118085. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  118086. */
  118087. scaleBoxSize: number;
  118088. /**
  118089. * 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)
  118090. */
  118091. fixedDragMeshScreenSize: boolean;
  118092. /**
  118093. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  118094. */
  118095. fixedDragMeshScreenSizeDistanceFactor: number;
  118096. /**
  118097. * Fired when a rotation sphere or scale box is dragged
  118098. */
  118099. onDragStartObservable: Observable<{}>;
  118100. /**
  118101. * Fired when a scale box is dragged
  118102. */
  118103. onScaleBoxDragObservable: Observable<{}>;
  118104. /**
  118105. * Fired when a scale box drag is ended
  118106. */
  118107. onScaleBoxDragEndObservable: Observable<{}>;
  118108. /**
  118109. * Fired when a rotation sphere is dragged
  118110. */
  118111. onRotationSphereDragObservable: Observable<{}>;
  118112. /**
  118113. * Fired when a rotation sphere drag is ended
  118114. */
  118115. onRotationSphereDragEndObservable: Observable<{}>;
  118116. /**
  118117. * 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)
  118118. */
  118119. scalePivot: Nullable<Vector3>;
  118120. /**
  118121. * Mesh used as a pivot to rotate the attached mesh
  118122. */
  118123. private _anchorMesh;
  118124. private _existingMeshScale;
  118125. private _dragMesh;
  118126. private pointerDragBehavior;
  118127. private coloredMaterial;
  118128. private hoverColoredMaterial;
  118129. /**
  118130. * Sets the color of the bounding box gizmo
  118131. * @param color the color to set
  118132. */
  118133. setColor(color: Color3): void;
  118134. /**
  118135. * Creates an BoundingBoxGizmo
  118136. * @param gizmoLayer The utility layer the gizmo will be added to
  118137. * @param color The color of the gizmo
  118138. */
  118139. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  118140. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118141. private _selectNode;
  118142. /**
  118143. * Updates the bounding box information for the Gizmo
  118144. */
  118145. updateBoundingBox(): void;
  118146. private _updateRotationSpheres;
  118147. private _updateScaleBoxes;
  118148. /**
  118149. * Enables rotation on the specified axis and disables rotation on the others
  118150. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  118151. */
  118152. setEnabledRotationAxis(axis: string): void;
  118153. /**
  118154. * Enables/disables scaling
  118155. * @param enable if scaling should be enabled
  118156. */
  118157. setEnabledScaling(enable: boolean): void;
  118158. private _updateDummy;
  118159. /**
  118160. * Enables a pointer drag behavior on the bounding box of the gizmo
  118161. */
  118162. enableDragBehavior(): void;
  118163. /**
  118164. * Disposes of the gizmo
  118165. */
  118166. dispose(): void;
  118167. /**
  118168. * 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)
  118169. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  118170. * @returns the bounding box mesh with the passed in mesh as a child
  118171. */
  118172. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  118173. /**
  118174. * CustomMeshes are not supported by this gizmo
  118175. * @param mesh The mesh to replace the default mesh of the gizmo
  118176. */
  118177. setCustomMesh(mesh: Mesh): void;
  118178. }
  118179. }
  118180. declare module BABYLON {
  118181. /**
  118182. * Single plane rotation gizmo
  118183. */
  118184. export class PlaneRotationGizmo extends Gizmo {
  118185. /**
  118186. * Drag behavior responsible for the gizmos dragging interactions
  118187. */
  118188. dragBehavior: PointerDragBehavior;
  118189. private _pointerObserver;
  118190. /**
  118191. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  118192. */
  118193. snapDistance: number;
  118194. /**
  118195. * Event that fires each time the gizmo snaps to a new location.
  118196. * * snapDistance is the the change in distance
  118197. */
  118198. onSnapObservable: Observable<{
  118199. snapDistance: number;
  118200. }>;
  118201. private _isEnabled;
  118202. private _parent;
  118203. /**
  118204. * Creates a PlaneRotationGizmo
  118205. * @param gizmoLayer The utility layer the gizmo will be added to
  118206. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  118207. * @param color The color of the gizmo
  118208. * @param tessellation Amount of tessellation to be used when creating rotation circles
  118209. * @param useEulerRotation Use and update Euler angle instead of quaternion
  118210. */
  118211. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  118212. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118213. /**
  118214. * If the gizmo is enabled
  118215. */
  118216. set isEnabled(value: boolean);
  118217. get isEnabled(): boolean;
  118218. /**
  118219. * Disposes of the gizmo
  118220. */
  118221. dispose(): void;
  118222. }
  118223. }
  118224. declare module BABYLON {
  118225. /**
  118226. * Gizmo that enables rotating a mesh along 3 axis
  118227. */
  118228. export class RotationGizmo extends Gizmo {
  118229. /**
  118230. * Internal gizmo used for interactions on the x axis
  118231. */
  118232. xGizmo: PlaneRotationGizmo;
  118233. /**
  118234. * Internal gizmo used for interactions on the y axis
  118235. */
  118236. yGizmo: PlaneRotationGizmo;
  118237. /**
  118238. * Internal gizmo used for interactions on the z axis
  118239. */
  118240. zGizmo: PlaneRotationGizmo;
  118241. /** Fires an event when any of it's sub gizmos are dragged */
  118242. onDragStartObservable: Observable<unknown>;
  118243. /** Fires an event when any of it's sub gizmos are released from dragging */
  118244. onDragEndObservable: Observable<unknown>;
  118245. private _meshAttached;
  118246. get attachedMesh(): Nullable<AbstractMesh>;
  118247. set attachedMesh(mesh: Nullable<AbstractMesh>);
  118248. /**
  118249. * Creates a RotationGizmo
  118250. * @param gizmoLayer The utility layer the gizmo will be added to
  118251. * @param tessellation Amount of tessellation to be used when creating rotation circles
  118252. * @param useEulerRotation Use and update Euler angle instead of quaternion
  118253. */
  118254. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  118255. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  118256. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  118257. /**
  118258. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118259. */
  118260. set snapDistance(value: number);
  118261. get snapDistance(): number;
  118262. /**
  118263. * Ratio for the scale of the gizmo (Default: 1)
  118264. */
  118265. set scaleRatio(value: number);
  118266. get scaleRatio(): number;
  118267. /**
  118268. * Disposes of the gizmo
  118269. */
  118270. dispose(): void;
  118271. /**
  118272. * CustomMeshes are not supported by this gizmo
  118273. * @param mesh The mesh to replace the default mesh of the gizmo
  118274. */
  118275. setCustomMesh(mesh: Mesh): void;
  118276. }
  118277. }
  118278. declare module BABYLON {
  118279. /**
  118280. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  118281. */
  118282. export class GizmoManager implements IDisposable {
  118283. private scene;
  118284. /**
  118285. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  118286. */
  118287. gizmos: {
  118288. positionGizmo: Nullable<PositionGizmo>;
  118289. rotationGizmo: Nullable<RotationGizmo>;
  118290. scaleGizmo: Nullable<ScaleGizmo>;
  118291. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  118292. };
  118293. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  118294. clearGizmoOnEmptyPointerEvent: boolean;
  118295. /** Fires an event when the manager is attached to a mesh */
  118296. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  118297. private _gizmosEnabled;
  118298. private _pointerObserver;
  118299. private _attachedMesh;
  118300. private _boundingBoxColor;
  118301. private _defaultUtilityLayer;
  118302. private _defaultKeepDepthUtilityLayer;
  118303. /**
  118304. * When bounding box gizmo is enabled, this can be used to track drag/end events
  118305. */
  118306. boundingBoxDragBehavior: SixDofDragBehavior;
  118307. /**
  118308. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  118309. */
  118310. attachableMeshes: Nullable<Array<AbstractMesh>>;
  118311. /**
  118312. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  118313. */
  118314. usePointerToAttachGizmos: boolean;
  118315. /**
  118316. * Utility layer that the bounding box gizmo belongs to
  118317. */
  118318. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  118319. /**
  118320. * Utility layer that all gizmos besides bounding box belong to
  118321. */
  118322. get utilityLayer(): UtilityLayerRenderer;
  118323. /**
  118324. * Instatiates a gizmo manager
  118325. * @param scene the scene to overlay the gizmos on top of
  118326. */
  118327. constructor(scene: Scene);
  118328. /**
  118329. * Attaches a set of gizmos to the specified mesh
  118330. * @param mesh The mesh the gizmo's should be attached to
  118331. */
  118332. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  118333. /**
  118334. * If the position gizmo is enabled
  118335. */
  118336. set positionGizmoEnabled(value: boolean);
  118337. get positionGizmoEnabled(): boolean;
  118338. /**
  118339. * If the rotation gizmo is enabled
  118340. */
  118341. set rotationGizmoEnabled(value: boolean);
  118342. get rotationGizmoEnabled(): boolean;
  118343. /**
  118344. * If the scale gizmo is enabled
  118345. */
  118346. set scaleGizmoEnabled(value: boolean);
  118347. get scaleGizmoEnabled(): boolean;
  118348. /**
  118349. * If the boundingBox gizmo is enabled
  118350. */
  118351. set boundingBoxGizmoEnabled(value: boolean);
  118352. get boundingBoxGizmoEnabled(): boolean;
  118353. /**
  118354. * Disposes of the gizmo manager
  118355. */
  118356. dispose(): void;
  118357. }
  118358. }
  118359. declare module BABYLON {
  118360. /**
  118361. * A directional light is defined by a direction (what a surprise!).
  118362. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  118363. * 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.
  118364. * Documentation: https://doc.babylonjs.com/babylon101/lights
  118365. */
  118366. export class DirectionalLight extends ShadowLight {
  118367. private _shadowFrustumSize;
  118368. /**
  118369. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  118370. */
  118371. get shadowFrustumSize(): number;
  118372. /**
  118373. * Specifies a fix frustum size for the shadow generation.
  118374. */
  118375. set shadowFrustumSize(value: number);
  118376. private _shadowOrthoScale;
  118377. /**
  118378. * Gets the shadow projection scale against the optimal computed one.
  118379. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  118380. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  118381. */
  118382. get shadowOrthoScale(): number;
  118383. /**
  118384. * Sets the shadow projection scale against the optimal computed one.
  118385. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  118386. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  118387. */
  118388. set shadowOrthoScale(value: number);
  118389. /**
  118390. * Automatically compute the projection matrix to best fit (including all the casters)
  118391. * on each frame.
  118392. */
  118393. autoUpdateExtends: boolean;
  118394. private _orthoLeft;
  118395. private _orthoRight;
  118396. private _orthoTop;
  118397. private _orthoBottom;
  118398. /**
  118399. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  118400. * The directional light is emitted from everywhere in the given direction.
  118401. * It can cast shadows.
  118402. * Documentation : https://doc.babylonjs.com/babylon101/lights
  118403. * @param name The friendly name of the light
  118404. * @param direction The direction of the light
  118405. * @param scene The scene the light belongs to
  118406. */
  118407. constructor(name: string, direction: Vector3, scene: Scene);
  118408. /**
  118409. * Returns the string "DirectionalLight".
  118410. * @return The class name
  118411. */
  118412. getClassName(): string;
  118413. /**
  118414. * Returns the integer 1.
  118415. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  118416. */
  118417. getTypeID(): number;
  118418. /**
  118419. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  118420. * Returns the DirectionalLight Shadow projection matrix.
  118421. */
  118422. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  118423. /**
  118424. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  118425. * Returns the DirectionalLight Shadow projection matrix.
  118426. */
  118427. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  118428. /**
  118429. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  118430. * Returns the DirectionalLight Shadow projection matrix.
  118431. */
  118432. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  118433. protected _buildUniformLayout(): void;
  118434. /**
  118435. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  118436. * @param effect The effect to update
  118437. * @param lightIndex The index of the light in the effect to update
  118438. * @returns The directional light
  118439. */
  118440. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  118441. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  118442. /**
  118443. * Gets the minZ used for shadow according to both the scene and the light.
  118444. *
  118445. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  118446. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  118447. * @param activeCamera The camera we are returning the min for
  118448. * @returns the depth min z
  118449. */
  118450. getDepthMinZ(activeCamera: Camera): number;
  118451. /**
  118452. * Gets the maxZ used for shadow according to both the scene and the light.
  118453. *
  118454. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  118455. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  118456. * @param activeCamera The camera we are returning the max for
  118457. * @returns the depth max z
  118458. */
  118459. getDepthMaxZ(activeCamera: Camera): number;
  118460. /**
  118461. * Prepares the list of defines specific to the light type.
  118462. * @param defines the list of defines
  118463. * @param lightIndex defines the index of the light for the effect
  118464. */
  118465. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  118466. }
  118467. }
  118468. declare module BABYLON {
  118469. /**
  118470. * Class containing static functions to help procedurally build meshes
  118471. */
  118472. export class HemisphereBuilder {
  118473. /**
  118474. * Creates a hemisphere mesh
  118475. * @param name defines the name of the mesh
  118476. * @param options defines the options used to create the mesh
  118477. * @param scene defines the hosting scene
  118478. * @returns the hemisphere mesh
  118479. */
  118480. static CreateHemisphere(name: string, options: {
  118481. segments?: number;
  118482. diameter?: number;
  118483. sideOrientation?: number;
  118484. }, scene: any): Mesh;
  118485. }
  118486. }
  118487. declare module BABYLON {
  118488. /**
  118489. * A spot light is defined by a position, a direction, an angle, and an exponent.
  118490. * These values define a cone of light starting from the position, emitting toward the direction.
  118491. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  118492. * and the exponent defines the speed of the decay of the light with distance (reach).
  118493. * Documentation: https://doc.babylonjs.com/babylon101/lights
  118494. */
  118495. export class SpotLight extends ShadowLight {
  118496. private _angle;
  118497. private _innerAngle;
  118498. private _cosHalfAngle;
  118499. private _lightAngleScale;
  118500. private _lightAngleOffset;
  118501. /**
  118502. * Gets the cone angle of the spot light in Radians.
  118503. */
  118504. get angle(): number;
  118505. /**
  118506. * Sets the cone angle of the spot light in Radians.
  118507. */
  118508. set angle(value: number);
  118509. /**
  118510. * Only used in gltf falloff mode, this defines the angle where
  118511. * the directional falloff will start before cutting at angle which could be seen
  118512. * as outer angle.
  118513. */
  118514. get innerAngle(): number;
  118515. /**
  118516. * Only used in gltf falloff mode, this defines the angle where
  118517. * the directional falloff will start before cutting at angle which could be seen
  118518. * as outer angle.
  118519. */
  118520. set innerAngle(value: number);
  118521. private _shadowAngleScale;
  118522. /**
  118523. * Allows scaling the angle of the light for shadow generation only.
  118524. */
  118525. get shadowAngleScale(): number;
  118526. /**
  118527. * Allows scaling the angle of the light for shadow generation only.
  118528. */
  118529. set shadowAngleScale(value: number);
  118530. /**
  118531. * The light decay speed with the distance from the emission spot.
  118532. */
  118533. exponent: number;
  118534. private _projectionTextureMatrix;
  118535. /**
  118536. * Allows reading the projecton texture
  118537. */
  118538. get projectionTextureMatrix(): Matrix;
  118539. protected _projectionTextureLightNear: number;
  118540. /**
  118541. * Gets the near clip of the Spotlight for texture projection.
  118542. */
  118543. get projectionTextureLightNear(): number;
  118544. /**
  118545. * Sets the near clip of the Spotlight for texture projection.
  118546. */
  118547. set projectionTextureLightNear(value: number);
  118548. protected _projectionTextureLightFar: number;
  118549. /**
  118550. * Gets the far clip of the Spotlight for texture projection.
  118551. */
  118552. get projectionTextureLightFar(): number;
  118553. /**
  118554. * Sets the far clip of the Spotlight for texture projection.
  118555. */
  118556. set projectionTextureLightFar(value: number);
  118557. protected _projectionTextureUpDirection: Vector3;
  118558. /**
  118559. * Gets the Up vector of the Spotlight for texture projection.
  118560. */
  118561. get projectionTextureUpDirection(): Vector3;
  118562. /**
  118563. * Sets the Up vector of the Spotlight for texture projection.
  118564. */
  118565. set projectionTextureUpDirection(value: Vector3);
  118566. private _projectionTexture;
  118567. /**
  118568. * Gets the projection texture of the light.
  118569. */
  118570. get projectionTexture(): Nullable<BaseTexture>;
  118571. /**
  118572. * Sets the projection texture of the light.
  118573. */
  118574. set projectionTexture(value: Nullable<BaseTexture>);
  118575. private _projectionTextureViewLightDirty;
  118576. private _projectionTextureProjectionLightDirty;
  118577. private _projectionTextureDirty;
  118578. private _projectionTextureViewTargetVector;
  118579. private _projectionTextureViewLightMatrix;
  118580. private _projectionTextureProjectionLightMatrix;
  118581. private _projectionTextureScalingMatrix;
  118582. /**
  118583. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  118584. * It can cast shadows.
  118585. * Documentation : https://doc.babylonjs.com/babylon101/lights
  118586. * @param name The light friendly name
  118587. * @param position The position of the spot light in the scene
  118588. * @param direction The direction of the light in the scene
  118589. * @param angle The cone angle of the light in Radians
  118590. * @param exponent The light decay speed with the distance from the emission spot
  118591. * @param scene The scene the lights belongs to
  118592. */
  118593. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  118594. /**
  118595. * Returns the string "SpotLight".
  118596. * @returns the class name
  118597. */
  118598. getClassName(): string;
  118599. /**
  118600. * Returns the integer 2.
  118601. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  118602. */
  118603. getTypeID(): number;
  118604. /**
  118605. * Overrides the direction setter to recompute the projection texture view light Matrix.
  118606. */
  118607. protected _setDirection(value: Vector3): void;
  118608. /**
  118609. * Overrides the position setter to recompute the projection texture view light Matrix.
  118610. */
  118611. protected _setPosition(value: Vector3): void;
  118612. /**
  118613. * 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.
  118614. * Returns the SpotLight.
  118615. */
  118616. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  118617. protected _computeProjectionTextureViewLightMatrix(): void;
  118618. protected _computeProjectionTextureProjectionLightMatrix(): void;
  118619. /**
  118620. * Main function for light texture projection matrix computing.
  118621. */
  118622. protected _computeProjectionTextureMatrix(): void;
  118623. protected _buildUniformLayout(): void;
  118624. private _computeAngleValues;
  118625. /**
  118626. * Sets the passed Effect "effect" with the Light textures.
  118627. * @param effect The effect to update
  118628. * @param lightIndex The index of the light in the effect to update
  118629. * @returns The light
  118630. */
  118631. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  118632. /**
  118633. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  118634. * @param effect The effect to update
  118635. * @param lightIndex The index of the light in the effect to update
  118636. * @returns The spot light
  118637. */
  118638. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  118639. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  118640. /**
  118641. * Disposes the light and the associated resources.
  118642. */
  118643. dispose(): void;
  118644. /**
  118645. * Prepares the list of defines specific to the light type.
  118646. * @param defines the list of defines
  118647. * @param lightIndex defines the index of the light for the effect
  118648. */
  118649. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  118650. }
  118651. }
  118652. declare module BABYLON {
  118653. /**
  118654. * Gizmo that enables viewing a light
  118655. */
  118656. export class LightGizmo extends Gizmo {
  118657. private _lightMesh;
  118658. private _material;
  118659. private _cachedPosition;
  118660. private _cachedForward;
  118661. private _attachedMeshParent;
  118662. /**
  118663. * Creates a LightGizmo
  118664. * @param gizmoLayer The utility layer the gizmo will be added to
  118665. */
  118666. constructor(gizmoLayer?: UtilityLayerRenderer);
  118667. private _light;
  118668. /**
  118669. * The light that the gizmo is attached to
  118670. */
  118671. set light(light: Nullable<Light>);
  118672. get light(): Nullable<Light>;
  118673. /**
  118674. * Gets the material used to render the light gizmo
  118675. */
  118676. get material(): StandardMaterial;
  118677. /**
  118678. * @hidden
  118679. * Updates the gizmo to match the attached mesh's position/rotation
  118680. */
  118681. protected _update(): void;
  118682. private static _Scale;
  118683. /**
  118684. * Creates the lines for a light mesh
  118685. */
  118686. private static _CreateLightLines;
  118687. /**
  118688. * Disposes of the light gizmo
  118689. */
  118690. dispose(): void;
  118691. private static _CreateHemisphericLightMesh;
  118692. private static _CreatePointLightMesh;
  118693. private static _CreateSpotLightMesh;
  118694. private static _CreateDirectionalLightMesh;
  118695. }
  118696. }
  118697. declare module BABYLON {
  118698. /** @hidden */
  118699. export var backgroundFragmentDeclaration: {
  118700. name: string;
  118701. shader: string;
  118702. };
  118703. }
  118704. declare module BABYLON {
  118705. /** @hidden */
  118706. export var backgroundUboDeclaration: {
  118707. name: string;
  118708. shader: string;
  118709. };
  118710. }
  118711. declare module BABYLON {
  118712. /** @hidden */
  118713. export var backgroundPixelShader: {
  118714. name: string;
  118715. shader: string;
  118716. };
  118717. }
  118718. declare module BABYLON {
  118719. /** @hidden */
  118720. export var backgroundVertexDeclaration: {
  118721. name: string;
  118722. shader: string;
  118723. };
  118724. }
  118725. declare module BABYLON {
  118726. /** @hidden */
  118727. export var backgroundVertexShader: {
  118728. name: string;
  118729. shader: string;
  118730. };
  118731. }
  118732. declare module BABYLON {
  118733. /**
  118734. * Background material used to create an efficient environement around your scene.
  118735. */
  118736. export class BackgroundMaterial extends PushMaterial {
  118737. /**
  118738. * Standard reflectance value at parallel view angle.
  118739. */
  118740. static StandardReflectance0: number;
  118741. /**
  118742. * Standard reflectance value at grazing angle.
  118743. */
  118744. static StandardReflectance90: number;
  118745. protected _primaryColor: Color3;
  118746. /**
  118747. * Key light Color (multiply against the environement texture)
  118748. */
  118749. primaryColor: Color3;
  118750. protected __perceptualColor: Nullable<Color3>;
  118751. /**
  118752. * Experimental Internal Use Only.
  118753. *
  118754. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  118755. * This acts as a helper to set the primary color to a more "human friendly" value.
  118756. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  118757. * output color as close as possible from the chosen value.
  118758. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  118759. * part of lighting setup.)
  118760. */
  118761. get _perceptualColor(): Nullable<Color3>;
  118762. set _perceptualColor(value: Nullable<Color3>);
  118763. protected _primaryColorShadowLevel: float;
  118764. /**
  118765. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  118766. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  118767. */
  118768. get primaryColorShadowLevel(): float;
  118769. set primaryColorShadowLevel(value: float);
  118770. protected _primaryColorHighlightLevel: float;
  118771. /**
  118772. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  118773. * The primary color is used at the level chosen to define what the white area would look.
  118774. */
  118775. get primaryColorHighlightLevel(): float;
  118776. set primaryColorHighlightLevel(value: float);
  118777. protected _reflectionTexture: Nullable<BaseTexture>;
  118778. /**
  118779. * Reflection Texture used in the material.
  118780. * Should be author in a specific way for the best result (refer to the documentation).
  118781. */
  118782. reflectionTexture: Nullable<BaseTexture>;
  118783. protected _reflectionBlur: float;
  118784. /**
  118785. * Reflection Texture level of blur.
  118786. *
  118787. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  118788. * texture twice.
  118789. */
  118790. reflectionBlur: float;
  118791. protected _diffuseTexture: Nullable<BaseTexture>;
  118792. /**
  118793. * Diffuse Texture used in the material.
  118794. * Should be author in a specific way for the best result (refer to the documentation).
  118795. */
  118796. diffuseTexture: Nullable<BaseTexture>;
  118797. protected _shadowLights: Nullable<IShadowLight[]>;
  118798. /**
  118799. * Specify the list of lights casting shadow on the material.
  118800. * All scene shadow lights will be included if null.
  118801. */
  118802. shadowLights: Nullable<IShadowLight[]>;
  118803. protected _shadowLevel: float;
  118804. /**
  118805. * Helps adjusting the shadow to a softer level if required.
  118806. * 0 means black shadows and 1 means no shadows.
  118807. */
  118808. shadowLevel: float;
  118809. protected _sceneCenter: Vector3;
  118810. /**
  118811. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  118812. * It is usually zero but might be interesting to modify according to your setup.
  118813. */
  118814. sceneCenter: Vector3;
  118815. protected _opacityFresnel: boolean;
  118816. /**
  118817. * This helps specifying that the material is falling off to the sky box at grazing angle.
  118818. * This helps ensuring a nice transition when the camera goes under the ground.
  118819. */
  118820. opacityFresnel: boolean;
  118821. protected _reflectionFresnel: boolean;
  118822. /**
  118823. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  118824. * This helps adding a mirror texture on the ground.
  118825. */
  118826. reflectionFresnel: boolean;
  118827. protected _reflectionFalloffDistance: number;
  118828. /**
  118829. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  118830. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  118831. */
  118832. reflectionFalloffDistance: number;
  118833. protected _reflectionAmount: number;
  118834. /**
  118835. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  118836. */
  118837. reflectionAmount: number;
  118838. protected _reflectionReflectance0: number;
  118839. /**
  118840. * This specifies the weight of the reflection at grazing angle.
  118841. */
  118842. reflectionReflectance0: number;
  118843. protected _reflectionReflectance90: number;
  118844. /**
  118845. * This specifies the weight of the reflection at a perpendicular point of view.
  118846. */
  118847. reflectionReflectance90: number;
  118848. /**
  118849. * Sets the reflection reflectance fresnel values according to the default standard
  118850. * empirically know to work well :-)
  118851. */
  118852. set reflectionStandardFresnelWeight(value: number);
  118853. protected _useRGBColor: boolean;
  118854. /**
  118855. * Helps to directly use the maps channels instead of their level.
  118856. */
  118857. useRGBColor: boolean;
  118858. protected _enableNoise: boolean;
  118859. /**
  118860. * This helps reducing the banding effect that could occur on the background.
  118861. */
  118862. enableNoise: boolean;
  118863. /**
  118864. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  118865. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  118866. * Recommended to be keep at 1.0 except for special cases.
  118867. */
  118868. get fovMultiplier(): number;
  118869. set fovMultiplier(value: number);
  118870. private _fovMultiplier;
  118871. /**
  118872. * Enable the FOV adjustment feature controlled by fovMultiplier.
  118873. */
  118874. useEquirectangularFOV: boolean;
  118875. private _maxSimultaneousLights;
  118876. /**
  118877. * Number of Simultaneous lights allowed on the material.
  118878. */
  118879. maxSimultaneousLights: int;
  118880. /**
  118881. * Default configuration related to image processing available in the Background Material.
  118882. */
  118883. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118884. /**
  118885. * Keep track of the image processing observer to allow dispose and replace.
  118886. */
  118887. private _imageProcessingObserver;
  118888. /**
  118889. * Attaches a new image processing configuration to the PBR Material.
  118890. * @param configuration (if null the scene configuration will be use)
  118891. */
  118892. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  118893. /**
  118894. * Gets the image processing configuration used either in this material.
  118895. */
  118896. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  118897. /**
  118898. * Sets the Default image processing configuration used either in the this material.
  118899. *
  118900. * If sets to null, the scene one is in use.
  118901. */
  118902. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  118903. /**
  118904. * Gets wether the color curves effect is enabled.
  118905. */
  118906. get cameraColorCurvesEnabled(): boolean;
  118907. /**
  118908. * Sets wether the color curves effect is enabled.
  118909. */
  118910. set cameraColorCurvesEnabled(value: boolean);
  118911. /**
  118912. * Gets wether the color grading effect is enabled.
  118913. */
  118914. get cameraColorGradingEnabled(): boolean;
  118915. /**
  118916. * Gets wether the color grading effect is enabled.
  118917. */
  118918. set cameraColorGradingEnabled(value: boolean);
  118919. /**
  118920. * Gets wether tonemapping is enabled or not.
  118921. */
  118922. get cameraToneMappingEnabled(): boolean;
  118923. /**
  118924. * Sets wether tonemapping is enabled or not
  118925. */
  118926. set cameraToneMappingEnabled(value: boolean);
  118927. /**
  118928. * The camera exposure used on this material.
  118929. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  118930. * This corresponds to a photographic exposure.
  118931. */
  118932. get cameraExposure(): float;
  118933. /**
  118934. * The camera exposure used on this material.
  118935. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  118936. * This corresponds to a photographic exposure.
  118937. */
  118938. set cameraExposure(value: float);
  118939. /**
  118940. * Gets The camera contrast used on this material.
  118941. */
  118942. get cameraContrast(): float;
  118943. /**
  118944. * Sets The camera contrast used on this material.
  118945. */
  118946. set cameraContrast(value: float);
  118947. /**
  118948. * Gets the Color Grading 2D Lookup Texture.
  118949. */
  118950. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  118951. /**
  118952. * Sets the Color Grading 2D Lookup Texture.
  118953. */
  118954. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  118955. /**
  118956. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  118957. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  118958. * 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;
  118959. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  118960. */
  118961. get cameraColorCurves(): Nullable<ColorCurves>;
  118962. /**
  118963. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  118964. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  118965. * 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;
  118966. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  118967. */
  118968. set cameraColorCurves(value: Nullable<ColorCurves>);
  118969. /**
  118970. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  118971. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  118972. */
  118973. switchToBGR: boolean;
  118974. private _renderTargets;
  118975. private _reflectionControls;
  118976. private _white;
  118977. private _primaryShadowColor;
  118978. private _primaryHighlightColor;
  118979. /**
  118980. * Instantiates a Background Material in the given scene
  118981. * @param name The friendly name of the material
  118982. * @param scene The scene to add the material to
  118983. */
  118984. constructor(name: string, scene: Scene);
  118985. /**
  118986. * Gets a boolean indicating that current material needs to register RTT
  118987. */
  118988. get hasRenderTargetTextures(): boolean;
  118989. /**
  118990. * The entire material has been created in order to prevent overdraw.
  118991. * @returns false
  118992. */
  118993. needAlphaTesting(): boolean;
  118994. /**
  118995. * The entire material has been created in order to prevent overdraw.
  118996. * @returns true if blending is enable
  118997. */
  118998. needAlphaBlending(): boolean;
  118999. /**
  119000. * Checks wether the material is ready to be rendered for a given mesh.
  119001. * @param mesh The mesh to render
  119002. * @param subMesh The submesh to check against
  119003. * @param useInstances Specify wether or not the material is used with instances
  119004. * @returns true if all the dependencies are ready (Textures, Effects...)
  119005. */
  119006. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  119007. /**
  119008. * Compute the primary color according to the chosen perceptual color.
  119009. */
  119010. private _computePrimaryColorFromPerceptualColor;
  119011. /**
  119012. * Compute the highlights and shadow colors according to their chosen levels.
  119013. */
  119014. private _computePrimaryColors;
  119015. /**
  119016. * Build the uniform buffer used in the material.
  119017. */
  119018. buildUniformLayout(): void;
  119019. /**
  119020. * Unbind the material.
  119021. */
  119022. unbind(): void;
  119023. /**
  119024. * Bind only the world matrix to the material.
  119025. * @param world The world matrix to bind.
  119026. */
  119027. bindOnlyWorldMatrix(world: Matrix): void;
  119028. /**
  119029. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  119030. * @param world The world matrix to bind.
  119031. * @param subMesh The submesh to bind for.
  119032. */
  119033. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  119034. /**
  119035. * Checks to see if a texture is used in the material.
  119036. * @param texture - Base texture to use.
  119037. * @returns - Boolean specifying if a texture is used in the material.
  119038. */
  119039. hasTexture(texture: BaseTexture): boolean;
  119040. /**
  119041. * Dispose the material.
  119042. * @param forceDisposeEffect Force disposal of the associated effect.
  119043. * @param forceDisposeTextures Force disposal of the associated textures.
  119044. */
  119045. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  119046. /**
  119047. * Clones the material.
  119048. * @param name The cloned name.
  119049. * @returns The cloned material.
  119050. */
  119051. clone(name: string): BackgroundMaterial;
  119052. /**
  119053. * Serializes the current material to its JSON representation.
  119054. * @returns The JSON representation.
  119055. */
  119056. serialize(): any;
  119057. /**
  119058. * Gets the class name of the material
  119059. * @returns "BackgroundMaterial"
  119060. */
  119061. getClassName(): string;
  119062. /**
  119063. * Parse a JSON input to create back a background material.
  119064. * @param source The JSON data to parse
  119065. * @param scene The scene to create the parsed material in
  119066. * @param rootUrl The root url of the assets the material depends upon
  119067. * @returns the instantiated BackgroundMaterial.
  119068. */
  119069. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  119070. }
  119071. }
  119072. declare module BABYLON {
  119073. /**
  119074. * Represents the different options available during the creation of
  119075. * a Environment helper.
  119076. *
  119077. * This can control the default ground, skybox and image processing setup of your scene.
  119078. */
  119079. export interface IEnvironmentHelperOptions {
  119080. /**
  119081. * Specifies wether or not to create a ground.
  119082. * True by default.
  119083. */
  119084. createGround: boolean;
  119085. /**
  119086. * Specifies the ground size.
  119087. * 15 by default.
  119088. */
  119089. groundSize: number;
  119090. /**
  119091. * The texture used on the ground for the main color.
  119092. * Comes from the BabylonJS CDN by default.
  119093. *
  119094. * Remarks: Can be either a texture or a url.
  119095. */
  119096. groundTexture: string | BaseTexture;
  119097. /**
  119098. * The color mixed in the ground texture by default.
  119099. * BabylonJS clearColor by default.
  119100. */
  119101. groundColor: Color3;
  119102. /**
  119103. * Specifies the ground opacity.
  119104. * 1 by default.
  119105. */
  119106. groundOpacity: number;
  119107. /**
  119108. * Enables the ground to receive shadows.
  119109. * True by default.
  119110. */
  119111. enableGroundShadow: boolean;
  119112. /**
  119113. * Helps preventing the shadow to be fully black on the ground.
  119114. * 0.5 by default.
  119115. */
  119116. groundShadowLevel: number;
  119117. /**
  119118. * Creates a mirror texture attach to the ground.
  119119. * false by default.
  119120. */
  119121. enableGroundMirror: boolean;
  119122. /**
  119123. * Specifies the ground mirror size ratio.
  119124. * 0.3 by default as the default kernel is 64.
  119125. */
  119126. groundMirrorSizeRatio: number;
  119127. /**
  119128. * Specifies the ground mirror blur kernel size.
  119129. * 64 by default.
  119130. */
  119131. groundMirrorBlurKernel: number;
  119132. /**
  119133. * Specifies the ground mirror visibility amount.
  119134. * 1 by default
  119135. */
  119136. groundMirrorAmount: number;
  119137. /**
  119138. * Specifies the ground mirror reflectance weight.
  119139. * This uses the standard weight of the background material to setup the fresnel effect
  119140. * of the mirror.
  119141. * 1 by default.
  119142. */
  119143. groundMirrorFresnelWeight: number;
  119144. /**
  119145. * Specifies the ground mirror Falloff distance.
  119146. * This can helps reducing the size of the reflection.
  119147. * 0 by Default.
  119148. */
  119149. groundMirrorFallOffDistance: number;
  119150. /**
  119151. * Specifies the ground mirror texture type.
  119152. * Unsigned Int by Default.
  119153. */
  119154. groundMirrorTextureType: number;
  119155. /**
  119156. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  119157. * the shown objects.
  119158. */
  119159. groundYBias: number;
  119160. /**
  119161. * Specifies wether or not to create a skybox.
  119162. * True by default.
  119163. */
  119164. createSkybox: boolean;
  119165. /**
  119166. * Specifies the skybox size.
  119167. * 20 by default.
  119168. */
  119169. skyboxSize: number;
  119170. /**
  119171. * The texture used on the skybox for the main color.
  119172. * Comes from the BabylonJS CDN by default.
  119173. *
  119174. * Remarks: Can be either a texture or a url.
  119175. */
  119176. skyboxTexture: string | BaseTexture;
  119177. /**
  119178. * The color mixed in the skybox texture by default.
  119179. * BabylonJS clearColor by default.
  119180. */
  119181. skyboxColor: Color3;
  119182. /**
  119183. * The background rotation around the Y axis of the scene.
  119184. * This helps aligning the key lights of your scene with the background.
  119185. * 0 by default.
  119186. */
  119187. backgroundYRotation: number;
  119188. /**
  119189. * Compute automatically the size of the elements to best fit with the scene.
  119190. */
  119191. sizeAuto: boolean;
  119192. /**
  119193. * Default position of the rootMesh if autoSize is not true.
  119194. */
  119195. rootPosition: Vector3;
  119196. /**
  119197. * Sets up the image processing in the scene.
  119198. * true by default.
  119199. */
  119200. setupImageProcessing: boolean;
  119201. /**
  119202. * The texture used as your environment texture in the scene.
  119203. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  119204. *
  119205. * Remarks: Can be either a texture or a url.
  119206. */
  119207. environmentTexture: string | BaseTexture;
  119208. /**
  119209. * The value of the exposure to apply to the scene.
  119210. * 0.6 by default if setupImageProcessing is true.
  119211. */
  119212. cameraExposure: number;
  119213. /**
  119214. * The value of the contrast to apply to the scene.
  119215. * 1.6 by default if setupImageProcessing is true.
  119216. */
  119217. cameraContrast: number;
  119218. /**
  119219. * Specifies wether or not tonemapping should be enabled in the scene.
  119220. * true by default if setupImageProcessing is true.
  119221. */
  119222. toneMappingEnabled: boolean;
  119223. }
  119224. /**
  119225. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  119226. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  119227. * It also helps with the default setup of your imageProcessing configuration.
  119228. */
  119229. export class EnvironmentHelper {
  119230. /**
  119231. * Default ground texture URL.
  119232. */
  119233. private static _groundTextureCDNUrl;
  119234. /**
  119235. * Default skybox texture URL.
  119236. */
  119237. private static _skyboxTextureCDNUrl;
  119238. /**
  119239. * Default environment texture URL.
  119240. */
  119241. private static _environmentTextureCDNUrl;
  119242. /**
  119243. * Creates the default options for the helper.
  119244. */
  119245. private static _getDefaultOptions;
  119246. private _rootMesh;
  119247. /**
  119248. * Gets the root mesh created by the helper.
  119249. */
  119250. get rootMesh(): Mesh;
  119251. private _skybox;
  119252. /**
  119253. * Gets the skybox created by the helper.
  119254. */
  119255. get skybox(): Nullable<Mesh>;
  119256. private _skyboxTexture;
  119257. /**
  119258. * Gets the skybox texture created by the helper.
  119259. */
  119260. get skyboxTexture(): Nullable<BaseTexture>;
  119261. private _skyboxMaterial;
  119262. /**
  119263. * Gets the skybox material created by the helper.
  119264. */
  119265. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  119266. private _ground;
  119267. /**
  119268. * Gets the ground mesh created by the helper.
  119269. */
  119270. get ground(): Nullable<Mesh>;
  119271. private _groundTexture;
  119272. /**
  119273. * Gets the ground texture created by the helper.
  119274. */
  119275. get groundTexture(): Nullable<BaseTexture>;
  119276. private _groundMirror;
  119277. /**
  119278. * Gets the ground mirror created by the helper.
  119279. */
  119280. get groundMirror(): Nullable<MirrorTexture>;
  119281. /**
  119282. * Gets the ground mirror render list to helps pushing the meshes
  119283. * you wish in the ground reflection.
  119284. */
  119285. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  119286. private _groundMaterial;
  119287. /**
  119288. * Gets the ground material created by the helper.
  119289. */
  119290. get groundMaterial(): Nullable<BackgroundMaterial>;
  119291. /**
  119292. * Stores the creation options.
  119293. */
  119294. private readonly _scene;
  119295. private _options;
  119296. /**
  119297. * This observable will be notified with any error during the creation of the environment,
  119298. * mainly texture creation errors.
  119299. */
  119300. onErrorObservable: Observable<{
  119301. message?: string;
  119302. exception?: any;
  119303. }>;
  119304. /**
  119305. * constructor
  119306. * @param options Defines the options we want to customize the helper
  119307. * @param scene The scene to add the material to
  119308. */
  119309. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  119310. /**
  119311. * Updates the background according to the new options
  119312. * @param options
  119313. */
  119314. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  119315. /**
  119316. * Sets the primary color of all the available elements.
  119317. * @param color the main color to affect to the ground and the background
  119318. */
  119319. setMainColor(color: Color3): void;
  119320. /**
  119321. * Setup the image processing according to the specified options.
  119322. */
  119323. private _setupImageProcessing;
  119324. /**
  119325. * Setup the environment texture according to the specified options.
  119326. */
  119327. private _setupEnvironmentTexture;
  119328. /**
  119329. * Setup the background according to the specified options.
  119330. */
  119331. private _setupBackground;
  119332. /**
  119333. * Get the scene sizes according to the setup.
  119334. */
  119335. private _getSceneSize;
  119336. /**
  119337. * Setup the ground according to the specified options.
  119338. */
  119339. private _setupGround;
  119340. /**
  119341. * Setup the ground material according to the specified options.
  119342. */
  119343. private _setupGroundMaterial;
  119344. /**
  119345. * Setup the ground diffuse texture according to the specified options.
  119346. */
  119347. private _setupGroundDiffuseTexture;
  119348. /**
  119349. * Setup the ground mirror texture according to the specified options.
  119350. */
  119351. private _setupGroundMirrorTexture;
  119352. /**
  119353. * Setup the ground to receive the mirror texture.
  119354. */
  119355. private _setupMirrorInGroundMaterial;
  119356. /**
  119357. * Setup the skybox according to the specified options.
  119358. */
  119359. private _setupSkybox;
  119360. /**
  119361. * Setup the skybox material according to the specified options.
  119362. */
  119363. private _setupSkyboxMaterial;
  119364. /**
  119365. * Setup the skybox reflection texture according to the specified options.
  119366. */
  119367. private _setupSkyboxReflectionTexture;
  119368. private _errorHandler;
  119369. /**
  119370. * Dispose all the elements created by the Helper.
  119371. */
  119372. dispose(): void;
  119373. }
  119374. }
  119375. declare module BABYLON {
  119376. /**
  119377. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  119378. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  119379. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  119380. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  119381. */
  119382. export class PhotoDome extends TransformNode {
  119383. /**
  119384. * Define the image as a Monoscopic panoramic 360 image.
  119385. */
  119386. static readonly MODE_MONOSCOPIC: number;
  119387. /**
  119388. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  119389. */
  119390. static readonly MODE_TOPBOTTOM: number;
  119391. /**
  119392. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  119393. */
  119394. static readonly MODE_SIDEBYSIDE: number;
  119395. private _useDirectMapping;
  119396. /**
  119397. * The texture being displayed on the sphere
  119398. */
  119399. protected _photoTexture: Texture;
  119400. /**
  119401. * Gets or sets the texture being displayed on the sphere
  119402. */
  119403. get photoTexture(): Texture;
  119404. set photoTexture(value: Texture);
  119405. /**
  119406. * Observable raised when an error occured while loading the 360 image
  119407. */
  119408. onLoadErrorObservable: Observable<string>;
  119409. /**
  119410. * The skybox material
  119411. */
  119412. protected _material: BackgroundMaterial;
  119413. /**
  119414. * The surface used for the skybox
  119415. */
  119416. protected _mesh: Mesh;
  119417. /**
  119418. * Gets the mesh used for the skybox.
  119419. */
  119420. get mesh(): Mesh;
  119421. /**
  119422. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  119423. * Also see the options.resolution property.
  119424. */
  119425. get fovMultiplier(): number;
  119426. set fovMultiplier(value: number);
  119427. private _imageMode;
  119428. /**
  119429. * Gets or set the current video mode for the video. It can be:
  119430. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  119431. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  119432. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  119433. */
  119434. get imageMode(): number;
  119435. set imageMode(value: number);
  119436. /**
  119437. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  119438. * @param name Element's name, child elements will append suffixes for their own names.
  119439. * @param urlsOfPhoto defines the url of the photo to display
  119440. * @param options defines an object containing optional or exposed sub element properties
  119441. * @param onError defines a callback called when an error occured while loading the texture
  119442. */
  119443. constructor(name: string, urlOfPhoto: string, options: {
  119444. resolution?: number;
  119445. size?: number;
  119446. useDirectMapping?: boolean;
  119447. faceForward?: boolean;
  119448. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  119449. private _onBeforeCameraRenderObserver;
  119450. private _changeImageMode;
  119451. /**
  119452. * Releases resources associated with this node.
  119453. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  119454. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  119455. */
  119456. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  119457. }
  119458. }
  119459. declare module BABYLON {
  119460. /**
  119461. * Class used to host RGBD texture specific utilities
  119462. */
  119463. export class RGBDTextureTools {
  119464. /**
  119465. * Expand the RGBD Texture from RGBD to Half Float if possible.
  119466. * @param texture the texture to expand.
  119467. */
  119468. static ExpandRGBDTexture(texture: Texture): void;
  119469. }
  119470. }
  119471. declare module BABYLON {
  119472. /**
  119473. * Class used to host texture specific utilities
  119474. */
  119475. export class BRDFTextureTools {
  119476. /**
  119477. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  119478. * @param scene defines the hosting scene
  119479. * @returns the environment BRDF texture
  119480. */
  119481. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  119482. private static _environmentBRDFBase64Texture;
  119483. }
  119484. }
  119485. declare module BABYLON {
  119486. /**
  119487. * @hidden
  119488. */
  119489. export interface IMaterialClearCoatDefines {
  119490. CLEARCOAT: boolean;
  119491. CLEARCOAT_DEFAULTIOR: boolean;
  119492. CLEARCOAT_TEXTURE: boolean;
  119493. CLEARCOAT_TEXTUREDIRECTUV: number;
  119494. CLEARCOAT_BUMP: boolean;
  119495. CLEARCOAT_BUMPDIRECTUV: number;
  119496. CLEARCOAT_TINT: boolean;
  119497. CLEARCOAT_TINT_TEXTURE: boolean;
  119498. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  119499. /** @hidden */
  119500. _areTexturesDirty: boolean;
  119501. }
  119502. /**
  119503. * Define the code related to the clear coat parameters of the pbr material.
  119504. */
  119505. export class PBRClearCoatConfiguration {
  119506. /**
  119507. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  119508. * The default fits with a polyurethane material.
  119509. */
  119510. private static readonly _DefaultIndexOfRefraction;
  119511. private _isEnabled;
  119512. /**
  119513. * Defines if the clear coat is enabled in the material.
  119514. */
  119515. isEnabled: boolean;
  119516. /**
  119517. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  119518. */
  119519. intensity: number;
  119520. /**
  119521. * Defines the clear coat layer roughness.
  119522. */
  119523. roughness: number;
  119524. private _indexOfRefraction;
  119525. /**
  119526. * Defines the index of refraction of the clear coat.
  119527. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  119528. * The default fits with a polyurethane material.
  119529. * Changing the default value is more performance intensive.
  119530. */
  119531. indexOfRefraction: number;
  119532. private _texture;
  119533. /**
  119534. * Stores the clear coat values in a texture.
  119535. */
  119536. texture: Nullable<BaseTexture>;
  119537. private _bumpTexture;
  119538. /**
  119539. * Define the clear coat specific bump texture.
  119540. */
  119541. bumpTexture: Nullable<BaseTexture>;
  119542. private _isTintEnabled;
  119543. /**
  119544. * Defines if the clear coat tint is enabled in the material.
  119545. */
  119546. isTintEnabled: boolean;
  119547. /**
  119548. * Defines the clear coat tint of the material.
  119549. * This is only use if tint is enabled
  119550. */
  119551. tintColor: Color3;
  119552. /**
  119553. * Defines the distance at which the tint color should be found in the
  119554. * clear coat media.
  119555. * This is only use if tint is enabled
  119556. */
  119557. tintColorAtDistance: number;
  119558. /**
  119559. * Defines the clear coat layer thickness.
  119560. * This is only use if tint is enabled
  119561. */
  119562. tintThickness: number;
  119563. private _tintTexture;
  119564. /**
  119565. * Stores the clear tint values in a texture.
  119566. * rgb is tint
  119567. * a is a thickness factor
  119568. */
  119569. tintTexture: Nullable<BaseTexture>;
  119570. /** @hidden */
  119571. private _internalMarkAllSubMeshesAsTexturesDirty;
  119572. /** @hidden */
  119573. _markAllSubMeshesAsTexturesDirty(): void;
  119574. /**
  119575. * Instantiate a new istance of clear coat configuration.
  119576. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  119577. */
  119578. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  119579. /**
  119580. * Gets wehter the submesh is ready to be used or not.
  119581. * @param defines the list of "defines" to update.
  119582. * @param scene defines the scene the material belongs to.
  119583. * @param engine defines the engine the material belongs to.
  119584. * @param disableBumpMap defines wether the material disables bump or not.
  119585. * @returns - boolean indicating that the submesh is ready or not.
  119586. */
  119587. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  119588. /**
  119589. * Checks to see if a texture is used in the material.
  119590. * @param defines the list of "defines" to update.
  119591. * @param scene defines the scene to the material belongs to.
  119592. */
  119593. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  119594. /**
  119595. * Binds the material data.
  119596. * @param uniformBuffer defines the Uniform buffer to fill in.
  119597. * @param scene defines the scene the material belongs to.
  119598. * @param engine defines the engine the material belongs to.
  119599. * @param disableBumpMap defines wether the material disables bump or not.
  119600. * @param isFrozen defines wether the material is frozen or not.
  119601. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  119602. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  119603. */
  119604. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  119605. /**
  119606. * Checks to see if a texture is used in the material.
  119607. * @param texture - Base texture to use.
  119608. * @returns - Boolean specifying if a texture is used in the material.
  119609. */
  119610. hasTexture(texture: BaseTexture): boolean;
  119611. /**
  119612. * Returns an array of the actively used textures.
  119613. * @param activeTextures Array of BaseTextures
  119614. */
  119615. getActiveTextures(activeTextures: BaseTexture[]): void;
  119616. /**
  119617. * Returns the animatable textures.
  119618. * @param animatables Array of animatable textures.
  119619. */
  119620. getAnimatables(animatables: IAnimatable[]): void;
  119621. /**
  119622. * Disposes the resources of the material.
  119623. * @param forceDisposeTextures - Forces the disposal of all textures.
  119624. */
  119625. dispose(forceDisposeTextures?: boolean): void;
  119626. /**
  119627. * Get the current class name of the texture useful for serialization or dynamic coding.
  119628. * @returns "PBRClearCoatConfiguration"
  119629. */
  119630. getClassName(): string;
  119631. /**
  119632. * Add fallbacks to the effect fallbacks list.
  119633. * @param defines defines the Base texture to use.
  119634. * @param fallbacks defines the current fallback list.
  119635. * @param currentRank defines the current fallback rank.
  119636. * @returns the new fallback rank.
  119637. */
  119638. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  119639. /**
  119640. * Add the required uniforms to the current list.
  119641. * @param uniforms defines the current uniform list.
  119642. */
  119643. static AddUniforms(uniforms: string[]): void;
  119644. /**
  119645. * Add the required samplers to the current list.
  119646. * @param samplers defines the current sampler list.
  119647. */
  119648. static AddSamplers(samplers: string[]): void;
  119649. /**
  119650. * Add the required uniforms to the current buffer.
  119651. * @param uniformBuffer defines the current uniform buffer.
  119652. */
  119653. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  119654. /**
  119655. * Makes a duplicate of the current configuration into another one.
  119656. * @param clearCoatConfiguration define the config where to copy the info
  119657. */
  119658. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  119659. /**
  119660. * Serializes this clear coat configuration.
  119661. * @returns - An object with the serialized config.
  119662. */
  119663. serialize(): any;
  119664. /**
  119665. * Parses a anisotropy Configuration from a serialized object.
  119666. * @param source - Serialized object.
  119667. * @param scene Defines the scene we are parsing for
  119668. * @param rootUrl Defines the rootUrl to load from
  119669. */
  119670. parse(source: any, scene: Scene, rootUrl: string): void;
  119671. }
  119672. }
  119673. declare module BABYLON {
  119674. /**
  119675. * @hidden
  119676. */
  119677. export interface IMaterialAnisotropicDefines {
  119678. ANISOTROPIC: boolean;
  119679. ANISOTROPIC_TEXTURE: boolean;
  119680. ANISOTROPIC_TEXTUREDIRECTUV: number;
  119681. MAINUV1: boolean;
  119682. _areTexturesDirty: boolean;
  119683. _needUVs: boolean;
  119684. }
  119685. /**
  119686. * Define the code related to the anisotropic parameters of the pbr material.
  119687. */
  119688. export class PBRAnisotropicConfiguration {
  119689. private _isEnabled;
  119690. /**
  119691. * Defines if the anisotropy is enabled in the material.
  119692. */
  119693. isEnabled: boolean;
  119694. /**
  119695. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  119696. */
  119697. intensity: number;
  119698. /**
  119699. * Defines if the effect is along the tangents, bitangents or in between.
  119700. * By default, the effect is "strectching" the highlights along the tangents.
  119701. */
  119702. direction: Vector2;
  119703. private _texture;
  119704. /**
  119705. * Stores the anisotropy values in a texture.
  119706. * rg is direction (like normal from -1 to 1)
  119707. * b is a intensity
  119708. */
  119709. texture: Nullable<BaseTexture>;
  119710. /** @hidden */
  119711. private _internalMarkAllSubMeshesAsTexturesDirty;
  119712. /** @hidden */
  119713. _markAllSubMeshesAsTexturesDirty(): void;
  119714. /**
  119715. * Instantiate a new istance of anisotropy configuration.
  119716. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  119717. */
  119718. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  119719. /**
  119720. * Specifies that the submesh is ready to be used.
  119721. * @param defines the list of "defines" to update.
  119722. * @param scene defines the scene the material belongs to.
  119723. * @returns - boolean indicating that the submesh is ready or not.
  119724. */
  119725. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  119726. /**
  119727. * Checks to see if a texture is used in the material.
  119728. * @param defines the list of "defines" to update.
  119729. * @param mesh the mesh we are preparing the defines for.
  119730. * @param scene defines the scene the material belongs to.
  119731. */
  119732. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  119733. /**
  119734. * Binds the material data.
  119735. * @param uniformBuffer defines the Uniform buffer to fill in.
  119736. * @param scene defines the scene the material belongs to.
  119737. * @param isFrozen defines wether the material is frozen or not.
  119738. */
  119739. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  119740. /**
  119741. * Checks to see if a texture is used in the material.
  119742. * @param texture - Base texture to use.
  119743. * @returns - Boolean specifying if a texture is used in the material.
  119744. */
  119745. hasTexture(texture: BaseTexture): boolean;
  119746. /**
  119747. * Returns an array of the actively used textures.
  119748. * @param activeTextures Array of BaseTextures
  119749. */
  119750. getActiveTextures(activeTextures: BaseTexture[]): void;
  119751. /**
  119752. * Returns the animatable textures.
  119753. * @param animatables Array of animatable textures.
  119754. */
  119755. getAnimatables(animatables: IAnimatable[]): void;
  119756. /**
  119757. * Disposes the resources of the material.
  119758. * @param forceDisposeTextures - Forces the disposal of all textures.
  119759. */
  119760. dispose(forceDisposeTextures?: boolean): void;
  119761. /**
  119762. * Get the current class name of the texture useful for serialization or dynamic coding.
  119763. * @returns "PBRAnisotropicConfiguration"
  119764. */
  119765. getClassName(): string;
  119766. /**
  119767. * Add fallbacks to the effect fallbacks list.
  119768. * @param defines defines the Base texture to use.
  119769. * @param fallbacks defines the current fallback list.
  119770. * @param currentRank defines the current fallback rank.
  119771. * @returns the new fallback rank.
  119772. */
  119773. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  119774. /**
  119775. * Add the required uniforms to the current list.
  119776. * @param uniforms defines the current uniform list.
  119777. */
  119778. static AddUniforms(uniforms: string[]): void;
  119779. /**
  119780. * Add the required uniforms to the current buffer.
  119781. * @param uniformBuffer defines the current uniform buffer.
  119782. */
  119783. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  119784. /**
  119785. * Add the required samplers to the current list.
  119786. * @param samplers defines the current sampler list.
  119787. */
  119788. static AddSamplers(samplers: string[]): void;
  119789. /**
  119790. * Makes a duplicate of the current configuration into another one.
  119791. * @param anisotropicConfiguration define the config where to copy the info
  119792. */
  119793. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  119794. /**
  119795. * Serializes this anisotropy configuration.
  119796. * @returns - An object with the serialized config.
  119797. */
  119798. serialize(): any;
  119799. /**
  119800. * Parses a anisotropy Configuration from a serialized object.
  119801. * @param source - Serialized object.
  119802. * @param scene Defines the scene we are parsing for
  119803. * @param rootUrl Defines the rootUrl to load from
  119804. */
  119805. parse(source: any, scene: Scene, rootUrl: string): void;
  119806. }
  119807. }
  119808. declare module BABYLON {
  119809. /**
  119810. * @hidden
  119811. */
  119812. export interface IMaterialBRDFDefines {
  119813. BRDF_V_HEIGHT_CORRELATED: boolean;
  119814. MS_BRDF_ENERGY_CONSERVATION: boolean;
  119815. SPHERICAL_HARMONICS: boolean;
  119816. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  119817. /** @hidden */
  119818. _areMiscDirty: boolean;
  119819. }
  119820. /**
  119821. * Define the code related to the BRDF parameters of the pbr material.
  119822. */
  119823. export class PBRBRDFConfiguration {
  119824. /**
  119825. * Default value used for the energy conservation.
  119826. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  119827. */
  119828. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  119829. /**
  119830. * Default value used for the Smith Visibility Height Correlated mode.
  119831. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  119832. */
  119833. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  119834. /**
  119835. * Default value used for the IBL diffuse part.
  119836. * This can help switching back to the polynomials mode globally which is a tiny bit
  119837. * less GPU intensive at the drawback of a lower quality.
  119838. */
  119839. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  119840. /**
  119841. * Default value used for activating energy conservation for the specular workflow.
  119842. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  119843. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  119844. */
  119845. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  119846. private _useEnergyConservation;
  119847. /**
  119848. * Defines if the material uses energy conservation.
  119849. */
  119850. useEnergyConservation: boolean;
  119851. private _useSmithVisibilityHeightCorrelated;
  119852. /**
  119853. * LEGACY Mode set to false
  119854. * Defines if the material uses height smith correlated visibility term.
  119855. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  119856. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  119857. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  119858. * Not relying on height correlated will also disable energy conservation.
  119859. */
  119860. useSmithVisibilityHeightCorrelated: boolean;
  119861. private _useSphericalHarmonics;
  119862. /**
  119863. * LEGACY Mode set to false
  119864. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  119865. * diffuse part of the IBL.
  119866. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  119867. * to the ground truth.
  119868. */
  119869. useSphericalHarmonics: boolean;
  119870. private _useSpecularGlossinessInputEnergyConservation;
  119871. /**
  119872. * Defines if the material uses energy conservation, when the specular workflow is active.
  119873. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  119874. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  119875. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  119876. */
  119877. useSpecularGlossinessInputEnergyConservation: boolean;
  119878. /** @hidden */
  119879. private _internalMarkAllSubMeshesAsMiscDirty;
  119880. /** @hidden */
  119881. _markAllSubMeshesAsMiscDirty(): void;
  119882. /**
  119883. * Instantiate a new istance of clear coat configuration.
  119884. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  119885. */
  119886. constructor(markAllSubMeshesAsMiscDirty: () => void);
  119887. /**
  119888. * Checks to see if a texture is used in the material.
  119889. * @param defines the list of "defines" to update.
  119890. */
  119891. prepareDefines(defines: IMaterialBRDFDefines): void;
  119892. /**
  119893. * Get the current class name of the texture useful for serialization or dynamic coding.
  119894. * @returns "PBRClearCoatConfiguration"
  119895. */
  119896. getClassName(): string;
  119897. /**
  119898. * Makes a duplicate of the current configuration into another one.
  119899. * @param brdfConfiguration define the config where to copy the info
  119900. */
  119901. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  119902. /**
  119903. * Serializes this BRDF configuration.
  119904. * @returns - An object with the serialized config.
  119905. */
  119906. serialize(): any;
  119907. /**
  119908. * Parses a anisotropy Configuration from a serialized object.
  119909. * @param source - Serialized object.
  119910. * @param scene Defines the scene we are parsing for
  119911. * @param rootUrl Defines the rootUrl to load from
  119912. */
  119913. parse(source: any, scene: Scene, rootUrl: string): void;
  119914. }
  119915. }
  119916. declare module BABYLON {
  119917. /**
  119918. * @hidden
  119919. */
  119920. export interface IMaterialSheenDefines {
  119921. SHEEN: boolean;
  119922. SHEEN_TEXTURE: boolean;
  119923. SHEEN_TEXTUREDIRECTUV: number;
  119924. SHEEN_LINKWITHALBEDO: boolean;
  119925. /** @hidden */
  119926. _areTexturesDirty: boolean;
  119927. }
  119928. /**
  119929. * Define the code related to the Sheen parameters of the pbr material.
  119930. */
  119931. export class PBRSheenConfiguration {
  119932. private _isEnabled;
  119933. /**
  119934. * Defines if the material uses sheen.
  119935. */
  119936. isEnabled: boolean;
  119937. private _linkSheenWithAlbedo;
  119938. /**
  119939. * Defines if the sheen is linked to the sheen color.
  119940. */
  119941. linkSheenWithAlbedo: boolean;
  119942. /**
  119943. * Defines the sheen intensity.
  119944. */
  119945. intensity: number;
  119946. /**
  119947. * Defines the sheen color.
  119948. */
  119949. color: Color3;
  119950. private _texture;
  119951. /**
  119952. * Stores the sheen tint values in a texture.
  119953. * rgb is tint
  119954. * a is a intensity
  119955. */
  119956. texture: Nullable<BaseTexture>;
  119957. /** @hidden */
  119958. private _internalMarkAllSubMeshesAsTexturesDirty;
  119959. /** @hidden */
  119960. _markAllSubMeshesAsTexturesDirty(): void;
  119961. /**
  119962. * Instantiate a new istance of clear coat configuration.
  119963. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  119964. */
  119965. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  119966. /**
  119967. * Specifies that the submesh is ready to be used.
  119968. * @param defines the list of "defines" to update.
  119969. * @param scene defines the scene the material belongs to.
  119970. * @returns - boolean indicating that the submesh is ready or not.
  119971. */
  119972. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  119973. /**
  119974. * Checks to see if a texture is used in the material.
  119975. * @param defines the list of "defines" to update.
  119976. * @param scene defines the scene the material belongs to.
  119977. */
  119978. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  119979. /**
  119980. * Binds the material data.
  119981. * @param uniformBuffer defines the Uniform buffer to fill in.
  119982. * @param scene defines the scene the material belongs to.
  119983. * @param isFrozen defines wether the material is frozen or not.
  119984. */
  119985. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  119986. /**
  119987. * Checks to see if a texture is used in the material.
  119988. * @param texture - Base texture to use.
  119989. * @returns - Boolean specifying if a texture is used in the material.
  119990. */
  119991. hasTexture(texture: BaseTexture): boolean;
  119992. /**
  119993. * Returns an array of the actively used textures.
  119994. * @param activeTextures Array of BaseTextures
  119995. */
  119996. getActiveTextures(activeTextures: BaseTexture[]): void;
  119997. /**
  119998. * Returns the animatable textures.
  119999. * @param animatables Array of animatable textures.
  120000. */
  120001. getAnimatables(animatables: IAnimatable[]): void;
  120002. /**
  120003. * Disposes the resources of the material.
  120004. * @param forceDisposeTextures - Forces the disposal of all textures.
  120005. */
  120006. dispose(forceDisposeTextures?: boolean): void;
  120007. /**
  120008. * Get the current class name of the texture useful for serialization or dynamic coding.
  120009. * @returns "PBRSheenConfiguration"
  120010. */
  120011. getClassName(): string;
  120012. /**
  120013. * Add fallbacks to the effect fallbacks list.
  120014. * @param defines defines the Base texture to use.
  120015. * @param fallbacks defines the current fallback list.
  120016. * @param currentRank defines the current fallback rank.
  120017. * @returns the new fallback rank.
  120018. */
  120019. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  120020. /**
  120021. * Add the required uniforms to the current list.
  120022. * @param uniforms defines the current uniform list.
  120023. */
  120024. static AddUniforms(uniforms: string[]): void;
  120025. /**
  120026. * Add the required uniforms to the current buffer.
  120027. * @param uniformBuffer defines the current uniform buffer.
  120028. */
  120029. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  120030. /**
  120031. * Add the required samplers to the current list.
  120032. * @param samplers defines the current sampler list.
  120033. */
  120034. static AddSamplers(samplers: string[]): void;
  120035. /**
  120036. * Makes a duplicate of the current configuration into another one.
  120037. * @param sheenConfiguration define the config where to copy the info
  120038. */
  120039. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  120040. /**
  120041. * Serializes this BRDF configuration.
  120042. * @returns - An object with the serialized config.
  120043. */
  120044. serialize(): any;
  120045. /**
  120046. * Parses a anisotropy Configuration from a serialized object.
  120047. * @param source - Serialized object.
  120048. * @param scene Defines the scene we are parsing for
  120049. * @param rootUrl Defines the rootUrl to load from
  120050. */
  120051. parse(source: any, scene: Scene, rootUrl: string): void;
  120052. }
  120053. }
  120054. declare module BABYLON {
  120055. /**
  120056. * @hidden
  120057. */
  120058. export interface IMaterialSubSurfaceDefines {
  120059. SUBSURFACE: boolean;
  120060. SS_REFRACTION: boolean;
  120061. SS_TRANSLUCENCY: boolean;
  120062. SS_SCATERRING: boolean;
  120063. SS_THICKNESSANDMASK_TEXTURE: boolean;
  120064. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  120065. SS_REFRACTIONMAP_3D: boolean;
  120066. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  120067. SS_LODINREFRACTIONALPHA: boolean;
  120068. SS_GAMMAREFRACTION: boolean;
  120069. SS_RGBDREFRACTION: boolean;
  120070. SS_LINEARSPECULARREFRACTION: boolean;
  120071. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  120072. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  120073. /** @hidden */
  120074. _areTexturesDirty: boolean;
  120075. }
  120076. /**
  120077. * Define the code related to the sub surface parameters of the pbr material.
  120078. */
  120079. export class PBRSubSurfaceConfiguration {
  120080. private _isRefractionEnabled;
  120081. /**
  120082. * Defines if the refraction is enabled in the material.
  120083. */
  120084. isRefractionEnabled: boolean;
  120085. private _isTranslucencyEnabled;
  120086. /**
  120087. * Defines if the translucency is enabled in the material.
  120088. */
  120089. isTranslucencyEnabled: boolean;
  120090. private _isScatteringEnabled;
  120091. /**
  120092. * Defines the refraction intensity of the material.
  120093. * The refraction when enabled replaces the Diffuse part of the material.
  120094. * The intensity helps transitionning between diffuse and refraction.
  120095. */
  120096. refractionIntensity: number;
  120097. /**
  120098. * Defines the translucency intensity of the material.
  120099. * When translucency has been enabled, this defines how much of the "translucency"
  120100. * is addded to the diffuse part of the material.
  120101. */
  120102. translucencyIntensity: number;
  120103. /**
  120104. * Defines the scattering intensity of the material.
  120105. * When scattering has been enabled, this defines how much of the "scattered light"
  120106. * is addded to the diffuse part of the material.
  120107. */
  120108. scatteringIntensity: number;
  120109. private _thicknessTexture;
  120110. /**
  120111. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  120112. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  120113. * 0 would mean minimumThickness
  120114. * 1 would mean maximumThickness
  120115. * The other channels might be use as a mask to vary the different effects intensity.
  120116. */
  120117. thicknessTexture: Nullable<BaseTexture>;
  120118. private _refractionTexture;
  120119. /**
  120120. * Defines the texture to use for refraction.
  120121. */
  120122. refractionTexture: Nullable<BaseTexture>;
  120123. private _indexOfRefraction;
  120124. /**
  120125. * Defines the index of refraction used in the material.
  120126. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  120127. */
  120128. indexOfRefraction: number;
  120129. private _invertRefractionY;
  120130. /**
  120131. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  120132. */
  120133. invertRefractionY: boolean;
  120134. private _linkRefractionWithTransparency;
  120135. /**
  120136. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  120137. * Materials half opaque for instance using refraction could benefit from this control.
  120138. */
  120139. linkRefractionWithTransparency: boolean;
  120140. /**
  120141. * Defines the minimum thickness stored in the thickness map.
  120142. * If no thickness map is defined, this value will be used to simulate thickness.
  120143. */
  120144. minimumThickness: number;
  120145. /**
  120146. * Defines the maximum thickness stored in the thickness map.
  120147. */
  120148. maximumThickness: number;
  120149. /**
  120150. * Defines the volume tint of the material.
  120151. * This is used for both translucency and scattering.
  120152. */
  120153. tintColor: Color3;
  120154. /**
  120155. * Defines the distance at which the tint color should be found in the media.
  120156. * This is used for refraction only.
  120157. */
  120158. tintColorAtDistance: number;
  120159. /**
  120160. * Defines how far each channel transmit through the media.
  120161. * It is defined as a color to simplify it selection.
  120162. */
  120163. diffusionDistance: Color3;
  120164. private _useMaskFromThicknessTexture;
  120165. /**
  120166. * Stores the intensity of the different subsurface effects in the thickness texture.
  120167. * * the green channel is the translucency intensity.
  120168. * * the blue channel is the scattering intensity.
  120169. * * the alpha channel is the refraction intensity.
  120170. */
  120171. useMaskFromThicknessTexture: boolean;
  120172. /** @hidden */
  120173. private _internalMarkAllSubMeshesAsTexturesDirty;
  120174. /** @hidden */
  120175. _markAllSubMeshesAsTexturesDirty(): void;
  120176. /**
  120177. * Instantiate a new istance of sub surface configuration.
  120178. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  120179. */
  120180. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  120181. /**
  120182. * Gets wehter the submesh is ready to be used or not.
  120183. * @param defines the list of "defines" to update.
  120184. * @param scene defines the scene the material belongs to.
  120185. * @returns - boolean indicating that the submesh is ready or not.
  120186. */
  120187. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  120188. /**
  120189. * Checks to see if a texture is used in the material.
  120190. * @param defines the list of "defines" to update.
  120191. * @param scene defines the scene to the material belongs to.
  120192. */
  120193. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  120194. /**
  120195. * Binds the material data.
  120196. * @param uniformBuffer defines the Uniform buffer to fill in.
  120197. * @param scene defines the scene the material belongs to.
  120198. * @param engine defines the engine the material belongs to.
  120199. * @param isFrozen defines wether the material is frozen or not.
  120200. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  120201. */
  120202. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  120203. /**
  120204. * Unbinds the material from the mesh.
  120205. * @param activeEffect defines the effect that should be unbound from.
  120206. * @returns true if unbound, otherwise false
  120207. */
  120208. unbind(activeEffect: Effect): boolean;
  120209. /**
  120210. * Returns the texture used for refraction or null if none is used.
  120211. * @param scene defines the scene the material belongs to.
  120212. * @returns - Refraction texture if present. If no refraction texture and refraction
  120213. * is linked with transparency, returns environment texture. Otherwise, returns null.
  120214. */
  120215. private _getRefractionTexture;
  120216. /**
  120217. * Returns true if alpha blending should be disabled.
  120218. */
  120219. get disableAlphaBlending(): boolean;
  120220. /**
  120221. * Fills the list of render target textures.
  120222. * @param renderTargets the list of render targets to update
  120223. */
  120224. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  120225. /**
  120226. * Checks to see if a texture is used in the material.
  120227. * @param texture - Base texture to use.
  120228. * @returns - Boolean specifying if a texture is used in the material.
  120229. */
  120230. hasTexture(texture: BaseTexture): boolean;
  120231. /**
  120232. * Gets a boolean indicating that current material needs to register RTT
  120233. * @returns true if this uses a render target otherwise false.
  120234. */
  120235. hasRenderTargetTextures(): boolean;
  120236. /**
  120237. * Returns an array of the actively used textures.
  120238. * @param activeTextures Array of BaseTextures
  120239. */
  120240. getActiveTextures(activeTextures: BaseTexture[]): void;
  120241. /**
  120242. * Returns the animatable textures.
  120243. * @param animatables Array of animatable textures.
  120244. */
  120245. getAnimatables(animatables: IAnimatable[]): void;
  120246. /**
  120247. * Disposes the resources of the material.
  120248. * @param forceDisposeTextures - Forces the disposal of all textures.
  120249. */
  120250. dispose(forceDisposeTextures?: boolean): void;
  120251. /**
  120252. * Get the current class name of the texture useful for serialization or dynamic coding.
  120253. * @returns "PBRSubSurfaceConfiguration"
  120254. */
  120255. getClassName(): string;
  120256. /**
  120257. * Add fallbacks to the effect fallbacks list.
  120258. * @param defines defines the Base texture to use.
  120259. * @param fallbacks defines the current fallback list.
  120260. * @param currentRank defines the current fallback rank.
  120261. * @returns the new fallback rank.
  120262. */
  120263. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  120264. /**
  120265. * Add the required uniforms to the current list.
  120266. * @param uniforms defines the current uniform list.
  120267. */
  120268. static AddUniforms(uniforms: string[]): void;
  120269. /**
  120270. * Add the required samplers to the current list.
  120271. * @param samplers defines the current sampler list.
  120272. */
  120273. static AddSamplers(samplers: string[]): void;
  120274. /**
  120275. * Add the required uniforms to the current buffer.
  120276. * @param uniformBuffer defines the current uniform buffer.
  120277. */
  120278. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  120279. /**
  120280. * Makes a duplicate of the current configuration into another one.
  120281. * @param configuration define the config where to copy the info
  120282. */
  120283. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  120284. /**
  120285. * Serializes this Sub Surface configuration.
  120286. * @returns - An object with the serialized config.
  120287. */
  120288. serialize(): any;
  120289. /**
  120290. * Parses a anisotropy Configuration from a serialized object.
  120291. * @param source - Serialized object.
  120292. * @param scene Defines the scene we are parsing for
  120293. * @param rootUrl Defines the rootUrl to load from
  120294. */
  120295. parse(source: any, scene: Scene, rootUrl: string): void;
  120296. }
  120297. }
  120298. declare module BABYLON {
  120299. /** @hidden */
  120300. export var pbrFragmentDeclaration: {
  120301. name: string;
  120302. shader: string;
  120303. };
  120304. }
  120305. declare module BABYLON {
  120306. /** @hidden */
  120307. export var pbrUboDeclaration: {
  120308. name: string;
  120309. shader: string;
  120310. };
  120311. }
  120312. declare module BABYLON {
  120313. /** @hidden */
  120314. export var pbrFragmentExtraDeclaration: {
  120315. name: string;
  120316. shader: string;
  120317. };
  120318. }
  120319. declare module BABYLON {
  120320. /** @hidden */
  120321. export var pbrFragmentSamplersDeclaration: {
  120322. name: string;
  120323. shader: string;
  120324. };
  120325. }
  120326. declare module BABYLON {
  120327. /** @hidden */
  120328. export var pbrHelperFunctions: {
  120329. name: string;
  120330. shader: string;
  120331. };
  120332. }
  120333. declare module BABYLON {
  120334. /** @hidden */
  120335. export var harmonicsFunctions: {
  120336. name: string;
  120337. shader: string;
  120338. };
  120339. }
  120340. declare module BABYLON {
  120341. /** @hidden */
  120342. export var pbrDirectLightingSetupFunctions: {
  120343. name: string;
  120344. shader: string;
  120345. };
  120346. }
  120347. declare module BABYLON {
  120348. /** @hidden */
  120349. export var pbrDirectLightingFalloffFunctions: {
  120350. name: string;
  120351. shader: string;
  120352. };
  120353. }
  120354. declare module BABYLON {
  120355. /** @hidden */
  120356. export var pbrBRDFFunctions: {
  120357. name: string;
  120358. shader: string;
  120359. };
  120360. }
  120361. declare module BABYLON {
  120362. /** @hidden */
  120363. export var pbrDirectLightingFunctions: {
  120364. name: string;
  120365. shader: string;
  120366. };
  120367. }
  120368. declare module BABYLON {
  120369. /** @hidden */
  120370. export var pbrIBLFunctions: {
  120371. name: string;
  120372. shader: string;
  120373. };
  120374. }
  120375. declare module BABYLON {
  120376. /** @hidden */
  120377. export var pbrDebug: {
  120378. name: string;
  120379. shader: string;
  120380. };
  120381. }
  120382. declare module BABYLON {
  120383. /** @hidden */
  120384. export var pbrPixelShader: {
  120385. name: string;
  120386. shader: string;
  120387. };
  120388. }
  120389. declare module BABYLON {
  120390. /** @hidden */
  120391. export var pbrVertexDeclaration: {
  120392. name: string;
  120393. shader: string;
  120394. };
  120395. }
  120396. declare module BABYLON {
  120397. /** @hidden */
  120398. export var pbrVertexShader: {
  120399. name: string;
  120400. shader: string;
  120401. };
  120402. }
  120403. declare module BABYLON {
  120404. /**
  120405. * Manages the defines for the PBR Material.
  120406. * @hidden
  120407. */
  120408. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  120409. PBR: boolean;
  120410. MAINUV1: boolean;
  120411. MAINUV2: boolean;
  120412. UV1: boolean;
  120413. UV2: boolean;
  120414. ALBEDO: boolean;
  120415. ALBEDODIRECTUV: number;
  120416. VERTEXCOLOR: boolean;
  120417. AMBIENT: boolean;
  120418. AMBIENTDIRECTUV: number;
  120419. AMBIENTINGRAYSCALE: boolean;
  120420. OPACITY: boolean;
  120421. VERTEXALPHA: boolean;
  120422. OPACITYDIRECTUV: number;
  120423. OPACITYRGB: boolean;
  120424. ALPHATEST: boolean;
  120425. DEPTHPREPASS: boolean;
  120426. ALPHABLEND: boolean;
  120427. ALPHAFROMALBEDO: boolean;
  120428. ALPHATESTVALUE: string;
  120429. SPECULAROVERALPHA: boolean;
  120430. RADIANCEOVERALPHA: boolean;
  120431. ALPHAFRESNEL: boolean;
  120432. LINEARALPHAFRESNEL: boolean;
  120433. PREMULTIPLYALPHA: boolean;
  120434. EMISSIVE: boolean;
  120435. EMISSIVEDIRECTUV: number;
  120436. REFLECTIVITY: boolean;
  120437. REFLECTIVITYDIRECTUV: number;
  120438. SPECULARTERM: boolean;
  120439. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  120440. MICROSURFACEAUTOMATIC: boolean;
  120441. LODBASEDMICROSFURACE: boolean;
  120442. MICROSURFACEMAP: boolean;
  120443. MICROSURFACEMAPDIRECTUV: number;
  120444. METALLICWORKFLOW: boolean;
  120445. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  120446. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  120447. METALLNESSSTOREINMETALMAPBLUE: boolean;
  120448. AOSTOREINMETALMAPRED: boolean;
  120449. METALLICF0FACTORFROMMETALLICMAP: boolean;
  120450. ENVIRONMENTBRDF: boolean;
  120451. ENVIRONMENTBRDF_RGBD: boolean;
  120452. NORMAL: boolean;
  120453. TANGENT: boolean;
  120454. BUMP: boolean;
  120455. BUMPDIRECTUV: number;
  120456. OBJECTSPACE_NORMALMAP: boolean;
  120457. PARALLAX: boolean;
  120458. PARALLAXOCCLUSION: boolean;
  120459. NORMALXYSCALE: boolean;
  120460. LIGHTMAP: boolean;
  120461. LIGHTMAPDIRECTUV: number;
  120462. USELIGHTMAPASSHADOWMAP: boolean;
  120463. GAMMALIGHTMAP: boolean;
  120464. RGBDLIGHTMAP: boolean;
  120465. REFLECTION: boolean;
  120466. REFLECTIONMAP_3D: boolean;
  120467. REFLECTIONMAP_SPHERICAL: boolean;
  120468. REFLECTIONMAP_PLANAR: boolean;
  120469. REFLECTIONMAP_CUBIC: boolean;
  120470. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  120471. REFLECTIONMAP_PROJECTION: boolean;
  120472. REFLECTIONMAP_SKYBOX: boolean;
  120473. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  120474. REFLECTIONMAP_EXPLICIT: boolean;
  120475. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  120476. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  120477. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  120478. INVERTCUBICMAP: boolean;
  120479. USESPHERICALFROMREFLECTIONMAP: boolean;
  120480. USEIRRADIANCEMAP: boolean;
  120481. SPHERICAL_HARMONICS: boolean;
  120482. USESPHERICALINVERTEX: boolean;
  120483. REFLECTIONMAP_OPPOSITEZ: boolean;
  120484. LODINREFLECTIONALPHA: boolean;
  120485. GAMMAREFLECTION: boolean;
  120486. RGBDREFLECTION: boolean;
  120487. LINEARSPECULARREFLECTION: boolean;
  120488. RADIANCEOCCLUSION: boolean;
  120489. HORIZONOCCLUSION: boolean;
  120490. INSTANCES: boolean;
  120491. NUM_BONE_INFLUENCERS: number;
  120492. BonesPerMesh: number;
  120493. BONETEXTURE: boolean;
  120494. NONUNIFORMSCALING: boolean;
  120495. MORPHTARGETS: boolean;
  120496. MORPHTARGETS_NORMAL: boolean;
  120497. MORPHTARGETS_TANGENT: boolean;
  120498. MORPHTARGETS_UV: boolean;
  120499. NUM_MORPH_INFLUENCERS: number;
  120500. IMAGEPROCESSING: boolean;
  120501. VIGNETTE: boolean;
  120502. VIGNETTEBLENDMODEMULTIPLY: boolean;
  120503. VIGNETTEBLENDMODEOPAQUE: boolean;
  120504. TONEMAPPING: boolean;
  120505. TONEMAPPING_ACES: boolean;
  120506. CONTRAST: boolean;
  120507. COLORCURVES: boolean;
  120508. COLORGRADING: boolean;
  120509. COLORGRADING3D: boolean;
  120510. SAMPLER3DGREENDEPTH: boolean;
  120511. SAMPLER3DBGRMAP: boolean;
  120512. IMAGEPROCESSINGPOSTPROCESS: boolean;
  120513. EXPOSURE: boolean;
  120514. MULTIVIEW: boolean;
  120515. USEPHYSICALLIGHTFALLOFF: boolean;
  120516. USEGLTFLIGHTFALLOFF: boolean;
  120517. TWOSIDEDLIGHTING: boolean;
  120518. SHADOWFLOAT: boolean;
  120519. CLIPPLANE: boolean;
  120520. CLIPPLANE2: boolean;
  120521. CLIPPLANE3: boolean;
  120522. CLIPPLANE4: boolean;
  120523. CLIPPLANE5: boolean;
  120524. CLIPPLANE6: boolean;
  120525. POINTSIZE: boolean;
  120526. FOG: boolean;
  120527. LOGARITHMICDEPTH: boolean;
  120528. FORCENORMALFORWARD: boolean;
  120529. SPECULARAA: boolean;
  120530. CLEARCOAT: boolean;
  120531. CLEARCOAT_DEFAULTIOR: boolean;
  120532. CLEARCOAT_TEXTURE: boolean;
  120533. CLEARCOAT_TEXTUREDIRECTUV: number;
  120534. CLEARCOAT_BUMP: boolean;
  120535. CLEARCOAT_BUMPDIRECTUV: number;
  120536. CLEARCOAT_TINT: boolean;
  120537. CLEARCOAT_TINT_TEXTURE: boolean;
  120538. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  120539. ANISOTROPIC: boolean;
  120540. ANISOTROPIC_TEXTURE: boolean;
  120541. ANISOTROPIC_TEXTUREDIRECTUV: number;
  120542. BRDF_V_HEIGHT_CORRELATED: boolean;
  120543. MS_BRDF_ENERGY_CONSERVATION: boolean;
  120544. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  120545. SHEEN: boolean;
  120546. SHEEN_TEXTURE: boolean;
  120547. SHEEN_TEXTUREDIRECTUV: number;
  120548. SHEEN_LINKWITHALBEDO: boolean;
  120549. SUBSURFACE: boolean;
  120550. SS_REFRACTION: boolean;
  120551. SS_TRANSLUCENCY: boolean;
  120552. SS_SCATERRING: boolean;
  120553. SS_THICKNESSANDMASK_TEXTURE: boolean;
  120554. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  120555. SS_REFRACTIONMAP_3D: boolean;
  120556. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  120557. SS_LODINREFRACTIONALPHA: boolean;
  120558. SS_GAMMAREFRACTION: boolean;
  120559. SS_RGBDREFRACTION: boolean;
  120560. SS_LINEARSPECULARREFRACTION: boolean;
  120561. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  120562. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  120563. UNLIT: boolean;
  120564. DEBUGMODE: number;
  120565. /**
  120566. * Initializes the PBR Material defines.
  120567. */
  120568. constructor();
  120569. /**
  120570. * Resets the PBR Material defines.
  120571. */
  120572. reset(): void;
  120573. }
  120574. /**
  120575. * The Physically based material base class of BJS.
  120576. *
  120577. * This offers the main features of a standard PBR material.
  120578. * For more information, please refer to the documentation :
  120579. * https://doc.babylonjs.com/how_to/physically_based_rendering
  120580. */
  120581. export abstract class PBRBaseMaterial extends PushMaterial {
  120582. /**
  120583. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  120584. */
  120585. static readonly PBRMATERIAL_OPAQUE: number;
  120586. /**
  120587. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  120588. */
  120589. static readonly PBRMATERIAL_ALPHATEST: number;
  120590. /**
  120591. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  120592. */
  120593. static readonly PBRMATERIAL_ALPHABLEND: number;
  120594. /**
  120595. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  120596. * They are also discarded below the alpha cutoff threshold to improve performances.
  120597. */
  120598. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  120599. /**
  120600. * Defines the default value of how much AO map is occluding the analytical lights
  120601. * (point spot...).
  120602. */
  120603. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  120604. /**
  120605. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  120606. */
  120607. static readonly LIGHTFALLOFF_PHYSICAL: number;
  120608. /**
  120609. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  120610. * to enhance interoperability with other engines.
  120611. */
  120612. static readonly LIGHTFALLOFF_GLTF: number;
  120613. /**
  120614. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  120615. * to enhance interoperability with other materials.
  120616. */
  120617. static readonly LIGHTFALLOFF_STANDARD: number;
  120618. /**
  120619. * Intensity of the direct lights e.g. the four lights available in your scene.
  120620. * This impacts both the direct diffuse and specular highlights.
  120621. */
  120622. protected _directIntensity: number;
  120623. /**
  120624. * Intensity of the emissive part of the material.
  120625. * This helps controlling the emissive effect without modifying the emissive color.
  120626. */
  120627. protected _emissiveIntensity: number;
  120628. /**
  120629. * Intensity of the environment e.g. how much the environment will light the object
  120630. * either through harmonics for rough material or through the refelction for shiny ones.
  120631. */
  120632. protected _environmentIntensity: number;
  120633. /**
  120634. * This is a special control allowing the reduction of the specular highlights coming from the
  120635. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  120636. */
  120637. protected _specularIntensity: number;
  120638. /**
  120639. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  120640. */
  120641. private _lightingInfos;
  120642. /**
  120643. * Debug Control allowing disabling the bump map on this material.
  120644. */
  120645. protected _disableBumpMap: boolean;
  120646. /**
  120647. * AKA Diffuse Texture in standard nomenclature.
  120648. */
  120649. protected _albedoTexture: Nullable<BaseTexture>;
  120650. /**
  120651. * AKA Occlusion Texture in other nomenclature.
  120652. */
  120653. protected _ambientTexture: Nullable<BaseTexture>;
  120654. /**
  120655. * AKA Occlusion Texture Intensity in other nomenclature.
  120656. */
  120657. protected _ambientTextureStrength: number;
  120658. /**
  120659. * Defines how much the AO map is occluding the analytical lights (point spot...).
  120660. * 1 means it completely occludes it
  120661. * 0 mean it has no impact
  120662. */
  120663. protected _ambientTextureImpactOnAnalyticalLights: number;
  120664. /**
  120665. * Stores the alpha values in a texture.
  120666. */
  120667. protected _opacityTexture: Nullable<BaseTexture>;
  120668. /**
  120669. * Stores the reflection values in a texture.
  120670. */
  120671. protected _reflectionTexture: Nullable<BaseTexture>;
  120672. /**
  120673. * Stores the emissive values in a texture.
  120674. */
  120675. protected _emissiveTexture: Nullable<BaseTexture>;
  120676. /**
  120677. * AKA Specular texture in other nomenclature.
  120678. */
  120679. protected _reflectivityTexture: Nullable<BaseTexture>;
  120680. /**
  120681. * Used to switch from specular/glossiness to metallic/roughness workflow.
  120682. */
  120683. protected _metallicTexture: Nullable<BaseTexture>;
  120684. /**
  120685. * Specifies the metallic scalar of the metallic/roughness workflow.
  120686. * Can also be used to scale the metalness values of the metallic texture.
  120687. */
  120688. protected _metallic: Nullable<number>;
  120689. /**
  120690. * Specifies the roughness scalar of the metallic/roughness workflow.
  120691. * Can also be used to scale the roughness values of the metallic texture.
  120692. */
  120693. protected _roughness: Nullable<number>;
  120694. /**
  120695. * Specifies the an F0 factor to help configuring the material F0.
  120696. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  120697. * to 0.5 the previously hard coded value stays the same.
  120698. * Can also be used to scale the F0 values of the metallic texture.
  120699. */
  120700. protected _metallicF0Factor: number;
  120701. /**
  120702. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  120703. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  120704. * your expectation as it multiplies with the texture data.
  120705. */
  120706. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  120707. /**
  120708. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  120709. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  120710. */
  120711. protected _microSurfaceTexture: Nullable<BaseTexture>;
  120712. /**
  120713. * Stores surface normal data used to displace a mesh in a texture.
  120714. */
  120715. protected _bumpTexture: Nullable<BaseTexture>;
  120716. /**
  120717. * Stores the pre-calculated light information of a mesh in a texture.
  120718. */
  120719. protected _lightmapTexture: Nullable<BaseTexture>;
  120720. /**
  120721. * The color of a material in ambient lighting.
  120722. */
  120723. protected _ambientColor: Color3;
  120724. /**
  120725. * AKA Diffuse Color in other nomenclature.
  120726. */
  120727. protected _albedoColor: Color3;
  120728. /**
  120729. * AKA Specular Color in other nomenclature.
  120730. */
  120731. protected _reflectivityColor: Color3;
  120732. /**
  120733. * The color applied when light is reflected from a material.
  120734. */
  120735. protected _reflectionColor: Color3;
  120736. /**
  120737. * The color applied when light is emitted from a material.
  120738. */
  120739. protected _emissiveColor: Color3;
  120740. /**
  120741. * AKA Glossiness in other nomenclature.
  120742. */
  120743. protected _microSurface: number;
  120744. /**
  120745. * Specifies that the material will use the light map as a show map.
  120746. */
  120747. protected _useLightmapAsShadowmap: boolean;
  120748. /**
  120749. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  120750. * makes the reflect vector face the model (under horizon).
  120751. */
  120752. protected _useHorizonOcclusion: boolean;
  120753. /**
  120754. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  120755. * too much the area relying on ambient texture to define their ambient occlusion.
  120756. */
  120757. protected _useRadianceOcclusion: boolean;
  120758. /**
  120759. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  120760. */
  120761. protected _useAlphaFromAlbedoTexture: boolean;
  120762. /**
  120763. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  120764. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  120765. */
  120766. protected _useSpecularOverAlpha: boolean;
  120767. /**
  120768. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  120769. */
  120770. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  120771. /**
  120772. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  120773. */
  120774. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  120775. /**
  120776. * Specifies if the metallic texture contains the roughness information in its green channel.
  120777. */
  120778. protected _useRoughnessFromMetallicTextureGreen: boolean;
  120779. /**
  120780. * Specifies if the metallic texture contains the metallness information in its blue channel.
  120781. */
  120782. protected _useMetallnessFromMetallicTextureBlue: boolean;
  120783. /**
  120784. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  120785. */
  120786. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  120787. /**
  120788. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  120789. */
  120790. protected _useAmbientInGrayScale: boolean;
  120791. /**
  120792. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  120793. * The material will try to infer what glossiness each pixel should be.
  120794. */
  120795. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  120796. /**
  120797. * Defines the falloff type used in this material.
  120798. * It by default is Physical.
  120799. */
  120800. protected _lightFalloff: number;
  120801. /**
  120802. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  120803. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  120804. */
  120805. protected _useRadianceOverAlpha: boolean;
  120806. /**
  120807. * Allows using an object space normal map (instead of tangent space).
  120808. */
  120809. protected _useObjectSpaceNormalMap: boolean;
  120810. /**
  120811. * Allows using the bump map in parallax mode.
  120812. */
  120813. protected _useParallax: boolean;
  120814. /**
  120815. * Allows using the bump map in parallax occlusion mode.
  120816. */
  120817. protected _useParallaxOcclusion: boolean;
  120818. /**
  120819. * Controls the scale bias of the parallax mode.
  120820. */
  120821. protected _parallaxScaleBias: number;
  120822. /**
  120823. * If sets to true, disables all the lights affecting the material.
  120824. */
  120825. protected _disableLighting: boolean;
  120826. /**
  120827. * Number of Simultaneous lights allowed on the material.
  120828. */
  120829. protected _maxSimultaneousLights: number;
  120830. /**
  120831. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  120832. */
  120833. protected _invertNormalMapX: boolean;
  120834. /**
  120835. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  120836. */
  120837. protected _invertNormalMapY: boolean;
  120838. /**
  120839. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  120840. */
  120841. protected _twoSidedLighting: boolean;
  120842. /**
  120843. * Defines the alpha limits in alpha test mode.
  120844. */
  120845. protected _alphaCutOff: number;
  120846. /**
  120847. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  120848. */
  120849. protected _forceAlphaTest: boolean;
  120850. /**
  120851. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  120852. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  120853. */
  120854. protected _useAlphaFresnel: boolean;
  120855. /**
  120856. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  120857. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  120858. */
  120859. protected _useLinearAlphaFresnel: boolean;
  120860. /**
  120861. * The transparency mode of the material.
  120862. */
  120863. protected _transparencyMode: Nullable<number>;
  120864. /**
  120865. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  120866. * from cos thetav and roughness:
  120867. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  120868. */
  120869. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  120870. /**
  120871. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  120872. */
  120873. protected _forceIrradianceInFragment: boolean;
  120874. /**
  120875. * Force normal to face away from face.
  120876. */
  120877. protected _forceNormalForward: boolean;
  120878. /**
  120879. * Enables specular anti aliasing in the PBR shader.
  120880. * It will both interacts on the Geometry for analytical and IBL lighting.
  120881. * It also prefilter the roughness map based on the bump values.
  120882. */
  120883. protected _enableSpecularAntiAliasing: boolean;
  120884. /**
  120885. * Default configuration related to image processing available in the PBR Material.
  120886. */
  120887. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  120888. /**
  120889. * Keep track of the image processing observer to allow dispose and replace.
  120890. */
  120891. private _imageProcessingObserver;
  120892. /**
  120893. * Attaches a new image processing configuration to the PBR Material.
  120894. * @param configuration
  120895. */
  120896. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  120897. /**
  120898. * Stores the available render targets.
  120899. */
  120900. private _renderTargets;
  120901. /**
  120902. * Sets the global ambient color for the material used in lighting calculations.
  120903. */
  120904. private _globalAmbientColor;
  120905. /**
  120906. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  120907. */
  120908. private _useLogarithmicDepth;
  120909. /**
  120910. * If set to true, no lighting calculations will be applied.
  120911. */
  120912. private _unlit;
  120913. private _debugMode;
  120914. /**
  120915. * @hidden
  120916. * This is reserved for the inspector.
  120917. * Defines the material debug mode.
  120918. * It helps seeing only some components of the material while troubleshooting.
  120919. */
  120920. debugMode: number;
  120921. /**
  120922. * @hidden
  120923. * This is reserved for the inspector.
  120924. * Specify from where on screen the debug mode should start.
  120925. * The value goes from -1 (full screen) to 1 (not visible)
  120926. * It helps with side by side comparison against the final render
  120927. * This defaults to -1
  120928. */
  120929. private debugLimit;
  120930. /**
  120931. * @hidden
  120932. * This is reserved for the inspector.
  120933. * As the default viewing range might not be enough (if the ambient is really small for instance)
  120934. * You can use the factor to better multiply the final value.
  120935. */
  120936. private debugFactor;
  120937. /**
  120938. * Defines the clear coat layer parameters for the material.
  120939. */
  120940. readonly clearCoat: PBRClearCoatConfiguration;
  120941. /**
  120942. * Defines the anisotropic parameters for the material.
  120943. */
  120944. readonly anisotropy: PBRAnisotropicConfiguration;
  120945. /**
  120946. * Defines the BRDF parameters for the material.
  120947. */
  120948. readonly brdf: PBRBRDFConfiguration;
  120949. /**
  120950. * Defines the Sheen parameters for the material.
  120951. */
  120952. readonly sheen: PBRSheenConfiguration;
  120953. /**
  120954. * Defines the SubSurface parameters for the material.
  120955. */
  120956. readonly subSurface: PBRSubSurfaceConfiguration;
  120957. /**
  120958. * Custom callback helping to override the default shader used in the material.
  120959. */
  120960. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  120961. protected _rebuildInParallel: boolean;
  120962. /**
  120963. * Instantiates a new PBRMaterial instance.
  120964. *
  120965. * @param name The material name
  120966. * @param scene The scene the material will be use in.
  120967. */
  120968. constructor(name: string, scene: Scene);
  120969. /**
  120970. * Gets a boolean indicating that current material needs to register RTT
  120971. */
  120972. get hasRenderTargetTextures(): boolean;
  120973. /**
  120974. * Gets the name of the material class.
  120975. */
  120976. getClassName(): string;
  120977. /**
  120978. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  120979. */
  120980. get useLogarithmicDepth(): boolean;
  120981. /**
  120982. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  120983. */
  120984. set useLogarithmicDepth(value: boolean);
  120985. /**
  120986. * Gets the current transparency mode.
  120987. */
  120988. get transparencyMode(): Nullable<number>;
  120989. /**
  120990. * Sets the transparency mode of the material.
  120991. *
  120992. * | Value | Type | Description |
  120993. * | ----- | ----------------------------------- | ----------- |
  120994. * | 0 | OPAQUE | |
  120995. * | 1 | ALPHATEST | |
  120996. * | 2 | ALPHABLEND | |
  120997. * | 3 | ALPHATESTANDBLEND | |
  120998. *
  120999. */
  121000. set transparencyMode(value: Nullable<number>);
  121001. /**
  121002. * Returns true if alpha blending should be disabled.
  121003. */
  121004. private get _disableAlphaBlending();
  121005. /**
  121006. * Specifies whether or not this material should be rendered in alpha blend mode.
  121007. */
  121008. needAlphaBlending(): boolean;
  121009. /**
  121010. * Specifies if the mesh will require alpha blending.
  121011. * @param mesh - BJS mesh.
  121012. */
  121013. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  121014. /**
  121015. * Specifies whether or not this material should be rendered in alpha test mode.
  121016. */
  121017. needAlphaTesting(): boolean;
  121018. /**
  121019. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  121020. */
  121021. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  121022. /**
  121023. * Gets the texture used for the alpha test.
  121024. */
  121025. getAlphaTestTexture(): Nullable<BaseTexture>;
  121026. /**
  121027. * Specifies that the submesh is ready to be used.
  121028. * @param mesh - BJS mesh.
  121029. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  121030. * @param useInstances - Specifies that instances should be used.
  121031. * @returns - boolean indicating that the submesh is ready or not.
  121032. */
  121033. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  121034. /**
  121035. * Specifies if the material uses metallic roughness workflow.
  121036. * @returns boolean specifiying if the material uses metallic roughness workflow.
  121037. */
  121038. isMetallicWorkflow(): boolean;
  121039. private _prepareEffect;
  121040. private _prepareDefines;
  121041. /**
  121042. * Force shader compilation
  121043. */
  121044. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  121045. /**
  121046. * Initializes the uniform buffer layout for the shader.
  121047. */
  121048. buildUniformLayout(): void;
  121049. /**
  121050. * Unbinds the material from the mesh
  121051. */
  121052. unbind(): void;
  121053. /**
  121054. * Binds the submesh data.
  121055. * @param world - The world matrix.
  121056. * @param mesh - The BJS mesh.
  121057. * @param subMesh - A submesh of the BJS mesh.
  121058. */
  121059. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  121060. /**
  121061. * Returns the animatable textures.
  121062. * @returns - Array of animatable textures.
  121063. */
  121064. getAnimatables(): IAnimatable[];
  121065. /**
  121066. * Returns the texture used for reflections.
  121067. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  121068. */
  121069. private _getReflectionTexture;
  121070. /**
  121071. * Returns an array of the actively used textures.
  121072. * @returns - Array of BaseTextures
  121073. */
  121074. getActiveTextures(): BaseTexture[];
  121075. /**
  121076. * Checks to see if a texture is used in the material.
  121077. * @param texture - Base texture to use.
  121078. * @returns - Boolean specifying if a texture is used in the material.
  121079. */
  121080. hasTexture(texture: BaseTexture): boolean;
  121081. /**
  121082. * Disposes the resources of the material.
  121083. * @param forceDisposeEffect - Forces the disposal of effects.
  121084. * @param forceDisposeTextures - Forces the disposal of all textures.
  121085. */
  121086. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  121087. }
  121088. }
  121089. declare module BABYLON {
  121090. /**
  121091. * The Physically based material of BJS.
  121092. *
  121093. * This offers the main features of a standard PBR material.
  121094. * For more information, please refer to the documentation :
  121095. * https://doc.babylonjs.com/how_to/physically_based_rendering
  121096. */
  121097. export class PBRMaterial extends PBRBaseMaterial {
  121098. /**
  121099. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  121100. */
  121101. static readonly PBRMATERIAL_OPAQUE: number;
  121102. /**
  121103. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  121104. */
  121105. static readonly PBRMATERIAL_ALPHATEST: number;
  121106. /**
  121107. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  121108. */
  121109. static readonly PBRMATERIAL_ALPHABLEND: number;
  121110. /**
  121111. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  121112. * They are also discarded below the alpha cutoff threshold to improve performances.
  121113. */
  121114. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  121115. /**
  121116. * Defines the default value of how much AO map is occluding the analytical lights
  121117. * (point spot...).
  121118. */
  121119. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  121120. /**
  121121. * Intensity of the direct lights e.g. the four lights available in your scene.
  121122. * This impacts both the direct diffuse and specular highlights.
  121123. */
  121124. directIntensity: number;
  121125. /**
  121126. * Intensity of the emissive part of the material.
  121127. * This helps controlling the emissive effect without modifying the emissive color.
  121128. */
  121129. emissiveIntensity: number;
  121130. /**
  121131. * Intensity of the environment e.g. how much the environment will light the object
  121132. * either through harmonics for rough material or through the refelction for shiny ones.
  121133. */
  121134. environmentIntensity: number;
  121135. /**
  121136. * This is a special control allowing the reduction of the specular highlights coming from the
  121137. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  121138. */
  121139. specularIntensity: number;
  121140. /**
  121141. * Debug Control allowing disabling the bump map on this material.
  121142. */
  121143. disableBumpMap: boolean;
  121144. /**
  121145. * AKA Diffuse Texture in standard nomenclature.
  121146. */
  121147. albedoTexture: BaseTexture;
  121148. /**
  121149. * AKA Occlusion Texture in other nomenclature.
  121150. */
  121151. ambientTexture: BaseTexture;
  121152. /**
  121153. * AKA Occlusion Texture Intensity in other nomenclature.
  121154. */
  121155. ambientTextureStrength: number;
  121156. /**
  121157. * Defines how much the AO map is occluding the analytical lights (point spot...).
  121158. * 1 means it completely occludes it
  121159. * 0 mean it has no impact
  121160. */
  121161. ambientTextureImpactOnAnalyticalLights: number;
  121162. /**
  121163. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  121164. */
  121165. opacityTexture: BaseTexture;
  121166. /**
  121167. * Stores the reflection values in a texture.
  121168. */
  121169. reflectionTexture: Nullable<BaseTexture>;
  121170. /**
  121171. * Stores the emissive values in a texture.
  121172. */
  121173. emissiveTexture: BaseTexture;
  121174. /**
  121175. * AKA Specular texture in other nomenclature.
  121176. */
  121177. reflectivityTexture: BaseTexture;
  121178. /**
  121179. * Used to switch from specular/glossiness to metallic/roughness workflow.
  121180. */
  121181. metallicTexture: BaseTexture;
  121182. /**
  121183. * Specifies the metallic scalar of the metallic/roughness workflow.
  121184. * Can also be used to scale the metalness values of the metallic texture.
  121185. */
  121186. metallic: Nullable<number>;
  121187. /**
  121188. * Specifies the roughness scalar of the metallic/roughness workflow.
  121189. * Can also be used to scale the roughness values of the metallic texture.
  121190. */
  121191. roughness: Nullable<number>;
  121192. /**
  121193. * Specifies the an F0 factor to help configuring the material F0.
  121194. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  121195. * to 0.5 the previously hard coded value stays the same.
  121196. * Can also be used to scale the F0 values of the metallic texture.
  121197. */
  121198. metallicF0Factor: number;
  121199. /**
  121200. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  121201. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  121202. * your expectation as it multiplies with the texture data.
  121203. */
  121204. useMetallicF0FactorFromMetallicTexture: boolean;
  121205. /**
  121206. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  121207. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  121208. */
  121209. microSurfaceTexture: BaseTexture;
  121210. /**
  121211. * Stores surface normal data used to displace a mesh in a texture.
  121212. */
  121213. bumpTexture: BaseTexture;
  121214. /**
  121215. * Stores the pre-calculated light information of a mesh in a texture.
  121216. */
  121217. lightmapTexture: BaseTexture;
  121218. /**
  121219. * Stores the refracted light information in a texture.
  121220. */
  121221. get refractionTexture(): Nullable<BaseTexture>;
  121222. set refractionTexture(value: Nullable<BaseTexture>);
  121223. /**
  121224. * The color of a material in ambient lighting.
  121225. */
  121226. ambientColor: Color3;
  121227. /**
  121228. * AKA Diffuse Color in other nomenclature.
  121229. */
  121230. albedoColor: Color3;
  121231. /**
  121232. * AKA Specular Color in other nomenclature.
  121233. */
  121234. reflectivityColor: Color3;
  121235. /**
  121236. * The color reflected from the material.
  121237. */
  121238. reflectionColor: Color3;
  121239. /**
  121240. * The color emitted from the material.
  121241. */
  121242. emissiveColor: Color3;
  121243. /**
  121244. * AKA Glossiness in other nomenclature.
  121245. */
  121246. microSurface: number;
  121247. /**
  121248. * source material index of refraction (IOR)' / 'destination material IOR.
  121249. */
  121250. get indexOfRefraction(): number;
  121251. set indexOfRefraction(value: number);
  121252. /**
  121253. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  121254. */
  121255. get invertRefractionY(): boolean;
  121256. set invertRefractionY(value: boolean);
  121257. /**
  121258. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  121259. * Materials half opaque for instance using refraction could benefit from this control.
  121260. */
  121261. get linkRefractionWithTransparency(): boolean;
  121262. set linkRefractionWithTransparency(value: boolean);
  121263. /**
  121264. * If true, the light map contains occlusion information instead of lighting info.
  121265. */
  121266. useLightmapAsShadowmap: boolean;
  121267. /**
  121268. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  121269. */
  121270. useAlphaFromAlbedoTexture: boolean;
  121271. /**
  121272. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  121273. */
  121274. forceAlphaTest: boolean;
  121275. /**
  121276. * Defines the alpha limits in alpha test mode.
  121277. */
  121278. alphaCutOff: number;
  121279. /**
  121280. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  121281. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  121282. */
  121283. useSpecularOverAlpha: boolean;
  121284. /**
  121285. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  121286. */
  121287. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  121288. /**
  121289. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  121290. */
  121291. useRoughnessFromMetallicTextureAlpha: boolean;
  121292. /**
  121293. * Specifies if the metallic texture contains the roughness information in its green channel.
  121294. */
  121295. useRoughnessFromMetallicTextureGreen: boolean;
  121296. /**
  121297. * Specifies if the metallic texture contains the metallness information in its blue channel.
  121298. */
  121299. useMetallnessFromMetallicTextureBlue: boolean;
  121300. /**
  121301. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  121302. */
  121303. useAmbientOcclusionFromMetallicTextureRed: boolean;
  121304. /**
  121305. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  121306. */
  121307. useAmbientInGrayScale: boolean;
  121308. /**
  121309. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  121310. * The material will try to infer what glossiness each pixel should be.
  121311. */
  121312. useAutoMicroSurfaceFromReflectivityMap: boolean;
  121313. /**
  121314. * BJS is using an harcoded light falloff based on a manually sets up range.
  121315. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  121316. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  121317. */
  121318. get usePhysicalLightFalloff(): boolean;
  121319. /**
  121320. * BJS is using an harcoded light falloff based on a manually sets up range.
  121321. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  121322. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  121323. */
  121324. set usePhysicalLightFalloff(value: boolean);
  121325. /**
  121326. * In order to support the falloff compatibility with gltf, a special mode has been added
  121327. * to reproduce the gltf light falloff.
  121328. */
  121329. get useGLTFLightFalloff(): boolean;
  121330. /**
  121331. * In order to support the falloff compatibility with gltf, a special mode has been added
  121332. * to reproduce the gltf light falloff.
  121333. */
  121334. set useGLTFLightFalloff(value: boolean);
  121335. /**
  121336. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  121337. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  121338. */
  121339. useRadianceOverAlpha: boolean;
  121340. /**
  121341. * Allows using an object space normal map (instead of tangent space).
  121342. */
  121343. useObjectSpaceNormalMap: boolean;
  121344. /**
  121345. * Allows using the bump map in parallax mode.
  121346. */
  121347. useParallax: boolean;
  121348. /**
  121349. * Allows using the bump map in parallax occlusion mode.
  121350. */
  121351. useParallaxOcclusion: boolean;
  121352. /**
  121353. * Controls the scale bias of the parallax mode.
  121354. */
  121355. parallaxScaleBias: number;
  121356. /**
  121357. * If sets to true, disables all the lights affecting the material.
  121358. */
  121359. disableLighting: boolean;
  121360. /**
  121361. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  121362. */
  121363. forceIrradianceInFragment: boolean;
  121364. /**
  121365. * Number of Simultaneous lights allowed on the material.
  121366. */
  121367. maxSimultaneousLights: number;
  121368. /**
  121369. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  121370. */
  121371. invertNormalMapX: boolean;
  121372. /**
  121373. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  121374. */
  121375. invertNormalMapY: boolean;
  121376. /**
  121377. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  121378. */
  121379. twoSidedLighting: boolean;
  121380. /**
  121381. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  121382. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  121383. */
  121384. useAlphaFresnel: boolean;
  121385. /**
  121386. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  121387. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  121388. */
  121389. useLinearAlphaFresnel: boolean;
  121390. /**
  121391. * Let user defines the brdf lookup texture used for IBL.
  121392. * A default 8bit version is embedded but you could point at :
  121393. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  121394. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  121395. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  121396. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  121397. */
  121398. environmentBRDFTexture: Nullable<BaseTexture>;
  121399. /**
  121400. * Force normal to face away from face.
  121401. */
  121402. forceNormalForward: boolean;
  121403. /**
  121404. * Enables specular anti aliasing in the PBR shader.
  121405. * It will both interacts on the Geometry for analytical and IBL lighting.
  121406. * It also prefilter the roughness map based on the bump values.
  121407. */
  121408. enableSpecularAntiAliasing: boolean;
  121409. /**
  121410. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  121411. * makes the reflect vector face the model (under horizon).
  121412. */
  121413. useHorizonOcclusion: boolean;
  121414. /**
  121415. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  121416. * too much the area relying on ambient texture to define their ambient occlusion.
  121417. */
  121418. useRadianceOcclusion: boolean;
  121419. /**
  121420. * If set to true, no lighting calculations will be applied.
  121421. */
  121422. unlit: boolean;
  121423. /**
  121424. * Gets the image processing configuration used either in this material.
  121425. */
  121426. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  121427. /**
  121428. * Sets the Default image processing configuration used either in the this material.
  121429. *
  121430. * If sets to null, the scene one is in use.
  121431. */
  121432. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  121433. /**
  121434. * Gets wether the color curves effect is enabled.
  121435. */
  121436. get cameraColorCurvesEnabled(): boolean;
  121437. /**
  121438. * Sets wether the color curves effect is enabled.
  121439. */
  121440. set cameraColorCurvesEnabled(value: boolean);
  121441. /**
  121442. * Gets wether the color grading effect is enabled.
  121443. */
  121444. get cameraColorGradingEnabled(): boolean;
  121445. /**
  121446. * Gets wether the color grading effect is enabled.
  121447. */
  121448. set cameraColorGradingEnabled(value: boolean);
  121449. /**
  121450. * Gets wether tonemapping is enabled or not.
  121451. */
  121452. get cameraToneMappingEnabled(): boolean;
  121453. /**
  121454. * Sets wether tonemapping is enabled or not
  121455. */
  121456. set cameraToneMappingEnabled(value: boolean);
  121457. /**
  121458. * The camera exposure used on this material.
  121459. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  121460. * This corresponds to a photographic exposure.
  121461. */
  121462. get cameraExposure(): number;
  121463. /**
  121464. * The camera exposure used on this material.
  121465. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  121466. * This corresponds to a photographic exposure.
  121467. */
  121468. set cameraExposure(value: number);
  121469. /**
  121470. * Gets The camera contrast used on this material.
  121471. */
  121472. get cameraContrast(): number;
  121473. /**
  121474. * Sets The camera contrast used on this material.
  121475. */
  121476. set cameraContrast(value: number);
  121477. /**
  121478. * Gets the Color Grading 2D Lookup Texture.
  121479. */
  121480. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  121481. /**
  121482. * Sets the Color Grading 2D Lookup Texture.
  121483. */
  121484. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  121485. /**
  121486. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  121487. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  121488. * 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;
  121489. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  121490. */
  121491. get cameraColorCurves(): Nullable<ColorCurves>;
  121492. /**
  121493. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  121494. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  121495. * 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;
  121496. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  121497. */
  121498. set cameraColorCurves(value: Nullable<ColorCurves>);
  121499. /**
  121500. * Instantiates a new PBRMaterial instance.
  121501. *
  121502. * @param name The material name
  121503. * @param scene The scene the material will be use in.
  121504. */
  121505. constructor(name: string, scene: Scene);
  121506. /**
  121507. * Returns the name of this material class.
  121508. */
  121509. getClassName(): string;
  121510. /**
  121511. * Makes a duplicate of the current material.
  121512. * @param name - name to use for the new material.
  121513. */
  121514. clone(name: string): PBRMaterial;
  121515. /**
  121516. * Serializes this PBR Material.
  121517. * @returns - An object with the serialized material.
  121518. */
  121519. serialize(): any;
  121520. /**
  121521. * Parses a PBR Material from a serialized object.
  121522. * @param source - Serialized object.
  121523. * @param scene - BJS scene instance.
  121524. * @param rootUrl - url for the scene object
  121525. * @returns - PBRMaterial
  121526. */
  121527. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  121528. }
  121529. }
  121530. declare module BABYLON {
  121531. /**
  121532. * Direct draw surface info
  121533. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  121534. */
  121535. export interface DDSInfo {
  121536. /**
  121537. * Width of the texture
  121538. */
  121539. width: number;
  121540. /**
  121541. * Width of the texture
  121542. */
  121543. height: number;
  121544. /**
  121545. * Number of Mipmaps for the texture
  121546. * @see https://en.wikipedia.org/wiki/Mipmap
  121547. */
  121548. mipmapCount: number;
  121549. /**
  121550. * If the textures format is a known fourCC format
  121551. * @see https://www.fourcc.org/
  121552. */
  121553. isFourCC: boolean;
  121554. /**
  121555. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  121556. */
  121557. isRGB: boolean;
  121558. /**
  121559. * If the texture is a lumincance format
  121560. */
  121561. isLuminance: boolean;
  121562. /**
  121563. * If this is a cube texture
  121564. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  121565. */
  121566. isCube: boolean;
  121567. /**
  121568. * If the texture is a compressed format eg. FOURCC_DXT1
  121569. */
  121570. isCompressed: boolean;
  121571. /**
  121572. * The dxgiFormat of the texture
  121573. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  121574. */
  121575. dxgiFormat: number;
  121576. /**
  121577. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  121578. */
  121579. textureType: number;
  121580. /**
  121581. * Sphericle polynomial created for the dds texture
  121582. */
  121583. sphericalPolynomial?: SphericalPolynomial;
  121584. }
  121585. /**
  121586. * Class used to provide DDS decompression tools
  121587. */
  121588. export class DDSTools {
  121589. /**
  121590. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  121591. */
  121592. static StoreLODInAlphaChannel: boolean;
  121593. /**
  121594. * Gets DDS information from an array buffer
  121595. * @param arrayBuffer defines the array buffer to read data from
  121596. * @returns the DDS information
  121597. */
  121598. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  121599. private static _FloatView;
  121600. private static _Int32View;
  121601. private static _ToHalfFloat;
  121602. private static _FromHalfFloat;
  121603. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  121604. private static _GetHalfFloatRGBAArrayBuffer;
  121605. private static _GetFloatRGBAArrayBuffer;
  121606. private static _GetFloatAsUIntRGBAArrayBuffer;
  121607. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  121608. private static _GetRGBAArrayBuffer;
  121609. private static _ExtractLongWordOrder;
  121610. private static _GetRGBArrayBuffer;
  121611. private static _GetLuminanceArrayBuffer;
  121612. /**
  121613. * Uploads DDS Levels to a Babylon Texture
  121614. * @hidden
  121615. */
  121616. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  121617. }
  121618. interface ThinEngine {
  121619. /**
  121620. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  121621. * @param rootUrl defines the url where the file to load is located
  121622. * @param scene defines the current scene
  121623. * @param lodScale defines scale to apply to the mip map selection
  121624. * @param lodOffset defines offset to apply to the mip map selection
  121625. * @param onLoad defines an optional callback raised when the texture is loaded
  121626. * @param onError defines an optional callback raised if there is an issue to load the texture
  121627. * @param format defines the format of the data
  121628. * @param forcedExtension defines the extension to use to pick the right loader
  121629. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  121630. * @returns the cube texture as an InternalTexture
  121631. */
  121632. 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;
  121633. }
  121634. }
  121635. declare module BABYLON {
  121636. /**
  121637. * Implementation of the DDS Texture Loader.
  121638. * @hidden
  121639. */
  121640. export class _DDSTextureLoader implements IInternalTextureLoader {
  121641. /**
  121642. * Defines wether the loader supports cascade loading the different faces.
  121643. */
  121644. readonly supportCascades: boolean;
  121645. /**
  121646. * This returns if the loader support the current file information.
  121647. * @param extension defines the file extension of the file being loaded
  121648. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121649. * @param fallback defines the fallback internal texture if any
  121650. * @param isBase64 defines whether the texture is encoded as a base64
  121651. * @param isBuffer defines whether the texture data are stored as a buffer
  121652. * @returns true if the loader can load the specified file
  121653. */
  121654. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121655. /**
  121656. * Transform the url before loading if required.
  121657. * @param rootUrl the url of the texture
  121658. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121659. * @returns the transformed texture
  121660. */
  121661. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121662. /**
  121663. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121664. * @param rootUrl the url of the texture
  121665. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121666. * @returns the fallback texture
  121667. */
  121668. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121669. /**
  121670. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  121671. * @param data contains the texture data
  121672. * @param texture defines the BabylonJS internal texture
  121673. * @param createPolynomials will be true if polynomials have been requested
  121674. * @param onLoad defines the callback to trigger once the texture is ready
  121675. * @param onError defines the callback to trigger in case of error
  121676. */
  121677. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121678. /**
  121679. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121680. * @param data contains the texture data
  121681. * @param texture defines the BabylonJS internal texture
  121682. * @param callback defines the method to call once ready to upload
  121683. */
  121684. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  121685. }
  121686. }
  121687. declare module BABYLON {
  121688. /**
  121689. * Implementation of the ENV Texture Loader.
  121690. * @hidden
  121691. */
  121692. export class _ENVTextureLoader implements IInternalTextureLoader {
  121693. /**
  121694. * Defines wether the loader supports cascade loading the different faces.
  121695. */
  121696. readonly supportCascades: boolean;
  121697. /**
  121698. * This returns if the loader support the current file information.
  121699. * @param extension defines the file extension of the file being loaded
  121700. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121701. * @param fallback defines the fallback internal texture if any
  121702. * @param isBase64 defines whether the texture is encoded as a base64
  121703. * @param isBuffer defines whether the texture data are stored as a buffer
  121704. * @returns true if the loader can load the specified file
  121705. */
  121706. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121707. /**
  121708. * Transform the url before loading if required.
  121709. * @param rootUrl the url of the texture
  121710. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121711. * @returns the transformed texture
  121712. */
  121713. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121714. /**
  121715. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121716. * @param rootUrl the url of the texture
  121717. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121718. * @returns the fallback texture
  121719. */
  121720. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121721. /**
  121722. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  121723. * @param data contains the texture data
  121724. * @param texture defines the BabylonJS internal texture
  121725. * @param createPolynomials will be true if polynomials have been requested
  121726. * @param onLoad defines the callback to trigger once the texture is ready
  121727. * @param onError defines the callback to trigger in case of error
  121728. */
  121729. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121730. /**
  121731. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121732. * @param data contains the texture data
  121733. * @param texture defines the BabylonJS internal texture
  121734. * @param callback defines the method to call once ready to upload
  121735. */
  121736. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  121737. }
  121738. }
  121739. declare module BABYLON {
  121740. /**
  121741. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  121742. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  121743. */
  121744. export class KhronosTextureContainer {
  121745. /** contents of the KTX container file */
  121746. arrayBuffer: any;
  121747. private static HEADER_LEN;
  121748. private static COMPRESSED_2D;
  121749. private static COMPRESSED_3D;
  121750. private static TEX_2D;
  121751. private static TEX_3D;
  121752. /**
  121753. * Gets the openGL type
  121754. */
  121755. glType: number;
  121756. /**
  121757. * Gets the openGL type size
  121758. */
  121759. glTypeSize: number;
  121760. /**
  121761. * Gets the openGL format
  121762. */
  121763. glFormat: number;
  121764. /**
  121765. * Gets the openGL internal format
  121766. */
  121767. glInternalFormat: number;
  121768. /**
  121769. * Gets the base internal format
  121770. */
  121771. glBaseInternalFormat: number;
  121772. /**
  121773. * Gets image width in pixel
  121774. */
  121775. pixelWidth: number;
  121776. /**
  121777. * Gets image height in pixel
  121778. */
  121779. pixelHeight: number;
  121780. /**
  121781. * Gets image depth in pixels
  121782. */
  121783. pixelDepth: number;
  121784. /**
  121785. * Gets the number of array elements
  121786. */
  121787. numberOfArrayElements: number;
  121788. /**
  121789. * Gets the number of faces
  121790. */
  121791. numberOfFaces: number;
  121792. /**
  121793. * Gets the number of mipmap levels
  121794. */
  121795. numberOfMipmapLevels: number;
  121796. /**
  121797. * Gets the bytes of key value data
  121798. */
  121799. bytesOfKeyValueData: number;
  121800. /**
  121801. * Gets the load type
  121802. */
  121803. loadType: number;
  121804. /**
  121805. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  121806. */
  121807. isInvalid: boolean;
  121808. /**
  121809. * Creates a new KhronosTextureContainer
  121810. * @param arrayBuffer contents of the KTX container file
  121811. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  121812. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  121813. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  121814. */
  121815. constructor(
  121816. /** contents of the KTX container file */
  121817. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  121818. /**
  121819. * Uploads KTX content to a Babylon Texture.
  121820. * It is assumed that the texture has already been created & is currently bound
  121821. * @hidden
  121822. */
  121823. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  121824. private _upload2DCompressedLevels;
  121825. }
  121826. }
  121827. declare module BABYLON {
  121828. /**
  121829. * Implementation of the KTX Texture Loader.
  121830. * @hidden
  121831. */
  121832. export class _KTXTextureLoader implements IInternalTextureLoader {
  121833. /**
  121834. * Defines wether the loader supports cascade loading the different faces.
  121835. */
  121836. readonly supportCascades: boolean;
  121837. /**
  121838. * This returns if the loader support the current file information.
  121839. * @param extension defines the file extension of the file being loaded
  121840. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121841. * @param fallback defines the fallback internal texture if any
  121842. * @param isBase64 defines whether the texture is encoded as a base64
  121843. * @param isBuffer defines whether the texture data are stored as a buffer
  121844. * @returns true if the loader can load the specified file
  121845. */
  121846. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121847. /**
  121848. * Transform the url before loading if required.
  121849. * @param rootUrl the url of the texture
  121850. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121851. * @returns the transformed texture
  121852. */
  121853. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121854. /**
  121855. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121856. * @param rootUrl the url of the texture
  121857. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121858. * @returns the fallback texture
  121859. */
  121860. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121861. /**
  121862. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  121863. * @param data contains the texture data
  121864. * @param texture defines the BabylonJS internal texture
  121865. * @param createPolynomials will be true if polynomials have been requested
  121866. * @param onLoad defines the callback to trigger once the texture is ready
  121867. * @param onError defines the callback to trigger in case of error
  121868. */
  121869. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121870. /**
  121871. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121872. * @param data contains the texture data
  121873. * @param texture defines the BabylonJS internal texture
  121874. * @param callback defines the method to call once ready to upload
  121875. */
  121876. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  121877. }
  121878. }
  121879. declare module BABYLON {
  121880. /** @hidden */
  121881. export var _forceSceneHelpersToBundle: boolean;
  121882. interface Scene {
  121883. /**
  121884. * Creates a default light for the scene.
  121885. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  121886. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  121887. */
  121888. createDefaultLight(replace?: boolean): void;
  121889. /**
  121890. * Creates a default camera for the scene.
  121891. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  121892. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  121893. * @param replace has default false, when true replaces the active camera in the scene
  121894. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  121895. */
  121896. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  121897. /**
  121898. * Creates a default camera and a default light.
  121899. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  121900. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  121901. * @param replace has the default false, when true replaces the active camera/light in the scene
  121902. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  121903. */
  121904. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  121905. /**
  121906. * Creates a new sky box
  121907. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  121908. * @param environmentTexture defines the texture to use as environment texture
  121909. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  121910. * @param scale defines the overall scale of the skybox
  121911. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  121912. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  121913. * @returns a new mesh holding the sky box
  121914. */
  121915. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  121916. /**
  121917. * Creates a new environment
  121918. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  121919. * @param options defines the options you can use to configure the environment
  121920. * @returns the new EnvironmentHelper
  121921. */
  121922. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  121923. /**
  121924. * Creates a new VREXperienceHelper
  121925. * @see http://doc.babylonjs.com/how_to/webvr_helper
  121926. * @param webVROptions defines the options used to create the new VREXperienceHelper
  121927. * @returns a new VREXperienceHelper
  121928. */
  121929. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  121930. /**
  121931. * Creates a new WebXRDefaultExperience
  121932. * @see http://doc.babylonjs.com/how_to/webxr
  121933. * @param options experience options
  121934. * @returns a promise for a new WebXRDefaultExperience
  121935. */
  121936. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  121937. }
  121938. }
  121939. declare module BABYLON {
  121940. /**
  121941. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  121942. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  121943. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  121944. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  121945. */
  121946. export class VideoDome extends TransformNode {
  121947. /**
  121948. * Define the video source as a Monoscopic panoramic 360 video.
  121949. */
  121950. static readonly MODE_MONOSCOPIC: number;
  121951. /**
  121952. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  121953. */
  121954. static readonly MODE_TOPBOTTOM: number;
  121955. /**
  121956. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  121957. */
  121958. static readonly MODE_SIDEBYSIDE: number;
  121959. private _halfDome;
  121960. private _useDirectMapping;
  121961. /**
  121962. * The video texture being displayed on the sphere
  121963. */
  121964. protected _videoTexture: VideoTexture;
  121965. /**
  121966. * Gets the video texture being displayed on the sphere
  121967. */
  121968. get videoTexture(): VideoTexture;
  121969. /**
  121970. * The skybox material
  121971. */
  121972. protected _material: BackgroundMaterial;
  121973. /**
  121974. * The surface used for the skybox
  121975. */
  121976. protected _mesh: Mesh;
  121977. /**
  121978. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  121979. */
  121980. private _halfDomeMask;
  121981. /**
  121982. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  121983. * Also see the options.resolution property.
  121984. */
  121985. get fovMultiplier(): number;
  121986. set fovMultiplier(value: number);
  121987. private _videoMode;
  121988. /**
  121989. * Gets or set the current video mode for the video. It can be:
  121990. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  121991. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  121992. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  121993. */
  121994. get videoMode(): number;
  121995. set videoMode(value: number);
  121996. /**
  121997. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  121998. *
  121999. */
  122000. get halfDome(): boolean;
  122001. /**
  122002. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  122003. */
  122004. set halfDome(enabled: boolean);
  122005. /**
  122006. * Oberserver used in Stereoscopic VR Mode.
  122007. */
  122008. private _onBeforeCameraRenderObserver;
  122009. /**
  122010. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  122011. * @param name Element's name, child elements will append suffixes for their own names.
  122012. * @param urlsOrVideo defines the url(s) or the video element to use
  122013. * @param options An object containing optional or exposed sub element properties
  122014. */
  122015. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  122016. resolution?: number;
  122017. clickToPlay?: boolean;
  122018. autoPlay?: boolean;
  122019. loop?: boolean;
  122020. size?: number;
  122021. poster?: string;
  122022. faceForward?: boolean;
  122023. useDirectMapping?: boolean;
  122024. halfDomeMode?: boolean;
  122025. }, scene: Scene);
  122026. private _changeVideoMode;
  122027. /**
  122028. * Releases resources associated with this node.
  122029. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  122030. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  122031. */
  122032. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  122033. }
  122034. }
  122035. declare module BABYLON {
  122036. /**
  122037. * This class can be used to get instrumentation data from a Babylon engine
  122038. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  122039. */
  122040. export class EngineInstrumentation implements IDisposable {
  122041. /**
  122042. * Define the instrumented engine.
  122043. */
  122044. engine: Engine;
  122045. private _captureGPUFrameTime;
  122046. private _gpuFrameTimeToken;
  122047. private _gpuFrameTime;
  122048. private _captureShaderCompilationTime;
  122049. private _shaderCompilationTime;
  122050. private _onBeginFrameObserver;
  122051. private _onEndFrameObserver;
  122052. private _onBeforeShaderCompilationObserver;
  122053. private _onAfterShaderCompilationObserver;
  122054. /**
  122055. * Gets the perf counter used for GPU frame time
  122056. */
  122057. get gpuFrameTimeCounter(): PerfCounter;
  122058. /**
  122059. * Gets the GPU frame time capture status
  122060. */
  122061. get captureGPUFrameTime(): boolean;
  122062. /**
  122063. * Enable or disable the GPU frame time capture
  122064. */
  122065. set captureGPUFrameTime(value: boolean);
  122066. /**
  122067. * Gets the perf counter used for shader compilation time
  122068. */
  122069. get shaderCompilationTimeCounter(): PerfCounter;
  122070. /**
  122071. * Gets the shader compilation time capture status
  122072. */
  122073. get captureShaderCompilationTime(): boolean;
  122074. /**
  122075. * Enable or disable the shader compilation time capture
  122076. */
  122077. set captureShaderCompilationTime(value: boolean);
  122078. /**
  122079. * Instantiates a new engine instrumentation.
  122080. * This class can be used to get instrumentation data from a Babylon engine
  122081. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  122082. * @param engine Defines the engine to instrument
  122083. */
  122084. constructor(
  122085. /**
  122086. * Define the instrumented engine.
  122087. */
  122088. engine: Engine);
  122089. /**
  122090. * Dispose and release associated resources.
  122091. */
  122092. dispose(): void;
  122093. }
  122094. }
  122095. declare module BABYLON {
  122096. /**
  122097. * This class can be used to get instrumentation data from a Babylon engine
  122098. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  122099. */
  122100. export class SceneInstrumentation implements IDisposable {
  122101. /**
  122102. * Defines the scene to instrument
  122103. */
  122104. scene: Scene;
  122105. private _captureActiveMeshesEvaluationTime;
  122106. private _activeMeshesEvaluationTime;
  122107. private _captureRenderTargetsRenderTime;
  122108. private _renderTargetsRenderTime;
  122109. private _captureFrameTime;
  122110. private _frameTime;
  122111. private _captureRenderTime;
  122112. private _renderTime;
  122113. private _captureInterFrameTime;
  122114. private _interFrameTime;
  122115. private _captureParticlesRenderTime;
  122116. private _particlesRenderTime;
  122117. private _captureSpritesRenderTime;
  122118. private _spritesRenderTime;
  122119. private _capturePhysicsTime;
  122120. private _physicsTime;
  122121. private _captureAnimationsTime;
  122122. private _animationsTime;
  122123. private _captureCameraRenderTime;
  122124. private _cameraRenderTime;
  122125. private _onBeforeActiveMeshesEvaluationObserver;
  122126. private _onAfterActiveMeshesEvaluationObserver;
  122127. private _onBeforeRenderTargetsRenderObserver;
  122128. private _onAfterRenderTargetsRenderObserver;
  122129. private _onAfterRenderObserver;
  122130. private _onBeforeDrawPhaseObserver;
  122131. private _onAfterDrawPhaseObserver;
  122132. private _onBeforeAnimationsObserver;
  122133. private _onBeforeParticlesRenderingObserver;
  122134. private _onAfterParticlesRenderingObserver;
  122135. private _onBeforeSpritesRenderingObserver;
  122136. private _onAfterSpritesRenderingObserver;
  122137. private _onBeforePhysicsObserver;
  122138. private _onAfterPhysicsObserver;
  122139. private _onAfterAnimationsObserver;
  122140. private _onBeforeCameraRenderObserver;
  122141. private _onAfterCameraRenderObserver;
  122142. /**
  122143. * Gets the perf counter used for active meshes evaluation time
  122144. */
  122145. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  122146. /**
  122147. * Gets the active meshes evaluation time capture status
  122148. */
  122149. get captureActiveMeshesEvaluationTime(): boolean;
  122150. /**
  122151. * Enable or disable the active meshes evaluation time capture
  122152. */
  122153. set captureActiveMeshesEvaluationTime(value: boolean);
  122154. /**
  122155. * Gets the perf counter used for render targets render time
  122156. */
  122157. get renderTargetsRenderTimeCounter(): PerfCounter;
  122158. /**
  122159. * Gets the render targets render time capture status
  122160. */
  122161. get captureRenderTargetsRenderTime(): boolean;
  122162. /**
  122163. * Enable or disable the render targets render time capture
  122164. */
  122165. set captureRenderTargetsRenderTime(value: boolean);
  122166. /**
  122167. * Gets the perf counter used for particles render time
  122168. */
  122169. get particlesRenderTimeCounter(): PerfCounter;
  122170. /**
  122171. * Gets the particles render time capture status
  122172. */
  122173. get captureParticlesRenderTime(): boolean;
  122174. /**
  122175. * Enable or disable the particles render time capture
  122176. */
  122177. set captureParticlesRenderTime(value: boolean);
  122178. /**
  122179. * Gets the perf counter used for sprites render time
  122180. */
  122181. get spritesRenderTimeCounter(): PerfCounter;
  122182. /**
  122183. * Gets the sprites render time capture status
  122184. */
  122185. get captureSpritesRenderTime(): boolean;
  122186. /**
  122187. * Enable or disable the sprites render time capture
  122188. */
  122189. set captureSpritesRenderTime(value: boolean);
  122190. /**
  122191. * Gets the perf counter used for physics time
  122192. */
  122193. get physicsTimeCounter(): PerfCounter;
  122194. /**
  122195. * Gets the physics time capture status
  122196. */
  122197. get capturePhysicsTime(): boolean;
  122198. /**
  122199. * Enable or disable the physics time capture
  122200. */
  122201. set capturePhysicsTime(value: boolean);
  122202. /**
  122203. * Gets the perf counter used for animations time
  122204. */
  122205. get animationsTimeCounter(): PerfCounter;
  122206. /**
  122207. * Gets the animations time capture status
  122208. */
  122209. get captureAnimationsTime(): boolean;
  122210. /**
  122211. * Enable or disable the animations time capture
  122212. */
  122213. set captureAnimationsTime(value: boolean);
  122214. /**
  122215. * Gets the perf counter used for frame time capture
  122216. */
  122217. get frameTimeCounter(): PerfCounter;
  122218. /**
  122219. * Gets the frame time capture status
  122220. */
  122221. get captureFrameTime(): boolean;
  122222. /**
  122223. * Enable or disable the frame time capture
  122224. */
  122225. set captureFrameTime(value: boolean);
  122226. /**
  122227. * Gets the perf counter used for inter-frames time capture
  122228. */
  122229. get interFrameTimeCounter(): PerfCounter;
  122230. /**
  122231. * Gets the inter-frames time capture status
  122232. */
  122233. get captureInterFrameTime(): boolean;
  122234. /**
  122235. * Enable or disable the inter-frames time capture
  122236. */
  122237. set captureInterFrameTime(value: boolean);
  122238. /**
  122239. * Gets the perf counter used for render time capture
  122240. */
  122241. get renderTimeCounter(): PerfCounter;
  122242. /**
  122243. * Gets the render time capture status
  122244. */
  122245. get captureRenderTime(): boolean;
  122246. /**
  122247. * Enable or disable the render time capture
  122248. */
  122249. set captureRenderTime(value: boolean);
  122250. /**
  122251. * Gets the perf counter used for camera render time capture
  122252. */
  122253. get cameraRenderTimeCounter(): PerfCounter;
  122254. /**
  122255. * Gets the camera render time capture status
  122256. */
  122257. get captureCameraRenderTime(): boolean;
  122258. /**
  122259. * Enable or disable the camera render time capture
  122260. */
  122261. set captureCameraRenderTime(value: boolean);
  122262. /**
  122263. * Gets the perf counter used for draw calls
  122264. */
  122265. get drawCallsCounter(): PerfCounter;
  122266. /**
  122267. * Instantiates a new scene instrumentation.
  122268. * This class can be used to get instrumentation data from a Babylon engine
  122269. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  122270. * @param scene Defines the scene to instrument
  122271. */
  122272. constructor(
  122273. /**
  122274. * Defines the scene to instrument
  122275. */
  122276. scene: Scene);
  122277. /**
  122278. * Dispose and release associated resources.
  122279. */
  122280. dispose(): void;
  122281. }
  122282. }
  122283. declare module BABYLON {
  122284. /** @hidden */
  122285. export var glowMapGenerationPixelShader: {
  122286. name: string;
  122287. shader: string;
  122288. };
  122289. }
  122290. declare module BABYLON {
  122291. /** @hidden */
  122292. export var glowMapGenerationVertexShader: {
  122293. name: string;
  122294. shader: string;
  122295. };
  122296. }
  122297. declare module BABYLON {
  122298. /**
  122299. * Effect layer options. This helps customizing the behaviour
  122300. * of the effect layer.
  122301. */
  122302. export interface IEffectLayerOptions {
  122303. /**
  122304. * Multiplication factor apply to the canvas size to compute the render target size
  122305. * used to generated the objects (the smaller the faster).
  122306. */
  122307. mainTextureRatio: number;
  122308. /**
  122309. * Enforces a fixed size texture to ensure effect stability across devices.
  122310. */
  122311. mainTextureFixedSize?: number;
  122312. /**
  122313. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  122314. */
  122315. alphaBlendingMode: number;
  122316. /**
  122317. * The camera attached to the layer.
  122318. */
  122319. camera: Nullable<Camera>;
  122320. /**
  122321. * The rendering group to draw the layer in.
  122322. */
  122323. renderingGroupId: number;
  122324. }
  122325. /**
  122326. * The effect layer Helps adding post process effect blended with the main pass.
  122327. *
  122328. * This can be for instance use to generate glow or higlight effects on the scene.
  122329. *
  122330. * The effect layer class can not be used directly and is intented to inherited from to be
  122331. * customized per effects.
  122332. */
  122333. export abstract class EffectLayer {
  122334. private _vertexBuffers;
  122335. private _indexBuffer;
  122336. private _cachedDefines;
  122337. private _effectLayerMapGenerationEffect;
  122338. private _effectLayerOptions;
  122339. private _mergeEffect;
  122340. protected _scene: Scene;
  122341. protected _engine: Engine;
  122342. protected _maxSize: number;
  122343. protected _mainTextureDesiredSize: ISize;
  122344. protected _mainTexture: RenderTargetTexture;
  122345. protected _shouldRender: boolean;
  122346. protected _postProcesses: PostProcess[];
  122347. protected _textures: BaseTexture[];
  122348. protected _emissiveTextureAndColor: {
  122349. texture: Nullable<BaseTexture>;
  122350. color: Color4;
  122351. };
  122352. /**
  122353. * The name of the layer
  122354. */
  122355. name: string;
  122356. /**
  122357. * The clear color of the texture used to generate the glow map.
  122358. */
  122359. neutralColor: Color4;
  122360. /**
  122361. * Specifies wether the highlight layer is enabled or not.
  122362. */
  122363. isEnabled: boolean;
  122364. /**
  122365. * Gets the camera attached to the layer.
  122366. */
  122367. get camera(): Nullable<Camera>;
  122368. /**
  122369. * Gets the rendering group id the layer should render in.
  122370. */
  122371. get renderingGroupId(): number;
  122372. set renderingGroupId(renderingGroupId: number);
  122373. /**
  122374. * An event triggered when the effect layer has been disposed.
  122375. */
  122376. onDisposeObservable: Observable<EffectLayer>;
  122377. /**
  122378. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  122379. */
  122380. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  122381. /**
  122382. * An event triggered when the generated texture is being merged in the scene.
  122383. */
  122384. onBeforeComposeObservable: Observable<EffectLayer>;
  122385. /**
  122386. * An event triggered when the mesh is rendered into the effect render target.
  122387. */
  122388. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  122389. /**
  122390. * An event triggered after the mesh has been rendered into the effect render target.
  122391. */
  122392. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  122393. /**
  122394. * An event triggered when the generated texture has been merged in the scene.
  122395. */
  122396. onAfterComposeObservable: Observable<EffectLayer>;
  122397. /**
  122398. * An event triggered when the efffect layer changes its size.
  122399. */
  122400. onSizeChangedObservable: Observable<EffectLayer>;
  122401. /** @hidden */
  122402. static _SceneComponentInitialization: (scene: Scene) => void;
  122403. /**
  122404. * Instantiates a new effect Layer and references it in the scene.
  122405. * @param name The name of the layer
  122406. * @param scene The scene to use the layer in
  122407. */
  122408. constructor(
  122409. /** The Friendly of the effect in the scene */
  122410. name: string, scene: Scene);
  122411. /**
  122412. * Get the effect name of the layer.
  122413. * @return The effect name
  122414. */
  122415. abstract getEffectName(): string;
  122416. /**
  122417. * Checks for the readiness of the element composing the layer.
  122418. * @param subMesh the mesh to check for
  122419. * @param useInstances specify wether or not to use instances to render the mesh
  122420. * @return true if ready otherwise, false
  122421. */
  122422. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122423. /**
  122424. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  122425. * @returns true if the effect requires stencil during the main canvas render pass.
  122426. */
  122427. abstract needStencil(): boolean;
  122428. /**
  122429. * Create the merge effect. This is the shader use to blit the information back
  122430. * to the main canvas at the end of the scene rendering.
  122431. * @returns The effect containing the shader used to merge the effect on the main canvas
  122432. */
  122433. protected abstract _createMergeEffect(): Effect;
  122434. /**
  122435. * Creates the render target textures and post processes used in the effect layer.
  122436. */
  122437. protected abstract _createTextureAndPostProcesses(): void;
  122438. /**
  122439. * Implementation specific of rendering the generating effect on the main canvas.
  122440. * @param effect The effect used to render through
  122441. */
  122442. protected abstract _internalRender(effect: Effect): void;
  122443. /**
  122444. * Sets the required values for both the emissive texture and and the main color.
  122445. */
  122446. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  122447. /**
  122448. * Free any resources and references associated to a mesh.
  122449. * Internal use
  122450. * @param mesh The mesh to free.
  122451. */
  122452. abstract _disposeMesh(mesh: Mesh): void;
  122453. /**
  122454. * Serializes this layer (Glow or Highlight for example)
  122455. * @returns a serialized layer object
  122456. */
  122457. abstract serialize?(): any;
  122458. /**
  122459. * Initializes the effect layer with the required options.
  122460. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  122461. */
  122462. protected _init(options: Partial<IEffectLayerOptions>): void;
  122463. /**
  122464. * Generates the index buffer of the full screen quad blending to the main canvas.
  122465. */
  122466. private _generateIndexBuffer;
  122467. /**
  122468. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  122469. */
  122470. private _generateVertexBuffer;
  122471. /**
  122472. * Sets the main texture desired size which is the closest power of two
  122473. * of the engine canvas size.
  122474. */
  122475. private _setMainTextureSize;
  122476. /**
  122477. * Creates the main texture for the effect layer.
  122478. */
  122479. protected _createMainTexture(): void;
  122480. /**
  122481. * Adds specific effects defines.
  122482. * @param defines The defines to add specifics to.
  122483. */
  122484. protected _addCustomEffectDefines(defines: string[]): void;
  122485. /**
  122486. * Checks for the readiness of the element composing the layer.
  122487. * @param subMesh the mesh to check for
  122488. * @param useInstances specify wether or not to use instances to render the mesh
  122489. * @param emissiveTexture the associated emissive texture used to generate the glow
  122490. * @return true if ready otherwise, false
  122491. */
  122492. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  122493. /**
  122494. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  122495. */
  122496. render(): void;
  122497. /**
  122498. * Determine if a given mesh will be used in the current effect.
  122499. * @param mesh mesh to test
  122500. * @returns true if the mesh will be used
  122501. */
  122502. hasMesh(mesh: AbstractMesh): boolean;
  122503. /**
  122504. * Returns true if the layer contains information to display, otherwise false.
  122505. * @returns true if the glow layer should be rendered
  122506. */
  122507. shouldRender(): boolean;
  122508. /**
  122509. * Returns true if the mesh should render, otherwise false.
  122510. * @param mesh The mesh to render
  122511. * @returns true if it should render otherwise false
  122512. */
  122513. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  122514. /**
  122515. * Returns true if the mesh can be rendered, otherwise false.
  122516. * @param mesh The mesh to render
  122517. * @param material The material used on the mesh
  122518. * @returns true if it can be rendered otherwise false
  122519. */
  122520. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  122521. /**
  122522. * Returns true if the mesh should render, otherwise false.
  122523. * @param mesh The mesh to render
  122524. * @returns true if it should render otherwise false
  122525. */
  122526. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  122527. /**
  122528. * Renders the submesh passed in parameter to the generation map.
  122529. */
  122530. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  122531. /**
  122532. * Defines wether the current material of the mesh should be use to render the effect.
  122533. * @param mesh defines the current mesh to render
  122534. */
  122535. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  122536. /**
  122537. * Rebuild the required buffers.
  122538. * @hidden Internal use only.
  122539. */
  122540. _rebuild(): void;
  122541. /**
  122542. * Dispose only the render target textures and post process.
  122543. */
  122544. private _disposeTextureAndPostProcesses;
  122545. /**
  122546. * Dispose the highlight layer and free resources.
  122547. */
  122548. dispose(): void;
  122549. /**
  122550. * Gets the class name of the effect layer
  122551. * @returns the string with the class name of the effect layer
  122552. */
  122553. getClassName(): string;
  122554. /**
  122555. * Creates an effect layer from parsed effect layer data
  122556. * @param parsedEffectLayer defines effect layer data
  122557. * @param scene defines the current scene
  122558. * @param rootUrl defines the root URL containing the effect layer information
  122559. * @returns a parsed effect Layer
  122560. */
  122561. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  122562. }
  122563. }
  122564. declare module BABYLON {
  122565. interface AbstractScene {
  122566. /**
  122567. * The list of effect layers (highlights/glow) added to the scene
  122568. * @see http://doc.babylonjs.com/how_to/highlight_layer
  122569. * @see http://doc.babylonjs.com/how_to/glow_layer
  122570. */
  122571. effectLayers: Array<EffectLayer>;
  122572. /**
  122573. * Removes the given effect layer from this scene.
  122574. * @param toRemove defines the effect layer to remove
  122575. * @returns the index of the removed effect layer
  122576. */
  122577. removeEffectLayer(toRemove: EffectLayer): number;
  122578. /**
  122579. * Adds the given effect layer to this scene
  122580. * @param newEffectLayer defines the effect layer to add
  122581. */
  122582. addEffectLayer(newEffectLayer: EffectLayer): void;
  122583. }
  122584. /**
  122585. * Defines the layer scene component responsible to manage any effect layers
  122586. * in a given scene.
  122587. */
  122588. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  122589. /**
  122590. * The component name helpfull to identify the component in the list of scene components.
  122591. */
  122592. readonly name: string;
  122593. /**
  122594. * The scene the component belongs to.
  122595. */
  122596. scene: Scene;
  122597. private _engine;
  122598. private _renderEffects;
  122599. private _needStencil;
  122600. private _previousStencilState;
  122601. /**
  122602. * Creates a new instance of the component for the given scene
  122603. * @param scene Defines the scene to register the component in
  122604. */
  122605. constructor(scene: Scene);
  122606. /**
  122607. * Registers the component in a given scene
  122608. */
  122609. register(): void;
  122610. /**
  122611. * Rebuilds the elements related to this component in case of
  122612. * context lost for instance.
  122613. */
  122614. rebuild(): void;
  122615. /**
  122616. * Serializes the component data to the specified json object
  122617. * @param serializationObject The object to serialize to
  122618. */
  122619. serialize(serializationObject: any): void;
  122620. /**
  122621. * Adds all the elements from the container to the scene
  122622. * @param container the container holding the elements
  122623. */
  122624. addFromContainer(container: AbstractScene): void;
  122625. /**
  122626. * Removes all the elements in the container from the scene
  122627. * @param container contains the elements to remove
  122628. * @param dispose if the removed element should be disposed (default: false)
  122629. */
  122630. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  122631. /**
  122632. * Disposes the component and the associated ressources.
  122633. */
  122634. dispose(): void;
  122635. private _isReadyForMesh;
  122636. private _renderMainTexture;
  122637. private _setStencil;
  122638. private _setStencilBack;
  122639. private _draw;
  122640. private _drawCamera;
  122641. private _drawRenderingGroup;
  122642. }
  122643. }
  122644. declare module BABYLON {
  122645. /** @hidden */
  122646. export var glowMapMergePixelShader: {
  122647. name: string;
  122648. shader: string;
  122649. };
  122650. }
  122651. declare module BABYLON {
  122652. /** @hidden */
  122653. export var glowMapMergeVertexShader: {
  122654. name: string;
  122655. shader: string;
  122656. };
  122657. }
  122658. declare module BABYLON {
  122659. interface AbstractScene {
  122660. /**
  122661. * Return a the first highlight layer of the scene with a given name.
  122662. * @param name The name of the highlight layer to look for.
  122663. * @return The highlight layer if found otherwise null.
  122664. */
  122665. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  122666. }
  122667. /**
  122668. * Glow layer options. This helps customizing the behaviour
  122669. * of the glow layer.
  122670. */
  122671. export interface IGlowLayerOptions {
  122672. /**
  122673. * Multiplication factor apply to the canvas size to compute the render target size
  122674. * used to generated the glowing objects (the smaller the faster).
  122675. */
  122676. mainTextureRatio: number;
  122677. /**
  122678. * Enforces a fixed size texture to ensure resize independant blur.
  122679. */
  122680. mainTextureFixedSize?: number;
  122681. /**
  122682. * How big is the kernel of the blur texture.
  122683. */
  122684. blurKernelSize: number;
  122685. /**
  122686. * The camera attached to the layer.
  122687. */
  122688. camera: Nullable<Camera>;
  122689. /**
  122690. * Enable MSAA by chosing the number of samples.
  122691. */
  122692. mainTextureSamples?: number;
  122693. /**
  122694. * The rendering group to draw the layer in.
  122695. */
  122696. renderingGroupId: number;
  122697. }
  122698. /**
  122699. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  122700. *
  122701. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  122702. *
  122703. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  122704. */
  122705. export class GlowLayer extends EffectLayer {
  122706. /**
  122707. * Effect Name of the layer.
  122708. */
  122709. static readonly EffectName: string;
  122710. /**
  122711. * The default blur kernel size used for the glow.
  122712. */
  122713. static DefaultBlurKernelSize: number;
  122714. /**
  122715. * The default texture size ratio used for the glow.
  122716. */
  122717. static DefaultTextureRatio: number;
  122718. /**
  122719. * Sets the kernel size of the blur.
  122720. */
  122721. set blurKernelSize(value: number);
  122722. /**
  122723. * Gets the kernel size of the blur.
  122724. */
  122725. get blurKernelSize(): number;
  122726. /**
  122727. * Sets the glow intensity.
  122728. */
  122729. set intensity(value: number);
  122730. /**
  122731. * Gets the glow intensity.
  122732. */
  122733. get intensity(): number;
  122734. private _options;
  122735. private _intensity;
  122736. private _horizontalBlurPostprocess1;
  122737. private _verticalBlurPostprocess1;
  122738. private _horizontalBlurPostprocess2;
  122739. private _verticalBlurPostprocess2;
  122740. private _blurTexture1;
  122741. private _blurTexture2;
  122742. private _postProcesses1;
  122743. private _postProcesses2;
  122744. private _includedOnlyMeshes;
  122745. private _excludedMeshes;
  122746. private _meshesUsingTheirOwnMaterials;
  122747. /**
  122748. * Callback used to let the user override the color selection on a per mesh basis
  122749. */
  122750. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  122751. /**
  122752. * Callback used to let the user override the texture selection on a per mesh basis
  122753. */
  122754. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  122755. /**
  122756. * Instantiates a new glow Layer and references it to the scene.
  122757. * @param name The name of the layer
  122758. * @param scene The scene to use the layer in
  122759. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  122760. */
  122761. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  122762. /**
  122763. * Get the effect name of the layer.
  122764. * @return The effect name
  122765. */
  122766. getEffectName(): string;
  122767. /**
  122768. * Create the merge effect. This is the shader use to blit the information back
  122769. * to the main canvas at the end of the scene rendering.
  122770. */
  122771. protected _createMergeEffect(): Effect;
  122772. /**
  122773. * Creates the render target textures and post processes used in the glow layer.
  122774. */
  122775. protected _createTextureAndPostProcesses(): void;
  122776. /**
  122777. * Checks for the readiness of the element composing the layer.
  122778. * @param subMesh the mesh to check for
  122779. * @param useInstances specify wether or not to use instances to render the mesh
  122780. * @param emissiveTexture the associated emissive texture used to generate the glow
  122781. * @return true if ready otherwise, false
  122782. */
  122783. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122784. /**
  122785. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  122786. */
  122787. needStencil(): boolean;
  122788. /**
  122789. * Returns true if the mesh can be rendered, otherwise false.
  122790. * @param mesh The mesh to render
  122791. * @param material The material used on the mesh
  122792. * @returns true if it can be rendered otherwise false
  122793. */
  122794. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  122795. /**
  122796. * Implementation specific of rendering the generating effect on the main canvas.
  122797. * @param effect The effect used to render through
  122798. */
  122799. protected _internalRender(effect: Effect): void;
  122800. /**
  122801. * Sets the required values for both the emissive texture and and the main color.
  122802. */
  122803. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  122804. /**
  122805. * Returns true if the mesh should render, otherwise false.
  122806. * @param mesh The mesh to render
  122807. * @returns true if it should render otherwise false
  122808. */
  122809. protected _shouldRenderMesh(mesh: Mesh): boolean;
  122810. /**
  122811. * Adds specific effects defines.
  122812. * @param defines The defines to add specifics to.
  122813. */
  122814. protected _addCustomEffectDefines(defines: string[]): void;
  122815. /**
  122816. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  122817. * @param mesh The mesh to exclude from the glow layer
  122818. */
  122819. addExcludedMesh(mesh: Mesh): void;
  122820. /**
  122821. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  122822. * @param mesh The mesh to remove
  122823. */
  122824. removeExcludedMesh(mesh: Mesh): void;
  122825. /**
  122826. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  122827. * @param mesh The mesh to include in the glow layer
  122828. */
  122829. addIncludedOnlyMesh(mesh: Mesh): void;
  122830. /**
  122831. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  122832. * @param mesh The mesh to remove
  122833. */
  122834. removeIncludedOnlyMesh(mesh: Mesh): void;
  122835. /**
  122836. * Determine if a given mesh will be used in the glow layer
  122837. * @param mesh The mesh to test
  122838. * @returns true if the mesh will be highlighted by the current glow layer
  122839. */
  122840. hasMesh(mesh: AbstractMesh): boolean;
  122841. /**
  122842. * Defines wether the current material of the mesh should be use to render the effect.
  122843. * @param mesh defines the current mesh to render
  122844. */
  122845. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  122846. /**
  122847. * Add a mesh to be rendered through its own material and not with emissive only.
  122848. * @param mesh The mesh for which we need to use its material
  122849. */
  122850. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  122851. /**
  122852. * Remove a mesh from being rendered through its own material and not with emissive only.
  122853. * @param mesh The mesh for which we need to not use its material
  122854. */
  122855. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  122856. /**
  122857. * Free any resources and references associated to a mesh.
  122858. * Internal use
  122859. * @param mesh The mesh to free.
  122860. * @hidden
  122861. */
  122862. _disposeMesh(mesh: Mesh): void;
  122863. /**
  122864. * Gets the class name of the effect layer
  122865. * @returns the string with the class name of the effect layer
  122866. */
  122867. getClassName(): string;
  122868. /**
  122869. * Serializes this glow layer
  122870. * @returns a serialized glow layer object
  122871. */
  122872. serialize(): any;
  122873. /**
  122874. * Creates a Glow Layer from parsed glow layer data
  122875. * @param parsedGlowLayer defines glow layer data
  122876. * @param scene defines the current scene
  122877. * @param rootUrl defines the root URL containing the glow layer information
  122878. * @returns a parsed Glow Layer
  122879. */
  122880. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  122881. }
  122882. }
  122883. declare module BABYLON {
  122884. /** @hidden */
  122885. export var glowBlurPostProcessPixelShader: {
  122886. name: string;
  122887. shader: string;
  122888. };
  122889. }
  122890. declare module BABYLON {
  122891. interface AbstractScene {
  122892. /**
  122893. * Return a the first highlight layer of the scene with a given name.
  122894. * @param name The name of the highlight layer to look for.
  122895. * @return The highlight layer if found otherwise null.
  122896. */
  122897. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  122898. }
  122899. /**
  122900. * Highlight layer options. This helps customizing the behaviour
  122901. * of the highlight layer.
  122902. */
  122903. export interface IHighlightLayerOptions {
  122904. /**
  122905. * Multiplication factor apply to the canvas size to compute the render target size
  122906. * used to generated the glowing objects (the smaller the faster).
  122907. */
  122908. mainTextureRatio: number;
  122909. /**
  122910. * Enforces a fixed size texture to ensure resize independant blur.
  122911. */
  122912. mainTextureFixedSize?: number;
  122913. /**
  122914. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  122915. * of the picture to blur (the smaller the faster).
  122916. */
  122917. blurTextureSizeRatio: number;
  122918. /**
  122919. * How big in texel of the blur texture is the vertical blur.
  122920. */
  122921. blurVerticalSize: number;
  122922. /**
  122923. * How big in texel of the blur texture is the horizontal blur.
  122924. */
  122925. blurHorizontalSize: number;
  122926. /**
  122927. * Alpha blending mode used to apply the blur. Default is combine.
  122928. */
  122929. alphaBlendingMode: number;
  122930. /**
  122931. * The camera attached to the layer.
  122932. */
  122933. camera: Nullable<Camera>;
  122934. /**
  122935. * Should we display highlight as a solid stroke?
  122936. */
  122937. isStroke?: boolean;
  122938. /**
  122939. * The rendering group to draw the layer in.
  122940. */
  122941. renderingGroupId: number;
  122942. }
  122943. /**
  122944. * The highlight layer Helps adding a glow effect around a mesh.
  122945. *
  122946. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  122947. * glowy meshes to your scene.
  122948. *
  122949. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  122950. */
  122951. export class HighlightLayer extends EffectLayer {
  122952. name: string;
  122953. /**
  122954. * Effect Name of the highlight layer.
  122955. */
  122956. static readonly EffectName: string;
  122957. /**
  122958. * The neutral color used during the preparation of the glow effect.
  122959. * This is black by default as the blend operation is a blend operation.
  122960. */
  122961. static NeutralColor: Color4;
  122962. /**
  122963. * Stencil value used for glowing meshes.
  122964. */
  122965. static GlowingMeshStencilReference: number;
  122966. /**
  122967. * Stencil value used for the other meshes in the scene.
  122968. */
  122969. static NormalMeshStencilReference: number;
  122970. /**
  122971. * Specifies whether or not the inner glow is ACTIVE in the layer.
  122972. */
  122973. innerGlow: boolean;
  122974. /**
  122975. * Specifies whether or not the outer glow is ACTIVE in the layer.
  122976. */
  122977. outerGlow: boolean;
  122978. /**
  122979. * Specifies the horizontal size of the blur.
  122980. */
  122981. set blurHorizontalSize(value: number);
  122982. /**
  122983. * Specifies the vertical size of the blur.
  122984. */
  122985. set blurVerticalSize(value: number);
  122986. /**
  122987. * Gets the horizontal size of the blur.
  122988. */
  122989. get blurHorizontalSize(): number;
  122990. /**
  122991. * Gets the vertical size of the blur.
  122992. */
  122993. get blurVerticalSize(): number;
  122994. /**
  122995. * An event triggered when the highlight layer is being blurred.
  122996. */
  122997. onBeforeBlurObservable: Observable<HighlightLayer>;
  122998. /**
  122999. * An event triggered when the highlight layer has been blurred.
  123000. */
  123001. onAfterBlurObservable: Observable<HighlightLayer>;
  123002. private _instanceGlowingMeshStencilReference;
  123003. private _options;
  123004. private _downSamplePostprocess;
  123005. private _horizontalBlurPostprocess;
  123006. private _verticalBlurPostprocess;
  123007. private _blurTexture;
  123008. private _meshes;
  123009. private _excludedMeshes;
  123010. /**
  123011. * Instantiates a new highlight Layer and references it to the scene..
  123012. * @param name The name of the layer
  123013. * @param scene The scene to use the layer in
  123014. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  123015. */
  123016. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  123017. /**
  123018. * Get the effect name of the layer.
  123019. * @return The effect name
  123020. */
  123021. getEffectName(): string;
  123022. /**
  123023. * Create the merge effect. This is the shader use to blit the information back
  123024. * to the main canvas at the end of the scene rendering.
  123025. */
  123026. protected _createMergeEffect(): Effect;
  123027. /**
  123028. * Creates the render target textures and post processes used in the highlight layer.
  123029. */
  123030. protected _createTextureAndPostProcesses(): void;
  123031. /**
  123032. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  123033. */
  123034. needStencil(): boolean;
  123035. /**
  123036. * Checks for the readiness of the element composing the layer.
  123037. * @param subMesh the mesh to check for
  123038. * @param useInstances specify wether or not to use instances to render the mesh
  123039. * @param emissiveTexture the associated emissive texture used to generate the glow
  123040. * @return true if ready otherwise, false
  123041. */
  123042. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  123043. /**
  123044. * Implementation specific of rendering the generating effect on the main canvas.
  123045. * @param effect The effect used to render through
  123046. */
  123047. protected _internalRender(effect: Effect): void;
  123048. /**
  123049. * Returns true if the layer contains information to display, otherwise false.
  123050. */
  123051. shouldRender(): boolean;
  123052. /**
  123053. * Returns true if the mesh should render, otherwise false.
  123054. * @param mesh The mesh to render
  123055. * @returns true if it should render otherwise false
  123056. */
  123057. protected _shouldRenderMesh(mesh: Mesh): boolean;
  123058. /**
  123059. * Sets the required values for both the emissive texture and and the main color.
  123060. */
  123061. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  123062. /**
  123063. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  123064. * @param mesh The mesh to exclude from the highlight layer
  123065. */
  123066. addExcludedMesh(mesh: Mesh): void;
  123067. /**
  123068. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  123069. * @param mesh The mesh to highlight
  123070. */
  123071. removeExcludedMesh(mesh: Mesh): void;
  123072. /**
  123073. * Determine if a given mesh will be highlighted by the current HighlightLayer
  123074. * @param mesh mesh to test
  123075. * @returns true if the mesh will be highlighted by the current HighlightLayer
  123076. */
  123077. hasMesh(mesh: AbstractMesh): boolean;
  123078. /**
  123079. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  123080. * @param mesh The mesh to highlight
  123081. * @param color The color of the highlight
  123082. * @param glowEmissiveOnly Extract the glow from the emissive texture
  123083. */
  123084. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  123085. /**
  123086. * Remove a mesh from the highlight layer in order to make it stop glowing.
  123087. * @param mesh The mesh to highlight
  123088. */
  123089. removeMesh(mesh: Mesh): void;
  123090. /**
  123091. * Force the stencil to the normal expected value for none glowing parts
  123092. */
  123093. private _defaultStencilReference;
  123094. /**
  123095. * Free any resources and references associated to a mesh.
  123096. * Internal use
  123097. * @param mesh The mesh to free.
  123098. * @hidden
  123099. */
  123100. _disposeMesh(mesh: Mesh): void;
  123101. /**
  123102. * Dispose the highlight layer and free resources.
  123103. */
  123104. dispose(): void;
  123105. /**
  123106. * Gets the class name of the effect layer
  123107. * @returns the string with the class name of the effect layer
  123108. */
  123109. getClassName(): string;
  123110. /**
  123111. * Serializes this Highlight layer
  123112. * @returns a serialized Highlight layer object
  123113. */
  123114. serialize(): any;
  123115. /**
  123116. * Creates a Highlight layer from parsed Highlight layer data
  123117. * @param parsedHightlightLayer defines the Highlight layer data
  123118. * @param scene defines the current scene
  123119. * @param rootUrl defines the root URL containing the Highlight layer information
  123120. * @returns a parsed Highlight layer
  123121. */
  123122. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  123123. }
  123124. }
  123125. declare module BABYLON {
  123126. interface AbstractScene {
  123127. /**
  123128. * The list of layers (background and foreground) of the scene
  123129. */
  123130. layers: Array<Layer>;
  123131. }
  123132. /**
  123133. * Defines the layer scene component responsible to manage any layers
  123134. * in a given scene.
  123135. */
  123136. export class LayerSceneComponent implements ISceneComponent {
  123137. /**
  123138. * The component name helpfull to identify the component in the list of scene components.
  123139. */
  123140. readonly name: string;
  123141. /**
  123142. * The scene the component belongs to.
  123143. */
  123144. scene: Scene;
  123145. private _engine;
  123146. /**
  123147. * Creates a new instance of the component for the given scene
  123148. * @param scene Defines the scene to register the component in
  123149. */
  123150. constructor(scene: Scene);
  123151. /**
  123152. * Registers the component in a given scene
  123153. */
  123154. register(): void;
  123155. /**
  123156. * Rebuilds the elements related to this component in case of
  123157. * context lost for instance.
  123158. */
  123159. rebuild(): void;
  123160. /**
  123161. * Disposes the component and the associated ressources.
  123162. */
  123163. dispose(): void;
  123164. private _draw;
  123165. private _drawCameraPredicate;
  123166. private _drawCameraBackground;
  123167. private _drawCameraForeground;
  123168. private _drawRenderTargetPredicate;
  123169. private _drawRenderTargetBackground;
  123170. private _drawRenderTargetForeground;
  123171. /**
  123172. * Adds all the elements from the container to the scene
  123173. * @param container the container holding the elements
  123174. */
  123175. addFromContainer(container: AbstractScene): void;
  123176. /**
  123177. * Removes all the elements in the container from the scene
  123178. * @param container contains the elements to remove
  123179. * @param dispose if the removed element should be disposed (default: false)
  123180. */
  123181. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  123182. }
  123183. }
  123184. declare module BABYLON {
  123185. /** @hidden */
  123186. export var layerPixelShader: {
  123187. name: string;
  123188. shader: string;
  123189. };
  123190. }
  123191. declare module BABYLON {
  123192. /** @hidden */
  123193. export var layerVertexShader: {
  123194. name: string;
  123195. shader: string;
  123196. };
  123197. }
  123198. declare module BABYLON {
  123199. /**
  123200. * This represents a full screen 2d layer.
  123201. * This can be useful to display a picture in the background of your scene for instance.
  123202. * @see https://www.babylonjs-playground.com/#08A2BS#1
  123203. */
  123204. export class Layer {
  123205. /**
  123206. * Define the name of the layer.
  123207. */
  123208. name: string;
  123209. /**
  123210. * Define the texture the layer should display.
  123211. */
  123212. texture: Nullable<Texture>;
  123213. /**
  123214. * Is the layer in background or foreground.
  123215. */
  123216. isBackground: boolean;
  123217. /**
  123218. * Define the color of the layer (instead of texture).
  123219. */
  123220. color: Color4;
  123221. /**
  123222. * Define the scale of the layer in order to zoom in out of the texture.
  123223. */
  123224. scale: Vector2;
  123225. /**
  123226. * Define an offset for the layer in order to shift the texture.
  123227. */
  123228. offset: Vector2;
  123229. /**
  123230. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  123231. */
  123232. alphaBlendingMode: number;
  123233. /**
  123234. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  123235. * Alpha test will not mix with the background color in case of transparency.
  123236. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  123237. */
  123238. alphaTest: boolean;
  123239. /**
  123240. * Define a mask to restrict the layer to only some of the scene cameras.
  123241. */
  123242. layerMask: number;
  123243. /**
  123244. * Define the list of render target the layer is visible into.
  123245. */
  123246. renderTargetTextures: RenderTargetTexture[];
  123247. /**
  123248. * Define if the layer is only used in renderTarget or if it also
  123249. * renders in the main frame buffer of the canvas.
  123250. */
  123251. renderOnlyInRenderTargetTextures: boolean;
  123252. private _scene;
  123253. private _vertexBuffers;
  123254. private _indexBuffer;
  123255. private _effect;
  123256. private _previousDefines;
  123257. /**
  123258. * An event triggered when the layer is disposed.
  123259. */
  123260. onDisposeObservable: Observable<Layer>;
  123261. private _onDisposeObserver;
  123262. /**
  123263. * Back compatibility with callback before the onDisposeObservable existed.
  123264. * The set callback will be triggered when the layer has been disposed.
  123265. */
  123266. set onDispose(callback: () => void);
  123267. /**
  123268. * An event triggered before rendering the scene
  123269. */
  123270. onBeforeRenderObservable: Observable<Layer>;
  123271. private _onBeforeRenderObserver;
  123272. /**
  123273. * Back compatibility with callback before the onBeforeRenderObservable existed.
  123274. * The set callback will be triggered just before rendering the layer.
  123275. */
  123276. set onBeforeRender(callback: () => void);
  123277. /**
  123278. * An event triggered after rendering the scene
  123279. */
  123280. onAfterRenderObservable: Observable<Layer>;
  123281. private _onAfterRenderObserver;
  123282. /**
  123283. * Back compatibility with callback before the onAfterRenderObservable existed.
  123284. * The set callback will be triggered just after rendering the layer.
  123285. */
  123286. set onAfterRender(callback: () => void);
  123287. /**
  123288. * Instantiates a new layer.
  123289. * This represents a full screen 2d layer.
  123290. * This can be useful to display a picture in the background of your scene for instance.
  123291. * @see https://www.babylonjs-playground.com/#08A2BS#1
  123292. * @param name Define the name of the layer in the scene
  123293. * @param imgUrl Define the url of the texture to display in the layer
  123294. * @param scene Define the scene the layer belongs to
  123295. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  123296. * @param color Defines a color for the layer
  123297. */
  123298. constructor(
  123299. /**
  123300. * Define the name of the layer.
  123301. */
  123302. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  123303. private _createIndexBuffer;
  123304. /** @hidden */
  123305. _rebuild(): void;
  123306. /**
  123307. * Renders the layer in the scene.
  123308. */
  123309. render(): void;
  123310. /**
  123311. * Disposes and releases the associated ressources.
  123312. */
  123313. dispose(): void;
  123314. }
  123315. }
  123316. declare module BABYLON {
  123317. /** @hidden */
  123318. export var lensFlarePixelShader: {
  123319. name: string;
  123320. shader: string;
  123321. };
  123322. }
  123323. declare module BABYLON {
  123324. /** @hidden */
  123325. export var lensFlareVertexShader: {
  123326. name: string;
  123327. shader: string;
  123328. };
  123329. }
  123330. declare module BABYLON {
  123331. /**
  123332. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  123333. * It is usually composed of several `lensFlare`.
  123334. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123335. */
  123336. export class LensFlareSystem {
  123337. /**
  123338. * Define the name of the lens flare system
  123339. */
  123340. name: string;
  123341. /**
  123342. * List of lens flares used in this system.
  123343. */
  123344. lensFlares: LensFlare[];
  123345. /**
  123346. * Define a limit from the border the lens flare can be visible.
  123347. */
  123348. borderLimit: number;
  123349. /**
  123350. * Define a viewport border we do not want to see the lens flare in.
  123351. */
  123352. viewportBorder: number;
  123353. /**
  123354. * Define a predicate which could limit the list of meshes able to occlude the effect.
  123355. */
  123356. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  123357. /**
  123358. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  123359. */
  123360. layerMask: number;
  123361. /**
  123362. * Define the id of the lens flare system in the scene.
  123363. * (equal to name by default)
  123364. */
  123365. id: string;
  123366. private _scene;
  123367. private _emitter;
  123368. private _vertexBuffers;
  123369. private _indexBuffer;
  123370. private _effect;
  123371. private _positionX;
  123372. private _positionY;
  123373. private _isEnabled;
  123374. /** @hidden */
  123375. static _SceneComponentInitialization: (scene: Scene) => void;
  123376. /**
  123377. * Instantiates a lens flare system.
  123378. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  123379. * It is usually composed of several `lensFlare`.
  123380. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123381. * @param name Define the name of the lens flare system in the scene
  123382. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  123383. * @param scene Define the scene the lens flare system belongs to
  123384. */
  123385. constructor(
  123386. /**
  123387. * Define the name of the lens flare system
  123388. */
  123389. name: string, emitter: any, scene: Scene);
  123390. /**
  123391. * Define if the lens flare system is enabled.
  123392. */
  123393. get isEnabled(): boolean;
  123394. set isEnabled(value: boolean);
  123395. /**
  123396. * Get the scene the effects belongs to.
  123397. * @returns the scene holding the lens flare system
  123398. */
  123399. getScene(): Scene;
  123400. /**
  123401. * Get the emitter of the lens flare system.
  123402. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  123403. * @returns the emitter of the lens flare system
  123404. */
  123405. getEmitter(): any;
  123406. /**
  123407. * Set the emitter of the lens flare system.
  123408. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  123409. * @param newEmitter Define the new emitter of the system
  123410. */
  123411. setEmitter(newEmitter: any): void;
  123412. /**
  123413. * Get the lens flare system emitter position.
  123414. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  123415. * @returns the position
  123416. */
  123417. getEmitterPosition(): Vector3;
  123418. /**
  123419. * @hidden
  123420. */
  123421. computeEffectivePosition(globalViewport: Viewport): boolean;
  123422. /** @hidden */
  123423. _isVisible(): boolean;
  123424. /**
  123425. * @hidden
  123426. */
  123427. render(): boolean;
  123428. /**
  123429. * Dispose and release the lens flare with its associated resources.
  123430. */
  123431. dispose(): void;
  123432. /**
  123433. * Parse a lens flare system from a JSON repressentation
  123434. * @param parsedLensFlareSystem Define the JSON to parse
  123435. * @param scene Define the scene the parsed system should be instantiated in
  123436. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  123437. * @returns the parsed system
  123438. */
  123439. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  123440. /**
  123441. * Serialize the current Lens Flare System into a JSON representation.
  123442. * @returns the serialized JSON
  123443. */
  123444. serialize(): any;
  123445. }
  123446. }
  123447. declare module BABYLON {
  123448. /**
  123449. * This represents one of the lens effect in a `lensFlareSystem`.
  123450. * It controls one of the indiviual texture used in the effect.
  123451. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123452. */
  123453. export class LensFlare {
  123454. /**
  123455. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  123456. */
  123457. size: number;
  123458. /**
  123459. * 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.
  123460. */
  123461. position: number;
  123462. /**
  123463. * Define the lens color.
  123464. */
  123465. color: Color3;
  123466. /**
  123467. * Define the lens texture.
  123468. */
  123469. texture: Nullable<Texture>;
  123470. /**
  123471. * Define the alpha mode to render this particular lens.
  123472. */
  123473. alphaMode: number;
  123474. private _system;
  123475. /**
  123476. * Creates a new Lens Flare.
  123477. * This represents one of the lens effect in a `lensFlareSystem`.
  123478. * It controls one of the indiviual texture used in the effect.
  123479. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123480. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  123481. * @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.
  123482. * @param color Define the lens color
  123483. * @param imgUrl Define the lens texture url
  123484. * @param system Define the `lensFlareSystem` this flare is part of
  123485. * @returns The newly created Lens Flare
  123486. */
  123487. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  123488. /**
  123489. * Instantiates a new Lens Flare.
  123490. * This represents one of the lens effect in a `lensFlareSystem`.
  123491. * It controls one of the indiviual texture used in the effect.
  123492. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123493. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  123494. * @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.
  123495. * @param color Define the lens color
  123496. * @param imgUrl Define the lens texture url
  123497. * @param system Define the `lensFlareSystem` this flare is part of
  123498. */
  123499. constructor(
  123500. /**
  123501. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  123502. */
  123503. size: number,
  123504. /**
  123505. * 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.
  123506. */
  123507. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  123508. /**
  123509. * Dispose and release the lens flare with its associated resources.
  123510. */
  123511. dispose(): void;
  123512. }
  123513. }
  123514. declare module BABYLON {
  123515. interface AbstractScene {
  123516. /**
  123517. * The list of lens flare system added to the scene
  123518. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  123519. */
  123520. lensFlareSystems: Array<LensFlareSystem>;
  123521. /**
  123522. * Removes the given lens flare system from this scene.
  123523. * @param toRemove The lens flare system to remove
  123524. * @returns The index of the removed lens flare system
  123525. */
  123526. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  123527. /**
  123528. * Adds the given lens flare system to this scene
  123529. * @param newLensFlareSystem The lens flare system to add
  123530. */
  123531. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  123532. /**
  123533. * Gets a lens flare system using its name
  123534. * @param name defines the name to look for
  123535. * @returns the lens flare system or null if not found
  123536. */
  123537. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  123538. /**
  123539. * Gets a lens flare system using its id
  123540. * @param id defines the id to look for
  123541. * @returns the lens flare system or null if not found
  123542. */
  123543. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  123544. }
  123545. /**
  123546. * Defines the lens flare scene component responsible to manage any lens flares
  123547. * in a given scene.
  123548. */
  123549. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  123550. /**
  123551. * The component name helpfull to identify the component in the list of scene components.
  123552. */
  123553. readonly name: string;
  123554. /**
  123555. * The scene the component belongs to.
  123556. */
  123557. scene: Scene;
  123558. /**
  123559. * Creates a new instance of the component for the given scene
  123560. * @param scene Defines the scene to register the component in
  123561. */
  123562. constructor(scene: Scene);
  123563. /**
  123564. * Registers the component in a given scene
  123565. */
  123566. register(): void;
  123567. /**
  123568. * Rebuilds the elements related to this component in case of
  123569. * context lost for instance.
  123570. */
  123571. rebuild(): void;
  123572. /**
  123573. * Adds all the elements from the container to the scene
  123574. * @param container the container holding the elements
  123575. */
  123576. addFromContainer(container: AbstractScene): void;
  123577. /**
  123578. * Removes all the elements in the container from the scene
  123579. * @param container contains the elements to remove
  123580. * @param dispose if the removed element should be disposed (default: false)
  123581. */
  123582. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  123583. /**
  123584. * Serializes the component data to the specified json object
  123585. * @param serializationObject The object to serialize to
  123586. */
  123587. serialize(serializationObject: any): void;
  123588. /**
  123589. * Disposes the component and the associated ressources.
  123590. */
  123591. dispose(): void;
  123592. private _draw;
  123593. }
  123594. }
  123595. declare module BABYLON {
  123596. /**
  123597. * Defines the shadow generator component responsible to manage any shadow generators
  123598. * in a given scene.
  123599. */
  123600. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  123601. /**
  123602. * The component name helpfull to identify the component in the list of scene components.
  123603. */
  123604. readonly name: string;
  123605. /**
  123606. * The scene the component belongs to.
  123607. */
  123608. scene: Scene;
  123609. /**
  123610. * Creates a new instance of the component for the given scene
  123611. * @param scene Defines the scene to register the component in
  123612. */
  123613. constructor(scene: Scene);
  123614. /**
  123615. * Registers the component in a given scene
  123616. */
  123617. register(): void;
  123618. /**
  123619. * Rebuilds the elements related to this component in case of
  123620. * context lost for instance.
  123621. */
  123622. rebuild(): void;
  123623. /**
  123624. * Serializes the component data to the specified json object
  123625. * @param serializationObject The object to serialize to
  123626. */
  123627. serialize(serializationObject: any): void;
  123628. /**
  123629. * Adds all the elements from the container to the scene
  123630. * @param container the container holding the elements
  123631. */
  123632. addFromContainer(container: AbstractScene): void;
  123633. /**
  123634. * Removes all the elements in the container from the scene
  123635. * @param container contains the elements to remove
  123636. * @param dispose if the removed element should be disposed (default: false)
  123637. */
  123638. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  123639. /**
  123640. * Rebuilds the elements related to this component in case of
  123641. * context lost for instance.
  123642. */
  123643. dispose(): void;
  123644. private _gatherRenderTargets;
  123645. }
  123646. }
  123647. declare module BABYLON {
  123648. /**
  123649. * A point light is a light defined by an unique point in world space.
  123650. * The light is emitted in every direction from this point.
  123651. * A good example of a point light is a standard light bulb.
  123652. * Documentation: https://doc.babylonjs.com/babylon101/lights
  123653. */
  123654. export class PointLight extends ShadowLight {
  123655. private _shadowAngle;
  123656. /**
  123657. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  123658. * This specifies what angle the shadow will use to be created.
  123659. *
  123660. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  123661. */
  123662. get shadowAngle(): number;
  123663. /**
  123664. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  123665. * This specifies what angle the shadow will use to be created.
  123666. *
  123667. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  123668. */
  123669. set shadowAngle(value: number);
  123670. /**
  123671. * Gets the direction if it has been set.
  123672. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  123673. */
  123674. get direction(): Vector3;
  123675. /**
  123676. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  123677. */
  123678. set direction(value: Vector3);
  123679. /**
  123680. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  123681. * A PointLight emits the light in every direction.
  123682. * It can cast shadows.
  123683. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  123684. * ```javascript
  123685. * var pointLight = new PointLight("pl", camera.position, scene);
  123686. * ```
  123687. * Documentation : https://doc.babylonjs.com/babylon101/lights
  123688. * @param name The light friendly name
  123689. * @param position The position of the point light in the scene
  123690. * @param scene The scene the lights belongs to
  123691. */
  123692. constructor(name: string, position: Vector3, scene: Scene);
  123693. /**
  123694. * Returns the string "PointLight"
  123695. * @returns the class name
  123696. */
  123697. getClassName(): string;
  123698. /**
  123699. * Returns the integer 0.
  123700. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  123701. */
  123702. getTypeID(): number;
  123703. /**
  123704. * Specifies wether or not the shadowmap should be a cube texture.
  123705. * @returns true if the shadowmap needs to be a cube texture.
  123706. */
  123707. needCube(): boolean;
  123708. /**
  123709. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  123710. * @param faceIndex The index of the face we are computed the direction to generate shadow
  123711. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  123712. */
  123713. getShadowDirection(faceIndex?: number): Vector3;
  123714. /**
  123715. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  123716. * - fov = PI / 2
  123717. * - aspect ratio : 1.0
  123718. * - z-near and far equal to the active camera minZ and maxZ.
  123719. * Returns the PointLight.
  123720. */
  123721. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  123722. protected _buildUniformLayout(): void;
  123723. /**
  123724. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  123725. * @param effect The effect to update
  123726. * @param lightIndex The index of the light in the effect to update
  123727. * @returns The point light
  123728. */
  123729. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  123730. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  123731. /**
  123732. * Prepares the list of defines specific to the light type.
  123733. * @param defines the list of defines
  123734. * @param lightIndex defines the index of the light for the effect
  123735. */
  123736. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  123737. }
  123738. }
  123739. declare module BABYLON {
  123740. /**
  123741. * Header information of HDR texture files.
  123742. */
  123743. export interface HDRInfo {
  123744. /**
  123745. * The height of the texture in pixels.
  123746. */
  123747. height: number;
  123748. /**
  123749. * The width of the texture in pixels.
  123750. */
  123751. width: number;
  123752. /**
  123753. * The index of the beginning of the data in the binary file.
  123754. */
  123755. dataPosition: number;
  123756. }
  123757. /**
  123758. * This groups tools to convert HDR texture to native colors array.
  123759. */
  123760. export class HDRTools {
  123761. private static Ldexp;
  123762. private static Rgbe2float;
  123763. private static readStringLine;
  123764. /**
  123765. * Reads header information from an RGBE texture stored in a native array.
  123766. * More information on this format are available here:
  123767. * https://en.wikipedia.org/wiki/RGBE_image_format
  123768. *
  123769. * @param uint8array The binary file stored in native array.
  123770. * @return The header information.
  123771. */
  123772. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  123773. /**
  123774. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  123775. * This RGBE texture needs to store the information as a panorama.
  123776. *
  123777. * More information on this format are available here:
  123778. * https://en.wikipedia.org/wiki/RGBE_image_format
  123779. *
  123780. * @param buffer The binary file stored in an array buffer.
  123781. * @param size The expected size of the extracted cubemap.
  123782. * @return The Cube Map information.
  123783. */
  123784. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  123785. /**
  123786. * Returns the pixels data extracted from an RGBE texture.
  123787. * This pixels will be stored left to right up to down in the R G B order in one array.
  123788. *
  123789. * More information on this format are available here:
  123790. * https://en.wikipedia.org/wiki/RGBE_image_format
  123791. *
  123792. * @param uint8array The binary file stored in an array buffer.
  123793. * @param hdrInfo The header information of the file.
  123794. * @return The pixels data in RGB right to left up to down order.
  123795. */
  123796. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  123797. private static RGBE_ReadPixels_RLE;
  123798. }
  123799. }
  123800. declare module BABYLON {
  123801. /**
  123802. * This represents a texture coming from an HDR input.
  123803. *
  123804. * The only supported format is currently panorama picture stored in RGBE format.
  123805. * Example of such files can be found on HDRLib: http://hdrlib.com/
  123806. */
  123807. export class HDRCubeTexture extends BaseTexture {
  123808. private static _facesMapping;
  123809. private _generateHarmonics;
  123810. private _noMipmap;
  123811. private _textureMatrix;
  123812. private _size;
  123813. private _onLoad;
  123814. private _onError;
  123815. /**
  123816. * The texture URL.
  123817. */
  123818. url: string;
  123819. /**
  123820. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  123821. */
  123822. coordinatesMode: number;
  123823. protected _isBlocking: boolean;
  123824. /**
  123825. * Sets wether or not the texture is blocking during loading.
  123826. */
  123827. set isBlocking(value: boolean);
  123828. /**
  123829. * Gets wether or not the texture is blocking during loading.
  123830. */
  123831. get isBlocking(): boolean;
  123832. protected _rotationY: number;
  123833. /**
  123834. * Sets texture matrix rotation angle around Y axis in radians.
  123835. */
  123836. set rotationY(value: number);
  123837. /**
  123838. * Gets texture matrix rotation angle around Y axis radians.
  123839. */
  123840. get rotationY(): number;
  123841. /**
  123842. * Gets or sets the center of the bounding box associated with the cube texture
  123843. * It must define where the camera used to render the texture was set
  123844. */
  123845. boundingBoxPosition: Vector3;
  123846. private _boundingBoxSize;
  123847. /**
  123848. * Gets or sets the size of the bounding box associated with the cube texture
  123849. * When defined, the cubemap will switch to local mode
  123850. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  123851. * @example https://www.babylonjs-playground.com/#RNASML
  123852. */
  123853. set boundingBoxSize(value: Vector3);
  123854. get boundingBoxSize(): Vector3;
  123855. /**
  123856. * Instantiates an HDRTexture from the following parameters.
  123857. *
  123858. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  123859. * @param scene The scene the texture will be used in
  123860. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  123861. * @param noMipmap Forces to not generate the mipmap if true
  123862. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  123863. * @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)
  123864. * @param reserved Reserved flag for internal use.
  123865. */
  123866. 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>);
  123867. /**
  123868. * Get the current class name of the texture useful for serialization or dynamic coding.
  123869. * @returns "HDRCubeTexture"
  123870. */
  123871. getClassName(): string;
  123872. /**
  123873. * Occurs when the file is raw .hdr file.
  123874. */
  123875. private loadTexture;
  123876. clone(): HDRCubeTexture;
  123877. delayLoad(): void;
  123878. /**
  123879. * Get the texture reflection matrix used to rotate/transform the reflection.
  123880. * @returns the reflection matrix
  123881. */
  123882. getReflectionTextureMatrix(): Matrix;
  123883. /**
  123884. * Set the texture reflection matrix used to rotate/transform the reflection.
  123885. * @param value Define the reflection matrix to set
  123886. */
  123887. setReflectionTextureMatrix(value: Matrix): void;
  123888. /**
  123889. * Parses a JSON representation of an HDR Texture in order to create the texture
  123890. * @param parsedTexture Define the JSON representation
  123891. * @param scene Define the scene the texture should be created in
  123892. * @param rootUrl Define the root url in case we need to load relative dependencies
  123893. * @returns the newly created texture after parsing
  123894. */
  123895. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  123896. serialize(): any;
  123897. }
  123898. }
  123899. declare module BABYLON {
  123900. /**
  123901. * Class used to control physics engine
  123902. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  123903. */
  123904. export class PhysicsEngine implements IPhysicsEngine {
  123905. private _physicsPlugin;
  123906. /**
  123907. * Global value used to control the smallest number supported by the simulation
  123908. */
  123909. static Epsilon: number;
  123910. private _impostors;
  123911. private _joints;
  123912. private _subTimeStep;
  123913. /**
  123914. * Gets the gravity vector used by the simulation
  123915. */
  123916. gravity: Vector3;
  123917. /**
  123918. * Factory used to create the default physics plugin.
  123919. * @returns The default physics plugin
  123920. */
  123921. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  123922. /**
  123923. * Creates a new Physics Engine
  123924. * @param gravity defines the gravity vector used by the simulation
  123925. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  123926. */
  123927. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  123928. /**
  123929. * Sets the gravity vector used by the simulation
  123930. * @param gravity defines the gravity vector to use
  123931. */
  123932. setGravity(gravity: Vector3): void;
  123933. /**
  123934. * Set the time step of the physics engine.
  123935. * Default is 1/60.
  123936. * To slow it down, enter 1/600 for example.
  123937. * To speed it up, 1/30
  123938. * @param newTimeStep defines the new timestep to apply to this world.
  123939. */
  123940. setTimeStep(newTimeStep?: number): void;
  123941. /**
  123942. * Get the time step of the physics engine.
  123943. * @returns the current time step
  123944. */
  123945. getTimeStep(): number;
  123946. /**
  123947. * Set the sub time step of the physics engine.
  123948. * Default is 0 meaning there is no sub steps
  123949. * To increase physics resolution precision, set a small value (like 1 ms)
  123950. * @param subTimeStep defines the new sub timestep used for physics resolution.
  123951. */
  123952. setSubTimeStep(subTimeStep?: number): void;
  123953. /**
  123954. * Get the sub time step of the physics engine.
  123955. * @returns the current sub time step
  123956. */
  123957. getSubTimeStep(): number;
  123958. /**
  123959. * Release all resources
  123960. */
  123961. dispose(): void;
  123962. /**
  123963. * Gets the name of the current physics plugin
  123964. * @returns the name of the plugin
  123965. */
  123966. getPhysicsPluginName(): string;
  123967. /**
  123968. * Adding a new impostor for the impostor tracking.
  123969. * This will be done by the impostor itself.
  123970. * @param impostor the impostor to add
  123971. */
  123972. addImpostor(impostor: PhysicsImpostor): void;
  123973. /**
  123974. * Remove an impostor from the engine.
  123975. * This impostor and its mesh will not longer be updated by the physics engine.
  123976. * @param impostor the impostor to remove
  123977. */
  123978. removeImpostor(impostor: PhysicsImpostor): void;
  123979. /**
  123980. * Add a joint to the physics engine
  123981. * @param mainImpostor defines the main impostor to which the joint is added.
  123982. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  123983. * @param joint defines the joint that will connect both impostors.
  123984. */
  123985. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  123986. /**
  123987. * Removes a joint from the simulation
  123988. * @param mainImpostor defines the impostor used with the joint
  123989. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  123990. * @param joint defines the joint to remove
  123991. */
  123992. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  123993. /**
  123994. * Called by the scene. No need to call it.
  123995. * @param delta defines the timespam between frames
  123996. */
  123997. _step(delta: number): void;
  123998. /**
  123999. * Gets the current plugin used to run the simulation
  124000. * @returns current plugin
  124001. */
  124002. getPhysicsPlugin(): IPhysicsEnginePlugin;
  124003. /**
  124004. * Gets the list of physic impostors
  124005. * @returns an array of PhysicsImpostor
  124006. */
  124007. getImpostors(): Array<PhysicsImpostor>;
  124008. /**
  124009. * Gets the impostor for a physics enabled object
  124010. * @param object defines the object impersonated by the impostor
  124011. * @returns the PhysicsImpostor or null if not found
  124012. */
  124013. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  124014. /**
  124015. * Gets the impostor for a physics body object
  124016. * @param body defines physics body used by the impostor
  124017. * @returns the PhysicsImpostor or null if not found
  124018. */
  124019. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  124020. /**
  124021. * Does a raycast in the physics world
  124022. * @param from when should the ray start?
  124023. * @param to when should the ray end?
  124024. * @returns PhysicsRaycastResult
  124025. */
  124026. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  124027. }
  124028. }
  124029. declare module BABYLON {
  124030. /** @hidden */
  124031. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  124032. private _useDeltaForWorldStep;
  124033. world: any;
  124034. name: string;
  124035. private _physicsMaterials;
  124036. private _fixedTimeStep;
  124037. private _cannonRaycastResult;
  124038. private _raycastResult;
  124039. private _physicsBodysToRemoveAfterStep;
  124040. BJSCANNON: any;
  124041. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  124042. setGravity(gravity: Vector3): void;
  124043. setTimeStep(timeStep: number): void;
  124044. getTimeStep(): number;
  124045. executeStep(delta: number): void;
  124046. private _removeMarkedPhysicsBodiesFromWorld;
  124047. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124048. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124049. generatePhysicsBody(impostor: PhysicsImpostor): void;
  124050. private _processChildMeshes;
  124051. removePhysicsBody(impostor: PhysicsImpostor): void;
  124052. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  124053. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  124054. private _addMaterial;
  124055. private _checkWithEpsilon;
  124056. private _createShape;
  124057. private _createHeightmap;
  124058. private _minus90X;
  124059. private _plus90X;
  124060. private _tmpPosition;
  124061. private _tmpDeltaPosition;
  124062. private _tmpUnityRotation;
  124063. private _updatePhysicsBodyTransformation;
  124064. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  124065. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  124066. isSupported(): boolean;
  124067. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124068. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124069. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124070. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124071. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  124072. getBodyMass(impostor: PhysicsImpostor): number;
  124073. getBodyFriction(impostor: PhysicsImpostor): number;
  124074. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  124075. getBodyRestitution(impostor: PhysicsImpostor): number;
  124076. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  124077. sleepBody(impostor: PhysicsImpostor): void;
  124078. wakeUpBody(impostor: PhysicsImpostor): void;
  124079. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  124080. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  124081. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  124082. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  124083. getRadius(impostor: PhysicsImpostor): number;
  124084. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  124085. dispose(): void;
  124086. private _extendNamespace;
  124087. /**
  124088. * Does a raycast in the physics world
  124089. * @param from when should the ray start?
  124090. * @param to when should the ray end?
  124091. * @returns PhysicsRaycastResult
  124092. */
  124093. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  124094. }
  124095. }
  124096. declare module BABYLON {
  124097. /** @hidden */
  124098. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  124099. world: any;
  124100. name: string;
  124101. BJSOIMO: any;
  124102. private _raycastResult;
  124103. constructor(iterations?: number, oimoInjection?: any);
  124104. setGravity(gravity: Vector3): void;
  124105. setTimeStep(timeStep: number): void;
  124106. getTimeStep(): number;
  124107. private _tmpImpostorsArray;
  124108. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  124109. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124110. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124111. generatePhysicsBody(impostor: PhysicsImpostor): void;
  124112. private _tmpPositionVector;
  124113. removePhysicsBody(impostor: PhysicsImpostor): void;
  124114. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  124115. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  124116. isSupported(): boolean;
  124117. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  124118. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  124119. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124120. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124121. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124122. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124123. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  124124. getBodyMass(impostor: PhysicsImpostor): number;
  124125. getBodyFriction(impostor: PhysicsImpostor): number;
  124126. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  124127. getBodyRestitution(impostor: PhysicsImpostor): number;
  124128. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  124129. sleepBody(impostor: PhysicsImpostor): void;
  124130. wakeUpBody(impostor: PhysicsImpostor): void;
  124131. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  124132. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  124133. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  124134. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  124135. getRadius(impostor: PhysicsImpostor): number;
  124136. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  124137. dispose(): void;
  124138. /**
  124139. * Does a raycast in the physics world
  124140. * @param from when should the ray start?
  124141. * @param to when should the ray end?
  124142. * @returns PhysicsRaycastResult
  124143. */
  124144. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  124145. }
  124146. }
  124147. declare module BABYLON {
  124148. /**
  124149. * Class containing static functions to help procedurally build meshes
  124150. */
  124151. export class RibbonBuilder {
  124152. /**
  124153. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  124154. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  124155. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  124156. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  124157. * * 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
  124158. * * 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
  124159. * * 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
  124160. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124161. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124162. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124163. * * 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
  124164. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  124165. * * 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
  124166. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  124167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124168. * @param name defines the name of the mesh
  124169. * @param options defines the options used to create the mesh
  124170. * @param scene defines the hosting scene
  124171. * @returns the ribbon mesh
  124172. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  124173. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124174. */
  124175. static CreateRibbon(name: string, options: {
  124176. pathArray: Vector3[][];
  124177. closeArray?: boolean;
  124178. closePath?: boolean;
  124179. offset?: number;
  124180. updatable?: boolean;
  124181. sideOrientation?: number;
  124182. frontUVs?: Vector4;
  124183. backUVs?: Vector4;
  124184. instance?: Mesh;
  124185. invertUV?: boolean;
  124186. uvs?: Vector2[];
  124187. colors?: Color4[];
  124188. }, scene?: Nullable<Scene>): Mesh;
  124189. }
  124190. }
  124191. declare module BABYLON {
  124192. /**
  124193. * Class containing static functions to help procedurally build meshes
  124194. */
  124195. export class ShapeBuilder {
  124196. /**
  124197. * 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.
  124198. * * 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.
  124199. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  124200. * * 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.
  124201. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  124202. * * 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
  124203. * * 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
  124204. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  124205. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124206. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124207. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  124208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124209. * @param name defines the name of the mesh
  124210. * @param options defines the options used to create the mesh
  124211. * @param scene defines the hosting scene
  124212. * @returns the extruded shape mesh
  124213. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124214. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124215. */
  124216. static ExtrudeShape(name: string, options: {
  124217. shape: Vector3[];
  124218. path: Vector3[];
  124219. scale?: number;
  124220. rotation?: number;
  124221. cap?: number;
  124222. updatable?: boolean;
  124223. sideOrientation?: number;
  124224. frontUVs?: Vector4;
  124225. backUVs?: Vector4;
  124226. instance?: Mesh;
  124227. invertUV?: boolean;
  124228. }, scene?: Nullable<Scene>): Mesh;
  124229. /**
  124230. * Creates an custom extruded shape mesh.
  124231. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  124232. * * 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.
  124233. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  124234. * * 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
  124235. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  124236. * * 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
  124237. * * It must returns a float value that will be the scale value applied to the shape on each path point
  124238. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  124239. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  124240. * * 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
  124241. * * 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
  124242. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  124243. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124244. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124245. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  124246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124247. * @param name defines the name of the mesh
  124248. * @param options defines the options used to create the mesh
  124249. * @param scene defines the hosting scene
  124250. * @returns the custom extruded shape mesh
  124251. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  124252. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  124253. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  124254. */
  124255. static ExtrudeShapeCustom(name: string, options: {
  124256. shape: Vector3[];
  124257. path: Vector3[];
  124258. scaleFunction?: any;
  124259. rotationFunction?: any;
  124260. ribbonCloseArray?: boolean;
  124261. ribbonClosePath?: boolean;
  124262. cap?: number;
  124263. updatable?: boolean;
  124264. sideOrientation?: number;
  124265. frontUVs?: Vector4;
  124266. backUVs?: Vector4;
  124267. instance?: Mesh;
  124268. invertUV?: boolean;
  124269. }, scene?: Nullable<Scene>): Mesh;
  124270. private static _ExtrudeShapeGeneric;
  124271. }
  124272. }
  124273. declare module BABYLON {
  124274. /**
  124275. * AmmoJS Physics plugin
  124276. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  124277. * @see https://github.com/kripken/ammo.js/
  124278. */
  124279. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  124280. private _useDeltaForWorldStep;
  124281. /**
  124282. * Reference to the Ammo library
  124283. */
  124284. bjsAMMO: any;
  124285. /**
  124286. * Created ammoJS world which physics bodies are added to
  124287. */
  124288. world: any;
  124289. /**
  124290. * Name of the plugin
  124291. */
  124292. name: string;
  124293. private _timeStep;
  124294. private _fixedTimeStep;
  124295. private _maxSteps;
  124296. private _tmpQuaternion;
  124297. private _tmpAmmoTransform;
  124298. private _tmpAmmoQuaternion;
  124299. private _tmpAmmoConcreteContactResultCallback;
  124300. private _collisionConfiguration;
  124301. private _dispatcher;
  124302. private _overlappingPairCache;
  124303. private _solver;
  124304. private _softBodySolver;
  124305. private _tmpAmmoVectorA;
  124306. private _tmpAmmoVectorB;
  124307. private _tmpAmmoVectorC;
  124308. private _tmpAmmoVectorD;
  124309. private _tmpContactCallbackResult;
  124310. private _tmpAmmoVectorRCA;
  124311. private _tmpAmmoVectorRCB;
  124312. private _raycastResult;
  124313. private static readonly DISABLE_COLLISION_FLAG;
  124314. private static readonly KINEMATIC_FLAG;
  124315. private static readonly DISABLE_DEACTIVATION_FLAG;
  124316. /**
  124317. * Initializes the ammoJS plugin
  124318. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  124319. * @param ammoInjection can be used to inject your own ammo reference
  124320. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  124321. */
  124322. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  124323. /**
  124324. * Sets the gravity of the physics world (m/(s^2))
  124325. * @param gravity Gravity to set
  124326. */
  124327. setGravity(gravity: Vector3): void;
  124328. /**
  124329. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  124330. * @param timeStep timestep to use in seconds
  124331. */
  124332. setTimeStep(timeStep: number): void;
  124333. /**
  124334. * 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)
  124335. * @param fixedTimeStep fixedTimeStep to use in seconds
  124336. */
  124337. setFixedTimeStep(fixedTimeStep: number): void;
  124338. /**
  124339. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  124340. * @param maxSteps the maximum number of steps by the physics engine per frame
  124341. */
  124342. setMaxSteps(maxSteps: number): void;
  124343. /**
  124344. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  124345. * @returns the current timestep in seconds
  124346. */
  124347. getTimeStep(): number;
  124348. /**
  124349. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  124350. */
  124351. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  124352. private _isImpostorInContact;
  124353. private _isImpostorPairInContact;
  124354. private _stepSimulation;
  124355. /**
  124356. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  124357. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  124358. * After the step the babylon meshes are set to the position of the physics imposters
  124359. * @param delta amount of time to step forward
  124360. * @param impostors array of imposters to update before/after the step
  124361. */
  124362. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  124363. /**
  124364. * Update babylon mesh to match physics world object
  124365. * @param impostor imposter to match
  124366. */
  124367. private _afterSoftStep;
  124368. /**
  124369. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  124370. * @param impostor imposter to match
  124371. */
  124372. private _ropeStep;
  124373. /**
  124374. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  124375. * @param impostor imposter to match
  124376. */
  124377. private _softbodyOrClothStep;
  124378. private _tmpVector;
  124379. private _tmpMatrix;
  124380. /**
  124381. * Applies an impulse on the imposter
  124382. * @param impostor imposter to apply impulse to
  124383. * @param force amount of force to be applied to the imposter
  124384. * @param contactPoint the location to apply the impulse on the imposter
  124385. */
  124386. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124387. /**
  124388. * Applies a force on the imposter
  124389. * @param impostor imposter to apply force
  124390. * @param force amount of force to be applied to the imposter
  124391. * @param contactPoint the location to apply the force on the imposter
  124392. */
  124393. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  124394. /**
  124395. * Creates a physics body using the plugin
  124396. * @param impostor the imposter to create the physics body on
  124397. */
  124398. generatePhysicsBody(impostor: PhysicsImpostor): void;
  124399. /**
  124400. * Removes the physics body from the imposter and disposes of the body's memory
  124401. * @param impostor imposter to remove the physics body from
  124402. */
  124403. removePhysicsBody(impostor: PhysicsImpostor): void;
  124404. /**
  124405. * Generates a joint
  124406. * @param impostorJoint the imposter joint to create the joint with
  124407. */
  124408. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  124409. /**
  124410. * Removes a joint
  124411. * @param impostorJoint the imposter joint to remove the joint from
  124412. */
  124413. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  124414. private _addMeshVerts;
  124415. /**
  124416. * Initialise the soft body vertices to match its object's (mesh) vertices
  124417. * Softbody vertices (nodes) are in world space and to match this
  124418. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  124419. * @param impostor to create the softbody for
  124420. */
  124421. private _softVertexData;
  124422. /**
  124423. * Create an impostor's soft body
  124424. * @param impostor to create the softbody for
  124425. */
  124426. private _createSoftbody;
  124427. /**
  124428. * Create cloth for an impostor
  124429. * @param impostor to create the softbody for
  124430. */
  124431. private _createCloth;
  124432. /**
  124433. * Create rope for an impostor
  124434. * @param impostor to create the softbody for
  124435. */
  124436. private _createRope;
  124437. /**
  124438. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  124439. * @param impostor to create the custom physics shape for
  124440. */
  124441. private _createCustom;
  124442. private _addHullVerts;
  124443. private _createShape;
  124444. /**
  124445. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  124446. * @param impostor imposter containing the physics body and babylon object
  124447. */
  124448. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  124449. /**
  124450. * Sets the babylon object's position/rotation from the physics body's position/rotation
  124451. * @param impostor imposter containing the physics body and babylon object
  124452. * @param newPosition new position
  124453. * @param newRotation new rotation
  124454. */
  124455. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  124456. /**
  124457. * If this plugin is supported
  124458. * @returns true if its supported
  124459. */
  124460. isSupported(): boolean;
  124461. /**
  124462. * Sets the linear velocity of the physics body
  124463. * @param impostor imposter to set the velocity on
  124464. * @param velocity velocity to set
  124465. */
  124466. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124467. /**
  124468. * Sets the angular velocity of the physics body
  124469. * @param impostor imposter to set the velocity on
  124470. * @param velocity velocity to set
  124471. */
  124472. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  124473. /**
  124474. * gets the linear velocity
  124475. * @param impostor imposter to get linear velocity from
  124476. * @returns linear velocity
  124477. */
  124478. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124479. /**
  124480. * gets the angular velocity
  124481. * @param impostor imposter to get angular velocity from
  124482. * @returns angular velocity
  124483. */
  124484. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  124485. /**
  124486. * Sets the mass of physics body
  124487. * @param impostor imposter to set the mass on
  124488. * @param mass mass to set
  124489. */
  124490. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  124491. /**
  124492. * Gets the mass of the physics body
  124493. * @param impostor imposter to get the mass from
  124494. * @returns mass
  124495. */
  124496. getBodyMass(impostor: PhysicsImpostor): number;
  124497. /**
  124498. * Gets friction of the impostor
  124499. * @param impostor impostor to get friction from
  124500. * @returns friction value
  124501. */
  124502. getBodyFriction(impostor: PhysicsImpostor): number;
  124503. /**
  124504. * Sets friction of the impostor
  124505. * @param impostor impostor to set friction on
  124506. * @param friction friction value
  124507. */
  124508. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  124509. /**
  124510. * Gets restitution of the impostor
  124511. * @param impostor impostor to get restitution from
  124512. * @returns restitution value
  124513. */
  124514. getBodyRestitution(impostor: PhysicsImpostor): number;
  124515. /**
  124516. * Sets resitution of the impostor
  124517. * @param impostor impostor to set resitution on
  124518. * @param restitution resitution value
  124519. */
  124520. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  124521. /**
  124522. * Gets pressure inside the impostor
  124523. * @param impostor impostor to get pressure from
  124524. * @returns pressure value
  124525. */
  124526. getBodyPressure(impostor: PhysicsImpostor): number;
  124527. /**
  124528. * Sets pressure inside a soft body impostor
  124529. * Cloth and rope must remain 0 pressure
  124530. * @param impostor impostor to set pressure on
  124531. * @param pressure pressure value
  124532. */
  124533. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  124534. /**
  124535. * Gets stiffness of the impostor
  124536. * @param impostor impostor to get stiffness from
  124537. * @returns pressure value
  124538. */
  124539. getBodyStiffness(impostor: PhysicsImpostor): number;
  124540. /**
  124541. * Sets stiffness of the impostor
  124542. * @param impostor impostor to set stiffness on
  124543. * @param stiffness stiffness value from 0 to 1
  124544. */
  124545. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  124546. /**
  124547. * Gets velocityIterations of the impostor
  124548. * @param impostor impostor to get velocity iterations from
  124549. * @returns velocityIterations value
  124550. */
  124551. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  124552. /**
  124553. * Sets velocityIterations of the impostor
  124554. * @param impostor impostor to set velocity iterations on
  124555. * @param velocityIterations velocityIterations value
  124556. */
  124557. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  124558. /**
  124559. * Gets positionIterations of the impostor
  124560. * @param impostor impostor to get position iterations from
  124561. * @returns positionIterations value
  124562. */
  124563. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  124564. /**
  124565. * Sets positionIterations of the impostor
  124566. * @param impostor impostor to set position on
  124567. * @param positionIterations positionIterations value
  124568. */
  124569. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  124570. /**
  124571. * Append an anchor to a cloth object
  124572. * @param impostor is the cloth impostor to add anchor to
  124573. * @param otherImpostor is the rigid impostor to anchor to
  124574. * @param width ratio across width from 0 to 1
  124575. * @param height ratio up height from 0 to 1
  124576. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  124577. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  124578. */
  124579. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  124580. /**
  124581. * Append an hook to a rope object
  124582. * @param impostor is the rope impostor to add hook to
  124583. * @param otherImpostor is the rigid impostor to hook to
  124584. * @param length ratio along the rope from 0 to 1
  124585. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  124586. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  124587. */
  124588. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  124589. /**
  124590. * Sleeps the physics body and stops it from being active
  124591. * @param impostor impostor to sleep
  124592. */
  124593. sleepBody(impostor: PhysicsImpostor): void;
  124594. /**
  124595. * Activates the physics body
  124596. * @param impostor impostor to activate
  124597. */
  124598. wakeUpBody(impostor: PhysicsImpostor): void;
  124599. /**
  124600. * Updates the distance parameters of the joint
  124601. * @param joint joint to update
  124602. * @param maxDistance maximum distance of the joint
  124603. * @param minDistance minimum distance of the joint
  124604. */
  124605. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  124606. /**
  124607. * Sets a motor on the joint
  124608. * @param joint joint to set motor on
  124609. * @param speed speed of the motor
  124610. * @param maxForce maximum force of the motor
  124611. * @param motorIndex index of the motor
  124612. */
  124613. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  124614. /**
  124615. * Sets the motors limit
  124616. * @param joint joint to set limit on
  124617. * @param upperLimit upper limit
  124618. * @param lowerLimit lower limit
  124619. */
  124620. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  124621. /**
  124622. * Syncs the position and rotation of a mesh with the impostor
  124623. * @param mesh mesh to sync
  124624. * @param impostor impostor to update the mesh with
  124625. */
  124626. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  124627. /**
  124628. * Gets the radius of the impostor
  124629. * @param impostor impostor to get radius from
  124630. * @returns the radius
  124631. */
  124632. getRadius(impostor: PhysicsImpostor): number;
  124633. /**
  124634. * Gets the box size of the impostor
  124635. * @param impostor impostor to get box size from
  124636. * @param result the resulting box size
  124637. */
  124638. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  124639. /**
  124640. * Disposes of the impostor
  124641. */
  124642. dispose(): void;
  124643. /**
  124644. * Does a raycast in the physics world
  124645. * @param from when should the ray start?
  124646. * @param to when should the ray end?
  124647. * @returns PhysicsRaycastResult
  124648. */
  124649. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  124650. }
  124651. }
  124652. declare module BABYLON {
  124653. interface AbstractScene {
  124654. /**
  124655. * The list of reflection probes added to the scene
  124656. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  124657. */
  124658. reflectionProbes: Array<ReflectionProbe>;
  124659. /**
  124660. * Removes the given reflection probe from this scene.
  124661. * @param toRemove The reflection probe to remove
  124662. * @returns The index of the removed reflection probe
  124663. */
  124664. removeReflectionProbe(toRemove: ReflectionProbe): number;
  124665. /**
  124666. * Adds the given reflection probe to this scene.
  124667. * @param newReflectionProbe The reflection probe to add
  124668. */
  124669. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  124670. }
  124671. /**
  124672. * Class used to generate realtime reflection / refraction cube textures
  124673. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  124674. */
  124675. export class ReflectionProbe {
  124676. /** defines the name of the probe */
  124677. name: string;
  124678. private _scene;
  124679. private _renderTargetTexture;
  124680. private _projectionMatrix;
  124681. private _viewMatrix;
  124682. private _target;
  124683. private _add;
  124684. private _attachedMesh;
  124685. private _invertYAxis;
  124686. /** Gets or sets probe position (center of the cube map) */
  124687. position: Vector3;
  124688. /**
  124689. * Creates a new reflection probe
  124690. * @param name defines the name of the probe
  124691. * @param size defines the texture resolution (for each face)
  124692. * @param scene defines the hosting scene
  124693. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  124694. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  124695. */
  124696. constructor(
  124697. /** defines the name of the probe */
  124698. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  124699. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  124700. get samples(): number;
  124701. set samples(value: number);
  124702. /** Gets or sets the refresh rate to use (on every frame by default) */
  124703. get refreshRate(): number;
  124704. set refreshRate(value: number);
  124705. /**
  124706. * Gets the hosting scene
  124707. * @returns a Scene
  124708. */
  124709. getScene(): Scene;
  124710. /** Gets the internal CubeTexture used to render to */
  124711. get cubeTexture(): RenderTargetTexture;
  124712. /** Gets the list of meshes to render */
  124713. get renderList(): Nullable<AbstractMesh[]>;
  124714. /**
  124715. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  124716. * @param mesh defines the mesh to attach to
  124717. */
  124718. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  124719. /**
  124720. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  124721. * @param renderingGroupId The rendering group id corresponding to its index
  124722. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  124723. */
  124724. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  124725. /**
  124726. * Clean all associated resources
  124727. */
  124728. dispose(): void;
  124729. /**
  124730. * Converts the reflection probe information to a readable string for debug purpose.
  124731. * @param fullDetails Supports for multiple levels of logging within scene loading
  124732. * @returns the human readable reflection probe info
  124733. */
  124734. toString(fullDetails?: boolean): string;
  124735. /**
  124736. * Get the class name of the relfection probe.
  124737. * @returns "ReflectionProbe"
  124738. */
  124739. getClassName(): string;
  124740. /**
  124741. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  124742. * @returns The JSON representation of the texture
  124743. */
  124744. serialize(): any;
  124745. /**
  124746. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  124747. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  124748. * @param scene Define the scene the parsed reflection probe should be instantiated in
  124749. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  124750. * @returns The parsed reflection probe if successful
  124751. */
  124752. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  124753. }
  124754. }
  124755. declare module BABYLON {
  124756. /** @hidden */
  124757. export var _BabylonLoaderRegistered: boolean;
  124758. /**
  124759. * Helps setting up some configuration for the babylon file loader.
  124760. */
  124761. export class BabylonFileLoaderConfiguration {
  124762. /**
  124763. * The loader does not allow injecting custom physix engine into the plugins.
  124764. * Unfortunately in ES6, we need to manually inject them into the plugin.
  124765. * So you could set this variable to your engine import to make it work.
  124766. */
  124767. static LoaderInjectedPhysicsEngine: any;
  124768. }
  124769. }
  124770. declare module BABYLON {
  124771. /**
  124772. * The Physically based simple base material of BJS.
  124773. *
  124774. * This enables better naming and convention enforcements on top of the pbrMaterial.
  124775. * It is used as the base class for both the specGloss and metalRough conventions.
  124776. */
  124777. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  124778. /**
  124779. * Number of Simultaneous lights allowed on the material.
  124780. */
  124781. maxSimultaneousLights: number;
  124782. /**
  124783. * If sets to true, disables all the lights affecting the material.
  124784. */
  124785. disableLighting: boolean;
  124786. /**
  124787. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  124788. */
  124789. environmentTexture: BaseTexture;
  124790. /**
  124791. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  124792. */
  124793. invertNormalMapX: boolean;
  124794. /**
  124795. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  124796. */
  124797. invertNormalMapY: boolean;
  124798. /**
  124799. * Normal map used in the model.
  124800. */
  124801. normalTexture: BaseTexture;
  124802. /**
  124803. * Emissivie color used to self-illuminate the model.
  124804. */
  124805. emissiveColor: Color3;
  124806. /**
  124807. * Emissivie texture used to self-illuminate the model.
  124808. */
  124809. emissiveTexture: BaseTexture;
  124810. /**
  124811. * Occlusion Channel Strenght.
  124812. */
  124813. occlusionStrength: number;
  124814. /**
  124815. * Occlusion Texture of the material (adding extra occlusion effects).
  124816. */
  124817. occlusionTexture: BaseTexture;
  124818. /**
  124819. * Defines the alpha limits in alpha test mode.
  124820. */
  124821. alphaCutOff: number;
  124822. /**
  124823. * Gets the current double sided mode.
  124824. */
  124825. get doubleSided(): boolean;
  124826. /**
  124827. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124828. */
  124829. set doubleSided(value: boolean);
  124830. /**
  124831. * Stores the pre-calculated light information of a mesh in a texture.
  124832. */
  124833. lightmapTexture: BaseTexture;
  124834. /**
  124835. * If true, the light map contains occlusion information instead of lighting info.
  124836. */
  124837. useLightmapAsShadowmap: boolean;
  124838. /**
  124839. * Instantiates a new PBRMaterial instance.
  124840. *
  124841. * @param name The material name
  124842. * @param scene The scene the material will be use in.
  124843. */
  124844. constructor(name: string, scene: Scene);
  124845. getClassName(): string;
  124846. }
  124847. }
  124848. declare module BABYLON {
  124849. /**
  124850. * The PBR material of BJS following the metal roughness convention.
  124851. *
  124852. * This fits to the PBR convention in the GLTF definition:
  124853. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  124854. */
  124855. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  124856. /**
  124857. * The base color has two different interpretations depending on the value of metalness.
  124858. * When the material is a metal, the base color is the specific measured reflectance value
  124859. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  124860. * of the material.
  124861. */
  124862. baseColor: Color3;
  124863. /**
  124864. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  124865. * well as opacity information in the alpha channel.
  124866. */
  124867. baseTexture: BaseTexture;
  124868. /**
  124869. * Specifies the metallic scalar value of the material.
  124870. * Can also be used to scale the metalness values of the metallic texture.
  124871. */
  124872. metallic: number;
  124873. /**
  124874. * Specifies the roughness scalar value of the material.
  124875. * Can also be used to scale the roughness values of the metallic texture.
  124876. */
  124877. roughness: number;
  124878. /**
  124879. * Texture containing both the metallic value in the B channel and the
  124880. * roughness value in the G channel to keep better precision.
  124881. */
  124882. metallicRoughnessTexture: BaseTexture;
  124883. /**
  124884. * Instantiates a new PBRMetalRoughnessMaterial instance.
  124885. *
  124886. * @param name The material name
  124887. * @param scene The scene the material will be use in.
  124888. */
  124889. constructor(name: string, scene: Scene);
  124890. /**
  124891. * Return the currrent class name of the material.
  124892. */
  124893. getClassName(): string;
  124894. /**
  124895. * Makes a duplicate of the current material.
  124896. * @param name - name to use for the new material.
  124897. */
  124898. clone(name: string): PBRMetallicRoughnessMaterial;
  124899. /**
  124900. * Serialize the material to a parsable JSON object.
  124901. */
  124902. serialize(): any;
  124903. /**
  124904. * Parses a JSON object correponding to the serialize function.
  124905. */
  124906. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  124907. }
  124908. }
  124909. declare module BABYLON {
  124910. /**
  124911. * The PBR material of BJS following the specular glossiness convention.
  124912. *
  124913. * This fits to the PBR convention in the GLTF definition:
  124914. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  124915. */
  124916. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  124917. /**
  124918. * Specifies the diffuse color of the material.
  124919. */
  124920. diffuseColor: Color3;
  124921. /**
  124922. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  124923. * channel.
  124924. */
  124925. diffuseTexture: BaseTexture;
  124926. /**
  124927. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  124928. */
  124929. specularColor: Color3;
  124930. /**
  124931. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  124932. */
  124933. glossiness: number;
  124934. /**
  124935. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  124936. */
  124937. specularGlossinessTexture: BaseTexture;
  124938. /**
  124939. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  124940. *
  124941. * @param name The material name
  124942. * @param scene The scene the material will be use in.
  124943. */
  124944. constructor(name: string, scene: Scene);
  124945. /**
  124946. * Return the currrent class name of the material.
  124947. */
  124948. getClassName(): string;
  124949. /**
  124950. * Makes a duplicate of the current material.
  124951. * @param name - name to use for the new material.
  124952. */
  124953. clone(name: string): PBRSpecularGlossinessMaterial;
  124954. /**
  124955. * Serialize the material to a parsable JSON object.
  124956. */
  124957. serialize(): any;
  124958. /**
  124959. * Parses a JSON object correponding to the serialize function.
  124960. */
  124961. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  124962. }
  124963. }
  124964. declare module BABYLON {
  124965. /**
  124966. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  124967. * It can help converting any input color in a desired output one. This can then be used to create effects
  124968. * from sepia, black and white to sixties or futuristic rendering...
  124969. *
  124970. * The only supported format is currently 3dl.
  124971. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  124972. */
  124973. export class ColorGradingTexture extends BaseTexture {
  124974. /**
  124975. * The current texture matrix. (will always be identity in color grading texture)
  124976. */
  124977. private _textureMatrix;
  124978. /**
  124979. * The texture URL.
  124980. */
  124981. url: string;
  124982. /**
  124983. * Empty line regex stored for GC.
  124984. */
  124985. private static _noneEmptyLineRegex;
  124986. private _engine;
  124987. /**
  124988. * Instantiates a ColorGradingTexture from the following parameters.
  124989. *
  124990. * @param url The location of the color gradind data (currently only supporting 3dl)
  124991. * @param scene The scene the texture will be used in
  124992. */
  124993. constructor(url: string, scene: Scene);
  124994. /**
  124995. * Returns the texture matrix used in most of the material.
  124996. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  124997. */
  124998. getTextureMatrix(): Matrix;
  124999. /**
  125000. * Occurs when the file being loaded is a .3dl LUT file.
  125001. */
  125002. private load3dlTexture;
  125003. /**
  125004. * Starts the loading process of the texture.
  125005. */
  125006. private loadTexture;
  125007. /**
  125008. * Clones the color gradind texture.
  125009. */
  125010. clone(): ColorGradingTexture;
  125011. /**
  125012. * Called during delayed load for textures.
  125013. */
  125014. delayLoad(): void;
  125015. /**
  125016. * Parses a color grading texture serialized by Babylon.
  125017. * @param parsedTexture The texture information being parsedTexture
  125018. * @param scene The scene to load the texture in
  125019. * @param rootUrl The root url of the data assets to load
  125020. * @return A color gradind texture
  125021. */
  125022. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  125023. /**
  125024. * Serializes the LUT texture to json format.
  125025. */
  125026. serialize(): any;
  125027. }
  125028. }
  125029. declare module BABYLON {
  125030. /**
  125031. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  125032. */
  125033. export class EquiRectangularCubeTexture extends BaseTexture {
  125034. /** The six faces of the cube. */
  125035. private static _FacesMapping;
  125036. private _noMipmap;
  125037. private _onLoad;
  125038. private _onError;
  125039. /** The size of the cubemap. */
  125040. private _size;
  125041. /** The buffer of the image. */
  125042. private _buffer;
  125043. /** The width of the input image. */
  125044. private _width;
  125045. /** The height of the input image. */
  125046. private _height;
  125047. /** The URL to the image. */
  125048. url: string;
  125049. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  125050. coordinatesMode: number;
  125051. /**
  125052. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  125053. * @param url The location of the image
  125054. * @param scene The scene the texture will be used in
  125055. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  125056. * @param noMipmap Forces to not generate the mipmap if true
  125057. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  125058. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  125059. * @param onLoad — defines a callback called when texture is loaded
  125060. * @param onError — defines a callback called if there is an error
  125061. */
  125062. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  125063. /**
  125064. * Load the image data, by putting the image on a canvas and extracting its buffer.
  125065. */
  125066. private loadImage;
  125067. /**
  125068. * Convert the image buffer into a cubemap and create a CubeTexture.
  125069. */
  125070. private loadTexture;
  125071. /**
  125072. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  125073. * @param buffer The ArrayBuffer that should be converted.
  125074. * @returns The buffer as Float32Array.
  125075. */
  125076. private getFloat32ArrayFromArrayBuffer;
  125077. /**
  125078. * Get the current class name of the texture useful for serialization or dynamic coding.
  125079. * @returns "EquiRectangularCubeTexture"
  125080. */
  125081. getClassName(): string;
  125082. /**
  125083. * Create a clone of the current EquiRectangularCubeTexture and return it.
  125084. * @returns A clone of the current EquiRectangularCubeTexture.
  125085. */
  125086. clone(): EquiRectangularCubeTexture;
  125087. }
  125088. }
  125089. declare module BABYLON {
  125090. /**
  125091. * Based on jsTGALoader - Javascript loader for TGA file
  125092. * By Vincent Thibault
  125093. * @see http://blog.robrowser.com/javascript-tga-loader.html
  125094. */
  125095. export class TGATools {
  125096. private static _TYPE_INDEXED;
  125097. private static _TYPE_RGB;
  125098. private static _TYPE_GREY;
  125099. private static _TYPE_RLE_INDEXED;
  125100. private static _TYPE_RLE_RGB;
  125101. private static _TYPE_RLE_GREY;
  125102. private static _ORIGIN_MASK;
  125103. private static _ORIGIN_SHIFT;
  125104. private static _ORIGIN_BL;
  125105. private static _ORIGIN_BR;
  125106. private static _ORIGIN_UL;
  125107. private static _ORIGIN_UR;
  125108. /**
  125109. * Gets the header of a TGA file
  125110. * @param data defines the TGA data
  125111. * @returns the header
  125112. */
  125113. static GetTGAHeader(data: Uint8Array): any;
  125114. /**
  125115. * Uploads TGA content to a Babylon Texture
  125116. * @hidden
  125117. */
  125118. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  125119. /** @hidden */
  125120. 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;
  125121. /** @hidden */
  125122. 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;
  125123. /** @hidden */
  125124. 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;
  125125. /** @hidden */
  125126. 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;
  125127. /** @hidden */
  125128. 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;
  125129. /** @hidden */
  125130. 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;
  125131. }
  125132. }
  125133. declare module BABYLON {
  125134. /**
  125135. * Implementation of the TGA Texture Loader.
  125136. * @hidden
  125137. */
  125138. export class _TGATextureLoader implements IInternalTextureLoader {
  125139. /**
  125140. * Defines wether the loader supports cascade loading the different faces.
  125141. */
  125142. readonly supportCascades: boolean;
  125143. /**
  125144. * This returns if the loader support the current file information.
  125145. * @param extension defines the file extension of the file being loaded
  125146. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125147. * @param fallback defines the fallback internal texture if any
  125148. * @param isBase64 defines whether the texture is encoded as a base64
  125149. * @param isBuffer defines whether the texture data are stored as a buffer
  125150. * @returns true if the loader can load the specified file
  125151. */
  125152. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125153. /**
  125154. * Transform the url before loading if required.
  125155. * @param rootUrl the url of the texture
  125156. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125157. * @returns the transformed texture
  125158. */
  125159. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125160. /**
  125161. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125162. * @param rootUrl the url of the texture
  125163. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125164. * @returns the fallback texture
  125165. */
  125166. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125167. /**
  125168. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  125169. * @param data contains the texture data
  125170. * @param texture defines the BabylonJS internal texture
  125171. * @param createPolynomials will be true if polynomials have been requested
  125172. * @param onLoad defines the callback to trigger once the texture is ready
  125173. * @param onError defines the callback to trigger in case of error
  125174. */
  125175. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125176. /**
  125177. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125178. * @param data contains the texture data
  125179. * @param texture defines the BabylonJS internal texture
  125180. * @param callback defines the method to call once ready to upload
  125181. */
  125182. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125183. }
  125184. }
  125185. declare module BABYLON {
  125186. /**
  125187. * Info about the .basis files
  125188. */
  125189. class BasisFileInfo {
  125190. /**
  125191. * If the file has alpha
  125192. */
  125193. hasAlpha: boolean;
  125194. /**
  125195. * Info about each image of the basis file
  125196. */
  125197. images: Array<{
  125198. levels: Array<{
  125199. width: number;
  125200. height: number;
  125201. transcodedPixels: ArrayBufferView;
  125202. }>;
  125203. }>;
  125204. }
  125205. /**
  125206. * Result of transcoding a basis file
  125207. */
  125208. class TranscodeResult {
  125209. /**
  125210. * Info about the .basis file
  125211. */
  125212. fileInfo: BasisFileInfo;
  125213. /**
  125214. * Format to use when loading the file
  125215. */
  125216. format: number;
  125217. }
  125218. /**
  125219. * Configuration options for the Basis transcoder
  125220. */
  125221. export class BasisTranscodeConfiguration {
  125222. /**
  125223. * Supported compression formats used to determine the supported output format of the transcoder
  125224. */
  125225. supportedCompressionFormats?: {
  125226. /**
  125227. * etc1 compression format
  125228. */
  125229. etc1?: boolean;
  125230. /**
  125231. * s3tc compression format
  125232. */
  125233. s3tc?: boolean;
  125234. /**
  125235. * pvrtc compression format
  125236. */
  125237. pvrtc?: boolean;
  125238. /**
  125239. * etc2 compression format
  125240. */
  125241. etc2?: boolean;
  125242. };
  125243. /**
  125244. * If mipmap levels should be loaded for transcoded images (Default: true)
  125245. */
  125246. loadMipmapLevels?: boolean;
  125247. /**
  125248. * Index of a single image to load (Default: all images)
  125249. */
  125250. loadSingleImage?: number;
  125251. }
  125252. /**
  125253. * Used to load .Basis files
  125254. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  125255. */
  125256. export class BasisTools {
  125257. private static _IgnoreSupportedFormats;
  125258. /**
  125259. * URL to use when loading the basis transcoder
  125260. */
  125261. static JSModuleURL: string;
  125262. /**
  125263. * URL to use when loading the wasm module for the transcoder
  125264. */
  125265. static WasmModuleURL: string;
  125266. /**
  125267. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  125268. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  125269. * @returns internal format corresponding to the Basis format
  125270. */
  125271. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  125272. private static _WorkerPromise;
  125273. private static _Worker;
  125274. private static _actionId;
  125275. private static _CreateWorkerAsync;
  125276. /**
  125277. * Transcodes a loaded image file to compressed pixel data
  125278. * @param imageData image data to transcode
  125279. * @param config configuration options for the transcoding
  125280. * @returns a promise resulting in the transcoded image
  125281. */
  125282. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  125283. /**
  125284. * Loads a texture from the transcode result
  125285. * @param texture texture load to
  125286. * @param transcodeResult the result of transcoding the basis file to load from
  125287. */
  125288. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  125289. }
  125290. }
  125291. declare module BABYLON {
  125292. /**
  125293. * Loader for .basis file format
  125294. */
  125295. export class _BasisTextureLoader implements IInternalTextureLoader {
  125296. /**
  125297. * Defines whether the loader supports cascade loading the different faces.
  125298. */
  125299. readonly supportCascades: boolean;
  125300. /**
  125301. * This returns if the loader support the current file information.
  125302. * @param extension defines the file extension of the file being loaded
  125303. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125304. * @param fallback defines the fallback internal texture if any
  125305. * @param isBase64 defines whether the texture is encoded as a base64
  125306. * @param isBuffer defines whether the texture data are stored as a buffer
  125307. * @returns true if the loader can load the specified file
  125308. */
  125309. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125310. /**
  125311. * Transform the url before loading if required.
  125312. * @param rootUrl the url of the texture
  125313. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125314. * @returns the transformed texture
  125315. */
  125316. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125317. /**
  125318. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125319. * @param rootUrl the url of the texture
  125320. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125321. * @returns the fallback texture
  125322. */
  125323. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125324. /**
  125325. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  125326. * @param data contains the texture data
  125327. * @param texture defines the BabylonJS internal texture
  125328. * @param createPolynomials will be true if polynomials have been requested
  125329. * @param onLoad defines the callback to trigger once the texture is ready
  125330. * @param onError defines the callback to trigger in case of error
  125331. */
  125332. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125333. /**
  125334. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125335. * @param data contains the texture data
  125336. * @param texture defines the BabylonJS internal texture
  125337. * @param callback defines the method to call once ready to upload
  125338. */
  125339. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125340. }
  125341. }
  125342. declare module BABYLON {
  125343. /**
  125344. * 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.
  125345. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  125346. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  125347. */
  125348. export class CustomProceduralTexture extends ProceduralTexture {
  125349. private _animate;
  125350. private _time;
  125351. private _config;
  125352. private _texturePath;
  125353. /**
  125354. * Instantiates a new Custom Procedural Texture.
  125355. * 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.
  125356. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  125357. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  125358. * @param name Define the name of the texture
  125359. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  125360. * @param size Define the size of the texture to create
  125361. * @param scene Define the scene the texture belongs to
  125362. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  125363. * @param generateMipMaps Define if the texture should creates mip maps or not
  125364. */
  125365. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  125366. private _loadJson;
  125367. /**
  125368. * Is the texture ready to be used ? (rendered at least once)
  125369. * @returns true if ready, otherwise, false.
  125370. */
  125371. isReady(): boolean;
  125372. /**
  125373. * Render the texture to its associated render target.
  125374. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  125375. */
  125376. render(useCameraPostProcess?: boolean): void;
  125377. /**
  125378. * Update the list of dependant textures samplers in the shader.
  125379. */
  125380. updateTextures(): void;
  125381. /**
  125382. * Update the uniform values of the procedural texture in the shader.
  125383. */
  125384. updateShaderUniforms(): void;
  125385. /**
  125386. * Define if the texture animates or not.
  125387. */
  125388. get animate(): boolean;
  125389. set animate(value: boolean);
  125390. }
  125391. }
  125392. declare module BABYLON {
  125393. /** @hidden */
  125394. export var noisePixelShader: {
  125395. name: string;
  125396. shader: string;
  125397. };
  125398. }
  125399. declare module BABYLON {
  125400. /**
  125401. * Class used to generate noise procedural textures
  125402. */
  125403. export class NoiseProceduralTexture extends ProceduralTexture {
  125404. private _time;
  125405. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  125406. brightness: number;
  125407. /** Defines the number of octaves to process */
  125408. octaves: number;
  125409. /** Defines the level of persistence (0.8 by default) */
  125410. persistence: number;
  125411. /** Gets or sets animation speed factor (default is 1) */
  125412. animationSpeedFactor: number;
  125413. /**
  125414. * Creates a new NoiseProceduralTexture
  125415. * @param name defines the name fo the texture
  125416. * @param size defines the size of the texture (default is 256)
  125417. * @param scene defines the hosting scene
  125418. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  125419. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  125420. */
  125421. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  125422. private _updateShaderUniforms;
  125423. protected _getDefines(): string;
  125424. /** Generate the current state of the procedural texture */
  125425. render(useCameraPostProcess?: boolean): void;
  125426. /**
  125427. * Serializes this noise procedural texture
  125428. * @returns a serialized noise procedural texture object
  125429. */
  125430. serialize(): any;
  125431. /**
  125432. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  125433. * @param parsedTexture defines parsed texture data
  125434. * @param scene defines the current scene
  125435. * @param rootUrl defines the root URL containing noise procedural texture information
  125436. * @returns a parsed NoiseProceduralTexture
  125437. */
  125438. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  125439. }
  125440. }
  125441. declare module BABYLON {
  125442. /**
  125443. * Raw cube texture where the raw buffers are passed in
  125444. */
  125445. export class RawCubeTexture extends CubeTexture {
  125446. /**
  125447. * Creates a cube texture where the raw buffers are passed in.
  125448. * @param scene defines the scene the texture is attached to
  125449. * @param data defines the array of data to use to create each face
  125450. * @param size defines the size of the textures
  125451. * @param format defines the format of the data
  125452. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  125453. * @param generateMipMaps defines if the engine should generate the mip levels
  125454. * @param invertY defines if data must be stored with Y axis inverted
  125455. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  125456. * @param compression defines the compression used (null by default)
  125457. */
  125458. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  125459. /**
  125460. * Updates the raw cube texture.
  125461. * @param data defines the data to store
  125462. * @param format defines the data format
  125463. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  125464. * @param invertY defines if data must be stored with Y axis inverted
  125465. * @param compression defines the compression used (null by default)
  125466. * @param level defines which level of the texture to update
  125467. */
  125468. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  125469. /**
  125470. * Updates a raw cube texture with RGBD encoded data.
  125471. * @param data defines the array of data [mipmap][face] to use to create each face
  125472. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  125473. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  125474. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  125475. * @returns a promsie that resolves when the operation is complete
  125476. */
  125477. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  125478. /**
  125479. * Clones the raw cube texture.
  125480. * @return a new cube texture
  125481. */
  125482. clone(): CubeTexture;
  125483. /** @hidden */
  125484. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  125485. }
  125486. }
  125487. declare module BABYLON {
  125488. /**
  125489. * Class used to store 3D textures containing user data
  125490. */
  125491. export class RawTexture3D extends Texture {
  125492. /** Gets or sets the texture format to use */
  125493. format: number;
  125494. private _engine;
  125495. /**
  125496. * Create a new RawTexture3D
  125497. * @param data defines the data of the texture
  125498. * @param width defines the width of the texture
  125499. * @param height defines the height of the texture
  125500. * @param depth defines the depth of the texture
  125501. * @param format defines the texture format to use
  125502. * @param scene defines the hosting scene
  125503. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  125504. * @param invertY defines if texture must be stored with Y axis inverted
  125505. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  125506. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  125507. */
  125508. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  125509. /** Gets or sets the texture format to use */
  125510. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  125511. /**
  125512. * Update the texture with new data
  125513. * @param data defines the data to store in the texture
  125514. */
  125515. update(data: ArrayBufferView): void;
  125516. }
  125517. }
  125518. declare module BABYLON {
  125519. /**
  125520. * Class used to store 2D array textures containing user data
  125521. */
  125522. export class RawTexture2DArray extends Texture {
  125523. /** Gets or sets the texture format to use */
  125524. format: number;
  125525. private _engine;
  125526. /**
  125527. * Create a new RawTexture2DArray
  125528. * @param data defines the data of the texture
  125529. * @param width defines the width of the texture
  125530. * @param height defines the height of the texture
  125531. * @param depth defines the number of layers of the texture
  125532. * @param format defines the texture format to use
  125533. * @param scene defines the hosting scene
  125534. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  125535. * @param invertY defines if texture must be stored with Y axis inverted
  125536. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  125537. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  125538. */
  125539. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  125540. /** Gets or sets the texture format to use */
  125541. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  125542. /**
  125543. * Update the texture with new data
  125544. * @param data defines the data to store in the texture
  125545. */
  125546. update(data: ArrayBufferView): void;
  125547. }
  125548. }
  125549. declare module BABYLON {
  125550. /**
  125551. * Creates a refraction texture used by refraction channel of the standard material.
  125552. * It is like a mirror but to see through a material.
  125553. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  125554. */
  125555. export class RefractionTexture extends RenderTargetTexture {
  125556. /**
  125557. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  125558. * 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.
  125559. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  125560. */
  125561. refractionPlane: Plane;
  125562. /**
  125563. * Define how deep under the surface we should see.
  125564. */
  125565. depth: number;
  125566. /**
  125567. * Creates a refraction texture used by refraction channel of the standard material.
  125568. * It is like a mirror but to see through a material.
  125569. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  125570. * @param name Define the texture name
  125571. * @param size Define the size of the underlying texture
  125572. * @param scene Define the scene the refraction belongs to
  125573. * @param generateMipMaps Define if we need to generate mips level for the refraction
  125574. */
  125575. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  125576. /**
  125577. * Clone the refraction texture.
  125578. * @returns the cloned texture
  125579. */
  125580. clone(): RefractionTexture;
  125581. /**
  125582. * Serialize the texture to a JSON representation you could use in Parse later on
  125583. * @returns the serialized JSON representation
  125584. */
  125585. serialize(): any;
  125586. }
  125587. }
  125588. declare module BABYLON {
  125589. /**
  125590. * Defines the options related to the creation of an HtmlElementTexture
  125591. */
  125592. export interface IHtmlElementTextureOptions {
  125593. /**
  125594. * Defines wether mip maps should be created or not.
  125595. */
  125596. generateMipMaps?: boolean;
  125597. /**
  125598. * Defines the sampling mode of the texture.
  125599. */
  125600. samplingMode?: number;
  125601. /**
  125602. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  125603. */
  125604. engine: Nullable<ThinEngine>;
  125605. /**
  125606. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  125607. */
  125608. scene: Nullable<Scene>;
  125609. }
  125610. /**
  125611. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  125612. * To be as efficient as possible depending on your constraints nothing aside the first upload
  125613. * is automatically managed.
  125614. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  125615. * in your application.
  125616. *
  125617. * As the update is not automatic, you need to call them manually.
  125618. */
  125619. export class HtmlElementTexture extends BaseTexture {
  125620. /**
  125621. * The texture URL.
  125622. */
  125623. element: HTMLVideoElement | HTMLCanvasElement;
  125624. private static readonly DefaultOptions;
  125625. private _textureMatrix;
  125626. private _engine;
  125627. private _isVideo;
  125628. private _generateMipMaps;
  125629. private _samplingMode;
  125630. /**
  125631. * Instantiates a HtmlElementTexture from the following parameters.
  125632. *
  125633. * @param name Defines the name of the texture
  125634. * @param element Defines the video or canvas the texture is filled with
  125635. * @param options Defines the other none mandatory texture creation options
  125636. */
  125637. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  125638. private _createInternalTexture;
  125639. /**
  125640. * Returns the texture matrix used in most of the material.
  125641. */
  125642. getTextureMatrix(): Matrix;
  125643. /**
  125644. * Updates the content of the texture.
  125645. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  125646. */
  125647. update(invertY?: Nullable<boolean>): void;
  125648. }
  125649. }
  125650. declare module BABYLON {
  125651. /**
  125652. * Enum used to define the target of a block
  125653. */
  125654. export enum NodeMaterialBlockTargets {
  125655. /** Vertex shader */
  125656. Vertex = 1,
  125657. /** Fragment shader */
  125658. Fragment = 2,
  125659. /** Neutral */
  125660. Neutral = 4,
  125661. /** Vertex and Fragment */
  125662. VertexAndFragment = 3
  125663. }
  125664. }
  125665. declare module BABYLON {
  125666. /**
  125667. * Defines the kind of connection point for node based material
  125668. */
  125669. export enum NodeMaterialBlockConnectionPointTypes {
  125670. /** Float */
  125671. Float = 1,
  125672. /** Int */
  125673. Int = 2,
  125674. /** Vector2 */
  125675. Vector2 = 4,
  125676. /** Vector3 */
  125677. Vector3 = 8,
  125678. /** Vector4 */
  125679. Vector4 = 16,
  125680. /** Color3 */
  125681. Color3 = 32,
  125682. /** Color4 */
  125683. Color4 = 64,
  125684. /** Matrix */
  125685. Matrix = 128,
  125686. /** Detect type based on connection */
  125687. AutoDetect = 1024,
  125688. /** Output type that will be defined by input type */
  125689. BasedOnInput = 2048
  125690. }
  125691. }
  125692. declare module BABYLON {
  125693. /**
  125694. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  125695. */
  125696. export enum NodeMaterialBlockConnectionPointMode {
  125697. /** Value is an uniform */
  125698. Uniform = 0,
  125699. /** Value is a mesh attribute */
  125700. Attribute = 1,
  125701. /** Value is a varying between vertex and fragment shaders */
  125702. Varying = 2,
  125703. /** Mode is undefined */
  125704. Undefined = 3
  125705. }
  125706. }
  125707. declare module BABYLON {
  125708. /**
  125709. * Enum used to define system values e.g. values automatically provided by the system
  125710. */
  125711. export enum NodeMaterialSystemValues {
  125712. /** World */
  125713. World = 1,
  125714. /** View */
  125715. View = 2,
  125716. /** Projection */
  125717. Projection = 3,
  125718. /** ViewProjection */
  125719. ViewProjection = 4,
  125720. /** WorldView */
  125721. WorldView = 5,
  125722. /** WorldViewProjection */
  125723. WorldViewProjection = 6,
  125724. /** CameraPosition */
  125725. CameraPosition = 7,
  125726. /** Fog Color */
  125727. FogColor = 8,
  125728. /** Delta time */
  125729. DeltaTime = 9
  125730. }
  125731. }
  125732. declare module BABYLON {
  125733. /**
  125734. * Root class for all node material optimizers
  125735. */
  125736. export class NodeMaterialOptimizer {
  125737. /**
  125738. * Function used to optimize a NodeMaterial graph
  125739. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  125740. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  125741. */
  125742. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  125743. }
  125744. }
  125745. declare module BABYLON {
  125746. /**
  125747. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  125748. */
  125749. export class TransformBlock extends NodeMaterialBlock {
  125750. /**
  125751. * Defines the value to use to complement W value to transform it to a Vector4
  125752. */
  125753. complementW: number;
  125754. /**
  125755. * Defines the value to use to complement z value to transform it to a Vector4
  125756. */
  125757. complementZ: number;
  125758. /**
  125759. * Creates a new TransformBlock
  125760. * @param name defines the block name
  125761. */
  125762. constructor(name: string);
  125763. /**
  125764. * Gets the current class name
  125765. * @returns the class name
  125766. */
  125767. getClassName(): string;
  125768. /**
  125769. * Gets the vector input
  125770. */
  125771. get vector(): NodeMaterialConnectionPoint;
  125772. /**
  125773. * Gets the output component
  125774. */
  125775. get output(): NodeMaterialConnectionPoint;
  125776. /**
  125777. * Gets the matrix transform input
  125778. */
  125779. get transform(): NodeMaterialConnectionPoint;
  125780. protected _buildBlock(state: NodeMaterialBuildState): this;
  125781. serialize(): any;
  125782. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125783. protected _dumpPropertiesCode(): string;
  125784. }
  125785. }
  125786. declare module BABYLON {
  125787. /**
  125788. * Block used to output the vertex position
  125789. */
  125790. export class VertexOutputBlock extends NodeMaterialBlock {
  125791. /**
  125792. * Creates a new VertexOutputBlock
  125793. * @param name defines the block name
  125794. */
  125795. constructor(name: string);
  125796. /**
  125797. * Gets the current class name
  125798. * @returns the class name
  125799. */
  125800. getClassName(): string;
  125801. /**
  125802. * Gets the vector input component
  125803. */
  125804. get vector(): NodeMaterialConnectionPoint;
  125805. protected _buildBlock(state: NodeMaterialBuildState): this;
  125806. }
  125807. }
  125808. declare module BABYLON {
  125809. /**
  125810. * Block used to output the final color
  125811. */
  125812. export class FragmentOutputBlock extends NodeMaterialBlock {
  125813. /**
  125814. * Create a new FragmentOutputBlock
  125815. * @param name defines the block name
  125816. */
  125817. constructor(name: string);
  125818. /**
  125819. * Gets the current class name
  125820. * @returns the class name
  125821. */
  125822. getClassName(): string;
  125823. /**
  125824. * Gets the rgba input component
  125825. */
  125826. get rgba(): NodeMaterialConnectionPoint;
  125827. /**
  125828. * Gets the rgb input component
  125829. */
  125830. get rgb(): NodeMaterialConnectionPoint;
  125831. /**
  125832. * Gets the a input component
  125833. */
  125834. get a(): NodeMaterialConnectionPoint;
  125835. protected _buildBlock(state: NodeMaterialBuildState): this;
  125836. }
  125837. }
  125838. declare module BABYLON {
  125839. /**
  125840. * Block used to read a reflection texture from a sampler
  125841. */
  125842. export class ReflectionTextureBlock extends NodeMaterialBlock {
  125843. private _define3DName;
  125844. private _defineCubicName;
  125845. private _defineExplicitName;
  125846. private _defineProjectionName;
  125847. private _defineLocalCubicName;
  125848. private _defineSphericalName;
  125849. private _definePlanarName;
  125850. private _defineEquirectangularName;
  125851. private _defineMirroredEquirectangularFixedName;
  125852. private _defineEquirectangularFixedName;
  125853. private _defineSkyboxName;
  125854. private _cubeSamplerName;
  125855. private _2DSamplerName;
  125856. private _positionUVWName;
  125857. private _directionWName;
  125858. private _reflectionCoordsName;
  125859. private _reflection2DCoordsName;
  125860. private _reflectionColorName;
  125861. private _reflectionMatrixName;
  125862. /**
  125863. * Gets or sets the texture associated with the node
  125864. */
  125865. texture: Nullable<BaseTexture>;
  125866. /**
  125867. * Create a new TextureBlock
  125868. * @param name defines the block name
  125869. */
  125870. constructor(name: string);
  125871. /**
  125872. * Gets the current class name
  125873. * @returns the class name
  125874. */
  125875. getClassName(): string;
  125876. /**
  125877. * Gets the world position input component
  125878. */
  125879. get position(): NodeMaterialConnectionPoint;
  125880. /**
  125881. * Gets the world position input component
  125882. */
  125883. get worldPosition(): NodeMaterialConnectionPoint;
  125884. /**
  125885. * Gets the world normal input component
  125886. */
  125887. get worldNormal(): NodeMaterialConnectionPoint;
  125888. /**
  125889. * Gets the world input component
  125890. */
  125891. get world(): NodeMaterialConnectionPoint;
  125892. /**
  125893. * Gets the camera (or eye) position component
  125894. */
  125895. get cameraPosition(): NodeMaterialConnectionPoint;
  125896. /**
  125897. * Gets the view input component
  125898. */
  125899. get view(): NodeMaterialConnectionPoint;
  125900. /**
  125901. * Gets the rgb output component
  125902. */
  125903. get rgb(): NodeMaterialConnectionPoint;
  125904. /**
  125905. * Gets the r output component
  125906. */
  125907. get r(): NodeMaterialConnectionPoint;
  125908. /**
  125909. * Gets the g output component
  125910. */
  125911. get g(): NodeMaterialConnectionPoint;
  125912. /**
  125913. * Gets the b output component
  125914. */
  125915. get b(): NodeMaterialConnectionPoint;
  125916. autoConfigure(material: NodeMaterial): void;
  125917. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  125918. isReady(): boolean;
  125919. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  125920. private _injectVertexCode;
  125921. private _writeOutput;
  125922. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  125923. protected _dumpPropertiesCode(): string;
  125924. serialize(): any;
  125925. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  125926. }
  125927. }
  125928. declare module BABYLON {
  125929. /**
  125930. * Interface used to configure the node material editor
  125931. */
  125932. export interface INodeMaterialEditorOptions {
  125933. /** Define the URl to load node editor script */
  125934. editorURL?: string;
  125935. }
  125936. /** @hidden */
  125937. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  125938. /** BONES */
  125939. NUM_BONE_INFLUENCERS: number;
  125940. BonesPerMesh: number;
  125941. BONETEXTURE: boolean;
  125942. /** MORPH TARGETS */
  125943. MORPHTARGETS: boolean;
  125944. MORPHTARGETS_NORMAL: boolean;
  125945. MORPHTARGETS_TANGENT: boolean;
  125946. MORPHTARGETS_UV: boolean;
  125947. NUM_MORPH_INFLUENCERS: number;
  125948. /** IMAGE PROCESSING */
  125949. IMAGEPROCESSING: boolean;
  125950. VIGNETTE: boolean;
  125951. VIGNETTEBLENDMODEMULTIPLY: boolean;
  125952. VIGNETTEBLENDMODEOPAQUE: boolean;
  125953. TONEMAPPING: boolean;
  125954. TONEMAPPING_ACES: boolean;
  125955. CONTRAST: boolean;
  125956. EXPOSURE: boolean;
  125957. COLORCURVES: boolean;
  125958. COLORGRADING: boolean;
  125959. COLORGRADING3D: boolean;
  125960. SAMPLER3DGREENDEPTH: boolean;
  125961. SAMPLER3DBGRMAP: boolean;
  125962. IMAGEPROCESSINGPOSTPROCESS: boolean;
  125963. /** MISC. */
  125964. BUMPDIRECTUV: number;
  125965. constructor();
  125966. setValue(name: string, value: boolean): void;
  125967. }
  125968. /**
  125969. * Class used to configure NodeMaterial
  125970. */
  125971. export interface INodeMaterialOptions {
  125972. /**
  125973. * Defines if blocks should emit comments
  125974. */
  125975. emitComments: boolean;
  125976. }
  125977. /**
  125978. * Class used to create a node based material built by assembling shader blocks
  125979. */
  125980. export class NodeMaterial extends PushMaterial {
  125981. private static _BuildIdGenerator;
  125982. private _options;
  125983. private _vertexCompilationState;
  125984. private _fragmentCompilationState;
  125985. private _sharedData;
  125986. private _buildId;
  125987. private _buildWasSuccessful;
  125988. private _cachedWorldViewMatrix;
  125989. private _cachedWorldViewProjectionMatrix;
  125990. private _optimizers;
  125991. private _animationFrame;
  125992. /** Define the URl to load node editor script */
  125993. static EditorURL: string;
  125994. private BJSNODEMATERIALEDITOR;
  125995. /** Get the inspector from bundle or global */
  125996. private _getGlobalNodeMaterialEditor;
  125997. /**
  125998. * Gets or sets data used by visual editor
  125999. * @see https://nme.babylonjs.com
  126000. */
  126001. editorData: any;
  126002. /**
  126003. * 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)
  126004. */
  126005. ignoreAlpha: boolean;
  126006. /**
  126007. * Defines the maximum number of lights that can be used in the material
  126008. */
  126009. maxSimultaneousLights: number;
  126010. /**
  126011. * Observable raised when the material is built
  126012. */
  126013. onBuildObservable: Observable<NodeMaterial>;
  126014. /**
  126015. * Gets or sets the root nodes of the material vertex shader
  126016. */
  126017. _vertexOutputNodes: NodeMaterialBlock[];
  126018. /**
  126019. * Gets or sets the root nodes of the material fragment (pixel) shader
  126020. */
  126021. _fragmentOutputNodes: NodeMaterialBlock[];
  126022. /** Gets or sets options to control the node material overall behavior */
  126023. get options(): INodeMaterialOptions;
  126024. set options(options: INodeMaterialOptions);
  126025. /**
  126026. * Default configuration related to image processing available in the standard Material.
  126027. */
  126028. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  126029. /**
  126030. * Gets the image processing configuration used either in this material.
  126031. */
  126032. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  126033. /**
  126034. * Sets the Default image processing configuration used either in the this material.
  126035. *
  126036. * If sets to null, the scene one is in use.
  126037. */
  126038. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  126039. /**
  126040. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  126041. */
  126042. attachedBlocks: NodeMaterialBlock[];
  126043. /**
  126044. * Create a new node based material
  126045. * @param name defines the material name
  126046. * @param scene defines the hosting scene
  126047. * @param options defines creation option
  126048. */
  126049. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  126050. /**
  126051. * Gets the current class name of the material e.g. "NodeMaterial"
  126052. * @returns the class name
  126053. */
  126054. getClassName(): string;
  126055. /**
  126056. * Keep track of the image processing observer to allow dispose and replace.
  126057. */
  126058. private _imageProcessingObserver;
  126059. /**
  126060. * Attaches a new image processing configuration to the Standard Material.
  126061. * @param configuration
  126062. */
  126063. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  126064. /**
  126065. * Get a block by its name
  126066. * @param name defines the name of the block to retrieve
  126067. * @returns the required block or null if not found
  126068. */
  126069. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  126070. /**
  126071. * Get a block by its name
  126072. * @param predicate defines the predicate used to find the good candidate
  126073. * @returns the required block or null if not found
  126074. */
  126075. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  126076. /**
  126077. * Get an input block by its name
  126078. * @param predicate defines the predicate used to find the good candidate
  126079. * @returns the required input block or null if not found
  126080. */
  126081. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  126082. /**
  126083. * Gets the list of input blocks attached to this material
  126084. * @returns an array of InputBlocks
  126085. */
  126086. getInputBlocks(): InputBlock[];
  126087. /**
  126088. * Adds a new optimizer to the list of optimizers
  126089. * @param optimizer defines the optimizers to add
  126090. * @returns the current material
  126091. */
  126092. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  126093. /**
  126094. * Remove an optimizer from the list of optimizers
  126095. * @param optimizer defines the optimizers to remove
  126096. * @returns the current material
  126097. */
  126098. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  126099. /**
  126100. * Add a new block to the list of output nodes
  126101. * @param node defines the node to add
  126102. * @returns the current material
  126103. */
  126104. addOutputNode(node: NodeMaterialBlock): this;
  126105. /**
  126106. * Remove a block from the list of root nodes
  126107. * @param node defines the node to remove
  126108. * @returns the current material
  126109. */
  126110. removeOutputNode(node: NodeMaterialBlock): this;
  126111. private _addVertexOutputNode;
  126112. private _removeVertexOutputNode;
  126113. private _addFragmentOutputNode;
  126114. private _removeFragmentOutputNode;
  126115. /**
  126116. * Specifies if the material will require alpha blending
  126117. * @returns a boolean specifying if alpha blending is needed
  126118. */
  126119. needAlphaBlending(): boolean;
  126120. /**
  126121. * Specifies if this material should be rendered in alpha test mode
  126122. * @returns a boolean specifying if an alpha test is needed.
  126123. */
  126124. needAlphaTesting(): boolean;
  126125. private _initializeBlock;
  126126. private _resetDualBlocks;
  126127. /**
  126128. * Remove a block from the current node material
  126129. * @param block defines the block to remove
  126130. */
  126131. removeBlock(block: NodeMaterialBlock): void;
  126132. /**
  126133. * Build the material and generates the inner effect
  126134. * @param verbose defines if the build should log activity
  126135. */
  126136. build(verbose?: boolean): void;
  126137. /**
  126138. * Runs an otpimization phase to try to improve the shader code
  126139. */
  126140. optimize(): void;
  126141. private _prepareDefinesForAttributes;
  126142. /**
  126143. * Get if the submesh is ready to be used and all its information available.
  126144. * Child classes can use it to update shaders
  126145. * @param mesh defines the mesh to check
  126146. * @param subMesh defines which submesh to check
  126147. * @param useInstances specifies that instances should be used
  126148. * @returns a boolean indicating that the submesh is ready or not
  126149. */
  126150. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  126151. /**
  126152. * Get a string representing the shaders built by the current node graph
  126153. */
  126154. get compiledShaders(): string;
  126155. /**
  126156. * Binds the world matrix to the material
  126157. * @param world defines the world transformation matrix
  126158. */
  126159. bindOnlyWorldMatrix(world: Matrix): void;
  126160. /**
  126161. * Binds the submesh to this material by preparing the effect and shader to draw
  126162. * @param world defines the world transformation matrix
  126163. * @param mesh defines the mesh containing the submesh
  126164. * @param subMesh defines the submesh to bind the material to
  126165. */
  126166. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  126167. /**
  126168. * Gets the active textures from the material
  126169. * @returns an array of textures
  126170. */
  126171. getActiveTextures(): BaseTexture[];
  126172. /**
  126173. * Gets the list of texture blocks
  126174. * @returns an array of texture blocks
  126175. */
  126176. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  126177. /**
  126178. * Specifies if the material uses a texture
  126179. * @param texture defines the texture to check against the material
  126180. * @returns a boolean specifying if the material uses the texture
  126181. */
  126182. hasTexture(texture: BaseTexture): boolean;
  126183. /**
  126184. * Disposes the material
  126185. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  126186. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  126187. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  126188. */
  126189. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  126190. /** Creates the node editor window. */
  126191. private _createNodeEditor;
  126192. /**
  126193. * Launch the node material editor
  126194. * @param config Define the configuration of the editor
  126195. * @return a promise fulfilled when the node editor is visible
  126196. */
  126197. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  126198. /**
  126199. * Clear the current material
  126200. */
  126201. clear(): void;
  126202. /**
  126203. * Clear the current material and set it to a default state
  126204. */
  126205. setToDefault(): void;
  126206. /**
  126207. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  126208. * @param url defines the url to load from
  126209. * @returns a promise that will fullfil when the material is fully loaded
  126210. */
  126211. loadAsync(url: string): Promise<void>;
  126212. private _gatherBlocks;
  126213. /**
  126214. * Generate a string containing the code declaration required to create an equivalent of this material
  126215. * @returns a string
  126216. */
  126217. generateCode(): string;
  126218. /**
  126219. * Serializes this material in a JSON representation
  126220. * @returns the serialized material object
  126221. */
  126222. serialize(): any;
  126223. private _restoreConnections;
  126224. /**
  126225. * Clear the current graph and load a new one from a serialization object
  126226. * @param source defines the JSON representation of the material
  126227. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  126228. */
  126229. loadFromSerialization(source: any, rootUrl?: string): void;
  126230. /**
  126231. * Creates a node material from parsed material data
  126232. * @param source defines the JSON representation of the material
  126233. * @param scene defines the hosting scene
  126234. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  126235. * @returns a new node material
  126236. */
  126237. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  126238. /**
  126239. * Creates a new node material set to default basic configuration
  126240. * @param name defines the name of the material
  126241. * @param scene defines the hosting scene
  126242. * @returns a new NodeMaterial
  126243. */
  126244. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  126245. }
  126246. }
  126247. declare module BABYLON {
  126248. /**
  126249. * Block used to read a texture from a sampler
  126250. */
  126251. export class TextureBlock extends NodeMaterialBlock {
  126252. private _defineName;
  126253. private _linearDefineName;
  126254. private _tempTextureRead;
  126255. private _samplerName;
  126256. private _transformedUVName;
  126257. private _textureTransformName;
  126258. private _textureInfoName;
  126259. private _mainUVName;
  126260. private _mainUVDefineName;
  126261. /**
  126262. * Gets or sets the texture associated with the node
  126263. */
  126264. texture: Nullable<Texture>;
  126265. /**
  126266. * Create a new TextureBlock
  126267. * @param name defines the block name
  126268. */
  126269. constructor(name: string);
  126270. /**
  126271. * Gets the current class name
  126272. * @returns the class name
  126273. */
  126274. getClassName(): string;
  126275. /**
  126276. * Gets the uv input component
  126277. */
  126278. get uv(): NodeMaterialConnectionPoint;
  126279. /**
  126280. * Gets the rgba output component
  126281. */
  126282. get rgba(): NodeMaterialConnectionPoint;
  126283. /**
  126284. * Gets the rgb output component
  126285. */
  126286. get rgb(): NodeMaterialConnectionPoint;
  126287. /**
  126288. * Gets the r output component
  126289. */
  126290. get r(): NodeMaterialConnectionPoint;
  126291. /**
  126292. * Gets the g output component
  126293. */
  126294. get g(): NodeMaterialConnectionPoint;
  126295. /**
  126296. * Gets the b output component
  126297. */
  126298. get b(): NodeMaterialConnectionPoint;
  126299. /**
  126300. * Gets the a output component
  126301. */
  126302. get a(): NodeMaterialConnectionPoint;
  126303. get target(): NodeMaterialBlockTargets;
  126304. autoConfigure(material: NodeMaterial): void;
  126305. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  126306. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  126307. private _getTextureBase;
  126308. isReady(): boolean;
  126309. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  126310. private get _isMixed();
  126311. private _injectVertexCode;
  126312. private _writeTextureRead;
  126313. private _writeOutput;
  126314. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  126315. protected _dumpPropertiesCode(): string;
  126316. serialize(): any;
  126317. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126318. }
  126319. }
  126320. declare module BABYLON {
  126321. /**
  126322. * Class used to store shared data between 2 NodeMaterialBuildState
  126323. */
  126324. export class NodeMaterialBuildStateSharedData {
  126325. /**
  126326. * Gets the list of emitted varyings
  126327. */
  126328. temps: string[];
  126329. /**
  126330. * Gets the list of emitted varyings
  126331. */
  126332. varyings: string[];
  126333. /**
  126334. * Gets the varying declaration string
  126335. */
  126336. varyingDeclaration: string;
  126337. /**
  126338. * Input blocks
  126339. */
  126340. inputBlocks: InputBlock[];
  126341. /**
  126342. * Input blocks
  126343. */
  126344. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  126345. /**
  126346. * Bindable blocks (Blocks that need to set data to the effect)
  126347. */
  126348. bindableBlocks: NodeMaterialBlock[];
  126349. /**
  126350. * List of blocks that can provide a compilation fallback
  126351. */
  126352. blocksWithFallbacks: NodeMaterialBlock[];
  126353. /**
  126354. * List of blocks that can provide a define update
  126355. */
  126356. blocksWithDefines: NodeMaterialBlock[];
  126357. /**
  126358. * List of blocks that can provide a repeatable content
  126359. */
  126360. repeatableContentBlocks: NodeMaterialBlock[];
  126361. /**
  126362. * List of blocks that can provide a dynamic list of uniforms
  126363. */
  126364. dynamicUniformBlocks: NodeMaterialBlock[];
  126365. /**
  126366. * List of blocks that can block the isReady function for the material
  126367. */
  126368. blockingBlocks: NodeMaterialBlock[];
  126369. /**
  126370. * Gets the list of animated inputs
  126371. */
  126372. animatedInputs: InputBlock[];
  126373. /**
  126374. * Build Id used to avoid multiple recompilations
  126375. */
  126376. buildId: number;
  126377. /** List of emitted variables */
  126378. variableNames: {
  126379. [key: string]: number;
  126380. };
  126381. /** List of emitted defines */
  126382. defineNames: {
  126383. [key: string]: number;
  126384. };
  126385. /** Should emit comments? */
  126386. emitComments: boolean;
  126387. /** Emit build activity */
  126388. verbose: boolean;
  126389. /** Gets or sets the hosting scene */
  126390. scene: Scene;
  126391. /**
  126392. * Gets the compilation hints emitted at compilation time
  126393. */
  126394. hints: {
  126395. needWorldViewMatrix: boolean;
  126396. needWorldViewProjectionMatrix: boolean;
  126397. needAlphaBlending: boolean;
  126398. needAlphaTesting: boolean;
  126399. };
  126400. /**
  126401. * List of compilation checks
  126402. */
  126403. checks: {
  126404. emitVertex: boolean;
  126405. emitFragment: boolean;
  126406. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  126407. };
  126408. /** Creates a new shared data */
  126409. constructor();
  126410. /**
  126411. * Emits console errors and exceptions if there is a failing check
  126412. */
  126413. emitErrors(): void;
  126414. }
  126415. }
  126416. declare module BABYLON {
  126417. /**
  126418. * Class used to store node based material build state
  126419. */
  126420. export class NodeMaterialBuildState {
  126421. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  126422. supportUniformBuffers: boolean;
  126423. /**
  126424. * Gets the list of emitted attributes
  126425. */
  126426. attributes: string[];
  126427. /**
  126428. * Gets the list of emitted uniforms
  126429. */
  126430. uniforms: string[];
  126431. /**
  126432. * Gets the list of emitted constants
  126433. */
  126434. constants: string[];
  126435. /**
  126436. * Gets the list of emitted samplers
  126437. */
  126438. samplers: string[];
  126439. /**
  126440. * Gets the list of emitted functions
  126441. */
  126442. functions: {
  126443. [key: string]: string;
  126444. };
  126445. /**
  126446. * Gets the list of emitted extensions
  126447. */
  126448. extensions: {
  126449. [key: string]: string;
  126450. };
  126451. /**
  126452. * Gets the target of the compilation state
  126453. */
  126454. target: NodeMaterialBlockTargets;
  126455. /**
  126456. * Gets the list of emitted counters
  126457. */
  126458. counters: {
  126459. [key: string]: number;
  126460. };
  126461. /**
  126462. * Shared data between multiple NodeMaterialBuildState instances
  126463. */
  126464. sharedData: NodeMaterialBuildStateSharedData;
  126465. /** @hidden */
  126466. _vertexState: NodeMaterialBuildState;
  126467. /** @hidden */
  126468. _attributeDeclaration: string;
  126469. /** @hidden */
  126470. _uniformDeclaration: string;
  126471. /** @hidden */
  126472. _constantDeclaration: string;
  126473. /** @hidden */
  126474. _samplerDeclaration: string;
  126475. /** @hidden */
  126476. _varyingTransfer: string;
  126477. private _repeatableContentAnchorIndex;
  126478. /** @hidden */
  126479. _builtCompilationString: string;
  126480. /**
  126481. * Gets the emitted compilation strings
  126482. */
  126483. compilationString: string;
  126484. /**
  126485. * Finalize the compilation strings
  126486. * @param state defines the current compilation state
  126487. */
  126488. finalize(state: NodeMaterialBuildState): void;
  126489. /** @hidden */
  126490. get _repeatableContentAnchor(): string;
  126491. /** @hidden */
  126492. _getFreeVariableName(prefix: string): string;
  126493. /** @hidden */
  126494. _getFreeDefineName(prefix: string): string;
  126495. /** @hidden */
  126496. _excludeVariableName(name: string): void;
  126497. /** @hidden */
  126498. _emit2DSampler(name: string): void;
  126499. /** @hidden */
  126500. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  126501. /** @hidden */
  126502. _emitExtension(name: string, extension: string): void;
  126503. /** @hidden */
  126504. _emitFunction(name: string, code: string, comments: string): void;
  126505. /** @hidden */
  126506. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  126507. replaceStrings?: {
  126508. search: RegExp;
  126509. replace: string;
  126510. }[];
  126511. repeatKey?: string;
  126512. }): string;
  126513. /** @hidden */
  126514. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  126515. repeatKey?: string;
  126516. removeAttributes?: boolean;
  126517. removeUniforms?: boolean;
  126518. removeVaryings?: boolean;
  126519. removeIfDef?: boolean;
  126520. replaceStrings?: {
  126521. search: RegExp;
  126522. replace: string;
  126523. }[];
  126524. }, storeKey?: string): void;
  126525. /** @hidden */
  126526. _registerTempVariable(name: string): boolean;
  126527. /** @hidden */
  126528. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  126529. /** @hidden */
  126530. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  126531. /** @hidden */
  126532. _emitFloat(value: number): string;
  126533. }
  126534. }
  126535. declare module BABYLON {
  126536. /**
  126537. * Defines a block that can be used inside a node based material
  126538. */
  126539. export class NodeMaterialBlock {
  126540. private _buildId;
  126541. private _buildTarget;
  126542. private _target;
  126543. private _isFinalMerger;
  126544. private _isInput;
  126545. protected _isUnique: boolean;
  126546. /** @hidden */
  126547. _codeVariableName: string;
  126548. /** @hidden */
  126549. _inputs: NodeMaterialConnectionPoint[];
  126550. /** @hidden */
  126551. _outputs: NodeMaterialConnectionPoint[];
  126552. /** @hidden */
  126553. _preparationId: number;
  126554. /**
  126555. * Gets or sets the name of the block
  126556. */
  126557. name: string;
  126558. /**
  126559. * Gets or sets the unique id of the node
  126560. */
  126561. uniqueId: number;
  126562. /**
  126563. * Gets or sets the comments associated with this block
  126564. */
  126565. comments: string;
  126566. /**
  126567. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  126568. */
  126569. get isUnique(): boolean;
  126570. /**
  126571. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  126572. */
  126573. get isFinalMerger(): boolean;
  126574. /**
  126575. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  126576. */
  126577. get isInput(): boolean;
  126578. /**
  126579. * Gets or sets the build Id
  126580. */
  126581. get buildId(): number;
  126582. set buildId(value: number);
  126583. /**
  126584. * Gets or sets the target of the block
  126585. */
  126586. get target(): NodeMaterialBlockTargets;
  126587. set target(value: NodeMaterialBlockTargets);
  126588. /**
  126589. * Gets the list of input points
  126590. */
  126591. get inputs(): NodeMaterialConnectionPoint[];
  126592. /** Gets the list of output points */
  126593. get outputs(): NodeMaterialConnectionPoint[];
  126594. /**
  126595. * Find an input by its name
  126596. * @param name defines the name of the input to look for
  126597. * @returns the input or null if not found
  126598. */
  126599. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  126600. /**
  126601. * Find an output by its name
  126602. * @param name defines the name of the outputto look for
  126603. * @returns the output or null if not found
  126604. */
  126605. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  126606. /**
  126607. * Creates a new NodeMaterialBlock
  126608. * @param name defines the block name
  126609. * @param target defines the target of that block (Vertex by default)
  126610. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  126611. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  126612. */
  126613. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  126614. /**
  126615. * Initialize the block and prepare the context for build
  126616. * @param state defines the state that will be used for the build
  126617. */
  126618. initialize(state: NodeMaterialBuildState): void;
  126619. /**
  126620. * Bind data to effect. Will only be called for blocks with isBindable === true
  126621. * @param effect defines the effect to bind data to
  126622. * @param nodeMaterial defines the hosting NodeMaterial
  126623. * @param mesh defines the mesh that will be rendered
  126624. */
  126625. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  126626. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  126627. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  126628. protected _writeFloat(value: number): string;
  126629. /**
  126630. * Gets the current class name e.g. "NodeMaterialBlock"
  126631. * @returns the class name
  126632. */
  126633. getClassName(): string;
  126634. /**
  126635. * Register a new input. Must be called inside a block constructor
  126636. * @param name defines the connection point name
  126637. * @param type defines the connection point type
  126638. * @param isOptional defines a boolean indicating that this input can be omitted
  126639. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  126640. * @returns the current block
  126641. */
  126642. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  126643. /**
  126644. * Register a new output. Must be called inside a block constructor
  126645. * @param name defines the connection point name
  126646. * @param type defines the connection point type
  126647. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  126648. * @returns the current block
  126649. */
  126650. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  126651. /**
  126652. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  126653. * @param forOutput defines an optional connection point to check compatibility with
  126654. * @returns the first available input or null
  126655. */
  126656. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  126657. /**
  126658. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  126659. * @param forBlock defines an optional block to check compatibility with
  126660. * @returns the first available input or null
  126661. */
  126662. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  126663. /**
  126664. * Gets the sibling of the given output
  126665. * @param current defines the current output
  126666. * @returns the next output in the list or null
  126667. */
  126668. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  126669. /**
  126670. * Connect current block with another block
  126671. * @param other defines the block to connect with
  126672. * @param options define the various options to help pick the right connections
  126673. * @returns the current block
  126674. */
  126675. connectTo(other: NodeMaterialBlock, options?: {
  126676. input?: string;
  126677. output?: string;
  126678. outputSwizzle?: string;
  126679. }): this | undefined;
  126680. protected _buildBlock(state: NodeMaterialBuildState): void;
  126681. /**
  126682. * Add uniforms, samplers and uniform buffers at compilation time
  126683. * @param state defines the state to update
  126684. * @param nodeMaterial defines the node material requesting the update
  126685. * @param defines defines the material defines to update
  126686. * @param uniformBuffers defines the list of uniform buffer names
  126687. */
  126688. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  126689. /**
  126690. * Add potential fallbacks if shader compilation fails
  126691. * @param mesh defines the mesh to be rendered
  126692. * @param fallbacks defines the current prioritized list of fallbacks
  126693. */
  126694. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  126695. /**
  126696. * Initialize defines for shader compilation
  126697. * @param mesh defines the mesh to be rendered
  126698. * @param nodeMaterial defines the node material requesting the update
  126699. * @param defines defines the material defines to update
  126700. * @param useInstances specifies that instances should be used
  126701. */
  126702. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  126703. /**
  126704. * Update defines for shader compilation
  126705. * @param mesh defines the mesh to be rendered
  126706. * @param nodeMaterial defines the node material requesting the update
  126707. * @param defines defines the material defines to update
  126708. * @param useInstances specifies that instances should be used
  126709. */
  126710. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  126711. /**
  126712. * Lets the block try to connect some inputs automatically
  126713. * @param material defines the hosting NodeMaterial
  126714. */
  126715. autoConfigure(material: NodeMaterial): void;
  126716. /**
  126717. * Function called when a block is declared as repeatable content generator
  126718. * @param vertexShaderState defines the current compilation state for the vertex shader
  126719. * @param fragmentShaderState defines the current compilation state for the fragment shader
  126720. * @param mesh defines the mesh to be rendered
  126721. * @param defines defines the material defines to update
  126722. */
  126723. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  126724. /**
  126725. * Checks if the block is ready
  126726. * @param mesh defines the mesh to be rendered
  126727. * @param nodeMaterial defines the node material requesting the update
  126728. * @param defines defines the material defines to update
  126729. * @param useInstances specifies that instances should be used
  126730. * @returns true if the block is ready
  126731. */
  126732. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  126733. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  126734. private _processBuild;
  126735. /**
  126736. * Compile the current node and generate the shader code
  126737. * @param state defines the current compilation state (uniforms, samplers, current string)
  126738. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  126739. * @returns true if already built
  126740. */
  126741. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  126742. protected _inputRename(name: string): string;
  126743. protected _outputRename(name: string): string;
  126744. protected _dumpPropertiesCode(): string;
  126745. /** @hidden */
  126746. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  126747. /** @hidden */
  126748. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  126749. /**
  126750. * Clone the current block to a new identical block
  126751. * @param scene defines the hosting scene
  126752. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  126753. * @returns a copy of the current block
  126754. */
  126755. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  126756. /**
  126757. * Serializes this block in a JSON representation
  126758. * @returns the serialized block object
  126759. */
  126760. serialize(): any;
  126761. /** @hidden */
  126762. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126763. /**
  126764. * Release resources
  126765. */
  126766. dispose(): void;
  126767. }
  126768. }
  126769. declare module BABYLON {
  126770. /**
  126771. * Enum defining the type of animations supported by InputBlock
  126772. */
  126773. export enum AnimatedInputBlockTypes {
  126774. /** No animation */
  126775. None = 0,
  126776. /** Time based animation. Will only work for floats */
  126777. Time = 1
  126778. }
  126779. }
  126780. declare module BABYLON {
  126781. /**
  126782. * Block used to expose an input value
  126783. */
  126784. export class InputBlock extends NodeMaterialBlock {
  126785. private _mode;
  126786. private _associatedVariableName;
  126787. private _storedValue;
  126788. private _valueCallback;
  126789. private _type;
  126790. private _animationType;
  126791. /** Gets or set a value used to limit the range of float values */
  126792. min: number;
  126793. /** Gets or set a value used to limit the range of float values */
  126794. max: number;
  126795. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  126796. matrixMode: number;
  126797. /** @hidden */
  126798. _systemValue: Nullable<NodeMaterialSystemValues>;
  126799. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  126800. visibleInInspector: boolean;
  126801. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  126802. isConstant: boolean;
  126803. /** Gets or sets the group to use to display this block in the Inspector */
  126804. groupInInspector: string;
  126805. /**
  126806. * Gets or sets the connection point type (default is float)
  126807. */
  126808. get type(): NodeMaterialBlockConnectionPointTypes;
  126809. /**
  126810. * Creates a new InputBlock
  126811. * @param name defines the block name
  126812. * @param target defines the target of that block (Vertex by default)
  126813. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  126814. */
  126815. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  126816. /**
  126817. * Gets the output component
  126818. */
  126819. get output(): NodeMaterialConnectionPoint;
  126820. /**
  126821. * Set the source of this connection point to a vertex attribute
  126822. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  126823. * @returns the current connection point
  126824. */
  126825. setAsAttribute(attributeName?: string): InputBlock;
  126826. /**
  126827. * Set the source of this connection point to a system value
  126828. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  126829. * @returns the current connection point
  126830. */
  126831. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  126832. /**
  126833. * Gets or sets the value of that point.
  126834. * Please note that this value will be ignored if valueCallback is defined
  126835. */
  126836. get value(): any;
  126837. set value(value: any);
  126838. /**
  126839. * Gets or sets a callback used to get the value of that point.
  126840. * Please note that setting this value will force the connection point to ignore the value property
  126841. */
  126842. get valueCallback(): () => any;
  126843. set valueCallback(value: () => any);
  126844. /**
  126845. * Gets or sets the associated variable name in the shader
  126846. */
  126847. get associatedVariableName(): string;
  126848. set associatedVariableName(value: string);
  126849. /** Gets or sets the type of animation applied to the input */
  126850. get animationType(): AnimatedInputBlockTypes;
  126851. set animationType(value: AnimatedInputBlockTypes);
  126852. /**
  126853. * Gets a boolean indicating that this connection point not defined yet
  126854. */
  126855. get isUndefined(): boolean;
  126856. /**
  126857. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  126858. * In this case the connection point name must be the name of the uniform to use.
  126859. * Can only be set on inputs
  126860. */
  126861. get isUniform(): boolean;
  126862. set isUniform(value: boolean);
  126863. /**
  126864. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  126865. * In this case the connection point name must be the name of the attribute to use
  126866. * Can only be set on inputs
  126867. */
  126868. get isAttribute(): boolean;
  126869. set isAttribute(value: boolean);
  126870. /**
  126871. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  126872. * Can only be set on exit points
  126873. */
  126874. get isVarying(): boolean;
  126875. set isVarying(value: boolean);
  126876. /**
  126877. * Gets a boolean indicating that the current connection point is a system value
  126878. */
  126879. get isSystemValue(): boolean;
  126880. /**
  126881. * Gets or sets the current well known value or null if not defined as a system value
  126882. */
  126883. get systemValue(): Nullable<NodeMaterialSystemValues>;
  126884. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  126885. /**
  126886. * Gets the current class name
  126887. * @returns the class name
  126888. */
  126889. getClassName(): string;
  126890. /**
  126891. * Animate the input if animationType !== None
  126892. * @param scene defines the rendering scene
  126893. */
  126894. animate(scene: Scene): void;
  126895. private _emitDefine;
  126896. initialize(state: NodeMaterialBuildState): void;
  126897. /**
  126898. * Set the input block to its default value (based on its type)
  126899. */
  126900. setDefaultValue(): void;
  126901. private _emitConstant;
  126902. private _emit;
  126903. /** @hidden */
  126904. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  126905. /** @hidden */
  126906. _transmit(effect: Effect, scene: Scene): void;
  126907. protected _buildBlock(state: NodeMaterialBuildState): void;
  126908. protected _dumpPropertiesCode(): string;
  126909. serialize(): any;
  126910. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  126911. }
  126912. }
  126913. declare module BABYLON {
  126914. /**
  126915. * Enum used to define the compatibility state between two connection points
  126916. */
  126917. export enum NodeMaterialConnectionPointCompatibilityStates {
  126918. /** Points are compatibles */
  126919. Compatible = 0,
  126920. /** Points are incompatible because of their types */
  126921. TypeIncompatible = 1,
  126922. /** Points are incompatible because of their targets (vertex vs fragment) */
  126923. TargetIncompatible = 2
  126924. }
  126925. /**
  126926. * Defines the direction of a connection point
  126927. */
  126928. export enum NodeMaterialConnectionPointDirection {
  126929. /** Input */
  126930. Input = 0,
  126931. /** Output */
  126932. Output = 1
  126933. }
  126934. /**
  126935. * Defines a connection point for a block
  126936. */
  126937. export class NodeMaterialConnectionPoint {
  126938. /** @hidden */
  126939. _ownerBlock: NodeMaterialBlock;
  126940. /** @hidden */
  126941. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  126942. private _endpoints;
  126943. private _associatedVariableName;
  126944. private _direction;
  126945. /** @hidden */
  126946. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  126947. /** @hidden */
  126948. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  126949. private _type;
  126950. /** @hidden */
  126951. _enforceAssociatedVariableName: boolean;
  126952. /** Gets the direction of the point */
  126953. get direction(): NodeMaterialConnectionPointDirection;
  126954. /**
  126955. * Gets or sets the additional types supported by this connection point
  126956. */
  126957. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  126958. /**
  126959. * Gets or sets the additional types excluded by this connection point
  126960. */
  126961. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  126962. /**
  126963. * Observable triggered when this point is connected
  126964. */
  126965. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  126966. /**
  126967. * Gets or sets the associated variable name in the shader
  126968. */
  126969. get associatedVariableName(): string;
  126970. set associatedVariableName(value: string);
  126971. /**
  126972. * Gets or sets the connection point type (default is float)
  126973. */
  126974. get type(): NodeMaterialBlockConnectionPointTypes;
  126975. set type(value: NodeMaterialBlockConnectionPointTypes);
  126976. /**
  126977. * Gets or sets the connection point name
  126978. */
  126979. name: string;
  126980. /**
  126981. * Gets or sets a boolean indicating that this connection point can be omitted
  126982. */
  126983. isOptional: boolean;
  126984. /**
  126985. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  126986. */
  126987. define: string;
  126988. /** @hidden */
  126989. _prioritizeVertex: boolean;
  126990. private _target;
  126991. /** Gets or sets the target of that connection point */
  126992. get target(): NodeMaterialBlockTargets;
  126993. set target(value: NodeMaterialBlockTargets);
  126994. /**
  126995. * Gets a boolean indicating that the current point is connected
  126996. */
  126997. get isConnected(): boolean;
  126998. /**
  126999. * Gets a boolean indicating that the current point is connected to an input block
  127000. */
  127001. get isConnectedToInputBlock(): boolean;
  127002. /**
  127003. * Gets a the connected input block (if any)
  127004. */
  127005. get connectInputBlock(): Nullable<InputBlock>;
  127006. /** Get the other side of the connection (if any) */
  127007. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  127008. /** Get the block that owns this connection point */
  127009. get ownerBlock(): NodeMaterialBlock;
  127010. /** Get the block connected on the other side of this connection (if any) */
  127011. get sourceBlock(): Nullable<NodeMaterialBlock>;
  127012. /** Get the block connected on the endpoints of this connection (if any) */
  127013. get connectedBlocks(): Array<NodeMaterialBlock>;
  127014. /** Gets the list of connected endpoints */
  127015. get endpoints(): NodeMaterialConnectionPoint[];
  127016. /** Gets a boolean indicating if that output point is connected to at least one input */
  127017. get hasEndpoints(): boolean;
  127018. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  127019. get isConnectedInVertexShader(): boolean;
  127020. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  127021. get isConnectedInFragmentShader(): boolean;
  127022. /**
  127023. * Creates a new connection point
  127024. * @param name defines the connection point name
  127025. * @param ownerBlock defines the block hosting this connection point
  127026. * @param direction defines the direction of the connection point
  127027. */
  127028. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  127029. /**
  127030. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  127031. * @returns the class name
  127032. */
  127033. getClassName(): string;
  127034. /**
  127035. * Gets a boolean indicating if the current point can be connected to another point
  127036. * @param connectionPoint defines the other connection point
  127037. * @returns a boolean
  127038. */
  127039. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  127040. /**
  127041. * Gets a number indicating if the current point can be connected to another point
  127042. * @param connectionPoint defines the other connection point
  127043. * @returns a number defining the compatibility state
  127044. */
  127045. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  127046. /**
  127047. * Connect this point to another connection point
  127048. * @param connectionPoint defines the other connection point
  127049. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  127050. * @returns the current connection point
  127051. */
  127052. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  127053. /**
  127054. * Disconnect this point from one of his endpoint
  127055. * @param endpoint defines the other connection point
  127056. * @returns the current connection point
  127057. */
  127058. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  127059. /**
  127060. * Serializes this point in a JSON representation
  127061. * @returns the serialized point object
  127062. */
  127063. serialize(): any;
  127064. /**
  127065. * Release resources
  127066. */
  127067. dispose(): void;
  127068. }
  127069. }
  127070. declare module BABYLON {
  127071. /**
  127072. * Block used to add support for vertex skinning (bones)
  127073. */
  127074. export class BonesBlock extends NodeMaterialBlock {
  127075. /**
  127076. * Creates a new BonesBlock
  127077. * @param name defines the block name
  127078. */
  127079. constructor(name: string);
  127080. /**
  127081. * Initialize the block and prepare the context for build
  127082. * @param state defines the state that will be used for the build
  127083. */
  127084. initialize(state: NodeMaterialBuildState): void;
  127085. /**
  127086. * Gets the current class name
  127087. * @returns the class name
  127088. */
  127089. getClassName(): string;
  127090. /**
  127091. * Gets the matrix indices input component
  127092. */
  127093. get matricesIndices(): NodeMaterialConnectionPoint;
  127094. /**
  127095. * Gets the matrix weights input component
  127096. */
  127097. get matricesWeights(): NodeMaterialConnectionPoint;
  127098. /**
  127099. * Gets the extra matrix indices input component
  127100. */
  127101. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  127102. /**
  127103. * Gets the extra matrix weights input component
  127104. */
  127105. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  127106. /**
  127107. * Gets the world input component
  127108. */
  127109. get world(): NodeMaterialConnectionPoint;
  127110. /**
  127111. * Gets the output component
  127112. */
  127113. get output(): NodeMaterialConnectionPoint;
  127114. autoConfigure(material: NodeMaterial): void;
  127115. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  127116. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127117. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127118. protected _buildBlock(state: NodeMaterialBuildState): this;
  127119. }
  127120. }
  127121. declare module BABYLON {
  127122. /**
  127123. * Block used to add support for instances
  127124. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  127125. */
  127126. export class InstancesBlock extends NodeMaterialBlock {
  127127. /**
  127128. * Creates a new InstancesBlock
  127129. * @param name defines the block name
  127130. */
  127131. constructor(name: string);
  127132. /**
  127133. * Gets the current class name
  127134. * @returns the class name
  127135. */
  127136. getClassName(): string;
  127137. /**
  127138. * Gets the first world row input component
  127139. */
  127140. get world0(): NodeMaterialConnectionPoint;
  127141. /**
  127142. * Gets the second world row input component
  127143. */
  127144. get world1(): NodeMaterialConnectionPoint;
  127145. /**
  127146. * Gets the third world row input component
  127147. */
  127148. get world2(): NodeMaterialConnectionPoint;
  127149. /**
  127150. * Gets the forth world row input component
  127151. */
  127152. get world3(): NodeMaterialConnectionPoint;
  127153. /**
  127154. * Gets the world input component
  127155. */
  127156. get world(): NodeMaterialConnectionPoint;
  127157. /**
  127158. * Gets the output component
  127159. */
  127160. get output(): NodeMaterialConnectionPoint;
  127161. autoConfigure(material: NodeMaterial): void;
  127162. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  127163. protected _buildBlock(state: NodeMaterialBuildState): this;
  127164. }
  127165. }
  127166. declare module BABYLON {
  127167. /**
  127168. * Block used to add morph targets support to vertex shader
  127169. */
  127170. export class MorphTargetsBlock extends NodeMaterialBlock {
  127171. private _repeatableContentAnchor;
  127172. private _repeatebleContentGenerated;
  127173. /**
  127174. * Create a new MorphTargetsBlock
  127175. * @param name defines the block name
  127176. */
  127177. constructor(name: string);
  127178. /**
  127179. * Gets the current class name
  127180. * @returns the class name
  127181. */
  127182. getClassName(): string;
  127183. /**
  127184. * Gets the position input component
  127185. */
  127186. get position(): NodeMaterialConnectionPoint;
  127187. /**
  127188. * Gets the normal input component
  127189. */
  127190. get normal(): NodeMaterialConnectionPoint;
  127191. /**
  127192. * Gets the tangent input component
  127193. */
  127194. get tangent(): NodeMaterialConnectionPoint;
  127195. /**
  127196. * Gets the tangent input component
  127197. */
  127198. get uv(): NodeMaterialConnectionPoint;
  127199. /**
  127200. * Gets the position output component
  127201. */
  127202. get positionOutput(): NodeMaterialConnectionPoint;
  127203. /**
  127204. * Gets the normal output component
  127205. */
  127206. get normalOutput(): NodeMaterialConnectionPoint;
  127207. /**
  127208. * Gets the tangent output component
  127209. */
  127210. get tangentOutput(): NodeMaterialConnectionPoint;
  127211. /**
  127212. * Gets the tangent output component
  127213. */
  127214. get uvOutput(): NodeMaterialConnectionPoint;
  127215. initialize(state: NodeMaterialBuildState): void;
  127216. autoConfigure(material: NodeMaterial): void;
  127217. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127218. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127219. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  127220. protected _buildBlock(state: NodeMaterialBuildState): this;
  127221. }
  127222. }
  127223. declare module BABYLON {
  127224. /**
  127225. * Block used to get data information from a light
  127226. */
  127227. export class LightInformationBlock extends NodeMaterialBlock {
  127228. private _lightDataUniformName;
  127229. private _lightColorUniformName;
  127230. private _lightTypeDefineName;
  127231. /**
  127232. * Gets or sets the light associated with this block
  127233. */
  127234. light: Nullable<Light>;
  127235. /**
  127236. * Creates a new LightInformationBlock
  127237. * @param name defines the block name
  127238. */
  127239. constructor(name: string);
  127240. /**
  127241. * Gets the current class name
  127242. * @returns the class name
  127243. */
  127244. getClassName(): string;
  127245. /**
  127246. * Gets the world position input component
  127247. */
  127248. get worldPosition(): NodeMaterialConnectionPoint;
  127249. /**
  127250. * Gets the direction output component
  127251. */
  127252. get direction(): NodeMaterialConnectionPoint;
  127253. /**
  127254. * Gets the direction output component
  127255. */
  127256. get color(): NodeMaterialConnectionPoint;
  127257. /**
  127258. * Gets the direction output component
  127259. */
  127260. get intensity(): NodeMaterialConnectionPoint;
  127261. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127262. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127263. protected _buildBlock(state: NodeMaterialBuildState): this;
  127264. serialize(): any;
  127265. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127266. }
  127267. }
  127268. declare module BABYLON {
  127269. /**
  127270. * Block used to add image processing support to fragment shader
  127271. */
  127272. export class ImageProcessingBlock extends NodeMaterialBlock {
  127273. /**
  127274. * Create a new ImageProcessingBlock
  127275. * @param name defines the block name
  127276. */
  127277. constructor(name: string);
  127278. /**
  127279. * Gets the current class name
  127280. * @returns the class name
  127281. */
  127282. getClassName(): string;
  127283. /**
  127284. * Gets the color input component
  127285. */
  127286. get color(): NodeMaterialConnectionPoint;
  127287. /**
  127288. * Gets the output component
  127289. */
  127290. get output(): NodeMaterialConnectionPoint;
  127291. /**
  127292. * Initialize the block and prepare the context for build
  127293. * @param state defines the state that will be used for the build
  127294. */
  127295. initialize(state: NodeMaterialBuildState): void;
  127296. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  127297. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127298. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127299. protected _buildBlock(state: NodeMaterialBuildState): this;
  127300. }
  127301. }
  127302. declare module BABYLON {
  127303. /**
  127304. * Block used to pertub normals based on a normal map
  127305. */
  127306. export class PerturbNormalBlock extends NodeMaterialBlock {
  127307. private _tangentSpaceParameterName;
  127308. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  127309. invertX: boolean;
  127310. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  127311. invertY: boolean;
  127312. /**
  127313. * Create a new PerturbNormalBlock
  127314. * @param name defines the block name
  127315. */
  127316. constructor(name: string);
  127317. /**
  127318. * Gets the current class name
  127319. * @returns the class name
  127320. */
  127321. getClassName(): string;
  127322. /**
  127323. * Gets the world position input component
  127324. */
  127325. get worldPosition(): NodeMaterialConnectionPoint;
  127326. /**
  127327. * Gets the world normal input component
  127328. */
  127329. get worldNormal(): NodeMaterialConnectionPoint;
  127330. /**
  127331. * Gets the uv input component
  127332. */
  127333. get uv(): NodeMaterialConnectionPoint;
  127334. /**
  127335. * Gets the normal map color input component
  127336. */
  127337. get normalMapColor(): NodeMaterialConnectionPoint;
  127338. /**
  127339. * Gets the strength input component
  127340. */
  127341. get strength(): NodeMaterialConnectionPoint;
  127342. /**
  127343. * Gets the output component
  127344. */
  127345. get output(): NodeMaterialConnectionPoint;
  127346. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127347. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127348. autoConfigure(material: NodeMaterial): void;
  127349. protected _buildBlock(state: NodeMaterialBuildState): this;
  127350. protected _dumpPropertiesCode(): string;
  127351. serialize(): any;
  127352. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127353. }
  127354. }
  127355. declare module BABYLON {
  127356. /**
  127357. * Block used to discard a pixel if a value is smaller than a cutoff
  127358. */
  127359. export class DiscardBlock extends NodeMaterialBlock {
  127360. /**
  127361. * Create a new DiscardBlock
  127362. * @param name defines the block name
  127363. */
  127364. constructor(name: string);
  127365. /**
  127366. * Gets the current class name
  127367. * @returns the class name
  127368. */
  127369. getClassName(): string;
  127370. /**
  127371. * Gets the color input component
  127372. */
  127373. get value(): NodeMaterialConnectionPoint;
  127374. /**
  127375. * Gets the cutoff input component
  127376. */
  127377. get cutoff(): NodeMaterialConnectionPoint;
  127378. protected _buildBlock(state: NodeMaterialBuildState): this;
  127379. }
  127380. }
  127381. declare module BABYLON {
  127382. /**
  127383. * Block used to test if the fragment shader is front facing
  127384. */
  127385. export class FrontFacingBlock extends NodeMaterialBlock {
  127386. /**
  127387. * Creates a new FrontFacingBlock
  127388. * @param name defines the block name
  127389. */
  127390. constructor(name: string);
  127391. /**
  127392. * Gets the current class name
  127393. * @returns the class name
  127394. */
  127395. getClassName(): string;
  127396. /**
  127397. * Gets the output component
  127398. */
  127399. get output(): NodeMaterialConnectionPoint;
  127400. protected _buildBlock(state: NodeMaterialBuildState): this;
  127401. }
  127402. }
  127403. declare module BABYLON {
  127404. /**
  127405. * Block used to get the derivative value on x and y of a given input
  127406. */
  127407. export class DerivativeBlock extends NodeMaterialBlock {
  127408. /**
  127409. * Create a new DerivativeBlock
  127410. * @param name defines the block name
  127411. */
  127412. constructor(name: string);
  127413. /**
  127414. * Gets the current class name
  127415. * @returns the class name
  127416. */
  127417. getClassName(): string;
  127418. /**
  127419. * Gets the input component
  127420. */
  127421. get input(): NodeMaterialConnectionPoint;
  127422. /**
  127423. * Gets the derivative output on x
  127424. */
  127425. get dx(): NodeMaterialConnectionPoint;
  127426. /**
  127427. * Gets the derivative output on y
  127428. */
  127429. get dy(): NodeMaterialConnectionPoint;
  127430. protected _buildBlock(state: NodeMaterialBuildState): this;
  127431. }
  127432. }
  127433. declare module BABYLON {
  127434. /**
  127435. * Block used to add support for scene fog
  127436. */
  127437. export class FogBlock extends NodeMaterialBlock {
  127438. private _fogDistanceName;
  127439. private _fogParameters;
  127440. /**
  127441. * Create a new FogBlock
  127442. * @param name defines the block name
  127443. */
  127444. constructor(name: string);
  127445. /**
  127446. * Gets the current class name
  127447. * @returns the class name
  127448. */
  127449. getClassName(): string;
  127450. /**
  127451. * Gets the world position input component
  127452. */
  127453. get worldPosition(): NodeMaterialConnectionPoint;
  127454. /**
  127455. * Gets the view input component
  127456. */
  127457. get view(): NodeMaterialConnectionPoint;
  127458. /**
  127459. * Gets the color input component
  127460. */
  127461. get input(): NodeMaterialConnectionPoint;
  127462. /**
  127463. * Gets the fog color input component
  127464. */
  127465. get fogColor(): NodeMaterialConnectionPoint;
  127466. /**
  127467. * Gets the output component
  127468. */
  127469. get output(): NodeMaterialConnectionPoint;
  127470. autoConfigure(material: NodeMaterial): void;
  127471. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127472. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127473. protected _buildBlock(state: NodeMaterialBuildState): this;
  127474. }
  127475. }
  127476. declare module BABYLON {
  127477. /**
  127478. * Block used to add light in the fragment shader
  127479. */
  127480. export class LightBlock extends NodeMaterialBlock {
  127481. private _lightId;
  127482. /**
  127483. * Gets or sets the light associated with this block
  127484. */
  127485. light: Nullable<Light>;
  127486. /**
  127487. * Create a new LightBlock
  127488. * @param name defines the block name
  127489. */
  127490. constructor(name: string);
  127491. /**
  127492. * Gets the current class name
  127493. * @returns the class name
  127494. */
  127495. getClassName(): string;
  127496. /**
  127497. * Gets the world position input component
  127498. */
  127499. get worldPosition(): NodeMaterialConnectionPoint;
  127500. /**
  127501. * Gets the world normal input component
  127502. */
  127503. get worldNormal(): NodeMaterialConnectionPoint;
  127504. /**
  127505. * Gets the camera (or eye) position component
  127506. */
  127507. get cameraPosition(): NodeMaterialConnectionPoint;
  127508. /**
  127509. * Gets the glossiness component
  127510. */
  127511. get glossiness(): NodeMaterialConnectionPoint;
  127512. /**
  127513. * Gets the glossinness power component
  127514. */
  127515. get glossPower(): NodeMaterialConnectionPoint;
  127516. /**
  127517. * Gets the diffuse color component
  127518. */
  127519. get diffuseColor(): NodeMaterialConnectionPoint;
  127520. /**
  127521. * Gets the specular color component
  127522. */
  127523. get specularColor(): NodeMaterialConnectionPoint;
  127524. /**
  127525. * Gets the diffuse output component
  127526. */
  127527. get diffuseOutput(): NodeMaterialConnectionPoint;
  127528. /**
  127529. * Gets the specular output component
  127530. */
  127531. get specularOutput(): NodeMaterialConnectionPoint;
  127532. /**
  127533. * Gets the shadow output component
  127534. */
  127535. get shadow(): NodeMaterialConnectionPoint;
  127536. autoConfigure(material: NodeMaterial): void;
  127537. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127538. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  127539. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127540. private _injectVertexCode;
  127541. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  127542. serialize(): any;
  127543. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127544. }
  127545. }
  127546. declare module BABYLON {
  127547. /**
  127548. * Block used to multiply 2 values
  127549. */
  127550. export class MultiplyBlock extends NodeMaterialBlock {
  127551. /**
  127552. * Creates a new MultiplyBlock
  127553. * @param name defines the block name
  127554. */
  127555. constructor(name: string);
  127556. /**
  127557. * Gets the current class name
  127558. * @returns the class name
  127559. */
  127560. getClassName(): string;
  127561. /**
  127562. * Gets the left operand input component
  127563. */
  127564. get left(): NodeMaterialConnectionPoint;
  127565. /**
  127566. * Gets the right operand input component
  127567. */
  127568. get right(): NodeMaterialConnectionPoint;
  127569. /**
  127570. * Gets the output component
  127571. */
  127572. get output(): NodeMaterialConnectionPoint;
  127573. protected _buildBlock(state: NodeMaterialBuildState): this;
  127574. }
  127575. }
  127576. declare module BABYLON {
  127577. /**
  127578. * Block used to add 2 vectors
  127579. */
  127580. export class AddBlock extends NodeMaterialBlock {
  127581. /**
  127582. * Creates a new AddBlock
  127583. * @param name defines the block name
  127584. */
  127585. constructor(name: string);
  127586. /**
  127587. * Gets the current class name
  127588. * @returns the class name
  127589. */
  127590. getClassName(): string;
  127591. /**
  127592. * Gets the left operand input component
  127593. */
  127594. get left(): NodeMaterialConnectionPoint;
  127595. /**
  127596. * Gets the right operand input component
  127597. */
  127598. get right(): NodeMaterialConnectionPoint;
  127599. /**
  127600. * Gets the output component
  127601. */
  127602. get output(): NodeMaterialConnectionPoint;
  127603. protected _buildBlock(state: NodeMaterialBuildState): this;
  127604. }
  127605. }
  127606. declare module BABYLON {
  127607. /**
  127608. * Block used to scale a vector by a float
  127609. */
  127610. export class ScaleBlock extends NodeMaterialBlock {
  127611. /**
  127612. * Creates a new ScaleBlock
  127613. * @param name defines the block name
  127614. */
  127615. constructor(name: string);
  127616. /**
  127617. * Gets the current class name
  127618. * @returns the class name
  127619. */
  127620. getClassName(): string;
  127621. /**
  127622. * Gets the input component
  127623. */
  127624. get input(): NodeMaterialConnectionPoint;
  127625. /**
  127626. * Gets the factor input component
  127627. */
  127628. get factor(): NodeMaterialConnectionPoint;
  127629. /**
  127630. * Gets the output component
  127631. */
  127632. get output(): NodeMaterialConnectionPoint;
  127633. protected _buildBlock(state: NodeMaterialBuildState): this;
  127634. }
  127635. }
  127636. declare module BABYLON {
  127637. /**
  127638. * Block used to clamp a float
  127639. */
  127640. export class ClampBlock extends NodeMaterialBlock {
  127641. /** Gets or sets the minimum range */
  127642. minimum: number;
  127643. /** Gets or sets the maximum range */
  127644. maximum: number;
  127645. /**
  127646. * Creates a new ClampBlock
  127647. * @param name defines the block name
  127648. */
  127649. constructor(name: string);
  127650. /**
  127651. * Gets the current class name
  127652. * @returns the class name
  127653. */
  127654. getClassName(): string;
  127655. /**
  127656. * Gets the value input component
  127657. */
  127658. get value(): NodeMaterialConnectionPoint;
  127659. /**
  127660. * Gets the output component
  127661. */
  127662. get output(): NodeMaterialConnectionPoint;
  127663. protected _buildBlock(state: NodeMaterialBuildState): this;
  127664. protected _dumpPropertiesCode(): string;
  127665. serialize(): any;
  127666. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127667. }
  127668. }
  127669. declare module BABYLON {
  127670. /**
  127671. * Block used to apply a cross product between 2 vectors
  127672. */
  127673. export class CrossBlock extends NodeMaterialBlock {
  127674. /**
  127675. * Creates a new CrossBlock
  127676. * @param name defines the block name
  127677. */
  127678. constructor(name: string);
  127679. /**
  127680. * Gets the current class name
  127681. * @returns the class name
  127682. */
  127683. getClassName(): string;
  127684. /**
  127685. * Gets the left operand input component
  127686. */
  127687. get left(): NodeMaterialConnectionPoint;
  127688. /**
  127689. * Gets the right operand input component
  127690. */
  127691. get right(): NodeMaterialConnectionPoint;
  127692. /**
  127693. * Gets the output component
  127694. */
  127695. get output(): NodeMaterialConnectionPoint;
  127696. protected _buildBlock(state: NodeMaterialBuildState): this;
  127697. }
  127698. }
  127699. declare module BABYLON {
  127700. /**
  127701. * Block used to apply a dot product between 2 vectors
  127702. */
  127703. export class DotBlock extends NodeMaterialBlock {
  127704. /**
  127705. * Creates a new DotBlock
  127706. * @param name defines the block name
  127707. */
  127708. constructor(name: string);
  127709. /**
  127710. * Gets the current class name
  127711. * @returns the class name
  127712. */
  127713. getClassName(): string;
  127714. /**
  127715. * Gets the left operand input component
  127716. */
  127717. get left(): NodeMaterialConnectionPoint;
  127718. /**
  127719. * Gets the right operand input component
  127720. */
  127721. get right(): NodeMaterialConnectionPoint;
  127722. /**
  127723. * Gets the output component
  127724. */
  127725. get output(): NodeMaterialConnectionPoint;
  127726. protected _buildBlock(state: NodeMaterialBuildState): this;
  127727. }
  127728. }
  127729. declare module BABYLON {
  127730. /**
  127731. * Block used to remap a float from a range to a new one
  127732. */
  127733. export class RemapBlock extends NodeMaterialBlock {
  127734. /**
  127735. * Gets or sets the source range
  127736. */
  127737. sourceRange: Vector2;
  127738. /**
  127739. * Gets or sets the target range
  127740. */
  127741. targetRange: Vector2;
  127742. /**
  127743. * Creates a new RemapBlock
  127744. * @param name defines the block name
  127745. */
  127746. constructor(name: string);
  127747. /**
  127748. * Gets the current class name
  127749. * @returns the class name
  127750. */
  127751. getClassName(): string;
  127752. /**
  127753. * Gets the input component
  127754. */
  127755. get input(): NodeMaterialConnectionPoint;
  127756. /**
  127757. * Gets the source min input component
  127758. */
  127759. get sourceMin(): NodeMaterialConnectionPoint;
  127760. /**
  127761. * Gets the source max input component
  127762. */
  127763. get sourceMax(): NodeMaterialConnectionPoint;
  127764. /**
  127765. * Gets the target min input component
  127766. */
  127767. get targetMin(): NodeMaterialConnectionPoint;
  127768. /**
  127769. * Gets the target max input component
  127770. */
  127771. get targetMax(): NodeMaterialConnectionPoint;
  127772. /**
  127773. * Gets the output component
  127774. */
  127775. get output(): NodeMaterialConnectionPoint;
  127776. protected _buildBlock(state: NodeMaterialBuildState): this;
  127777. protected _dumpPropertiesCode(): string;
  127778. serialize(): any;
  127779. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127780. }
  127781. }
  127782. declare module BABYLON {
  127783. /**
  127784. * Block used to normalize a vector
  127785. */
  127786. export class NormalizeBlock extends NodeMaterialBlock {
  127787. /**
  127788. * Creates a new NormalizeBlock
  127789. * @param name defines the block name
  127790. */
  127791. constructor(name: string);
  127792. /**
  127793. * Gets the current class name
  127794. * @returns the class name
  127795. */
  127796. getClassName(): string;
  127797. /**
  127798. * Gets the input component
  127799. */
  127800. get input(): NodeMaterialConnectionPoint;
  127801. /**
  127802. * Gets the output component
  127803. */
  127804. get output(): NodeMaterialConnectionPoint;
  127805. protected _buildBlock(state: NodeMaterialBuildState): this;
  127806. }
  127807. }
  127808. declare module BABYLON {
  127809. /**
  127810. * Operations supported by the Trigonometry block
  127811. */
  127812. export enum TrigonometryBlockOperations {
  127813. /** Cos */
  127814. Cos = 0,
  127815. /** Sin */
  127816. Sin = 1,
  127817. /** Abs */
  127818. Abs = 2,
  127819. /** Exp */
  127820. Exp = 3,
  127821. /** Exp2 */
  127822. Exp2 = 4,
  127823. /** Round */
  127824. Round = 5,
  127825. /** Floor */
  127826. Floor = 6,
  127827. /** Ceiling */
  127828. Ceiling = 7,
  127829. /** Square root */
  127830. Sqrt = 8,
  127831. /** Log */
  127832. Log = 9,
  127833. /** Tangent */
  127834. Tan = 10,
  127835. /** Arc tangent */
  127836. ArcTan = 11,
  127837. /** Arc cosinus */
  127838. ArcCos = 12,
  127839. /** Arc sinus */
  127840. ArcSin = 13,
  127841. /** Fraction */
  127842. Fract = 14,
  127843. /** Sign */
  127844. Sign = 15,
  127845. /** To radians (from degrees) */
  127846. Radians = 16,
  127847. /** To degrees (from radians) */
  127848. Degrees = 17
  127849. }
  127850. /**
  127851. * Block used to apply trigonometry operation to floats
  127852. */
  127853. export class TrigonometryBlock extends NodeMaterialBlock {
  127854. /**
  127855. * Gets or sets the operation applied by the block
  127856. */
  127857. operation: TrigonometryBlockOperations;
  127858. /**
  127859. * Creates a new TrigonometryBlock
  127860. * @param name defines the block name
  127861. */
  127862. constructor(name: string);
  127863. /**
  127864. * Gets the current class name
  127865. * @returns the class name
  127866. */
  127867. getClassName(): string;
  127868. /**
  127869. * Gets the input component
  127870. */
  127871. get input(): NodeMaterialConnectionPoint;
  127872. /**
  127873. * Gets the output component
  127874. */
  127875. get output(): NodeMaterialConnectionPoint;
  127876. protected _buildBlock(state: NodeMaterialBuildState): this;
  127877. serialize(): any;
  127878. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127879. protected _dumpPropertiesCode(): string;
  127880. }
  127881. }
  127882. declare module BABYLON {
  127883. /**
  127884. * Block used to create a Color3/4 out of individual inputs (one for each component)
  127885. */
  127886. export class ColorMergerBlock extends NodeMaterialBlock {
  127887. /**
  127888. * Create a new ColorMergerBlock
  127889. * @param name defines the block name
  127890. */
  127891. constructor(name: string);
  127892. /**
  127893. * Gets the current class name
  127894. * @returns the class name
  127895. */
  127896. getClassName(): string;
  127897. /**
  127898. * Gets the rgb component (input)
  127899. */
  127900. get rgbIn(): NodeMaterialConnectionPoint;
  127901. /**
  127902. * Gets the r component (input)
  127903. */
  127904. get r(): NodeMaterialConnectionPoint;
  127905. /**
  127906. * Gets the g component (input)
  127907. */
  127908. get g(): NodeMaterialConnectionPoint;
  127909. /**
  127910. * Gets the b component (input)
  127911. */
  127912. get b(): NodeMaterialConnectionPoint;
  127913. /**
  127914. * Gets the a component (input)
  127915. */
  127916. get a(): NodeMaterialConnectionPoint;
  127917. /**
  127918. * Gets the rgba component (output)
  127919. */
  127920. get rgba(): NodeMaterialConnectionPoint;
  127921. /**
  127922. * Gets the rgb component (output)
  127923. */
  127924. get rgbOut(): NodeMaterialConnectionPoint;
  127925. /**
  127926. * Gets the rgb component (output)
  127927. * @deprecated Please use rgbOut instead.
  127928. */
  127929. get rgb(): NodeMaterialConnectionPoint;
  127930. protected _buildBlock(state: NodeMaterialBuildState): this;
  127931. }
  127932. }
  127933. declare module BABYLON {
  127934. /**
  127935. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  127936. */
  127937. export class VectorMergerBlock extends NodeMaterialBlock {
  127938. /**
  127939. * Create a new VectorMergerBlock
  127940. * @param name defines the block name
  127941. */
  127942. constructor(name: string);
  127943. /**
  127944. * Gets the current class name
  127945. * @returns the class name
  127946. */
  127947. getClassName(): string;
  127948. /**
  127949. * Gets the xyz component (input)
  127950. */
  127951. get xyzIn(): NodeMaterialConnectionPoint;
  127952. /**
  127953. * Gets the xy component (input)
  127954. */
  127955. get xyIn(): NodeMaterialConnectionPoint;
  127956. /**
  127957. * Gets the x component (input)
  127958. */
  127959. get x(): NodeMaterialConnectionPoint;
  127960. /**
  127961. * Gets the y component (input)
  127962. */
  127963. get y(): NodeMaterialConnectionPoint;
  127964. /**
  127965. * Gets the z component (input)
  127966. */
  127967. get z(): NodeMaterialConnectionPoint;
  127968. /**
  127969. * Gets the w component (input)
  127970. */
  127971. get w(): NodeMaterialConnectionPoint;
  127972. /**
  127973. * Gets the xyzw component (output)
  127974. */
  127975. get xyzw(): NodeMaterialConnectionPoint;
  127976. /**
  127977. * Gets the xyz component (output)
  127978. */
  127979. get xyzOut(): NodeMaterialConnectionPoint;
  127980. /**
  127981. * Gets the xy component (output)
  127982. */
  127983. get xyOut(): NodeMaterialConnectionPoint;
  127984. /**
  127985. * Gets the xy component (output)
  127986. * @deprecated Please use xyOut instead.
  127987. */
  127988. get xy(): NodeMaterialConnectionPoint;
  127989. /**
  127990. * Gets the xyz component (output)
  127991. * @deprecated Please use xyzOut instead.
  127992. */
  127993. get xyz(): NodeMaterialConnectionPoint;
  127994. protected _buildBlock(state: NodeMaterialBuildState): this;
  127995. }
  127996. }
  127997. declare module BABYLON {
  127998. /**
  127999. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  128000. */
  128001. export class ColorSplitterBlock extends NodeMaterialBlock {
  128002. /**
  128003. * Create a new ColorSplitterBlock
  128004. * @param name defines the block name
  128005. */
  128006. constructor(name: string);
  128007. /**
  128008. * Gets the current class name
  128009. * @returns the class name
  128010. */
  128011. getClassName(): string;
  128012. /**
  128013. * Gets the rgba component (input)
  128014. */
  128015. get rgba(): NodeMaterialConnectionPoint;
  128016. /**
  128017. * Gets the rgb component (input)
  128018. */
  128019. get rgbIn(): NodeMaterialConnectionPoint;
  128020. /**
  128021. * Gets the rgb component (output)
  128022. */
  128023. get rgbOut(): NodeMaterialConnectionPoint;
  128024. /**
  128025. * Gets the r component (output)
  128026. */
  128027. get r(): NodeMaterialConnectionPoint;
  128028. /**
  128029. * Gets the g component (output)
  128030. */
  128031. get g(): NodeMaterialConnectionPoint;
  128032. /**
  128033. * Gets the b component (output)
  128034. */
  128035. get b(): NodeMaterialConnectionPoint;
  128036. /**
  128037. * Gets the a component (output)
  128038. */
  128039. get a(): NodeMaterialConnectionPoint;
  128040. protected _inputRename(name: string): string;
  128041. protected _outputRename(name: string): string;
  128042. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  128043. }
  128044. }
  128045. declare module BABYLON {
  128046. /**
  128047. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  128048. */
  128049. export class VectorSplitterBlock extends NodeMaterialBlock {
  128050. /**
  128051. * Create a new VectorSplitterBlock
  128052. * @param name defines the block name
  128053. */
  128054. constructor(name: string);
  128055. /**
  128056. * Gets the current class name
  128057. * @returns the class name
  128058. */
  128059. getClassName(): string;
  128060. /**
  128061. * Gets the xyzw component (input)
  128062. */
  128063. get xyzw(): NodeMaterialConnectionPoint;
  128064. /**
  128065. * Gets the xyz component (input)
  128066. */
  128067. get xyzIn(): NodeMaterialConnectionPoint;
  128068. /**
  128069. * Gets the xy component (input)
  128070. */
  128071. get xyIn(): NodeMaterialConnectionPoint;
  128072. /**
  128073. * Gets the xyz component (output)
  128074. */
  128075. get xyzOut(): NodeMaterialConnectionPoint;
  128076. /**
  128077. * Gets the xy component (output)
  128078. */
  128079. get xyOut(): NodeMaterialConnectionPoint;
  128080. /**
  128081. * Gets the x component (output)
  128082. */
  128083. get x(): NodeMaterialConnectionPoint;
  128084. /**
  128085. * Gets the y component (output)
  128086. */
  128087. get y(): NodeMaterialConnectionPoint;
  128088. /**
  128089. * Gets the z component (output)
  128090. */
  128091. get z(): NodeMaterialConnectionPoint;
  128092. /**
  128093. * Gets the w component (output)
  128094. */
  128095. get w(): NodeMaterialConnectionPoint;
  128096. protected _inputRename(name: string): string;
  128097. protected _outputRename(name: string): string;
  128098. protected _buildBlock(state: NodeMaterialBuildState): this;
  128099. }
  128100. }
  128101. declare module BABYLON {
  128102. /**
  128103. * Block used to lerp between 2 values
  128104. */
  128105. export class LerpBlock extends NodeMaterialBlock {
  128106. /**
  128107. * Creates a new LerpBlock
  128108. * @param name defines the block name
  128109. */
  128110. constructor(name: string);
  128111. /**
  128112. * Gets the current class name
  128113. * @returns the class name
  128114. */
  128115. getClassName(): string;
  128116. /**
  128117. * Gets the left operand input component
  128118. */
  128119. get left(): NodeMaterialConnectionPoint;
  128120. /**
  128121. * Gets the right operand input component
  128122. */
  128123. get right(): NodeMaterialConnectionPoint;
  128124. /**
  128125. * Gets the gradient operand input component
  128126. */
  128127. get gradient(): NodeMaterialConnectionPoint;
  128128. /**
  128129. * Gets the output component
  128130. */
  128131. get output(): NodeMaterialConnectionPoint;
  128132. protected _buildBlock(state: NodeMaterialBuildState): this;
  128133. }
  128134. }
  128135. declare module BABYLON {
  128136. /**
  128137. * Block used to divide 2 vectors
  128138. */
  128139. export class DivideBlock extends NodeMaterialBlock {
  128140. /**
  128141. * Creates a new DivideBlock
  128142. * @param name defines the block name
  128143. */
  128144. constructor(name: string);
  128145. /**
  128146. * Gets the current class name
  128147. * @returns the class name
  128148. */
  128149. getClassName(): string;
  128150. /**
  128151. * Gets the left operand input component
  128152. */
  128153. get left(): NodeMaterialConnectionPoint;
  128154. /**
  128155. * Gets the right operand input component
  128156. */
  128157. get right(): NodeMaterialConnectionPoint;
  128158. /**
  128159. * Gets the output component
  128160. */
  128161. get output(): NodeMaterialConnectionPoint;
  128162. protected _buildBlock(state: NodeMaterialBuildState): this;
  128163. }
  128164. }
  128165. declare module BABYLON {
  128166. /**
  128167. * Block used to subtract 2 vectors
  128168. */
  128169. export class SubtractBlock extends NodeMaterialBlock {
  128170. /**
  128171. * Creates a new SubtractBlock
  128172. * @param name defines the block name
  128173. */
  128174. constructor(name: string);
  128175. /**
  128176. * Gets the current class name
  128177. * @returns the class name
  128178. */
  128179. getClassName(): string;
  128180. /**
  128181. * Gets the left operand input component
  128182. */
  128183. get left(): NodeMaterialConnectionPoint;
  128184. /**
  128185. * Gets the right operand input component
  128186. */
  128187. get right(): NodeMaterialConnectionPoint;
  128188. /**
  128189. * Gets the output component
  128190. */
  128191. get output(): NodeMaterialConnectionPoint;
  128192. protected _buildBlock(state: NodeMaterialBuildState): this;
  128193. }
  128194. }
  128195. declare module BABYLON {
  128196. /**
  128197. * Block used to step a value
  128198. */
  128199. export class StepBlock extends NodeMaterialBlock {
  128200. /**
  128201. * Creates a new StepBlock
  128202. * @param name defines the block name
  128203. */
  128204. constructor(name: string);
  128205. /**
  128206. * Gets the current class name
  128207. * @returns the class name
  128208. */
  128209. getClassName(): string;
  128210. /**
  128211. * Gets the value operand input component
  128212. */
  128213. get value(): NodeMaterialConnectionPoint;
  128214. /**
  128215. * Gets the edge operand input component
  128216. */
  128217. get edge(): NodeMaterialConnectionPoint;
  128218. /**
  128219. * Gets the output component
  128220. */
  128221. get output(): NodeMaterialConnectionPoint;
  128222. protected _buildBlock(state: NodeMaterialBuildState): this;
  128223. }
  128224. }
  128225. declare module BABYLON {
  128226. /**
  128227. * Block used to get the opposite (1 - x) of a value
  128228. */
  128229. export class OneMinusBlock extends NodeMaterialBlock {
  128230. /**
  128231. * Creates a new OneMinusBlock
  128232. * @param name defines the block name
  128233. */
  128234. constructor(name: string);
  128235. /**
  128236. * Gets the current class name
  128237. * @returns the class name
  128238. */
  128239. getClassName(): string;
  128240. /**
  128241. * Gets the input component
  128242. */
  128243. get input(): NodeMaterialConnectionPoint;
  128244. /**
  128245. * Gets the output component
  128246. */
  128247. get output(): NodeMaterialConnectionPoint;
  128248. protected _buildBlock(state: NodeMaterialBuildState): this;
  128249. }
  128250. }
  128251. declare module BABYLON {
  128252. /**
  128253. * Block used to get the view direction
  128254. */
  128255. export class ViewDirectionBlock extends NodeMaterialBlock {
  128256. /**
  128257. * Creates a new ViewDirectionBlock
  128258. * @param name defines the block name
  128259. */
  128260. constructor(name: string);
  128261. /**
  128262. * Gets the current class name
  128263. * @returns the class name
  128264. */
  128265. getClassName(): string;
  128266. /**
  128267. * Gets the world position component
  128268. */
  128269. get worldPosition(): NodeMaterialConnectionPoint;
  128270. /**
  128271. * Gets the camera position component
  128272. */
  128273. get cameraPosition(): NodeMaterialConnectionPoint;
  128274. /**
  128275. * Gets the output component
  128276. */
  128277. get output(): NodeMaterialConnectionPoint;
  128278. autoConfigure(material: NodeMaterial): void;
  128279. protected _buildBlock(state: NodeMaterialBuildState): this;
  128280. }
  128281. }
  128282. declare module BABYLON {
  128283. /**
  128284. * Block used to compute fresnel value
  128285. */
  128286. export class FresnelBlock extends NodeMaterialBlock {
  128287. /**
  128288. * Create a new FresnelBlock
  128289. * @param name defines the block name
  128290. */
  128291. constructor(name: string);
  128292. /**
  128293. * Gets the current class name
  128294. * @returns the class name
  128295. */
  128296. getClassName(): string;
  128297. /**
  128298. * Gets the world normal input component
  128299. */
  128300. get worldNormal(): NodeMaterialConnectionPoint;
  128301. /**
  128302. * Gets the view direction input component
  128303. */
  128304. get viewDirection(): NodeMaterialConnectionPoint;
  128305. /**
  128306. * Gets the bias input component
  128307. */
  128308. get bias(): NodeMaterialConnectionPoint;
  128309. /**
  128310. * Gets the camera (or eye) position component
  128311. */
  128312. get power(): NodeMaterialConnectionPoint;
  128313. /**
  128314. * Gets the fresnel output component
  128315. */
  128316. get fresnel(): NodeMaterialConnectionPoint;
  128317. autoConfigure(material: NodeMaterial): void;
  128318. protected _buildBlock(state: NodeMaterialBuildState): this;
  128319. }
  128320. }
  128321. declare module BABYLON {
  128322. /**
  128323. * Block used to get the max of 2 values
  128324. */
  128325. export class MaxBlock extends NodeMaterialBlock {
  128326. /**
  128327. * Creates a new MaxBlock
  128328. * @param name defines the block name
  128329. */
  128330. constructor(name: string);
  128331. /**
  128332. * Gets the current class name
  128333. * @returns the class name
  128334. */
  128335. getClassName(): string;
  128336. /**
  128337. * Gets the left operand input component
  128338. */
  128339. get left(): NodeMaterialConnectionPoint;
  128340. /**
  128341. * Gets the right operand input component
  128342. */
  128343. get right(): NodeMaterialConnectionPoint;
  128344. /**
  128345. * Gets the output component
  128346. */
  128347. get output(): NodeMaterialConnectionPoint;
  128348. protected _buildBlock(state: NodeMaterialBuildState): this;
  128349. }
  128350. }
  128351. declare module BABYLON {
  128352. /**
  128353. * Block used to get the min of 2 values
  128354. */
  128355. export class MinBlock extends NodeMaterialBlock {
  128356. /**
  128357. * Creates a new MinBlock
  128358. * @param name defines the block name
  128359. */
  128360. constructor(name: string);
  128361. /**
  128362. * Gets the current class name
  128363. * @returns the class name
  128364. */
  128365. getClassName(): string;
  128366. /**
  128367. * Gets the left operand input component
  128368. */
  128369. get left(): NodeMaterialConnectionPoint;
  128370. /**
  128371. * Gets the right operand input component
  128372. */
  128373. get right(): NodeMaterialConnectionPoint;
  128374. /**
  128375. * Gets the output component
  128376. */
  128377. get output(): NodeMaterialConnectionPoint;
  128378. protected _buildBlock(state: NodeMaterialBuildState): this;
  128379. }
  128380. }
  128381. declare module BABYLON {
  128382. /**
  128383. * Block used to get the distance between 2 values
  128384. */
  128385. export class DistanceBlock extends NodeMaterialBlock {
  128386. /**
  128387. * Creates a new DistanceBlock
  128388. * @param name defines the block name
  128389. */
  128390. constructor(name: string);
  128391. /**
  128392. * Gets the current class name
  128393. * @returns the class name
  128394. */
  128395. getClassName(): string;
  128396. /**
  128397. * Gets the left operand input component
  128398. */
  128399. get left(): NodeMaterialConnectionPoint;
  128400. /**
  128401. * Gets the right operand input component
  128402. */
  128403. get right(): NodeMaterialConnectionPoint;
  128404. /**
  128405. * Gets the output component
  128406. */
  128407. get output(): NodeMaterialConnectionPoint;
  128408. protected _buildBlock(state: NodeMaterialBuildState): this;
  128409. }
  128410. }
  128411. declare module BABYLON {
  128412. /**
  128413. * Block used to get the length of a vector
  128414. */
  128415. export class LengthBlock extends NodeMaterialBlock {
  128416. /**
  128417. * Creates a new LengthBlock
  128418. * @param name defines the block name
  128419. */
  128420. constructor(name: string);
  128421. /**
  128422. * Gets the current class name
  128423. * @returns the class name
  128424. */
  128425. getClassName(): string;
  128426. /**
  128427. * Gets the value input component
  128428. */
  128429. get value(): NodeMaterialConnectionPoint;
  128430. /**
  128431. * Gets the output component
  128432. */
  128433. get output(): NodeMaterialConnectionPoint;
  128434. protected _buildBlock(state: NodeMaterialBuildState): this;
  128435. }
  128436. }
  128437. declare module BABYLON {
  128438. /**
  128439. * Block used to get negative version of a value (i.e. x * -1)
  128440. */
  128441. export class NegateBlock extends NodeMaterialBlock {
  128442. /**
  128443. * Creates a new NegateBlock
  128444. * @param name defines the block name
  128445. */
  128446. constructor(name: string);
  128447. /**
  128448. * Gets the current class name
  128449. * @returns the class name
  128450. */
  128451. getClassName(): string;
  128452. /**
  128453. * Gets the value input component
  128454. */
  128455. get value(): NodeMaterialConnectionPoint;
  128456. /**
  128457. * Gets the output component
  128458. */
  128459. get output(): NodeMaterialConnectionPoint;
  128460. protected _buildBlock(state: NodeMaterialBuildState): this;
  128461. }
  128462. }
  128463. declare module BABYLON {
  128464. /**
  128465. * Block used to get the value of the first parameter raised to the power of the second
  128466. */
  128467. export class PowBlock extends NodeMaterialBlock {
  128468. /**
  128469. * Creates a new PowBlock
  128470. * @param name defines the block name
  128471. */
  128472. constructor(name: string);
  128473. /**
  128474. * Gets the current class name
  128475. * @returns the class name
  128476. */
  128477. getClassName(): string;
  128478. /**
  128479. * Gets the value operand input component
  128480. */
  128481. get value(): NodeMaterialConnectionPoint;
  128482. /**
  128483. * Gets the power operand input component
  128484. */
  128485. get power(): NodeMaterialConnectionPoint;
  128486. /**
  128487. * Gets the output component
  128488. */
  128489. get output(): NodeMaterialConnectionPoint;
  128490. protected _buildBlock(state: NodeMaterialBuildState): this;
  128491. }
  128492. }
  128493. declare module BABYLON {
  128494. /**
  128495. * Block used to get a random number
  128496. */
  128497. export class RandomNumberBlock extends NodeMaterialBlock {
  128498. /**
  128499. * Creates a new RandomNumberBlock
  128500. * @param name defines the block name
  128501. */
  128502. constructor(name: string);
  128503. /**
  128504. * Gets the current class name
  128505. * @returns the class name
  128506. */
  128507. getClassName(): string;
  128508. /**
  128509. * Gets the seed input component
  128510. */
  128511. get seed(): NodeMaterialConnectionPoint;
  128512. /**
  128513. * Gets the output component
  128514. */
  128515. get output(): NodeMaterialConnectionPoint;
  128516. protected _buildBlock(state: NodeMaterialBuildState): this;
  128517. }
  128518. }
  128519. declare module BABYLON {
  128520. /**
  128521. * Block used to compute arc tangent of 2 values
  128522. */
  128523. export class ArcTan2Block extends NodeMaterialBlock {
  128524. /**
  128525. * Creates a new ArcTan2Block
  128526. * @param name defines the block name
  128527. */
  128528. constructor(name: string);
  128529. /**
  128530. * Gets the current class name
  128531. * @returns the class name
  128532. */
  128533. getClassName(): string;
  128534. /**
  128535. * Gets the x operand input component
  128536. */
  128537. get x(): NodeMaterialConnectionPoint;
  128538. /**
  128539. * Gets the y operand input component
  128540. */
  128541. get y(): NodeMaterialConnectionPoint;
  128542. /**
  128543. * Gets the output component
  128544. */
  128545. get output(): NodeMaterialConnectionPoint;
  128546. protected _buildBlock(state: NodeMaterialBuildState): this;
  128547. }
  128548. }
  128549. declare module BABYLON {
  128550. /**
  128551. * Block used to smooth step a value
  128552. */
  128553. export class SmoothStepBlock extends NodeMaterialBlock {
  128554. /**
  128555. * Creates a new SmoothStepBlock
  128556. * @param name defines the block name
  128557. */
  128558. constructor(name: string);
  128559. /**
  128560. * Gets the current class name
  128561. * @returns the class name
  128562. */
  128563. getClassName(): string;
  128564. /**
  128565. * Gets the value operand input component
  128566. */
  128567. get value(): NodeMaterialConnectionPoint;
  128568. /**
  128569. * Gets the first edge operand input component
  128570. */
  128571. get edge0(): NodeMaterialConnectionPoint;
  128572. /**
  128573. * Gets the second edge operand input component
  128574. */
  128575. get edge1(): NodeMaterialConnectionPoint;
  128576. /**
  128577. * Gets the output component
  128578. */
  128579. get output(): NodeMaterialConnectionPoint;
  128580. protected _buildBlock(state: NodeMaterialBuildState): this;
  128581. }
  128582. }
  128583. declare module BABYLON {
  128584. /**
  128585. * Block used to get the reciprocal (1 / x) of a value
  128586. */
  128587. export class ReciprocalBlock extends NodeMaterialBlock {
  128588. /**
  128589. * Creates a new ReciprocalBlock
  128590. * @param name defines the block name
  128591. */
  128592. constructor(name: string);
  128593. /**
  128594. * Gets the current class name
  128595. * @returns the class name
  128596. */
  128597. getClassName(): string;
  128598. /**
  128599. * Gets the input component
  128600. */
  128601. get input(): NodeMaterialConnectionPoint;
  128602. /**
  128603. * Gets the output component
  128604. */
  128605. get output(): NodeMaterialConnectionPoint;
  128606. protected _buildBlock(state: NodeMaterialBuildState): this;
  128607. }
  128608. }
  128609. declare module BABYLON {
  128610. /**
  128611. * Block used to replace a color by another one
  128612. */
  128613. export class ReplaceColorBlock extends NodeMaterialBlock {
  128614. /**
  128615. * Creates a new ReplaceColorBlock
  128616. * @param name defines the block name
  128617. */
  128618. constructor(name: string);
  128619. /**
  128620. * Gets the current class name
  128621. * @returns the class name
  128622. */
  128623. getClassName(): string;
  128624. /**
  128625. * Gets the value input component
  128626. */
  128627. get value(): NodeMaterialConnectionPoint;
  128628. /**
  128629. * Gets the reference input component
  128630. */
  128631. get reference(): NodeMaterialConnectionPoint;
  128632. /**
  128633. * Gets the distance input component
  128634. */
  128635. get distance(): NodeMaterialConnectionPoint;
  128636. /**
  128637. * Gets the replacement input component
  128638. */
  128639. get replacement(): NodeMaterialConnectionPoint;
  128640. /**
  128641. * Gets the output component
  128642. */
  128643. get output(): NodeMaterialConnectionPoint;
  128644. protected _buildBlock(state: NodeMaterialBuildState): this;
  128645. }
  128646. }
  128647. declare module BABYLON {
  128648. /**
  128649. * Block used to posterize a value
  128650. * @see https://en.wikipedia.org/wiki/Posterization
  128651. */
  128652. export class PosterizeBlock extends NodeMaterialBlock {
  128653. /**
  128654. * Creates a new PosterizeBlock
  128655. * @param name defines the block name
  128656. */
  128657. constructor(name: string);
  128658. /**
  128659. * Gets the current class name
  128660. * @returns the class name
  128661. */
  128662. getClassName(): string;
  128663. /**
  128664. * Gets the value input component
  128665. */
  128666. get value(): NodeMaterialConnectionPoint;
  128667. /**
  128668. * Gets the steps input component
  128669. */
  128670. get steps(): NodeMaterialConnectionPoint;
  128671. /**
  128672. * Gets the output component
  128673. */
  128674. get output(): NodeMaterialConnectionPoint;
  128675. protected _buildBlock(state: NodeMaterialBuildState): this;
  128676. }
  128677. }
  128678. declare module BABYLON {
  128679. /**
  128680. * Operations supported by the Wave block
  128681. */
  128682. export enum WaveBlockKind {
  128683. /** SawTooth */
  128684. SawTooth = 0,
  128685. /** Square */
  128686. Square = 1,
  128687. /** Triangle */
  128688. Triangle = 2
  128689. }
  128690. /**
  128691. * Block used to apply wave operation to floats
  128692. */
  128693. export class WaveBlock extends NodeMaterialBlock {
  128694. /**
  128695. * Gets or sets the kibnd of wave to be applied by the block
  128696. */
  128697. kind: WaveBlockKind;
  128698. /**
  128699. * Creates a new WaveBlock
  128700. * @param name defines the block name
  128701. */
  128702. constructor(name: string);
  128703. /**
  128704. * Gets the current class name
  128705. * @returns the class name
  128706. */
  128707. getClassName(): string;
  128708. /**
  128709. * Gets the input component
  128710. */
  128711. get input(): NodeMaterialConnectionPoint;
  128712. /**
  128713. * Gets the output component
  128714. */
  128715. get output(): NodeMaterialConnectionPoint;
  128716. protected _buildBlock(state: NodeMaterialBuildState): this;
  128717. serialize(): any;
  128718. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128719. }
  128720. }
  128721. declare module BABYLON {
  128722. /**
  128723. * Class used to store a color step for the GradientBlock
  128724. */
  128725. export class GradientBlockColorStep {
  128726. /**
  128727. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  128728. */
  128729. step: number;
  128730. /**
  128731. * Gets or sets the color associated with this step
  128732. */
  128733. color: Color3;
  128734. /**
  128735. * Creates a new GradientBlockColorStep
  128736. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  128737. * @param color defines the color associated with this step
  128738. */
  128739. constructor(
  128740. /**
  128741. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  128742. */
  128743. step: number,
  128744. /**
  128745. * Gets or sets the color associated with this step
  128746. */
  128747. color: Color3);
  128748. }
  128749. /**
  128750. * Block used to return a color from a gradient based on an input value between 0 and 1
  128751. */
  128752. export class GradientBlock extends NodeMaterialBlock {
  128753. /**
  128754. * Gets or sets the list of color steps
  128755. */
  128756. colorSteps: GradientBlockColorStep[];
  128757. /**
  128758. * Creates a new GradientBlock
  128759. * @param name defines the block name
  128760. */
  128761. constructor(name: string);
  128762. /**
  128763. * Gets the current class name
  128764. * @returns the class name
  128765. */
  128766. getClassName(): string;
  128767. /**
  128768. * Gets the gradient input component
  128769. */
  128770. get gradient(): NodeMaterialConnectionPoint;
  128771. /**
  128772. * Gets the output component
  128773. */
  128774. get output(): NodeMaterialConnectionPoint;
  128775. private _writeColorConstant;
  128776. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  128777. serialize(): any;
  128778. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128779. protected _dumpPropertiesCode(): string;
  128780. }
  128781. }
  128782. declare module BABYLON {
  128783. /**
  128784. * Block used to normalize lerp between 2 values
  128785. */
  128786. export class NLerpBlock extends NodeMaterialBlock {
  128787. /**
  128788. * Creates a new NLerpBlock
  128789. * @param name defines the block name
  128790. */
  128791. constructor(name: string);
  128792. /**
  128793. * Gets the current class name
  128794. * @returns the class name
  128795. */
  128796. getClassName(): string;
  128797. /**
  128798. * Gets the left operand input component
  128799. */
  128800. get left(): NodeMaterialConnectionPoint;
  128801. /**
  128802. * Gets the right operand input component
  128803. */
  128804. get right(): NodeMaterialConnectionPoint;
  128805. /**
  128806. * Gets the gradient operand input component
  128807. */
  128808. get gradient(): NodeMaterialConnectionPoint;
  128809. /**
  128810. * Gets the output component
  128811. */
  128812. get output(): NodeMaterialConnectionPoint;
  128813. protected _buildBlock(state: NodeMaterialBuildState): this;
  128814. }
  128815. }
  128816. declare module BABYLON {
  128817. /**
  128818. * block used to Generate a Worley Noise 3D Noise Pattern
  128819. */
  128820. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  128821. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  128822. manhattanDistance: boolean;
  128823. /**
  128824. * Creates a new WorleyNoise3DBlock
  128825. * @param name defines the block name
  128826. */
  128827. constructor(name: string);
  128828. /**
  128829. * Gets the current class name
  128830. * @returns the class name
  128831. */
  128832. getClassName(): string;
  128833. /**
  128834. * Gets the seed input component
  128835. */
  128836. get seed(): NodeMaterialConnectionPoint;
  128837. /**
  128838. * Gets the jitter input component
  128839. */
  128840. get jitter(): NodeMaterialConnectionPoint;
  128841. /**
  128842. * Gets the output component
  128843. */
  128844. get output(): NodeMaterialConnectionPoint;
  128845. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  128846. /**
  128847. * Exposes the properties to the UI?
  128848. */
  128849. protected _dumpPropertiesCode(): string;
  128850. /**
  128851. * Exposes the properties to the Seralize?
  128852. */
  128853. serialize(): any;
  128854. /**
  128855. * Exposes the properties to the deseralize?
  128856. */
  128857. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128858. }
  128859. }
  128860. declare module BABYLON {
  128861. /**
  128862. * block used to Generate a Simplex Perlin 3d Noise Pattern
  128863. */
  128864. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  128865. /**
  128866. * Creates a new SimplexPerlin3DBlock
  128867. * @param name defines the block name
  128868. */
  128869. constructor(name: string);
  128870. /**
  128871. * Gets the current class name
  128872. * @returns the class name
  128873. */
  128874. getClassName(): string;
  128875. /**
  128876. * Gets the seed operand input component
  128877. */
  128878. get seed(): NodeMaterialConnectionPoint;
  128879. /**
  128880. * Gets the output component
  128881. */
  128882. get output(): NodeMaterialConnectionPoint;
  128883. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  128884. }
  128885. }
  128886. declare module BABYLON {
  128887. /**
  128888. * Block used to blend normals
  128889. */
  128890. export class NormalBlendBlock extends NodeMaterialBlock {
  128891. /**
  128892. * Creates a new NormalBlendBlock
  128893. * @param name defines the block name
  128894. */
  128895. constructor(name: string);
  128896. /**
  128897. * Gets the current class name
  128898. * @returns the class name
  128899. */
  128900. getClassName(): string;
  128901. /**
  128902. * Gets the first input component
  128903. */
  128904. get normalMap0(): NodeMaterialConnectionPoint;
  128905. /**
  128906. * Gets the second input component
  128907. */
  128908. get normalMap1(): NodeMaterialConnectionPoint;
  128909. /**
  128910. * Gets the output component
  128911. */
  128912. get output(): NodeMaterialConnectionPoint;
  128913. protected _buildBlock(state: NodeMaterialBuildState): this;
  128914. }
  128915. }
  128916. declare module BABYLON {
  128917. /**
  128918. * Block used to rotate a 2d vector by a given angle
  128919. */
  128920. export class Rotate2dBlock extends NodeMaterialBlock {
  128921. /**
  128922. * Creates a new Rotate2dBlock
  128923. * @param name defines the block name
  128924. */
  128925. constructor(name: string);
  128926. /**
  128927. * Gets the current class name
  128928. * @returns the class name
  128929. */
  128930. getClassName(): string;
  128931. /**
  128932. * Gets the input vector
  128933. */
  128934. get input(): NodeMaterialConnectionPoint;
  128935. /**
  128936. * Gets the input angle
  128937. */
  128938. get angle(): NodeMaterialConnectionPoint;
  128939. /**
  128940. * Gets the output component
  128941. */
  128942. get output(): NodeMaterialConnectionPoint;
  128943. autoConfigure(material: NodeMaterial): void;
  128944. protected _buildBlock(state: NodeMaterialBuildState): this;
  128945. }
  128946. }
  128947. declare module BABYLON {
  128948. /**
  128949. * Block used to get the reflected vector from a direction and a normal
  128950. */
  128951. export class ReflectBlock extends NodeMaterialBlock {
  128952. /**
  128953. * Creates a new ReflectBlock
  128954. * @param name defines the block name
  128955. */
  128956. constructor(name: string);
  128957. /**
  128958. * Gets the current class name
  128959. * @returns the class name
  128960. */
  128961. getClassName(): string;
  128962. /**
  128963. * Gets the incident component
  128964. */
  128965. get incident(): NodeMaterialConnectionPoint;
  128966. /**
  128967. * Gets the normal component
  128968. */
  128969. get normal(): NodeMaterialConnectionPoint;
  128970. /**
  128971. * Gets the output component
  128972. */
  128973. get output(): NodeMaterialConnectionPoint;
  128974. protected _buildBlock(state: NodeMaterialBuildState): this;
  128975. }
  128976. }
  128977. declare module BABYLON {
  128978. /**
  128979. * Block used to get the refracted vector from a direction and a normal
  128980. */
  128981. export class RefractBlock extends NodeMaterialBlock {
  128982. /**
  128983. * Creates a new RefractBlock
  128984. * @param name defines the block name
  128985. */
  128986. constructor(name: string);
  128987. /**
  128988. * Gets the current class name
  128989. * @returns the class name
  128990. */
  128991. getClassName(): string;
  128992. /**
  128993. * Gets the incident component
  128994. */
  128995. get incident(): NodeMaterialConnectionPoint;
  128996. /**
  128997. * Gets the normal component
  128998. */
  128999. get normal(): NodeMaterialConnectionPoint;
  129000. /**
  129001. * Gets the index of refraction component
  129002. */
  129003. get ior(): NodeMaterialConnectionPoint;
  129004. /**
  129005. * Gets the output component
  129006. */
  129007. get output(): NodeMaterialConnectionPoint;
  129008. protected _buildBlock(state: NodeMaterialBuildState): this;
  129009. }
  129010. }
  129011. declare module BABYLON {
  129012. /**
  129013. * Block used to desaturate a color
  129014. */
  129015. export class DesaturateBlock extends NodeMaterialBlock {
  129016. /**
  129017. * Creates a new DesaturateBlock
  129018. * @param name defines the block name
  129019. */
  129020. constructor(name: string);
  129021. /**
  129022. * Gets the current class name
  129023. * @returns the class name
  129024. */
  129025. getClassName(): string;
  129026. /**
  129027. * Gets the color operand input component
  129028. */
  129029. get color(): NodeMaterialConnectionPoint;
  129030. /**
  129031. * Gets the level operand input component
  129032. */
  129033. get level(): NodeMaterialConnectionPoint;
  129034. /**
  129035. * Gets the output component
  129036. */
  129037. get output(): NodeMaterialConnectionPoint;
  129038. protected _buildBlock(state: NodeMaterialBuildState): this;
  129039. }
  129040. }
  129041. declare module BABYLON {
  129042. /**
  129043. * Effect Render Options
  129044. */
  129045. export interface IEffectRendererOptions {
  129046. /**
  129047. * Defines the vertices positions.
  129048. */
  129049. positions?: number[];
  129050. /**
  129051. * Defines the indices.
  129052. */
  129053. indices?: number[];
  129054. }
  129055. /**
  129056. * Helper class to render one or more effects
  129057. */
  129058. export class EffectRenderer {
  129059. private engine;
  129060. private static _DefaultOptions;
  129061. private _vertexBuffers;
  129062. private _indexBuffer;
  129063. private _ringBufferIndex;
  129064. private _ringScreenBuffer;
  129065. private _fullscreenViewport;
  129066. private _getNextFrameBuffer;
  129067. /**
  129068. * Creates an effect renderer
  129069. * @param engine the engine to use for rendering
  129070. * @param options defines the options of the effect renderer
  129071. */
  129072. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  129073. /**
  129074. * Sets the current viewport in normalized coordinates 0-1
  129075. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  129076. */
  129077. setViewport(viewport?: Viewport): void;
  129078. /**
  129079. * Binds the embedded attributes buffer to the effect.
  129080. * @param effect Defines the effect to bind the attributes for
  129081. */
  129082. bindBuffers(effect: Effect): void;
  129083. /**
  129084. * Sets the current effect wrapper to use during draw.
  129085. * The effect needs to be ready before calling this api.
  129086. * This also sets the default full screen position attribute.
  129087. * @param effectWrapper Defines the effect to draw with
  129088. */
  129089. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  129090. /**
  129091. * Draws a full screen quad.
  129092. */
  129093. draw(): void;
  129094. /**
  129095. * renders one or more effects to a specified texture
  129096. * @param effectWrappers list of effects to renderer
  129097. * @param outputTexture texture to draw to, if null it will render to the screen
  129098. */
  129099. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  129100. /**
  129101. * Disposes of the effect renderer
  129102. */
  129103. dispose(): void;
  129104. }
  129105. /**
  129106. * Options to create an EffectWrapper
  129107. */
  129108. interface EffectWrapperCreationOptions {
  129109. /**
  129110. * Engine to use to create the effect
  129111. */
  129112. engine: ThinEngine;
  129113. /**
  129114. * Fragment shader for the effect
  129115. */
  129116. fragmentShader: string;
  129117. /**
  129118. * Vertex shader for the effect
  129119. */
  129120. vertexShader?: string;
  129121. /**
  129122. * Attributes to use in the shader
  129123. */
  129124. attributeNames?: Array<string>;
  129125. /**
  129126. * Uniforms to use in the shader
  129127. */
  129128. uniformNames?: Array<string>;
  129129. /**
  129130. * Texture sampler names to use in the shader
  129131. */
  129132. samplerNames?: Array<string>;
  129133. /**
  129134. * The friendly name of the effect displayed in Spector.
  129135. */
  129136. name?: string;
  129137. }
  129138. /**
  129139. * Wraps an effect to be used for rendering
  129140. */
  129141. export class EffectWrapper {
  129142. /**
  129143. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  129144. */
  129145. onApplyObservable: Observable<{}>;
  129146. /**
  129147. * The underlying effect
  129148. */
  129149. effect: Effect;
  129150. /**
  129151. * Creates an effect to be renderer
  129152. * @param creationOptions options to create the effect
  129153. */
  129154. constructor(creationOptions: EffectWrapperCreationOptions);
  129155. /**
  129156. * Disposes of the effect wrapper
  129157. */
  129158. dispose(): void;
  129159. }
  129160. }
  129161. declare module BABYLON {
  129162. /**
  129163. * Helper class to push actions to a pool of workers.
  129164. */
  129165. export class WorkerPool implements IDisposable {
  129166. private _workerInfos;
  129167. private _pendingActions;
  129168. /**
  129169. * Constructor
  129170. * @param workers Array of workers to use for actions
  129171. */
  129172. constructor(workers: Array<Worker>);
  129173. /**
  129174. * Terminates all workers and clears any pending actions.
  129175. */
  129176. dispose(): void;
  129177. /**
  129178. * Pushes an action to the worker pool. If all the workers are active, the action will be
  129179. * pended until a worker has completed its action.
  129180. * @param action The action to perform. Call onComplete when the action is complete.
  129181. */
  129182. push(action: (worker: Worker, onComplete: () => void) => void): void;
  129183. private _execute;
  129184. }
  129185. }
  129186. declare module BABYLON {
  129187. /**
  129188. * Configuration for Draco compression
  129189. */
  129190. export interface IDracoCompressionConfiguration {
  129191. /**
  129192. * Configuration for the decoder.
  129193. */
  129194. decoder: {
  129195. /**
  129196. * The url to the WebAssembly module.
  129197. */
  129198. wasmUrl?: string;
  129199. /**
  129200. * The url to the WebAssembly binary.
  129201. */
  129202. wasmBinaryUrl?: string;
  129203. /**
  129204. * The url to the fallback JavaScript module.
  129205. */
  129206. fallbackUrl?: string;
  129207. };
  129208. }
  129209. /**
  129210. * Draco compression (https://google.github.io/draco/)
  129211. *
  129212. * This class wraps the Draco module.
  129213. *
  129214. * **Encoder**
  129215. *
  129216. * The encoder is not currently implemented.
  129217. *
  129218. * **Decoder**
  129219. *
  129220. * 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.
  129221. *
  129222. * To update the configuration, use the following code:
  129223. * ```javascript
  129224. * DracoCompression.Configuration = {
  129225. * decoder: {
  129226. * wasmUrl: "<url to the WebAssembly library>",
  129227. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  129228. * fallbackUrl: "<url to the fallback JavaScript library>",
  129229. * }
  129230. * };
  129231. * ```
  129232. *
  129233. * 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.
  129234. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  129235. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  129236. *
  129237. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  129238. * ```javascript
  129239. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  129240. * ```
  129241. *
  129242. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  129243. */
  129244. export class DracoCompression implements IDisposable {
  129245. private _workerPoolPromise?;
  129246. private _decoderModulePromise?;
  129247. /**
  129248. * The configuration. Defaults to the following urls:
  129249. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  129250. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  129251. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  129252. */
  129253. static Configuration: IDracoCompressionConfiguration;
  129254. /**
  129255. * Returns true if the decoder configuration is available.
  129256. */
  129257. static get DecoderAvailable(): boolean;
  129258. /**
  129259. * Default number of workers to create when creating the draco compression object.
  129260. */
  129261. static DefaultNumWorkers: number;
  129262. private static GetDefaultNumWorkers;
  129263. private static _Default;
  129264. /**
  129265. * Default instance for the draco compression object.
  129266. */
  129267. static get Default(): DracoCompression;
  129268. /**
  129269. * Constructor
  129270. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  129271. */
  129272. constructor(numWorkers?: number);
  129273. /**
  129274. * Stop all async operations and release resources.
  129275. */
  129276. dispose(): void;
  129277. /**
  129278. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  129279. * @returns a promise that resolves when ready
  129280. */
  129281. whenReadyAsync(): Promise<void>;
  129282. /**
  129283. * Decode Draco compressed mesh data to vertex data.
  129284. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  129285. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  129286. * @returns A promise that resolves with the decoded vertex data
  129287. */
  129288. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  129289. [kind: string]: number;
  129290. }): Promise<VertexData>;
  129291. }
  129292. }
  129293. declare module BABYLON {
  129294. /**
  129295. * Class for building Constructive Solid Geometry
  129296. */
  129297. export class CSG {
  129298. private polygons;
  129299. /**
  129300. * The world matrix
  129301. */
  129302. matrix: Matrix;
  129303. /**
  129304. * Stores the position
  129305. */
  129306. position: Vector3;
  129307. /**
  129308. * Stores the rotation
  129309. */
  129310. rotation: Vector3;
  129311. /**
  129312. * Stores the rotation quaternion
  129313. */
  129314. rotationQuaternion: Nullable<Quaternion>;
  129315. /**
  129316. * Stores the scaling vector
  129317. */
  129318. scaling: Vector3;
  129319. /**
  129320. * Convert the Mesh to CSG
  129321. * @param mesh The Mesh to convert to CSG
  129322. * @returns A new CSG from the Mesh
  129323. */
  129324. static FromMesh(mesh: Mesh): CSG;
  129325. /**
  129326. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  129327. * @param polygons Polygons used to construct a CSG solid
  129328. */
  129329. private static FromPolygons;
  129330. /**
  129331. * Clones, or makes a deep copy, of the CSG
  129332. * @returns A new CSG
  129333. */
  129334. clone(): CSG;
  129335. /**
  129336. * Unions this CSG with another CSG
  129337. * @param csg The CSG to union against this CSG
  129338. * @returns The unioned CSG
  129339. */
  129340. union(csg: CSG): CSG;
  129341. /**
  129342. * Unions this CSG with another CSG in place
  129343. * @param csg The CSG to union against this CSG
  129344. */
  129345. unionInPlace(csg: CSG): void;
  129346. /**
  129347. * Subtracts this CSG with another CSG
  129348. * @param csg The CSG to subtract against this CSG
  129349. * @returns A new CSG
  129350. */
  129351. subtract(csg: CSG): CSG;
  129352. /**
  129353. * Subtracts this CSG with another CSG in place
  129354. * @param csg The CSG to subtact against this CSG
  129355. */
  129356. subtractInPlace(csg: CSG): void;
  129357. /**
  129358. * Intersect this CSG with another CSG
  129359. * @param csg The CSG to intersect against this CSG
  129360. * @returns A new CSG
  129361. */
  129362. intersect(csg: CSG): CSG;
  129363. /**
  129364. * Intersects this CSG with another CSG in place
  129365. * @param csg The CSG to intersect against this CSG
  129366. */
  129367. intersectInPlace(csg: CSG): void;
  129368. /**
  129369. * Return a new CSG solid with solid and empty space switched. This solid is
  129370. * not modified.
  129371. * @returns A new CSG solid with solid and empty space switched
  129372. */
  129373. inverse(): CSG;
  129374. /**
  129375. * Inverses the CSG in place
  129376. */
  129377. inverseInPlace(): void;
  129378. /**
  129379. * This is used to keep meshes transformations so they can be restored
  129380. * when we build back a Babylon Mesh
  129381. * NB : All CSG operations are performed in world coordinates
  129382. * @param csg The CSG to copy the transform attributes from
  129383. * @returns This CSG
  129384. */
  129385. copyTransformAttributes(csg: CSG): CSG;
  129386. /**
  129387. * Build Raw mesh from CSG
  129388. * Coordinates here are in world space
  129389. * @param name The name of the mesh geometry
  129390. * @param scene The Scene
  129391. * @param keepSubMeshes Specifies if the submeshes should be kept
  129392. * @returns A new Mesh
  129393. */
  129394. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  129395. /**
  129396. * Build Mesh from CSG taking material and transforms into account
  129397. * @param name The name of the Mesh
  129398. * @param material The material of the Mesh
  129399. * @param scene The Scene
  129400. * @param keepSubMeshes Specifies if submeshes should be kept
  129401. * @returns The new Mesh
  129402. */
  129403. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  129404. }
  129405. }
  129406. declare module BABYLON {
  129407. /**
  129408. * Class used to create a trail following a mesh
  129409. */
  129410. export class TrailMesh extends Mesh {
  129411. private _generator;
  129412. private _autoStart;
  129413. private _running;
  129414. private _diameter;
  129415. private _length;
  129416. private _sectionPolygonPointsCount;
  129417. private _sectionVectors;
  129418. private _sectionNormalVectors;
  129419. private _beforeRenderObserver;
  129420. /**
  129421. * @constructor
  129422. * @param name The value used by scene.getMeshByName() to do a lookup.
  129423. * @param generator The mesh to generate a trail.
  129424. * @param scene The scene to add this mesh to.
  129425. * @param diameter Diameter of trailing mesh. Default is 1.
  129426. * @param length Length of trailing mesh. Default is 60.
  129427. * @param autoStart Automatically start trailing mesh. Default true.
  129428. */
  129429. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  129430. /**
  129431. * "TrailMesh"
  129432. * @returns "TrailMesh"
  129433. */
  129434. getClassName(): string;
  129435. private _createMesh;
  129436. /**
  129437. * Start trailing mesh.
  129438. */
  129439. start(): void;
  129440. /**
  129441. * Stop trailing mesh.
  129442. */
  129443. stop(): void;
  129444. /**
  129445. * Update trailing mesh geometry.
  129446. */
  129447. update(): void;
  129448. /**
  129449. * Returns a new TrailMesh object.
  129450. * @param name is a string, the name given to the new mesh
  129451. * @param newGenerator use new generator object for cloned trail mesh
  129452. * @returns a new mesh
  129453. */
  129454. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  129455. /**
  129456. * Serializes this trail mesh
  129457. * @param serializationObject object to write serialization to
  129458. */
  129459. serialize(serializationObject: any): void;
  129460. /**
  129461. * Parses a serialized trail mesh
  129462. * @param parsedMesh the serialized mesh
  129463. * @param scene the scene to create the trail mesh in
  129464. * @returns the created trail mesh
  129465. */
  129466. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  129467. }
  129468. }
  129469. declare module BABYLON {
  129470. /**
  129471. * Class containing static functions to help procedurally build meshes
  129472. */
  129473. export class TiledBoxBuilder {
  129474. /**
  129475. * Creates a box mesh
  129476. * 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)
  129477. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129478. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129479. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129480. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129481. * @param name defines the name of the mesh
  129482. * @param options defines the options used to create the mesh
  129483. * @param scene defines the hosting scene
  129484. * @returns the box mesh
  129485. */
  129486. static CreateTiledBox(name: string, options: {
  129487. pattern?: number;
  129488. width?: number;
  129489. height?: number;
  129490. depth?: number;
  129491. tileSize?: number;
  129492. tileWidth?: number;
  129493. tileHeight?: number;
  129494. alignHorizontal?: number;
  129495. alignVertical?: number;
  129496. faceUV?: Vector4[];
  129497. faceColors?: Color4[];
  129498. sideOrientation?: number;
  129499. updatable?: boolean;
  129500. }, scene?: Nullable<Scene>): Mesh;
  129501. }
  129502. }
  129503. declare module BABYLON {
  129504. /**
  129505. * Class containing static functions to help procedurally build meshes
  129506. */
  129507. export class TorusKnotBuilder {
  129508. /**
  129509. * Creates a torus knot mesh
  129510. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  129511. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  129512. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  129513. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  129514. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129515. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129517. * @param name defines the name of the mesh
  129518. * @param options defines the options used to create the mesh
  129519. * @param scene defines the hosting scene
  129520. * @returns the torus knot mesh
  129521. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  129522. */
  129523. static CreateTorusKnot(name: string, options: {
  129524. radius?: number;
  129525. tube?: number;
  129526. radialSegments?: number;
  129527. tubularSegments?: number;
  129528. p?: number;
  129529. q?: number;
  129530. updatable?: boolean;
  129531. sideOrientation?: number;
  129532. frontUVs?: Vector4;
  129533. backUVs?: Vector4;
  129534. }, scene: any): Mesh;
  129535. }
  129536. }
  129537. declare module BABYLON {
  129538. /**
  129539. * Polygon
  129540. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  129541. */
  129542. export class Polygon {
  129543. /**
  129544. * Creates a rectangle
  129545. * @param xmin bottom X coord
  129546. * @param ymin bottom Y coord
  129547. * @param xmax top X coord
  129548. * @param ymax top Y coord
  129549. * @returns points that make the resulting rectation
  129550. */
  129551. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  129552. /**
  129553. * Creates a circle
  129554. * @param radius radius of circle
  129555. * @param cx scale in x
  129556. * @param cy scale in y
  129557. * @param numberOfSides number of sides that make up the circle
  129558. * @returns points that make the resulting circle
  129559. */
  129560. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  129561. /**
  129562. * Creates a polygon from input string
  129563. * @param input Input polygon data
  129564. * @returns the parsed points
  129565. */
  129566. static Parse(input: string): Vector2[];
  129567. /**
  129568. * Starts building a polygon from x and y coordinates
  129569. * @param x x coordinate
  129570. * @param y y coordinate
  129571. * @returns the started path2
  129572. */
  129573. static StartingAt(x: number, y: number): Path2;
  129574. }
  129575. /**
  129576. * Builds a polygon
  129577. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  129578. */
  129579. export class PolygonMeshBuilder {
  129580. private _points;
  129581. private _outlinepoints;
  129582. private _holes;
  129583. private _name;
  129584. private _scene;
  129585. private _epoints;
  129586. private _eholes;
  129587. private _addToepoint;
  129588. /**
  129589. * Babylon reference to the earcut plugin.
  129590. */
  129591. bjsEarcut: any;
  129592. /**
  129593. * Creates a PolygonMeshBuilder
  129594. * @param name name of the builder
  129595. * @param contours Path of the polygon
  129596. * @param scene scene to add to when creating the mesh
  129597. * @param earcutInjection can be used to inject your own earcut reference
  129598. */
  129599. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  129600. /**
  129601. * Adds a whole within the polygon
  129602. * @param hole Array of points defining the hole
  129603. * @returns this
  129604. */
  129605. addHole(hole: Vector2[]): PolygonMeshBuilder;
  129606. /**
  129607. * Creates the polygon
  129608. * @param updatable If the mesh should be updatable
  129609. * @param depth The depth of the mesh created
  129610. * @returns the created mesh
  129611. */
  129612. build(updatable?: boolean, depth?: number): Mesh;
  129613. /**
  129614. * Creates the polygon
  129615. * @param depth The depth of the mesh created
  129616. * @returns the created VertexData
  129617. */
  129618. buildVertexData(depth?: number): VertexData;
  129619. /**
  129620. * Adds a side to the polygon
  129621. * @param positions points that make the polygon
  129622. * @param normals normals of the polygon
  129623. * @param uvs uvs of the polygon
  129624. * @param indices indices of the polygon
  129625. * @param bounds bounds of the polygon
  129626. * @param points points of the polygon
  129627. * @param depth depth of the polygon
  129628. * @param flip flip of the polygon
  129629. */
  129630. private addSide;
  129631. }
  129632. }
  129633. declare module BABYLON {
  129634. /**
  129635. * Class containing static functions to help procedurally build meshes
  129636. */
  129637. export class PolygonBuilder {
  129638. /**
  129639. * Creates a polygon mesh
  129640. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  129641. * * 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
  129642. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  129643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129644. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  129645. * * Remember you can only change the shape positions, not their number when updating a polygon
  129646. * @param name defines the name of the mesh
  129647. * @param options defines the options used to create the mesh
  129648. * @param scene defines the hosting scene
  129649. * @param earcutInjection can be used to inject your own earcut reference
  129650. * @returns the polygon mesh
  129651. */
  129652. static CreatePolygon(name: string, options: {
  129653. shape: Vector3[];
  129654. holes?: Vector3[][];
  129655. depth?: number;
  129656. faceUV?: Vector4[];
  129657. faceColors?: Color4[];
  129658. updatable?: boolean;
  129659. sideOrientation?: number;
  129660. frontUVs?: Vector4;
  129661. backUVs?: Vector4;
  129662. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  129663. /**
  129664. * Creates an extruded polygon mesh, with depth in the Y direction.
  129665. * * 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)
  129666. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129667. * @param name defines the name of the mesh
  129668. * @param options defines the options used to create the mesh
  129669. * @param scene defines the hosting scene
  129670. * @param earcutInjection can be used to inject your own earcut reference
  129671. * @returns the polygon mesh
  129672. */
  129673. static ExtrudePolygon(name: string, options: {
  129674. shape: Vector3[];
  129675. holes?: Vector3[][];
  129676. depth?: number;
  129677. faceUV?: Vector4[];
  129678. faceColors?: Color4[];
  129679. updatable?: boolean;
  129680. sideOrientation?: number;
  129681. frontUVs?: Vector4;
  129682. backUVs?: Vector4;
  129683. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  129684. }
  129685. }
  129686. declare module BABYLON {
  129687. /**
  129688. * Class containing static functions to help procedurally build meshes
  129689. */
  129690. export class LatheBuilder {
  129691. /**
  129692. * Creates lathe mesh.
  129693. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  129694. * * 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
  129695. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  129696. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  129697. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  129698. * * 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
  129699. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  129700. * * 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
  129701. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129702. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129703. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129704. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129705. * @param name defines the name of the mesh
  129706. * @param options defines the options used to create the mesh
  129707. * @param scene defines the hosting scene
  129708. * @returns the lathe mesh
  129709. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  129710. */
  129711. static CreateLathe(name: string, options: {
  129712. shape: Vector3[];
  129713. radius?: number;
  129714. tessellation?: number;
  129715. clip?: number;
  129716. arc?: number;
  129717. closed?: boolean;
  129718. updatable?: boolean;
  129719. sideOrientation?: number;
  129720. frontUVs?: Vector4;
  129721. backUVs?: Vector4;
  129722. cap?: number;
  129723. invertUV?: boolean;
  129724. }, scene?: Nullable<Scene>): Mesh;
  129725. }
  129726. }
  129727. declare module BABYLON {
  129728. /**
  129729. * Class containing static functions to help procedurally build meshes
  129730. */
  129731. export class TiledPlaneBuilder {
  129732. /**
  129733. * Creates a tiled plane mesh
  129734. * * The parameter `pattern` will, depending on value, do nothing or
  129735. * * * flip (reflect about central vertical) alternate tiles across and up
  129736. * * * flip every tile on alternate rows
  129737. * * * rotate (180 degs) alternate tiles across and up
  129738. * * * rotate every tile on alternate rows
  129739. * * * flip and rotate alternate tiles across and up
  129740. * * * flip and rotate every tile on alternate rows
  129741. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  129742. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  129743. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129744. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  129745. * * 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)
  129746. * * 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)
  129747. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  129748. * @param name defines the name of the mesh
  129749. * @param options defines the options used to create the mesh
  129750. * @param scene defines the hosting scene
  129751. * @returns the box mesh
  129752. */
  129753. static CreateTiledPlane(name: string, options: {
  129754. pattern?: number;
  129755. tileSize?: number;
  129756. tileWidth?: number;
  129757. tileHeight?: number;
  129758. size?: number;
  129759. width?: number;
  129760. height?: number;
  129761. alignHorizontal?: number;
  129762. alignVertical?: number;
  129763. sideOrientation?: number;
  129764. frontUVs?: Vector4;
  129765. backUVs?: Vector4;
  129766. updatable?: boolean;
  129767. }, scene?: Nullable<Scene>): Mesh;
  129768. }
  129769. }
  129770. declare module BABYLON {
  129771. /**
  129772. * Class containing static functions to help procedurally build meshes
  129773. */
  129774. export class TubeBuilder {
  129775. /**
  129776. * Creates a tube mesh.
  129777. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  129778. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  129779. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  129780. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  129781. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  129782. * * 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)
  129783. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  129784. * * 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
  129785. * * 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
  129786. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129787. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129788. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129790. * @param name defines the name of the mesh
  129791. * @param options defines the options used to create the mesh
  129792. * @param scene defines the hosting scene
  129793. * @returns the tube mesh
  129794. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129795. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  129796. */
  129797. static CreateTube(name: string, options: {
  129798. path: Vector3[];
  129799. radius?: number;
  129800. tessellation?: number;
  129801. radiusFunction?: {
  129802. (i: number, distance: number): number;
  129803. };
  129804. cap?: number;
  129805. arc?: number;
  129806. updatable?: boolean;
  129807. sideOrientation?: number;
  129808. frontUVs?: Vector4;
  129809. backUVs?: Vector4;
  129810. instance?: Mesh;
  129811. invertUV?: boolean;
  129812. }, scene?: Nullable<Scene>): Mesh;
  129813. }
  129814. }
  129815. declare module BABYLON {
  129816. /**
  129817. * Class containing static functions to help procedurally build meshes
  129818. */
  129819. export class IcoSphereBuilder {
  129820. /**
  129821. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  129822. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  129823. * * 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`)
  129824. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  129825. * * 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
  129826. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129827. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129829. * @param name defines the name of the mesh
  129830. * @param options defines the options used to create the mesh
  129831. * @param scene defines the hosting scene
  129832. * @returns the icosahedron mesh
  129833. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  129834. */
  129835. static CreateIcoSphere(name: string, options: {
  129836. radius?: number;
  129837. radiusX?: number;
  129838. radiusY?: number;
  129839. radiusZ?: number;
  129840. flat?: boolean;
  129841. subdivisions?: number;
  129842. sideOrientation?: number;
  129843. frontUVs?: Vector4;
  129844. backUVs?: Vector4;
  129845. updatable?: boolean;
  129846. }, scene?: Nullable<Scene>): Mesh;
  129847. }
  129848. }
  129849. declare module BABYLON {
  129850. /**
  129851. * Class containing static functions to help procedurally build meshes
  129852. */
  129853. export class DecalBuilder {
  129854. /**
  129855. * Creates a decal mesh.
  129856. * 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
  129857. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  129858. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  129859. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  129860. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  129861. * @param name defines the name of the mesh
  129862. * @param sourceMesh defines the mesh where the decal must be applied
  129863. * @param options defines the options used to create the mesh
  129864. * @param scene defines the hosting scene
  129865. * @returns the decal mesh
  129866. * @see https://doc.babylonjs.com/how_to/decals
  129867. */
  129868. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  129869. position?: Vector3;
  129870. normal?: Vector3;
  129871. size?: Vector3;
  129872. angle?: number;
  129873. }): Mesh;
  129874. }
  129875. }
  129876. declare module BABYLON {
  129877. /**
  129878. * Class containing static functions to help procedurally build meshes
  129879. */
  129880. export class MeshBuilder {
  129881. /**
  129882. * Creates a box mesh
  129883. * * The parameter `size` sets the size (float) of each box side (default 1)
  129884. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  129885. * * 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)
  129886. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  129887. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129888. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129890. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  129891. * @param name defines the name of the mesh
  129892. * @param options defines the options used to create the mesh
  129893. * @param scene defines the hosting scene
  129894. * @returns the box mesh
  129895. */
  129896. static CreateBox(name: string, options: {
  129897. size?: number;
  129898. width?: number;
  129899. height?: number;
  129900. depth?: number;
  129901. faceUV?: Vector4[];
  129902. faceColors?: Color4[];
  129903. sideOrientation?: number;
  129904. frontUVs?: Vector4;
  129905. backUVs?: Vector4;
  129906. updatable?: boolean;
  129907. }, scene?: Nullable<Scene>): Mesh;
  129908. /**
  129909. * Creates a tiled box mesh
  129910. * * faceTiles sets the pattern, tile size and number of tiles for a face
  129911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129912. * @param name defines the name of the mesh
  129913. * @param options defines the options used to create the mesh
  129914. * @param scene defines the hosting scene
  129915. * @returns the tiled box mesh
  129916. */
  129917. static CreateTiledBox(name: string, options: {
  129918. pattern?: number;
  129919. size?: number;
  129920. width?: number;
  129921. height?: number;
  129922. depth: number;
  129923. tileSize?: number;
  129924. tileWidth?: number;
  129925. tileHeight?: number;
  129926. faceUV?: Vector4[];
  129927. faceColors?: Color4[];
  129928. alignHorizontal?: number;
  129929. alignVertical?: number;
  129930. sideOrientation?: number;
  129931. updatable?: boolean;
  129932. }, scene?: Nullable<Scene>): Mesh;
  129933. /**
  129934. * Creates a sphere mesh
  129935. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  129936. * * 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`)
  129937. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  129938. * * 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
  129939. * * 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)
  129940. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129941. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129942. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129943. * @param name defines the name of the mesh
  129944. * @param options defines the options used to create the mesh
  129945. * @param scene defines the hosting scene
  129946. * @returns the sphere mesh
  129947. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  129948. */
  129949. static CreateSphere(name: string, options: {
  129950. segments?: number;
  129951. diameter?: number;
  129952. diameterX?: number;
  129953. diameterY?: number;
  129954. diameterZ?: number;
  129955. arc?: number;
  129956. slice?: number;
  129957. sideOrientation?: number;
  129958. frontUVs?: Vector4;
  129959. backUVs?: Vector4;
  129960. updatable?: boolean;
  129961. }, scene?: Nullable<Scene>): Mesh;
  129962. /**
  129963. * Creates a plane polygonal mesh. By default, this is a disc
  129964. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  129965. * * 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
  129966. * * 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
  129967. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129968. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129970. * @param name defines the name of the mesh
  129971. * @param options defines the options used to create the mesh
  129972. * @param scene defines the hosting scene
  129973. * @returns the plane polygonal mesh
  129974. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  129975. */
  129976. static CreateDisc(name: string, options: {
  129977. radius?: number;
  129978. tessellation?: number;
  129979. arc?: number;
  129980. updatable?: boolean;
  129981. sideOrientation?: number;
  129982. frontUVs?: Vector4;
  129983. backUVs?: Vector4;
  129984. }, scene?: Nullable<Scene>): Mesh;
  129985. /**
  129986. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  129987. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  129988. * * 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`)
  129989. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  129990. * * 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
  129991. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129992. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129994. * @param name defines the name of the mesh
  129995. * @param options defines the options used to create the mesh
  129996. * @param scene defines the hosting scene
  129997. * @returns the icosahedron mesh
  129998. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  129999. */
  130000. static CreateIcoSphere(name: string, options: {
  130001. radius?: number;
  130002. radiusX?: number;
  130003. radiusY?: number;
  130004. radiusZ?: number;
  130005. flat?: boolean;
  130006. subdivisions?: number;
  130007. sideOrientation?: number;
  130008. frontUVs?: Vector4;
  130009. backUVs?: Vector4;
  130010. updatable?: boolean;
  130011. }, scene?: Nullable<Scene>): Mesh;
  130012. /**
  130013. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  130014. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  130015. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  130016. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  130017. * * 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
  130018. * * 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
  130019. * * 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
  130020. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130021. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130022. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130023. * * 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
  130024. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  130025. * * 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
  130026. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  130027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130028. * @param name defines the name of the mesh
  130029. * @param options defines the options used to create the mesh
  130030. * @param scene defines the hosting scene
  130031. * @returns the ribbon mesh
  130032. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  130033. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130034. */
  130035. static CreateRibbon(name: string, options: {
  130036. pathArray: Vector3[][];
  130037. closeArray?: boolean;
  130038. closePath?: boolean;
  130039. offset?: number;
  130040. updatable?: boolean;
  130041. sideOrientation?: number;
  130042. frontUVs?: Vector4;
  130043. backUVs?: Vector4;
  130044. instance?: Mesh;
  130045. invertUV?: boolean;
  130046. uvs?: Vector2[];
  130047. colors?: Color4[];
  130048. }, scene?: Nullable<Scene>): Mesh;
  130049. /**
  130050. * Creates a cylinder or a cone mesh
  130051. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  130052. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  130053. * * 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.
  130054. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  130055. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  130056. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  130057. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  130058. * * 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).
  130059. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  130060. * * 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).
  130061. * * 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
  130062. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  130063. * * 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
  130064. * * 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.
  130065. * * If `enclose` is false, a ring surface is one element.
  130066. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  130067. * * 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
  130068. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130069. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130070. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130071. * @param name defines the name of the mesh
  130072. * @param options defines the options used to create the mesh
  130073. * @param scene defines the hosting scene
  130074. * @returns the cylinder mesh
  130075. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  130076. */
  130077. static CreateCylinder(name: string, options: {
  130078. height?: number;
  130079. diameterTop?: number;
  130080. diameterBottom?: number;
  130081. diameter?: number;
  130082. tessellation?: number;
  130083. subdivisions?: number;
  130084. arc?: number;
  130085. faceColors?: Color4[];
  130086. faceUV?: Vector4[];
  130087. updatable?: boolean;
  130088. hasRings?: boolean;
  130089. enclose?: boolean;
  130090. cap?: number;
  130091. sideOrientation?: number;
  130092. frontUVs?: Vector4;
  130093. backUVs?: Vector4;
  130094. }, scene?: Nullable<Scene>): Mesh;
  130095. /**
  130096. * Creates a torus mesh
  130097. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  130098. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  130099. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  130100. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130101. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130103. * @param name defines the name of the mesh
  130104. * @param options defines the options used to create the mesh
  130105. * @param scene defines the hosting scene
  130106. * @returns the torus mesh
  130107. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  130108. */
  130109. static CreateTorus(name: string, options: {
  130110. diameter?: number;
  130111. thickness?: number;
  130112. tessellation?: number;
  130113. updatable?: boolean;
  130114. sideOrientation?: number;
  130115. frontUVs?: Vector4;
  130116. backUVs?: Vector4;
  130117. }, scene?: Nullable<Scene>): Mesh;
  130118. /**
  130119. * Creates a torus knot mesh
  130120. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  130121. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  130122. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  130123. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  130124. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130125. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130127. * @param name defines the name of the mesh
  130128. * @param options defines the options used to create the mesh
  130129. * @param scene defines the hosting scene
  130130. * @returns the torus knot mesh
  130131. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  130132. */
  130133. static CreateTorusKnot(name: string, options: {
  130134. radius?: number;
  130135. tube?: number;
  130136. radialSegments?: number;
  130137. tubularSegments?: number;
  130138. p?: number;
  130139. q?: number;
  130140. updatable?: boolean;
  130141. sideOrientation?: number;
  130142. frontUVs?: Vector4;
  130143. backUVs?: Vector4;
  130144. }, scene?: Nullable<Scene>): Mesh;
  130145. /**
  130146. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  130147. * * 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
  130148. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  130149. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  130150. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  130151. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  130152. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  130153. * * 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
  130154. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  130155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130156. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  130157. * @param name defines the name of the new line system
  130158. * @param options defines the options used to create the line system
  130159. * @param scene defines the hosting scene
  130160. * @returns a new line system mesh
  130161. */
  130162. static CreateLineSystem(name: string, options: {
  130163. lines: Vector3[][];
  130164. updatable?: boolean;
  130165. instance?: Nullable<LinesMesh>;
  130166. colors?: Nullable<Color4[][]>;
  130167. useVertexAlpha?: boolean;
  130168. }, scene: Nullable<Scene>): LinesMesh;
  130169. /**
  130170. * Creates a line mesh
  130171. * 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
  130172. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  130173. * * The parameter `points` is an array successive Vector3
  130174. * * 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
  130175. * * The optional parameter `colors` is an array of successive Color4, one per line point
  130176. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  130177. * * When updating an instance, remember that only point positions can change, not the number of points
  130178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130179. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  130180. * @param name defines the name of the new line system
  130181. * @param options defines the options used to create the line system
  130182. * @param scene defines the hosting scene
  130183. * @returns a new line mesh
  130184. */
  130185. static CreateLines(name: string, options: {
  130186. points: Vector3[];
  130187. updatable?: boolean;
  130188. instance?: Nullable<LinesMesh>;
  130189. colors?: Color4[];
  130190. useVertexAlpha?: boolean;
  130191. }, scene?: Nullable<Scene>): LinesMesh;
  130192. /**
  130193. * Creates a dashed line mesh
  130194. * * 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
  130195. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  130196. * * The parameter `points` is an array successive Vector3
  130197. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  130198. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  130199. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  130200. * * 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
  130201. * * When updating an instance, remember that only point positions can change, not the number of points
  130202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130203. * @param name defines the name of the mesh
  130204. * @param options defines the options used to create the mesh
  130205. * @param scene defines the hosting scene
  130206. * @returns the dashed line mesh
  130207. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  130208. */
  130209. static CreateDashedLines(name: string, options: {
  130210. points: Vector3[];
  130211. dashSize?: number;
  130212. gapSize?: number;
  130213. dashNb?: number;
  130214. updatable?: boolean;
  130215. instance?: LinesMesh;
  130216. }, scene?: Nullable<Scene>): LinesMesh;
  130217. /**
  130218. * 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.
  130219. * * 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.
  130220. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  130221. * * 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.
  130222. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  130223. * * 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
  130224. * * 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
  130225. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  130226. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130227. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130228. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  130229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130230. * @param name defines the name of the mesh
  130231. * @param options defines the options used to create the mesh
  130232. * @param scene defines the hosting scene
  130233. * @returns the extruded shape mesh
  130234. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130235. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  130236. */
  130237. static ExtrudeShape(name: string, options: {
  130238. shape: Vector3[];
  130239. path: Vector3[];
  130240. scale?: number;
  130241. rotation?: number;
  130242. cap?: number;
  130243. updatable?: boolean;
  130244. sideOrientation?: number;
  130245. frontUVs?: Vector4;
  130246. backUVs?: Vector4;
  130247. instance?: Mesh;
  130248. invertUV?: boolean;
  130249. }, scene?: Nullable<Scene>): Mesh;
  130250. /**
  130251. * Creates an custom extruded shape mesh.
  130252. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  130253. * * 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.
  130254. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  130255. * * 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
  130256. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  130257. * * 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
  130258. * * It must returns a float value that will be the scale value applied to the shape on each path point
  130259. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  130260. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  130261. * * 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
  130262. * * 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
  130263. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  130264. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130265. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130266. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130268. * @param name defines the name of the mesh
  130269. * @param options defines the options used to create the mesh
  130270. * @param scene defines the hosting scene
  130271. * @returns the custom extruded shape mesh
  130272. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  130273. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130274. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  130275. */
  130276. static ExtrudeShapeCustom(name: string, options: {
  130277. shape: Vector3[];
  130278. path: Vector3[];
  130279. scaleFunction?: any;
  130280. rotationFunction?: any;
  130281. ribbonCloseArray?: boolean;
  130282. ribbonClosePath?: boolean;
  130283. cap?: number;
  130284. updatable?: boolean;
  130285. sideOrientation?: number;
  130286. frontUVs?: Vector4;
  130287. backUVs?: Vector4;
  130288. instance?: Mesh;
  130289. invertUV?: boolean;
  130290. }, scene?: Nullable<Scene>): Mesh;
  130291. /**
  130292. * Creates lathe mesh.
  130293. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  130294. * * 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
  130295. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  130296. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  130297. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  130298. * * 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
  130299. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  130300. * * 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
  130301. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130302. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130303. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130304. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130305. * @param name defines the name of the mesh
  130306. * @param options defines the options used to create the mesh
  130307. * @param scene defines the hosting scene
  130308. * @returns the lathe mesh
  130309. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  130310. */
  130311. static CreateLathe(name: string, options: {
  130312. shape: Vector3[];
  130313. radius?: number;
  130314. tessellation?: number;
  130315. clip?: number;
  130316. arc?: number;
  130317. closed?: boolean;
  130318. updatable?: boolean;
  130319. sideOrientation?: number;
  130320. frontUVs?: Vector4;
  130321. backUVs?: Vector4;
  130322. cap?: number;
  130323. invertUV?: boolean;
  130324. }, scene?: Nullable<Scene>): Mesh;
  130325. /**
  130326. * Creates a tiled plane mesh
  130327. * * You can set a limited pattern arrangement with the tiles
  130328. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130329. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130331. * @param name defines the name of the mesh
  130332. * @param options defines the options used to create the mesh
  130333. * @param scene defines the hosting scene
  130334. * @returns the plane mesh
  130335. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  130336. */
  130337. static CreateTiledPlane(name: string, options: {
  130338. pattern?: number;
  130339. tileSize?: number;
  130340. tileWidth?: number;
  130341. tileHeight?: number;
  130342. size?: number;
  130343. width?: number;
  130344. height?: number;
  130345. alignHorizontal?: number;
  130346. alignVertical?: number;
  130347. sideOrientation?: number;
  130348. frontUVs?: Vector4;
  130349. backUVs?: Vector4;
  130350. updatable?: boolean;
  130351. }, scene?: Nullable<Scene>): Mesh;
  130352. /**
  130353. * Creates a plane mesh
  130354. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  130355. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  130356. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  130357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130358. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130360. * @param name defines the name of the mesh
  130361. * @param options defines the options used to create the mesh
  130362. * @param scene defines the hosting scene
  130363. * @returns the plane mesh
  130364. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  130365. */
  130366. static CreatePlane(name: string, options: {
  130367. size?: number;
  130368. width?: number;
  130369. height?: number;
  130370. sideOrientation?: number;
  130371. frontUVs?: Vector4;
  130372. backUVs?: Vector4;
  130373. updatable?: boolean;
  130374. sourcePlane?: Plane;
  130375. }, scene?: Nullable<Scene>): Mesh;
  130376. /**
  130377. * Creates a ground mesh
  130378. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  130379. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  130380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130381. * @param name defines the name of the mesh
  130382. * @param options defines the options used to create the mesh
  130383. * @param scene defines the hosting scene
  130384. * @returns the ground mesh
  130385. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  130386. */
  130387. static CreateGround(name: string, options: {
  130388. width?: number;
  130389. height?: number;
  130390. subdivisions?: number;
  130391. subdivisionsX?: number;
  130392. subdivisionsY?: number;
  130393. updatable?: boolean;
  130394. }, scene?: Nullable<Scene>): Mesh;
  130395. /**
  130396. * Creates a tiled ground mesh
  130397. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  130398. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  130399. * * 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
  130400. * * 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
  130401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130402. * @param name defines the name of the mesh
  130403. * @param options defines the options used to create the mesh
  130404. * @param scene defines the hosting scene
  130405. * @returns the tiled ground mesh
  130406. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  130407. */
  130408. static CreateTiledGround(name: string, options: {
  130409. xmin: number;
  130410. zmin: number;
  130411. xmax: number;
  130412. zmax: number;
  130413. subdivisions?: {
  130414. w: number;
  130415. h: number;
  130416. };
  130417. precision?: {
  130418. w: number;
  130419. h: number;
  130420. };
  130421. updatable?: boolean;
  130422. }, scene?: Nullable<Scene>): Mesh;
  130423. /**
  130424. * Creates a ground mesh from a height map
  130425. * * The parameter `url` sets the URL of the height map image resource.
  130426. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  130427. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  130428. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  130429. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  130430. * * 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.
  130431. * * 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).
  130432. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  130433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130434. * @param name defines the name of the mesh
  130435. * @param url defines the url to the height map
  130436. * @param options defines the options used to create the mesh
  130437. * @param scene defines the hosting scene
  130438. * @returns the ground mesh
  130439. * @see https://doc.babylonjs.com/babylon101/height_map
  130440. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  130441. */
  130442. static CreateGroundFromHeightMap(name: string, url: string, options: {
  130443. width?: number;
  130444. height?: number;
  130445. subdivisions?: number;
  130446. minHeight?: number;
  130447. maxHeight?: number;
  130448. colorFilter?: Color3;
  130449. alphaFilter?: number;
  130450. updatable?: boolean;
  130451. onReady?: (mesh: GroundMesh) => void;
  130452. }, scene?: Nullable<Scene>): GroundMesh;
  130453. /**
  130454. * Creates a polygon mesh
  130455. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  130456. * * 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
  130457. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  130458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130459. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  130460. * * Remember you can only change the shape positions, not their number when updating a polygon
  130461. * @param name defines the name of the mesh
  130462. * @param options defines the options used to create the mesh
  130463. * @param scene defines the hosting scene
  130464. * @param earcutInjection can be used to inject your own earcut reference
  130465. * @returns the polygon mesh
  130466. */
  130467. static CreatePolygon(name: string, options: {
  130468. shape: Vector3[];
  130469. holes?: Vector3[][];
  130470. depth?: number;
  130471. faceUV?: Vector4[];
  130472. faceColors?: Color4[];
  130473. updatable?: boolean;
  130474. sideOrientation?: number;
  130475. frontUVs?: Vector4;
  130476. backUVs?: Vector4;
  130477. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  130478. /**
  130479. * Creates an extruded polygon mesh, with depth in the Y direction.
  130480. * * 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)
  130481. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  130482. * @param name defines the name of the mesh
  130483. * @param options defines the options used to create the mesh
  130484. * @param scene defines the hosting scene
  130485. * @param earcutInjection can be used to inject your own earcut reference
  130486. * @returns the polygon mesh
  130487. */
  130488. static ExtrudePolygon(name: string, options: {
  130489. shape: Vector3[];
  130490. holes?: Vector3[][];
  130491. depth?: number;
  130492. faceUV?: Vector4[];
  130493. faceColors?: Color4[];
  130494. updatable?: boolean;
  130495. sideOrientation?: number;
  130496. frontUVs?: Vector4;
  130497. backUVs?: Vector4;
  130498. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  130499. /**
  130500. * Creates a tube mesh.
  130501. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  130502. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  130503. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  130504. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  130505. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  130506. * * 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)
  130507. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  130508. * * 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
  130509. * * 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
  130510. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130511. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130512. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130514. * @param name defines the name of the mesh
  130515. * @param options defines the options used to create the mesh
  130516. * @param scene defines the hosting scene
  130517. * @returns the tube mesh
  130518. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130519. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  130520. */
  130521. static CreateTube(name: string, options: {
  130522. path: Vector3[];
  130523. radius?: number;
  130524. tessellation?: number;
  130525. radiusFunction?: {
  130526. (i: number, distance: number): number;
  130527. };
  130528. cap?: number;
  130529. arc?: number;
  130530. updatable?: boolean;
  130531. sideOrientation?: number;
  130532. frontUVs?: Vector4;
  130533. backUVs?: Vector4;
  130534. instance?: Mesh;
  130535. invertUV?: boolean;
  130536. }, scene?: Nullable<Scene>): Mesh;
  130537. /**
  130538. * Creates a polyhedron mesh
  130539. * * 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
  130540. * * The parameter `size` (positive float, default 1) sets the polygon size
  130541. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  130542. * * 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`
  130543. * * 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
  130544. * * 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)`)
  130545. * * 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
  130546. * * 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
  130547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130548. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130550. * @param name defines the name of the mesh
  130551. * @param options defines the options used to create the mesh
  130552. * @param scene defines the hosting scene
  130553. * @returns the polyhedron mesh
  130554. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  130555. */
  130556. static CreatePolyhedron(name: string, options: {
  130557. type?: number;
  130558. size?: number;
  130559. sizeX?: number;
  130560. sizeY?: number;
  130561. sizeZ?: number;
  130562. custom?: any;
  130563. faceUV?: Vector4[];
  130564. faceColors?: Color4[];
  130565. flat?: boolean;
  130566. updatable?: boolean;
  130567. sideOrientation?: number;
  130568. frontUVs?: Vector4;
  130569. backUVs?: Vector4;
  130570. }, scene?: Nullable<Scene>): Mesh;
  130571. /**
  130572. * Creates a decal mesh.
  130573. * 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
  130574. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  130575. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  130576. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  130577. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  130578. * @param name defines the name of the mesh
  130579. * @param sourceMesh defines the mesh where the decal must be applied
  130580. * @param options defines the options used to create the mesh
  130581. * @param scene defines the hosting scene
  130582. * @returns the decal mesh
  130583. * @see https://doc.babylonjs.com/how_to/decals
  130584. */
  130585. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  130586. position?: Vector3;
  130587. normal?: Vector3;
  130588. size?: Vector3;
  130589. angle?: number;
  130590. }): Mesh;
  130591. }
  130592. }
  130593. declare module BABYLON {
  130594. /**
  130595. * A simplifier interface for future simplification implementations
  130596. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130597. */
  130598. export interface ISimplifier {
  130599. /**
  130600. * Simplification of a given mesh according to the given settings.
  130601. * Since this requires computation, it is assumed that the function runs async.
  130602. * @param settings The settings of the simplification, including quality and distance
  130603. * @param successCallback A callback that will be called after the mesh was simplified.
  130604. * @param errorCallback in case of an error, this callback will be called. optional.
  130605. */
  130606. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  130607. }
  130608. /**
  130609. * Expected simplification settings.
  130610. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  130611. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130612. */
  130613. export interface ISimplificationSettings {
  130614. /**
  130615. * Gets or sets the expected quality
  130616. */
  130617. quality: number;
  130618. /**
  130619. * Gets or sets the distance when this optimized version should be used
  130620. */
  130621. distance: number;
  130622. /**
  130623. * Gets an already optimized mesh
  130624. */
  130625. optimizeMesh?: boolean;
  130626. }
  130627. /**
  130628. * Class used to specify simplification options
  130629. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130630. */
  130631. export class SimplificationSettings implements ISimplificationSettings {
  130632. /** expected quality */
  130633. quality: number;
  130634. /** distance when this optimized version should be used */
  130635. distance: number;
  130636. /** already optimized mesh */
  130637. optimizeMesh?: boolean | undefined;
  130638. /**
  130639. * Creates a SimplificationSettings
  130640. * @param quality expected quality
  130641. * @param distance distance when this optimized version should be used
  130642. * @param optimizeMesh already optimized mesh
  130643. */
  130644. constructor(
  130645. /** expected quality */
  130646. quality: number,
  130647. /** distance when this optimized version should be used */
  130648. distance: number,
  130649. /** already optimized mesh */
  130650. optimizeMesh?: boolean | undefined);
  130651. }
  130652. /**
  130653. * Interface used to define a simplification task
  130654. */
  130655. export interface ISimplificationTask {
  130656. /**
  130657. * Array of settings
  130658. */
  130659. settings: Array<ISimplificationSettings>;
  130660. /**
  130661. * Simplification type
  130662. */
  130663. simplificationType: SimplificationType;
  130664. /**
  130665. * Mesh to simplify
  130666. */
  130667. mesh: Mesh;
  130668. /**
  130669. * Callback called on success
  130670. */
  130671. successCallback?: () => void;
  130672. /**
  130673. * Defines if parallel processing can be used
  130674. */
  130675. parallelProcessing: boolean;
  130676. }
  130677. /**
  130678. * Queue used to order the simplification tasks
  130679. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130680. */
  130681. export class SimplificationQueue {
  130682. private _simplificationArray;
  130683. /**
  130684. * Gets a boolean indicating that the process is still running
  130685. */
  130686. running: boolean;
  130687. /**
  130688. * Creates a new queue
  130689. */
  130690. constructor();
  130691. /**
  130692. * Adds a new simplification task
  130693. * @param task defines a task to add
  130694. */
  130695. addTask(task: ISimplificationTask): void;
  130696. /**
  130697. * Execute next task
  130698. */
  130699. executeNext(): void;
  130700. /**
  130701. * Execute a simplification task
  130702. * @param task defines the task to run
  130703. */
  130704. runSimplification(task: ISimplificationTask): void;
  130705. private getSimplifier;
  130706. }
  130707. /**
  130708. * The implemented types of simplification
  130709. * At the moment only Quadratic Error Decimation is implemented
  130710. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130711. */
  130712. export enum SimplificationType {
  130713. /** Quadratic error decimation */
  130714. QUADRATIC = 0
  130715. }
  130716. }
  130717. declare module BABYLON {
  130718. interface Scene {
  130719. /** @hidden (Backing field) */
  130720. _simplificationQueue: SimplificationQueue;
  130721. /**
  130722. * Gets or sets the simplification queue attached to the scene
  130723. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  130724. */
  130725. simplificationQueue: SimplificationQueue;
  130726. }
  130727. interface Mesh {
  130728. /**
  130729. * Simplify the mesh according to the given array of settings.
  130730. * Function will return immediately and will simplify async
  130731. * @param settings a collection of simplification settings
  130732. * @param parallelProcessing should all levels calculate parallel or one after the other
  130733. * @param simplificationType the type of simplification to run
  130734. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  130735. * @returns the current mesh
  130736. */
  130737. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  130738. }
  130739. /**
  130740. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  130741. * created in a scene
  130742. */
  130743. export class SimplicationQueueSceneComponent implements ISceneComponent {
  130744. /**
  130745. * The component name helpfull to identify the component in the list of scene components.
  130746. */
  130747. readonly name: string;
  130748. /**
  130749. * The scene the component belongs to.
  130750. */
  130751. scene: Scene;
  130752. /**
  130753. * Creates a new instance of the component for the given scene
  130754. * @param scene Defines the scene to register the component in
  130755. */
  130756. constructor(scene: Scene);
  130757. /**
  130758. * Registers the component in a given scene
  130759. */
  130760. register(): void;
  130761. /**
  130762. * Rebuilds the elements related to this component in case of
  130763. * context lost for instance.
  130764. */
  130765. rebuild(): void;
  130766. /**
  130767. * Disposes the component and the associated ressources
  130768. */
  130769. dispose(): void;
  130770. private _beforeCameraUpdate;
  130771. }
  130772. }
  130773. declare module BABYLON {
  130774. /**
  130775. * Navigation plugin interface to add navigation constrained by a navigation mesh
  130776. */
  130777. export interface INavigationEnginePlugin {
  130778. /**
  130779. * plugin name
  130780. */
  130781. name: string;
  130782. /**
  130783. * Creates a navigation mesh
  130784. * @param meshes array of all the geometry used to compute the navigatio mesh
  130785. * @param parameters bunch of parameters used to filter geometry
  130786. */
  130787. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  130788. /**
  130789. * Create a navigation mesh debug mesh
  130790. * @param scene is where the mesh will be added
  130791. * @returns debug display mesh
  130792. */
  130793. createDebugNavMesh(scene: Scene): Mesh;
  130794. /**
  130795. * Get a navigation mesh constrained position, closest to the parameter position
  130796. * @param position world position
  130797. * @returns the closest point to position constrained by the navigation mesh
  130798. */
  130799. getClosestPoint(position: Vector3): Vector3;
  130800. /**
  130801. * Get a navigation mesh constrained position, within a particular radius
  130802. * @param position world position
  130803. * @param maxRadius the maximum distance to the constrained world position
  130804. * @returns the closest point to position constrained by the navigation mesh
  130805. */
  130806. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  130807. /**
  130808. * Compute the final position from a segment made of destination-position
  130809. * @param position world position
  130810. * @param destination world position
  130811. * @returns the resulting point along the navmesh
  130812. */
  130813. moveAlong(position: Vector3, destination: Vector3): Vector3;
  130814. /**
  130815. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  130816. * @param start world position
  130817. * @param end world position
  130818. * @returns array containing world position composing the path
  130819. */
  130820. computePath(start: Vector3, end: Vector3): Vector3[];
  130821. /**
  130822. * If this plugin is supported
  130823. * @returns true if plugin is supported
  130824. */
  130825. isSupported(): boolean;
  130826. /**
  130827. * Create a new Crowd so you can add agents
  130828. * @param maxAgents the maximum agent count in the crowd
  130829. * @param maxAgentRadius the maximum radius an agent can have
  130830. * @param scene to attach the crowd to
  130831. * @returns the crowd you can add agents to
  130832. */
  130833. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  130834. /**
  130835. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  130836. * The queries will try to find a solution within those bounds
  130837. * default is (1,1,1)
  130838. * @param extent x,y,z value that define the extent around the queries point of reference
  130839. */
  130840. setDefaultQueryExtent(extent: Vector3): void;
  130841. /**
  130842. * Get the Bounding box extent specified by setDefaultQueryExtent
  130843. * @returns the box extent values
  130844. */
  130845. getDefaultQueryExtent(): Vector3;
  130846. /**
  130847. * Release all resources
  130848. */
  130849. dispose(): void;
  130850. }
  130851. /**
  130852. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  130853. */
  130854. export interface ICrowd {
  130855. /**
  130856. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  130857. * You can attach anything to that node. The node position is updated in the scene update tick.
  130858. * @param pos world position that will be constrained by the navigation mesh
  130859. * @param parameters agent parameters
  130860. * @param transform hooked to the agent that will be update by the scene
  130861. * @returns agent index
  130862. */
  130863. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  130864. /**
  130865. * Returns the agent position in world space
  130866. * @param index agent index returned by addAgent
  130867. * @returns world space position
  130868. */
  130869. getAgentPosition(index: number): Vector3;
  130870. /**
  130871. * Gets the agent velocity in world space
  130872. * @param index agent index returned by addAgent
  130873. * @returns world space velocity
  130874. */
  130875. getAgentVelocity(index: number): Vector3;
  130876. /**
  130877. * remove a particular agent previously created
  130878. * @param index agent index returned by addAgent
  130879. */
  130880. removeAgent(index: number): void;
  130881. /**
  130882. * get the list of all agents attached to this crowd
  130883. * @returns list of agent indices
  130884. */
  130885. getAgents(): number[];
  130886. /**
  130887. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  130888. * @param deltaTime in seconds
  130889. */
  130890. update(deltaTime: number): void;
  130891. /**
  130892. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  130893. * @param index agent index returned by addAgent
  130894. * @param destination targeted world position
  130895. */
  130896. agentGoto(index: number, destination: Vector3): void;
  130897. /**
  130898. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  130899. * The queries will try to find a solution within those bounds
  130900. * default is (1,1,1)
  130901. * @param extent x,y,z value that define the extent around the queries point of reference
  130902. */
  130903. setDefaultQueryExtent(extent: Vector3): void;
  130904. /**
  130905. * Get the Bounding box extent specified by setDefaultQueryExtent
  130906. * @returns the box extent values
  130907. */
  130908. getDefaultQueryExtent(): Vector3;
  130909. /**
  130910. * Release all resources
  130911. */
  130912. dispose(): void;
  130913. }
  130914. /**
  130915. * Configures an agent
  130916. */
  130917. export interface IAgentParameters {
  130918. /**
  130919. * Agent radius. [Limit: >= 0]
  130920. */
  130921. radius: number;
  130922. /**
  130923. * Agent height. [Limit: > 0]
  130924. */
  130925. height: number;
  130926. /**
  130927. * Maximum allowed acceleration. [Limit: >= 0]
  130928. */
  130929. maxAcceleration: number;
  130930. /**
  130931. * Maximum allowed speed. [Limit: >= 0]
  130932. */
  130933. maxSpeed: number;
  130934. /**
  130935. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  130936. */
  130937. collisionQueryRange: number;
  130938. /**
  130939. * The path visibility optimization range. [Limit: > 0]
  130940. */
  130941. pathOptimizationRange: number;
  130942. /**
  130943. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  130944. */
  130945. separationWeight: number;
  130946. }
  130947. /**
  130948. * Configures the navigation mesh creation
  130949. */
  130950. export interface INavMeshParameters {
  130951. /**
  130952. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  130953. */
  130954. cs: number;
  130955. /**
  130956. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  130957. */
  130958. ch: number;
  130959. /**
  130960. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  130961. */
  130962. walkableSlopeAngle: number;
  130963. /**
  130964. * Minimum floor to 'ceiling' height that will still allow the floor area to
  130965. * be considered walkable. [Limit: >= 3] [Units: vx]
  130966. */
  130967. walkableHeight: number;
  130968. /**
  130969. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  130970. */
  130971. walkableClimb: number;
  130972. /**
  130973. * The distance to erode/shrink the walkable area of the heightfield away from
  130974. * obstructions. [Limit: >=0] [Units: vx]
  130975. */
  130976. walkableRadius: number;
  130977. /**
  130978. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  130979. */
  130980. maxEdgeLen: number;
  130981. /**
  130982. * The maximum distance a simplfied contour's border edges should deviate
  130983. * the original raw contour. [Limit: >=0] [Units: vx]
  130984. */
  130985. maxSimplificationError: number;
  130986. /**
  130987. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  130988. */
  130989. minRegionArea: number;
  130990. /**
  130991. * Any regions with a span count smaller than this value will, if possible,
  130992. * be merged with larger regions. [Limit: >=0] [Units: vx]
  130993. */
  130994. mergeRegionArea: number;
  130995. /**
  130996. * The maximum number of vertices allowed for polygons generated during the
  130997. * contour to polygon conversion process. [Limit: >= 3]
  130998. */
  130999. maxVertsPerPoly: number;
  131000. /**
  131001. * Sets the sampling distance to use when generating the detail mesh.
  131002. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  131003. */
  131004. detailSampleDist: number;
  131005. /**
  131006. * The maximum distance the detail mesh surface should deviate from heightfield
  131007. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  131008. */
  131009. detailSampleMaxError: number;
  131010. }
  131011. }
  131012. declare module BABYLON {
  131013. /**
  131014. * RecastJS navigation plugin
  131015. */
  131016. export class RecastJSPlugin implements INavigationEnginePlugin {
  131017. /**
  131018. * Reference to the Recast library
  131019. */
  131020. bjsRECAST: any;
  131021. /**
  131022. * plugin name
  131023. */
  131024. name: string;
  131025. /**
  131026. * the first navmesh created. We might extend this to support multiple navmeshes
  131027. */
  131028. navMesh: any;
  131029. /**
  131030. * Initializes the recastJS plugin
  131031. * @param recastInjection can be used to inject your own recast reference
  131032. */
  131033. constructor(recastInjection?: any);
  131034. /**
  131035. * Creates a navigation mesh
  131036. * @param meshes array of all the geometry used to compute the navigatio mesh
  131037. * @param parameters bunch of parameters used to filter geometry
  131038. */
  131039. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  131040. /**
  131041. * Create a navigation mesh debug mesh
  131042. * @param scene is where the mesh will be added
  131043. * @returns debug display mesh
  131044. */
  131045. createDebugNavMesh(scene: Scene): Mesh;
  131046. /**
  131047. * Get a navigation mesh constrained position, closest to the parameter position
  131048. * @param position world position
  131049. * @returns the closest point to position constrained by the navigation mesh
  131050. */
  131051. getClosestPoint(position: Vector3): Vector3;
  131052. /**
  131053. * Get a navigation mesh constrained position, within a particular radius
  131054. * @param position world position
  131055. * @param maxRadius the maximum distance to the constrained world position
  131056. * @returns the closest point to position constrained by the navigation mesh
  131057. */
  131058. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  131059. /**
  131060. * Compute the final position from a segment made of destination-position
  131061. * @param position world position
  131062. * @param destination world position
  131063. * @returns the resulting point along the navmesh
  131064. */
  131065. moveAlong(position: Vector3, destination: Vector3): Vector3;
  131066. /**
  131067. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  131068. * @param start world position
  131069. * @param end world position
  131070. * @returns array containing world position composing the path
  131071. */
  131072. computePath(start: Vector3, end: Vector3): Vector3[];
  131073. /**
  131074. * Create a new Crowd so you can add agents
  131075. * @param maxAgents the maximum agent count in the crowd
  131076. * @param maxAgentRadius the maximum radius an agent can have
  131077. * @param scene to attach the crowd to
  131078. * @returns the crowd you can add agents to
  131079. */
  131080. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  131081. /**
  131082. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  131083. * The queries will try to find a solution within those bounds
  131084. * default is (1,1,1)
  131085. * @param extent x,y,z value that define the extent around the queries point of reference
  131086. */
  131087. setDefaultQueryExtent(extent: Vector3): void;
  131088. /**
  131089. * Get the Bounding box extent specified by setDefaultQueryExtent
  131090. * @returns the box extent values
  131091. */
  131092. getDefaultQueryExtent(): Vector3;
  131093. /**
  131094. * Disposes
  131095. */
  131096. dispose(): void;
  131097. /**
  131098. * If this plugin is supported
  131099. * @returns true if plugin is supported
  131100. */
  131101. isSupported(): boolean;
  131102. }
  131103. /**
  131104. * Recast detour crowd implementation
  131105. */
  131106. export class RecastJSCrowd implements ICrowd {
  131107. /**
  131108. * Recast/detour plugin
  131109. */
  131110. bjsRECASTPlugin: RecastJSPlugin;
  131111. /**
  131112. * Link to the detour crowd
  131113. */
  131114. recastCrowd: any;
  131115. /**
  131116. * One transform per agent
  131117. */
  131118. transforms: TransformNode[];
  131119. /**
  131120. * All agents created
  131121. */
  131122. agents: number[];
  131123. /**
  131124. * Link to the scene is kept to unregister the crowd from the scene
  131125. */
  131126. private _scene;
  131127. /**
  131128. * Observer for crowd updates
  131129. */
  131130. private _onBeforeAnimationsObserver;
  131131. /**
  131132. * Constructor
  131133. * @param plugin recastJS plugin
  131134. * @param maxAgents the maximum agent count in the crowd
  131135. * @param maxAgentRadius the maximum radius an agent can have
  131136. * @param scene to attach the crowd to
  131137. * @returns the crowd you can add agents to
  131138. */
  131139. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  131140. /**
  131141. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  131142. * You can attach anything to that node. The node position is updated in the scene update tick.
  131143. * @param pos world position that will be constrained by the navigation mesh
  131144. * @param parameters agent parameters
  131145. * @param transform hooked to the agent that will be update by the scene
  131146. * @returns agent index
  131147. */
  131148. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  131149. /**
  131150. * Returns the agent position in world space
  131151. * @param index agent index returned by addAgent
  131152. * @returns world space position
  131153. */
  131154. getAgentPosition(index: number): Vector3;
  131155. /**
  131156. * Returns the agent velocity in world space
  131157. * @param index agent index returned by addAgent
  131158. * @returns world space velocity
  131159. */
  131160. getAgentVelocity(index: number): Vector3;
  131161. /**
  131162. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  131163. * @param index agent index returned by addAgent
  131164. * @param destination targeted world position
  131165. */
  131166. agentGoto(index: number, destination: Vector3): void;
  131167. /**
  131168. * remove a particular agent previously created
  131169. * @param index agent index returned by addAgent
  131170. */
  131171. removeAgent(index: number): void;
  131172. /**
  131173. * get the list of all agents attached to this crowd
  131174. * @returns list of agent indices
  131175. */
  131176. getAgents(): number[];
  131177. /**
  131178. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  131179. * @param deltaTime in seconds
  131180. */
  131181. update(deltaTime: number): void;
  131182. /**
  131183. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  131184. * The queries will try to find a solution within those bounds
  131185. * default is (1,1,1)
  131186. * @param extent x,y,z value that define the extent around the queries point of reference
  131187. */
  131188. setDefaultQueryExtent(extent: Vector3): void;
  131189. /**
  131190. * Get the Bounding box extent specified by setDefaultQueryExtent
  131191. * @returns the box extent values
  131192. */
  131193. getDefaultQueryExtent(): Vector3;
  131194. /**
  131195. * Release all resources
  131196. */
  131197. dispose(): void;
  131198. }
  131199. }
  131200. declare module BABYLON {
  131201. /**
  131202. * Class used to enable access to IndexedDB
  131203. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  131204. */
  131205. export class Database implements IOfflineProvider {
  131206. private _callbackManifestChecked;
  131207. private _currentSceneUrl;
  131208. private _db;
  131209. private _enableSceneOffline;
  131210. private _enableTexturesOffline;
  131211. private _manifestVersionFound;
  131212. private _mustUpdateRessources;
  131213. private _hasReachedQuota;
  131214. private _isSupported;
  131215. private _idbFactory;
  131216. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  131217. private static IsUASupportingBlobStorage;
  131218. /**
  131219. * Gets a boolean indicating if Database storate is enabled (off by default)
  131220. */
  131221. static IDBStorageEnabled: boolean;
  131222. /**
  131223. * Gets a boolean indicating if scene must be saved in the database
  131224. */
  131225. get enableSceneOffline(): boolean;
  131226. /**
  131227. * Gets a boolean indicating if textures must be saved in the database
  131228. */
  131229. get enableTexturesOffline(): boolean;
  131230. /**
  131231. * Creates a new Database
  131232. * @param urlToScene defines the url to load the scene
  131233. * @param callbackManifestChecked defines the callback to use when manifest is checked
  131234. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  131235. */
  131236. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  131237. private static _ParseURL;
  131238. private static _ReturnFullUrlLocation;
  131239. private _checkManifestFile;
  131240. /**
  131241. * Open the database and make it available
  131242. * @param successCallback defines the callback to call on success
  131243. * @param errorCallback defines the callback to call on error
  131244. */
  131245. open(successCallback: () => void, errorCallback: () => void): void;
  131246. /**
  131247. * Loads an image from the database
  131248. * @param url defines the url to load from
  131249. * @param image defines the target DOM image
  131250. */
  131251. loadImage(url: string, image: HTMLImageElement): void;
  131252. private _loadImageFromDBAsync;
  131253. private _saveImageIntoDBAsync;
  131254. private _checkVersionFromDB;
  131255. private _loadVersionFromDBAsync;
  131256. private _saveVersionIntoDBAsync;
  131257. /**
  131258. * Loads a file from database
  131259. * @param url defines the URL to load from
  131260. * @param sceneLoaded defines a callback to call on success
  131261. * @param progressCallBack defines a callback to call when progress changed
  131262. * @param errorCallback defines a callback to call on error
  131263. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  131264. */
  131265. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  131266. private _loadFileAsync;
  131267. private _saveFileAsync;
  131268. /**
  131269. * Validates if xhr data is correct
  131270. * @param xhr defines the request to validate
  131271. * @param dataType defines the expected data type
  131272. * @returns true if data is correct
  131273. */
  131274. private static _ValidateXHRData;
  131275. }
  131276. }
  131277. declare module BABYLON {
  131278. /** @hidden */
  131279. export var gpuUpdateParticlesPixelShader: {
  131280. name: string;
  131281. shader: string;
  131282. };
  131283. }
  131284. declare module BABYLON {
  131285. /** @hidden */
  131286. export var gpuUpdateParticlesVertexShader: {
  131287. name: string;
  131288. shader: string;
  131289. };
  131290. }
  131291. declare module BABYLON {
  131292. /** @hidden */
  131293. export var clipPlaneFragmentDeclaration2: {
  131294. name: string;
  131295. shader: string;
  131296. };
  131297. }
  131298. declare module BABYLON {
  131299. /** @hidden */
  131300. export var gpuRenderParticlesPixelShader: {
  131301. name: string;
  131302. shader: string;
  131303. };
  131304. }
  131305. declare module BABYLON {
  131306. /** @hidden */
  131307. export var clipPlaneVertexDeclaration2: {
  131308. name: string;
  131309. shader: string;
  131310. };
  131311. }
  131312. declare module BABYLON {
  131313. /** @hidden */
  131314. export var gpuRenderParticlesVertexShader: {
  131315. name: string;
  131316. shader: string;
  131317. };
  131318. }
  131319. declare module BABYLON {
  131320. /**
  131321. * This represents a GPU particle system in Babylon
  131322. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  131323. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  131324. */
  131325. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  131326. /**
  131327. * The layer mask we are rendering the particles through.
  131328. */
  131329. layerMask: number;
  131330. private _capacity;
  131331. private _activeCount;
  131332. private _currentActiveCount;
  131333. private _accumulatedCount;
  131334. private _renderEffect;
  131335. private _updateEffect;
  131336. private _buffer0;
  131337. private _buffer1;
  131338. private _spriteBuffer;
  131339. private _updateVAO;
  131340. private _renderVAO;
  131341. private _targetIndex;
  131342. private _sourceBuffer;
  131343. private _targetBuffer;
  131344. private _engine;
  131345. private _currentRenderId;
  131346. private _started;
  131347. private _stopped;
  131348. private _timeDelta;
  131349. private _randomTexture;
  131350. private _randomTexture2;
  131351. private _attributesStrideSize;
  131352. private _updateEffectOptions;
  131353. private _randomTextureSize;
  131354. private _actualFrame;
  131355. private readonly _rawTextureWidth;
  131356. /**
  131357. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  131358. */
  131359. static get IsSupported(): boolean;
  131360. /**
  131361. * An event triggered when the system is disposed.
  131362. */
  131363. onDisposeObservable: Observable<GPUParticleSystem>;
  131364. /**
  131365. * Gets the maximum number of particles active at the same time.
  131366. * @returns The max number of active particles.
  131367. */
  131368. getCapacity(): number;
  131369. /**
  131370. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  131371. * to override the particles.
  131372. */
  131373. forceDepthWrite: boolean;
  131374. /**
  131375. * Gets or set the number of active particles
  131376. */
  131377. get activeParticleCount(): number;
  131378. set activeParticleCount(value: number);
  131379. private _preWarmDone;
  131380. /**
  131381. * Is this system ready to be used/rendered
  131382. * @return true if the system is ready
  131383. */
  131384. isReady(): boolean;
  131385. /**
  131386. * Gets if the system has been started. (Note: this will still be true after stop is called)
  131387. * @returns True if it has been started, otherwise false.
  131388. */
  131389. isStarted(): boolean;
  131390. /**
  131391. * Starts the particle system and begins to emit
  131392. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  131393. */
  131394. start(delay?: number): void;
  131395. /**
  131396. * Stops the particle system.
  131397. */
  131398. stop(): void;
  131399. /**
  131400. * Remove all active particles
  131401. */
  131402. reset(): void;
  131403. /**
  131404. * Returns the string "GPUParticleSystem"
  131405. * @returns a string containing the class name
  131406. */
  131407. getClassName(): string;
  131408. private _colorGradientsTexture;
  131409. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  131410. /**
  131411. * Adds a new color gradient
  131412. * @param gradient defines the gradient to use (between 0 and 1)
  131413. * @param color1 defines the color to affect to the specified gradient
  131414. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  131415. * @returns the current particle system
  131416. */
  131417. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  131418. /**
  131419. * Remove a specific color gradient
  131420. * @param gradient defines the gradient to remove
  131421. * @returns the current particle system
  131422. */
  131423. removeColorGradient(gradient: number): GPUParticleSystem;
  131424. private _angularSpeedGradientsTexture;
  131425. private _sizeGradientsTexture;
  131426. private _velocityGradientsTexture;
  131427. private _limitVelocityGradientsTexture;
  131428. private _dragGradientsTexture;
  131429. private _addFactorGradient;
  131430. /**
  131431. * Adds a new size gradient
  131432. * @param gradient defines the gradient to use (between 0 and 1)
  131433. * @param factor defines the size factor to affect to the specified gradient
  131434. * @returns the current particle system
  131435. */
  131436. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  131437. /**
  131438. * Remove a specific size gradient
  131439. * @param gradient defines the gradient to remove
  131440. * @returns the current particle system
  131441. */
  131442. removeSizeGradient(gradient: number): GPUParticleSystem;
  131443. /**
  131444. * Adds a new angular speed gradient
  131445. * @param gradient defines the gradient to use (between 0 and 1)
  131446. * @param factor defines the angular speed to affect to the specified gradient
  131447. * @returns the current particle system
  131448. */
  131449. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  131450. /**
  131451. * Remove a specific angular speed gradient
  131452. * @param gradient defines the gradient to remove
  131453. * @returns the current particle system
  131454. */
  131455. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  131456. /**
  131457. * Adds a new velocity gradient
  131458. * @param gradient defines the gradient to use (between 0 and 1)
  131459. * @param factor defines the velocity to affect to the specified gradient
  131460. * @returns the current particle system
  131461. */
  131462. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  131463. /**
  131464. * Remove a specific velocity gradient
  131465. * @param gradient defines the gradient to remove
  131466. * @returns the current particle system
  131467. */
  131468. removeVelocityGradient(gradient: number): GPUParticleSystem;
  131469. /**
  131470. * Adds a new limit velocity gradient
  131471. * @param gradient defines the gradient to use (between 0 and 1)
  131472. * @param factor defines the limit velocity value to affect to the specified gradient
  131473. * @returns the current particle system
  131474. */
  131475. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  131476. /**
  131477. * Remove a specific limit velocity gradient
  131478. * @param gradient defines the gradient to remove
  131479. * @returns the current particle system
  131480. */
  131481. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  131482. /**
  131483. * Adds a new drag gradient
  131484. * @param gradient defines the gradient to use (between 0 and 1)
  131485. * @param factor defines the drag value to affect to the specified gradient
  131486. * @returns the current particle system
  131487. */
  131488. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  131489. /**
  131490. * Remove a specific drag gradient
  131491. * @param gradient defines the gradient to remove
  131492. * @returns the current particle system
  131493. */
  131494. removeDragGradient(gradient: number): GPUParticleSystem;
  131495. /**
  131496. * Not supported by GPUParticleSystem
  131497. * @param gradient defines the gradient to use (between 0 and 1)
  131498. * @param factor defines the emit rate value to affect to the specified gradient
  131499. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  131500. * @returns the current particle system
  131501. */
  131502. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  131503. /**
  131504. * Not supported by GPUParticleSystem
  131505. * @param gradient defines the gradient to remove
  131506. * @returns the current particle system
  131507. */
  131508. removeEmitRateGradient(gradient: number): IParticleSystem;
  131509. /**
  131510. * Not supported by GPUParticleSystem
  131511. * @param gradient defines the gradient to use (between 0 and 1)
  131512. * @param factor defines the start size value to affect to the specified gradient
  131513. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  131514. * @returns the current particle system
  131515. */
  131516. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  131517. /**
  131518. * Not supported by GPUParticleSystem
  131519. * @param gradient defines the gradient to remove
  131520. * @returns the current particle system
  131521. */
  131522. removeStartSizeGradient(gradient: number): IParticleSystem;
  131523. /**
  131524. * Not supported by GPUParticleSystem
  131525. * @param gradient defines the gradient to use (between 0 and 1)
  131526. * @param min defines the color remap minimal range
  131527. * @param max defines the color remap maximal range
  131528. * @returns the current particle system
  131529. */
  131530. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  131531. /**
  131532. * Not supported by GPUParticleSystem
  131533. * @param gradient defines the gradient to remove
  131534. * @returns the current particle system
  131535. */
  131536. removeColorRemapGradient(): IParticleSystem;
  131537. /**
  131538. * Not supported by GPUParticleSystem
  131539. * @param gradient defines the gradient to use (between 0 and 1)
  131540. * @param min defines the alpha remap minimal range
  131541. * @param max defines the alpha remap maximal range
  131542. * @returns the current particle system
  131543. */
  131544. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  131545. /**
  131546. * Not supported by GPUParticleSystem
  131547. * @param gradient defines the gradient to remove
  131548. * @returns the current particle system
  131549. */
  131550. removeAlphaRemapGradient(): IParticleSystem;
  131551. /**
  131552. * Not supported by GPUParticleSystem
  131553. * @param gradient defines the gradient to use (between 0 and 1)
  131554. * @param color defines the color to affect to the specified gradient
  131555. * @returns the current particle system
  131556. */
  131557. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  131558. /**
  131559. * Not supported by GPUParticleSystem
  131560. * @param gradient defines the gradient to remove
  131561. * @returns the current particle system
  131562. */
  131563. removeRampGradient(): IParticleSystem;
  131564. /**
  131565. * Not supported by GPUParticleSystem
  131566. * @returns the list of ramp gradients
  131567. */
  131568. getRampGradients(): Nullable<Array<Color3Gradient>>;
  131569. /**
  131570. * Not supported by GPUParticleSystem
  131571. * Gets or sets a boolean indicating that ramp gradients must be used
  131572. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  131573. */
  131574. get useRampGradients(): boolean;
  131575. set useRampGradients(value: boolean);
  131576. /**
  131577. * Not supported by GPUParticleSystem
  131578. * @param gradient defines the gradient to use (between 0 and 1)
  131579. * @param factor defines the life time factor to affect to the specified gradient
  131580. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  131581. * @returns the current particle system
  131582. */
  131583. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  131584. /**
  131585. * Not supported by GPUParticleSystem
  131586. * @param gradient defines the gradient to remove
  131587. * @returns the current particle system
  131588. */
  131589. removeLifeTimeGradient(gradient: number): IParticleSystem;
  131590. /**
  131591. * Instantiates a GPU particle system.
  131592. * 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.
  131593. * @param name The name of the particle system
  131594. * @param options The options used to create the system
  131595. * @param scene The scene the particle system belongs to
  131596. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  131597. */
  131598. constructor(name: string, options: Partial<{
  131599. capacity: number;
  131600. randomTextureSize: number;
  131601. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  131602. protected _reset(): void;
  131603. private _createUpdateVAO;
  131604. private _createRenderVAO;
  131605. private _initialize;
  131606. /** @hidden */
  131607. _recreateUpdateEffect(): void;
  131608. /** @hidden */
  131609. _recreateRenderEffect(): void;
  131610. /**
  131611. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  131612. * @param preWarm defines if we are in the pre-warmimg phase
  131613. */
  131614. animate(preWarm?: boolean): void;
  131615. private _createFactorGradientTexture;
  131616. private _createSizeGradientTexture;
  131617. private _createAngularSpeedGradientTexture;
  131618. private _createVelocityGradientTexture;
  131619. private _createLimitVelocityGradientTexture;
  131620. private _createDragGradientTexture;
  131621. private _createColorGradientTexture;
  131622. /**
  131623. * Renders the particle system in its current state
  131624. * @param preWarm defines if the system should only update the particles but not render them
  131625. * @returns the current number of particles
  131626. */
  131627. render(preWarm?: boolean): number;
  131628. /**
  131629. * Rebuilds the particle system
  131630. */
  131631. rebuild(): void;
  131632. private _releaseBuffers;
  131633. private _releaseVAOs;
  131634. /**
  131635. * Disposes the particle system and free the associated resources
  131636. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  131637. */
  131638. dispose(disposeTexture?: boolean): void;
  131639. /**
  131640. * Clones the particle system.
  131641. * @param name The name of the cloned object
  131642. * @param newEmitter The new emitter to use
  131643. * @returns the cloned particle system
  131644. */
  131645. clone(name: string, newEmitter: any): GPUParticleSystem;
  131646. /**
  131647. * Serializes the particle system to a JSON object.
  131648. * @returns the JSON object
  131649. */
  131650. serialize(): any;
  131651. /**
  131652. * Parses a JSON object to create a GPU particle system.
  131653. * @param parsedParticleSystem The JSON object to parse
  131654. * @param scene The scene to create the particle system in
  131655. * @param rootUrl The root url to use to load external dependencies like texture
  131656. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  131657. * @returns the parsed GPU particle system
  131658. */
  131659. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  131660. }
  131661. }
  131662. declare module BABYLON {
  131663. /**
  131664. * Represents a set of particle systems working together to create a specific effect
  131665. */
  131666. export class ParticleSystemSet implements IDisposable {
  131667. /**
  131668. * Gets or sets base Assets URL
  131669. */
  131670. static BaseAssetsUrl: string;
  131671. private _emitterCreationOptions;
  131672. private _emitterNode;
  131673. /**
  131674. * Gets the particle system list
  131675. */
  131676. systems: IParticleSystem[];
  131677. /**
  131678. * Gets the emitter node used with this set
  131679. */
  131680. get emitterNode(): Nullable<TransformNode>;
  131681. /**
  131682. * Creates a new emitter mesh as a sphere
  131683. * @param options defines the options used to create the sphere
  131684. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  131685. * @param scene defines the hosting scene
  131686. */
  131687. setEmitterAsSphere(options: {
  131688. diameter: number;
  131689. segments: number;
  131690. color: Color3;
  131691. }, renderingGroupId: number, scene: Scene): void;
  131692. /**
  131693. * Starts all particle systems of the set
  131694. * @param emitter defines an optional mesh to use as emitter for the particle systems
  131695. */
  131696. start(emitter?: AbstractMesh): void;
  131697. /**
  131698. * Release all associated resources
  131699. */
  131700. dispose(): void;
  131701. /**
  131702. * Serialize the set into a JSON compatible object
  131703. * @returns a JSON compatible representation of the set
  131704. */
  131705. serialize(): any;
  131706. /**
  131707. * Parse a new ParticleSystemSet from a serialized source
  131708. * @param data defines a JSON compatible representation of the set
  131709. * @param scene defines the hosting scene
  131710. * @param gpu defines if we want GPU particles or CPU particles
  131711. * @returns a new ParticleSystemSet
  131712. */
  131713. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  131714. }
  131715. }
  131716. declare module BABYLON {
  131717. /**
  131718. * This class is made for on one-liner static method to help creating particle system set.
  131719. */
  131720. export class ParticleHelper {
  131721. /**
  131722. * Gets or sets base Assets URL
  131723. */
  131724. static BaseAssetsUrl: string;
  131725. /**
  131726. * Create a default particle system that you can tweak
  131727. * @param emitter defines the emitter to use
  131728. * @param capacity defines the system capacity (default is 500 particles)
  131729. * @param scene defines the hosting scene
  131730. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  131731. * @returns the new Particle system
  131732. */
  131733. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  131734. /**
  131735. * This is the main static method (one-liner) of this helper to create different particle systems
  131736. * @param type This string represents the type to the particle system to create
  131737. * @param scene The scene where the particle system should live
  131738. * @param gpu If the system will use gpu
  131739. * @returns the ParticleSystemSet created
  131740. */
  131741. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  131742. /**
  131743. * Static function used to export a particle system to a ParticleSystemSet variable.
  131744. * Please note that the emitter shape is not exported
  131745. * @param systems defines the particle systems to export
  131746. * @returns the created particle system set
  131747. */
  131748. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  131749. }
  131750. }
  131751. declare module BABYLON {
  131752. interface Engine {
  131753. /**
  131754. * Create an effect to use with particle systems.
  131755. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  131756. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  131757. * @param uniformsNames defines a list of attribute names
  131758. * @param samplers defines an array of string used to represent textures
  131759. * @param defines defines the string containing the defines to use to compile the shaders
  131760. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  131761. * @param onCompiled defines a function to call when the effect creation is successful
  131762. * @param onError defines a function to call when the effect creation has failed
  131763. * @returns the new Effect
  131764. */
  131765. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  131766. }
  131767. interface Mesh {
  131768. /**
  131769. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  131770. * @returns an array of IParticleSystem
  131771. */
  131772. getEmittedParticleSystems(): IParticleSystem[];
  131773. /**
  131774. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  131775. * @returns an array of IParticleSystem
  131776. */
  131777. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  131778. }
  131779. /**
  131780. * @hidden
  131781. */
  131782. export var _IDoNeedToBeInTheBuild: number;
  131783. }
  131784. declare module BABYLON {
  131785. /** Defines the 4 color options */
  131786. export enum PointColor {
  131787. /** color value */
  131788. Color = 2,
  131789. /** uv value */
  131790. UV = 1,
  131791. /** random value */
  131792. Random = 0,
  131793. /** stated value */
  131794. Stated = 3
  131795. }
  131796. /**
  131797. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  131798. * 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.
  131799. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  131800. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  131801. *
  131802. * Full documentation here : TO BE ENTERED
  131803. */
  131804. export class PointsCloudSystem implements IDisposable {
  131805. /**
  131806. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  131807. * Example : var p = SPS.particles[i];
  131808. */
  131809. particles: CloudPoint[];
  131810. /**
  131811. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  131812. */
  131813. nbParticles: number;
  131814. /**
  131815. * This a counter for your own usage. It's not set by any SPS functions.
  131816. */
  131817. counter: number;
  131818. /**
  131819. * The PCS name. This name is also given to the underlying mesh.
  131820. */
  131821. name: string;
  131822. /**
  131823. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  131824. */
  131825. mesh: Mesh;
  131826. /**
  131827. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  131828. * Please read :
  131829. */
  131830. vars: any;
  131831. /**
  131832. * @hidden
  131833. */
  131834. _size: number;
  131835. private _scene;
  131836. private _promises;
  131837. private _positions;
  131838. private _indices;
  131839. private _normals;
  131840. private _colors;
  131841. private _uvs;
  131842. private _indices32;
  131843. private _positions32;
  131844. private _colors32;
  131845. private _uvs32;
  131846. private _updatable;
  131847. private _isVisibilityBoxLocked;
  131848. private _alwaysVisible;
  131849. private _groups;
  131850. private _groupCounter;
  131851. private _computeParticleColor;
  131852. private _computeParticleTexture;
  131853. private _computeParticleRotation;
  131854. private _computeBoundingBox;
  131855. private _isReady;
  131856. /**
  131857. * Creates a PCS (Points Cloud System) object
  131858. * @param name (String) is the PCS name, this will be the underlying mesh name
  131859. * @param pointSize (number) is the size for each point
  131860. * @param scene (Scene) is the scene in which the PCS is added
  131861. * @param options defines the options of the PCS e.g.
  131862. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  131863. */
  131864. constructor(name: string, pointSize: number, scene: Scene, options?: {
  131865. updatable?: boolean;
  131866. });
  131867. /**
  131868. * Builds the PCS underlying mesh. Returns a standard Mesh.
  131869. * If no points were added to the PCS, the returned mesh is just a single point.
  131870. * @returns a promise for the created mesh
  131871. */
  131872. buildMeshAsync(): Promise<Mesh>;
  131873. /**
  131874. * @hidden
  131875. */
  131876. private _buildMesh;
  131877. private _addParticle;
  131878. private _randomUnitVector;
  131879. private _getColorIndicesForCoord;
  131880. private _setPointsColorOrUV;
  131881. private _colorFromTexture;
  131882. private _calculateDensity;
  131883. /**
  131884. * Adds points to the PCS in random positions within a unit sphere
  131885. * @param nb (positive integer) the number of particles to be created from this model
  131886. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  131887. * @returns the number of groups in the system
  131888. */
  131889. addPoints(nb: number, pointFunction?: any): number;
  131890. /**
  131891. * Adds points to the PCS from the surface of the model shape
  131892. * @param mesh is any Mesh object that will be used as a surface model for the points
  131893. * @param nb (positive integer) the number of particles to be created from this model
  131894. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  131895. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  131896. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  131897. * @returns the number of groups in the system
  131898. */
  131899. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  131900. /**
  131901. * Adds points to the PCS inside the model shape
  131902. * @param mesh is any Mesh object that will be used as a surface model for the points
  131903. * @param nb (positive integer) the number of particles to be created from this model
  131904. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  131905. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  131906. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  131907. * @returns the number of groups in the system
  131908. */
  131909. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  131910. /**
  131911. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  131912. * This method calls `updateParticle()` for each particle of the SPS.
  131913. * For an animated SPS, it is usually called within the render loop.
  131914. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  131915. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  131916. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  131917. * @returns the PCS.
  131918. */
  131919. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  131920. /**
  131921. * Disposes the PCS.
  131922. */
  131923. dispose(): void;
  131924. /**
  131925. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  131926. * doc :
  131927. * @returns the PCS.
  131928. */
  131929. refreshVisibleSize(): PointsCloudSystem;
  131930. /**
  131931. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  131932. * @param size the size (float) of the visibility box
  131933. * note : this doesn't lock the PCS mesh bounding box.
  131934. * doc :
  131935. */
  131936. setVisibilityBox(size: number): void;
  131937. /**
  131938. * Gets whether the PCS is always visible or not
  131939. * doc :
  131940. */
  131941. get isAlwaysVisible(): boolean;
  131942. /**
  131943. * Sets the PCS as always visible or not
  131944. * doc :
  131945. */
  131946. set isAlwaysVisible(val: boolean);
  131947. /**
  131948. * Tells to `setParticles()` to compute the particle rotations or not
  131949. * Default value : false. The PCS is faster when it's set to false
  131950. * Note : particle rotations are only applied to parent particles
  131951. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  131952. */
  131953. set computeParticleRotation(val: boolean);
  131954. /**
  131955. * Tells to `setParticles()` to compute the particle colors or not.
  131956. * Default value : true. The PCS is faster when it's set to false.
  131957. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  131958. */
  131959. set computeParticleColor(val: boolean);
  131960. set computeParticleTexture(val: boolean);
  131961. /**
  131962. * Gets if `setParticles()` computes the particle colors or not.
  131963. * Default value : false. The PCS is faster when it's set to false.
  131964. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  131965. */
  131966. get computeParticleColor(): boolean;
  131967. /**
  131968. * Gets if `setParticles()` computes the particle textures or not.
  131969. * Default value : false. The PCS is faster when it's set to false.
  131970. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  131971. */
  131972. get computeParticleTexture(): boolean;
  131973. /**
  131974. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  131975. */
  131976. set computeBoundingBox(val: boolean);
  131977. /**
  131978. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  131979. */
  131980. get computeBoundingBox(): boolean;
  131981. /**
  131982. * This function does nothing. It may be overwritten to set all the particle first values.
  131983. * The PCS doesn't call this function, you may have to call it by your own.
  131984. * doc :
  131985. */
  131986. initParticles(): void;
  131987. /**
  131988. * This function does nothing. It may be overwritten to recycle a particle
  131989. * The PCS doesn't call this function, you can to call it
  131990. * doc :
  131991. * @param particle The particle to recycle
  131992. * @returns the recycled particle
  131993. */
  131994. recycleParticle(particle: CloudPoint): CloudPoint;
  131995. /**
  131996. * Updates a particle : this function should be overwritten by the user.
  131997. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  131998. * doc :
  131999. * @example : just set a particle position or velocity and recycle conditions
  132000. * @param particle The particle to update
  132001. * @returns the updated particle
  132002. */
  132003. updateParticle(particle: CloudPoint): CloudPoint;
  132004. /**
  132005. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  132006. * This does nothing and may be overwritten by the user.
  132007. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  132008. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  132009. * @param update the boolean update value actually passed to setParticles()
  132010. */
  132011. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  132012. /**
  132013. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  132014. * This will be passed three parameters.
  132015. * This does nothing and may be overwritten by the user.
  132016. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  132017. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  132018. * @param update the boolean update value actually passed to setParticles()
  132019. */
  132020. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  132021. }
  132022. }
  132023. declare module BABYLON {
  132024. /**
  132025. * Represents one particle of a points cloud system.
  132026. */
  132027. export class CloudPoint {
  132028. /**
  132029. * particle global index
  132030. */
  132031. idx: number;
  132032. /**
  132033. * The color of the particle
  132034. */
  132035. color: Nullable<Color4>;
  132036. /**
  132037. * The world space position of the particle.
  132038. */
  132039. position: Vector3;
  132040. /**
  132041. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  132042. */
  132043. rotation: Vector3;
  132044. /**
  132045. * The world space rotation quaternion of the particle.
  132046. */
  132047. rotationQuaternion: Nullable<Quaternion>;
  132048. /**
  132049. * The uv of the particle.
  132050. */
  132051. uv: Nullable<Vector2>;
  132052. /**
  132053. * The current speed of the particle.
  132054. */
  132055. velocity: Vector3;
  132056. /**
  132057. * The pivot point in the particle local space.
  132058. */
  132059. pivot: Vector3;
  132060. /**
  132061. * Must the particle be translated from its pivot point in its local space ?
  132062. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  132063. * Default : false
  132064. */
  132065. translateFromPivot: boolean;
  132066. /**
  132067. * Index of this particle in the global "positions" array (Internal use)
  132068. * @hidden
  132069. */
  132070. _pos: number;
  132071. /**
  132072. * @hidden Index of this particle in the global "indices" array (Internal use)
  132073. */
  132074. _ind: number;
  132075. /**
  132076. * Group this particle belongs to
  132077. */
  132078. _group: PointsGroup;
  132079. /**
  132080. * Group id of this particle
  132081. */
  132082. groupId: number;
  132083. /**
  132084. * Index of the particle in its group id (Internal use)
  132085. */
  132086. idxInGroup: number;
  132087. /**
  132088. * @hidden Particle BoundingInfo object (Internal use)
  132089. */
  132090. _boundingInfo: BoundingInfo;
  132091. /**
  132092. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  132093. */
  132094. _pcs: PointsCloudSystem;
  132095. /**
  132096. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  132097. */
  132098. _stillInvisible: boolean;
  132099. /**
  132100. * @hidden Last computed particle rotation matrix
  132101. */
  132102. _rotationMatrix: number[];
  132103. /**
  132104. * Parent particle Id, if any.
  132105. * Default null.
  132106. */
  132107. parentId: Nullable<number>;
  132108. /**
  132109. * @hidden Internal global position in the PCS.
  132110. */
  132111. _globalPosition: Vector3;
  132112. /**
  132113. * Creates a Point Cloud object.
  132114. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  132115. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  132116. * @param group (PointsGroup) is the group the particle belongs to
  132117. * @param groupId (integer) is the group identifier in the PCS.
  132118. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  132119. * @param pcs defines the PCS it is associated to
  132120. */
  132121. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  132122. /**
  132123. * get point size
  132124. */
  132125. get size(): Vector3;
  132126. /**
  132127. * Set point size
  132128. */
  132129. set size(scale: Vector3);
  132130. /**
  132131. * Legacy support, changed quaternion to rotationQuaternion
  132132. */
  132133. get quaternion(): Nullable<Quaternion>;
  132134. /**
  132135. * Legacy support, changed quaternion to rotationQuaternion
  132136. */
  132137. set quaternion(q: Nullable<Quaternion>);
  132138. /**
  132139. * Returns a boolean. True if the particle intersects a mesh, else false
  132140. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  132141. * @param target is the object (point or mesh) what the intersection is computed against
  132142. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  132143. * @returns true if it intersects
  132144. */
  132145. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  132146. /**
  132147. * get the rotation matrix of the particle
  132148. * @hidden
  132149. */
  132150. getRotationMatrix(m: Matrix): void;
  132151. }
  132152. /**
  132153. * Represents a group of points in a points cloud system
  132154. * * PCS internal tool, don't use it manually.
  132155. */
  132156. export class PointsGroup {
  132157. /**
  132158. * The group id
  132159. * @hidden
  132160. */
  132161. groupID: number;
  132162. /**
  132163. * image data for group (internal use)
  132164. * @hidden
  132165. */
  132166. _groupImageData: Nullable<ArrayBufferView>;
  132167. /**
  132168. * Image Width (internal use)
  132169. * @hidden
  132170. */
  132171. _groupImgWidth: number;
  132172. /**
  132173. * Image Height (internal use)
  132174. * @hidden
  132175. */
  132176. _groupImgHeight: number;
  132177. /**
  132178. * Custom position function (internal use)
  132179. * @hidden
  132180. */
  132181. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  132182. /**
  132183. * density per facet for surface points
  132184. * @hidden
  132185. */
  132186. _groupDensity: number[];
  132187. /**
  132188. * Only when points are colored by texture carries pointer to texture list array
  132189. * @hidden
  132190. */
  132191. _textureNb: number;
  132192. /**
  132193. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  132194. * PCS internal tool, don't use it manually.
  132195. * @hidden
  132196. */
  132197. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  132198. }
  132199. }
  132200. declare module BABYLON {
  132201. interface Scene {
  132202. /** @hidden (Backing field) */
  132203. _physicsEngine: Nullable<IPhysicsEngine>;
  132204. /** @hidden */
  132205. _physicsTimeAccumulator: number;
  132206. /**
  132207. * Gets the current physics engine
  132208. * @returns a IPhysicsEngine or null if none attached
  132209. */
  132210. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  132211. /**
  132212. * Enables physics to the current scene
  132213. * @param gravity defines the scene's gravity for the physics engine
  132214. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  132215. * @return a boolean indicating if the physics engine was initialized
  132216. */
  132217. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  132218. /**
  132219. * Disables and disposes the physics engine associated with the scene
  132220. */
  132221. disablePhysicsEngine(): void;
  132222. /**
  132223. * Gets a boolean indicating if there is an active physics engine
  132224. * @returns a boolean indicating if there is an active physics engine
  132225. */
  132226. isPhysicsEnabled(): boolean;
  132227. /**
  132228. * Deletes a physics compound impostor
  132229. * @param compound defines the compound to delete
  132230. */
  132231. deleteCompoundImpostor(compound: any): void;
  132232. /**
  132233. * An event triggered when physic simulation is about to be run
  132234. */
  132235. onBeforePhysicsObservable: Observable<Scene>;
  132236. /**
  132237. * An event triggered when physic simulation has been done
  132238. */
  132239. onAfterPhysicsObservable: Observable<Scene>;
  132240. }
  132241. interface AbstractMesh {
  132242. /** @hidden */
  132243. _physicsImpostor: Nullable<PhysicsImpostor>;
  132244. /**
  132245. * Gets or sets impostor used for physic simulation
  132246. * @see http://doc.babylonjs.com/features/physics_engine
  132247. */
  132248. physicsImpostor: Nullable<PhysicsImpostor>;
  132249. /**
  132250. * Gets the current physics impostor
  132251. * @see http://doc.babylonjs.com/features/physics_engine
  132252. * @returns a physics impostor or null
  132253. */
  132254. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  132255. /** Apply a physic impulse to the mesh
  132256. * @param force defines the force to apply
  132257. * @param contactPoint defines where to apply the force
  132258. * @returns the current mesh
  132259. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  132260. */
  132261. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  132262. /**
  132263. * Creates a physic joint between two meshes
  132264. * @param otherMesh defines the other mesh to use
  132265. * @param pivot1 defines the pivot to use on this mesh
  132266. * @param pivot2 defines the pivot to use on the other mesh
  132267. * @param options defines additional options (can be plugin dependent)
  132268. * @returns the current mesh
  132269. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  132270. */
  132271. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  132272. /** @hidden */
  132273. _disposePhysicsObserver: Nullable<Observer<Node>>;
  132274. }
  132275. /**
  132276. * Defines the physics engine scene component responsible to manage a physics engine
  132277. */
  132278. export class PhysicsEngineSceneComponent implements ISceneComponent {
  132279. /**
  132280. * The component name helpful to identify the component in the list of scene components.
  132281. */
  132282. readonly name: string;
  132283. /**
  132284. * The scene the component belongs to.
  132285. */
  132286. scene: Scene;
  132287. /**
  132288. * Creates a new instance of the component for the given scene
  132289. * @param scene Defines the scene to register the component in
  132290. */
  132291. constructor(scene: Scene);
  132292. /**
  132293. * Registers the component in a given scene
  132294. */
  132295. register(): void;
  132296. /**
  132297. * Rebuilds the elements related to this component in case of
  132298. * context lost for instance.
  132299. */
  132300. rebuild(): void;
  132301. /**
  132302. * Disposes the component and the associated ressources
  132303. */
  132304. dispose(): void;
  132305. }
  132306. }
  132307. declare module BABYLON {
  132308. /**
  132309. * A helper for physics simulations
  132310. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132311. */
  132312. export class PhysicsHelper {
  132313. private _scene;
  132314. private _physicsEngine;
  132315. /**
  132316. * Initializes the Physics helper
  132317. * @param scene Babylon.js scene
  132318. */
  132319. constructor(scene: Scene);
  132320. /**
  132321. * Applies a radial explosion impulse
  132322. * @param origin the origin of the explosion
  132323. * @param radiusOrEventOptions the radius or the options of radial explosion
  132324. * @param strength the explosion strength
  132325. * @param falloff possible options: Constant & Linear. Defaults to Constant
  132326. * @returns A physics radial explosion event, or null
  132327. */
  132328. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  132329. /**
  132330. * Applies a radial explosion force
  132331. * @param origin the origin of the explosion
  132332. * @param radiusOrEventOptions the radius or the options of radial explosion
  132333. * @param strength the explosion strength
  132334. * @param falloff possible options: Constant & Linear. Defaults to Constant
  132335. * @returns A physics radial explosion event, or null
  132336. */
  132337. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  132338. /**
  132339. * Creates a gravitational field
  132340. * @param origin the origin of the explosion
  132341. * @param radiusOrEventOptions the radius or the options of radial explosion
  132342. * @param strength the explosion strength
  132343. * @param falloff possible options: Constant & Linear. Defaults to Constant
  132344. * @returns A physics gravitational field event, or null
  132345. */
  132346. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  132347. /**
  132348. * Creates a physics updraft event
  132349. * @param origin the origin of the updraft
  132350. * @param radiusOrEventOptions the radius or the options of the updraft
  132351. * @param strength the strength of the updraft
  132352. * @param height the height of the updraft
  132353. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  132354. * @returns A physics updraft event, or null
  132355. */
  132356. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  132357. /**
  132358. * Creates a physics vortex event
  132359. * @param origin the of the vortex
  132360. * @param radiusOrEventOptions the radius or the options of the vortex
  132361. * @param strength the strength of the vortex
  132362. * @param height the height of the vortex
  132363. * @returns a Physics vortex event, or null
  132364. * A physics vortex event or null
  132365. */
  132366. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  132367. }
  132368. /**
  132369. * Represents a physics radial explosion event
  132370. */
  132371. class PhysicsRadialExplosionEvent {
  132372. private _scene;
  132373. private _options;
  132374. private _sphere;
  132375. private _dataFetched;
  132376. /**
  132377. * Initializes a radial explosioin event
  132378. * @param _scene BabylonJS scene
  132379. * @param _options The options for the vortex event
  132380. */
  132381. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  132382. /**
  132383. * Returns the data related to the radial explosion event (sphere).
  132384. * @returns The radial explosion event data
  132385. */
  132386. getData(): PhysicsRadialExplosionEventData;
  132387. /**
  132388. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  132389. * @param impostor A physics imposter
  132390. * @param origin the origin of the explosion
  132391. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  132392. */
  132393. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  132394. /**
  132395. * Triggers affecterd impostors callbacks
  132396. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  132397. */
  132398. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  132399. /**
  132400. * Disposes the sphere.
  132401. * @param force Specifies if the sphere should be disposed by force
  132402. */
  132403. dispose(force?: boolean): void;
  132404. /*** Helpers ***/
  132405. private _prepareSphere;
  132406. private _intersectsWithSphere;
  132407. }
  132408. /**
  132409. * Represents a gravitational field event
  132410. */
  132411. class PhysicsGravitationalFieldEvent {
  132412. private _physicsHelper;
  132413. private _scene;
  132414. private _origin;
  132415. private _options;
  132416. private _tickCallback;
  132417. private _sphere;
  132418. private _dataFetched;
  132419. /**
  132420. * Initializes the physics gravitational field event
  132421. * @param _physicsHelper A physics helper
  132422. * @param _scene BabylonJS scene
  132423. * @param _origin The origin position of the gravitational field event
  132424. * @param _options The options for the vortex event
  132425. */
  132426. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  132427. /**
  132428. * Returns the data related to the gravitational field event (sphere).
  132429. * @returns A gravitational field event
  132430. */
  132431. getData(): PhysicsGravitationalFieldEventData;
  132432. /**
  132433. * Enables the gravitational field.
  132434. */
  132435. enable(): void;
  132436. /**
  132437. * Disables the gravitational field.
  132438. */
  132439. disable(): void;
  132440. /**
  132441. * Disposes the sphere.
  132442. * @param force The force to dispose from the gravitational field event
  132443. */
  132444. dispose(force?: boolean): void;
  132445. private _tick;
  132446. }
  132447. /**
  132448. * Represents a physics updraft event
  132449. */
  132450. class PhysicsUpdraftEvent {
  132451. private _scene;
  132452. private _origin;
  132453. private _options;
  132454. private _physicsEngine;
  132455. private _originTop;
  132456. private _originDirection;
  132457. private _tickCallback;
  132458. private _cylinder;
  132459. private _cylinderPosition;
  132460. private _dataFetched;
  132461. /**
  132462. * Initializes the physics updraft event
  132463. * @param _scene BabylonJS scene
  132464. * @param _origin The origin position of the updraft
  132465. * @param _options The options for the updraft event
  132466. */
  132467. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  132468. /**
  132469. * Returns the data related to the updraft event (cylinder).
  132470. * @returns A physics updraft event
  132471. */
  132472. getData(): PhysicsUpdraftEventData;
  132473. /**
  132474. * Enables the updraft.
  132475. */
  132476. enable(): void;
  132477. /**
  132478. * Disables the updraft.
  132479. */
  132480. disable(): void;
  132481. /**
  132482. * Disposes the cylinder.
  132483. * @param force Specifies if the updraft should be disposed by force
  132484. */
  132485. dispose(force?: boolean): void;
  132486. private getImpostorHitData;
  132487. private _tick;
  132488. /*** Helpers ***/
  132489. private _prepareCylinder;
  132490. private _intersectsWithCylinder;
  132491. }
  132492. /**
  132493. * Represents a physics vortex event
  132494. */
  132495. class PhysicsVortexEvent {
  132496. private _scene;
  132497. private _origin;
  132498. private _options;
  132499. private _physicsEngine;
  132500. private _originTop;
  132501. private _tickCallback;
  132502. private _cylinder;
  132503. private _cylinderPosition;
  132504. private _dataFetched;
  132505. /**
  132506. * Initializes the physics vortex event
  132507. * @param _scene The BabylonJS scene
  132508. * @param _origin The origin position of the vortex
  132509. * @param _options The options for the vortex event
  132510. */
  132511. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  132512. /**
  132513. * Returns the data related to the vortex event (cylinder).
  132514. * @returns The physics vortex event data
  132515. */
  132516. getData(): PhysicsVortexEventData;
  132517. /**
  132518. * Enables the vortex.
  132519. */
  132520. enable(): void;
  132521. /**
  132522. * Disables the cortex.
  132523. */
  132524. disable(): void;
  132525. /**
  132526. * Disposes the sphere.
  132527. * @param force
  132528. */
  132529. dispose(force?: boolean): void;
  132530. private getImpostorHitData;
  132531. private _tick;
  132532. /*** Helpers ***/
  132533. private _prepareCylinder;
  132534. private _intersectsWithCylinder;
  132535. }
  132536. /**
  132537. * Options fot the radial explosion event
  132538. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132539. */
  132540. export class PhysicsRadialExplosionEventOptions {
  132541. /**
  132542. * The radius of the sphere for the radial explosion.
  132543. */
  132544. radius: number;
  132545. /**
  132546. * The strenth of the explosion.
  132547. */
  132548. strength: number;
  132549. /**
  132550. * The strenght of the force in correspondence to the distance of the affected object
  132551. */
  132552. falloff: PhysicsRadialImpulseFalloff;
  132553. /**
  132554. * Sphere options for the radial explosion.
  132555. */
  132556. sphere: {
  132557. segments: number;
  132558. diameter: number;
  132559. };
  132560. /**
  132561. * Sphere options for the radial explosion.
  132562. */
  132563. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  132564. }
  132565. /**
  132566. * Options fot the updraft event
  132567. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132568. */
  132569. export class PhysicsUpdraftEventOptions {
  132570. /**
  132571. * The radius of the cylinder for the vortex
  132572. */
  132573. radius: number;
  132574. /**
  132575. * The strenth of the updraft.
  132576. */
  132577. strength: number;
  132578. /**
  132579. * The height of the cylinder for the updraft.
  132580. */
  132581. height: number;
  132582. /**
  132583. * The mode for the the updraft.
  132584. */
  132585. updraftMode: PhysicsUpdraftMode;
  132586. }
  132587. /**
  132588. * Options fot the vortex event
  132589. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132590. */
  132591. export class PhysicsVortexEventOptions {
  132592. /**
  132593. * The radius of the cylinder for the vortex
  132594. */
  132595. radius: number;
  132596. /**
  132597. * The strenth of the vortex.
  132598. */
  132599. strength: number;
  132600. /**
  132601. * The height of the cylinder for the vortex.
  132602. */
  132603. height: number;
  132604. /**
  132605. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  132606. */
  132607. centripetalForceThreshold: number;
  132608. /**
  132609. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  132610. */
  132611. centripetalForceMultiplier: number;
  132612. /**
  132613. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  132614. */
  132615. centrifugalForceMultiplier: number;
  132616. /**
  132617. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  132618. */
  132619. updraftForceMultiplier: number;
  132620. }
  132621. /**
  132622. * The strenght of the force in correspondence to the distance of the affected object
  132623. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132624. */
  132625. export enum PhysicsRadialImpulseFalloff {
  132626. /** Defines that impulse is constant in strength across it's whole radius */
  132627. Constant = 0,
  132628. /** Defines that impulse gets weaker if it's further from the origin */
  132629. Linear = 1
  132630. }
  132631. /**
  132632. * The strength of the force in correspondence to the distance of the affected object
  132633. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132634. */
  132635. export enum PhysicsUpdraftMode {
  132636. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  132637. Center = 0,
  132638. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  132639. Perpendicular = 1
  132640. }
  132641. /**
  132642. * Interface for a physics hit data
  132643. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132644. */
  132645. export interface PhysicsHitData {
  132646. /**
  132647. * The force applied at the contact point
  132648. */
  132649. force: Vector3;
  132650. /**
  132651. * The contact point
  132652. */
  132653. contactPoint: Vector3;
  132654. /**
  132655. * The distance from the origin to the contact point
  132656. */
  132657. distanceFromOrigin: number;
  132658. }
  132659. /**
  132660. * Interface for radial explosion event data
  132661. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132662. */
  132663. export interface PhysicsRadialExplosionEventData {
  132664. /**
  132665. * A sphere used for the radial explosion event
  132666. */
  132667. sphere: Mesh;
  132668. }
  132669. /**
  132670. * Interface for gravitational field event data
  132671. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132672. */
  132673. export interface PhysicsGravitationalFieldEventData {
  132674. /**
  132675. * A sphere mesh used for the gravitational field event
  132676. */
  132677. sphere: Mesh;
  132678. }
  132679. /**
  132680. * Interface for updraft event data
  132681. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132682. */
  132683. export interface PhysicsUpdraftEventData {
  132684. /**
  132685. * A cylinder used for the updraft event
  132686. */
  132687. cylinder: Mesh;
  132688. }
  132689. /**
  132690. * Interface for vortex event data
  132691. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132692. */
  132693. export interface PhysicsVortexEventData {
  132694. /**
  132695. * A cylinder used for the vortex event
  132696. */
  132697. cylinder: Mesh;
  132698. }
  132699. /**
  132700. * Interface for an affected physics impostor
  132701. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  132702. */
  132703. export interface PhysicsAffectedImpostorWithData {
  132704. /**
  132705. * The impostor affected by the effect
  132706. */
  132707. impostor: PhysicsImpostor;
  132708. /**
  132709. * The data about the hit/horce from the explosion
  132710. */
  132711. hitData: PhysicsHitData;
  132712. }
  132713. }
  132714. declare module BABYLON {
  132715. /** @hidden */
  132716. export var blackAndWhitePixelShader: {
  132717. name: string;
  132718. shader: string;
  132719. };
  132720. }
  132721. declare module BABYLON {
  132722. /**
  132723. * Post process used to render in black and white
  132724. */
  132725. export class BlackAndWhitePostProcess extends PostProcess {
  132726. /**
  132727. * Linear about to convert he result to black and white (default: 1)
  132728. */
  132729. degree: number;
  132730. /**
  132731. * Creates a black and white post process
  132732. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  132733. * @param name The name of the effect.
  132734. * @param options The required width/height ratio to downsize to before computing the render pass.
  132735. * @param camera The camera to apply the render pass to.
  132736. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132737. * @param engine The engine which the post process will be applied. (default: current engine)
  132738. * @param reusable If the post process can be reused on the same frame. (default: false)
  132739. */
  132740. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  132741. }
  132742. }
  132743. declare module BABYLON {
  132744. /**
  132745. * This represents a set of one or more post processes in Babylon.
  132746. * A post process can be used to apply a shader to a texture after it is rendered.
  132747. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  132748. */
  132749. export class PostProcessRenderEffect {
  132750. private _postProcesses;
  132751. private _getPostProcesses;
  132752. private _singleInstance;
  132753. private _cameras;
  132754. private _indicesForCamera;
  132755. /**
  132756. * Name of the effect
  132757. * @hidden
  132758. */
  132759. _name: string;
  132760. /**
  132761. * Instantiates a post process render effect.
  132762. * A post process can be used to apply a shader to a texture after it is rendered.
  132763. * @param engine The engine the effect is tied to
  132764. * @param name The name of the effect
  132765. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  132766. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  132767. */
  132768. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  132769. /**
  132770. * Checks if all the post processes in the effect are supported.
  132771. */
  132772. get isSupported(): boolean;
  132773. /**
  132774. * Updates the current state of the effect
  132775. * @hidden
  132776. */
  132777. _update(): void;
  132778. /**
  132779. * Attaches the effect on cameras
  132780. * @param cameras The camera to attach to.
  132781. * @hidden
  132782. */
  132783. _attachCameras(cameras: Camera): void;
  132784. /**
  132785. * Attaches the effect on cameras
  132786. * @param cameras The camera to attach to.
  132787. * @hidden
  132788. */
  132789. _attachCameras(cameras: Camera[]): void;
  132790. /**
  132791. * Detaches the effect on cameras
  132792. * @param cameras The camera to detatch from.
  132793. * @hidden
  132794. */
  132795. _detachCameras(cameras: Camera): void;
  132796. /**
  132797. * Detatches the effect on cameras
  132798. * @param cameras The camera to detatch from.
  132799. * @hidden
  132800. */
  132801. _detachCameras(cameras: Camera[]): void;
  132802. /**
  132803. * Enables the effect on given cameras
  132804. * @param cameras The camera to enable.
  132805. * @hidden
  132806. */
  132807. _enable(cameras: Camera): void;
  132808. /**
  132809. * Enables the effect on given cameras
  132810. * @param cameras The camera to enable.
  132811. * @hidden
  132812. */
  132813. _enable(cameras: Nullable<Camera[]>): void;
  132814. /**
  132815. * Disables the effect on the given cameras
  132816. * @param cameras The camera to disable.
  132817. * @hidden
  132818. */
  132819. _disable(cameras: Camera): void;
  132820. /**
  132821. * Disables the effect on the given cameras
  132822. * @param cameras The camera to disable.
  132823. * @hidden
  132824. */
  132825. _disable(cameras: Nullable<Camera[]>): void;
  132826. /**
  132827. * Gets a list of the post processes contained in the effect.
  132828. * @param camera The camera to get the post processes on.
  132829. * @returns The list of the post processes in the effect.
  132830. */
  132831. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  132832. }
  132833. }
  132834. declare module BABYLON {
  132835. /** @hidden */
  132836. export var extractHighlightsPixelShader: {
  132837. name: string;
  132838. shader: string;
  132839. };
  132840. }
  132841. declare module BABYLON {
  132842. /**
  132843. * 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.
  132844. */
  132845. export class ExtractHighlightsPostProcess extends PostProcess {
  132846. /**
  132847. * The luminance threshold, pixels below this value will be set to black.
  132848. */
  132849. threshold: number;
  132850. /** @hidden */
  132851. _exposure: number;
  132852. /**
  132853. * Post process which has the input texture to be used when performing highlight extraction
  132854. * @hidden
  132855. */
  132856. _inputPostProcess: Nullable<PostProcess>;
  132857. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  132858. }
  132859. }
  132860. declare module BABYLON {
  132861. /** @hidden */
  132862. export var bloomMergePixelShader: {
  132863. name: string;
  132864. shader: string;
  132865. };
  132866. }
  132867. declare module BABYLON {
  132868. /**
  132869. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  132870. */
  132871. export class BloomMergePostProcess extends PostProcess {
  132872. /** Weight of the bloom to be added to the original input. */
  132873. weight: number;
  132874. /**
  132875. * Creates a new instance of @see BloomMergePostProcess
  132876. * @param name The name of the effect.
  132877. * @param originalFromInput Post process which's input will be used for the merge.
  132878. * @param blurred Blurred highlights post process which's output will be used.
  132879. * @param weight Weight of the bloom to be added to the original input.
  132880. * @param options The required width/height ratio to downsize to before computing the render pass.
  132881. * @param camera The camera to apply the render pass to.
  132882. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132883. * @param engine The engine which the post process will be applied. (default: current engine)
  132884. * @param reusable If the post process can be reused on the same frame. (default: false)
  132885. * @param textureType Type of textures used when performing the post process. (default: 0)
  132886. * @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)
  132887. */
  132888. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  132889. /** Weight of the bloom to be added to the original input. */
  132890. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  132891. }
  132892. }
  132893. declare module BABYLON {
  132894. /**
  132895. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  132896. */
  132897. export class BloomEffect extends PostProcessRenderEffect {
  132898. private bloomScale;
  132899. /**
  132900. * @hidden Internal
  132901. */
  132902. _effects: Array<PostProcess>;
  132903. /**
  132904. * @hidden Internal
  132905. */
  132906. _downscale: ExtractHighlightsPostProcess;
  132907. private _blurX;
  132908. private _blurY;
  132909. private _merge;
  132910. /**
  132911. * The luminance threshold to find bright areas of the image to bloom.
  132912. */
  132913. get threshold(): number;
  132914. set threshold(value: number);
  132915. /**
  132916. * The strength of the bloom.
  132917. */
  132918. get weight(): number;
  132919. set weight(value: number);
  132920. /**
  132921. * Specifies the size of the bloom blur kernel, relative to the final output size
  132922. */
  132923. get kernel(): number;
  132924. set kernel(value: number);
  132925. /**
  132926. * Creates a new instance of @see BloomEffect
  132927. * @param scene The scene the effect belongs to.
  132928. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  132929. * @param bloomKernel The size of the kernel to be used when applying the blur.
  132930. * @param bloomWeight The the strength of bloom.
  132931. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  132932. * @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)
  132933. */
  132934. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  132935. /**
  132936. * Disposes each of the internal effects for a given camera.
  132937. * @param camera The camera to dispose the effect on.
  132938. */
  132939. disposeEffects(camera: Camera): void;
  132940. /**
  132941. * @hidden Internal
  132942. */
  132943. _updateEffects(): void;
  132944. /**
  132945. * Internal
  132946. * @returns if all the contained post processes are ready.
  132947. * @hidden
  132948. */
  132949. _isReady(): boolean;
  132950. }
  132951. }
  132952. declare module BABYLON {
  132953. /** @hidden */
  132954. export var chromaticAberrationPixelShader: {
  132955. name: string;
  132956. shader: string;
  132957. };
  132958. }
  132959. declare module BABYLON {
  132960. /**
  132961. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  132962. */
  132963. export class ChromaticAberrationPostProcess extends PostProcess {
  132964. /**
  132965. * The amount of seperation of rgb channels (default: 30)
  132966. */
  132967. aberrationAmount: number;
  132968. /**
  132969. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  132970. */
  132971. radialIntensity: number;
  132972. /**
  132973. * 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))
  132974. */
  132975. direction: Vector2;
  132976. /**
  132977. * 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))
  132978. */
  132979. centerPosition: Vector2;
  132980. /**
  132981. * Creates a new instance ChromaticAberrationPostProcess
  132982. * @param name The name of the effect.
  132983. * @param screenWidth The width of the screen to apply the effect on.
  132984. * @param screenHeight The height of the screen to apply the effect on.
  132985. * @param options The required width/height ratio to downsize to before computing the render pass.
  132986. * @param camera The camera to apply the render pass to.
  132987. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  132988. * @param engine The engine which the post process will be applied. (default: current engine)
  132989. * @param reusable If the post process can be reused on the same frame. (default: false)
  132990. * @param textureType Type of textures used when performing the post process. (default: 0)
  132991. * @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)
  132992. */
  132993. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  132994. }
  132995. }
  132996. declare module BABYLON {
  132997. /** @hidden */
  132998. export var circleOfConfusionPixelShader: {
  132999. name: string;
  133000. shader: string;
  133001. };
  133002. }
  133003. declare module BABYLON {
  133004. /**
  133005. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  133006. */
  133007. export class CircleOfConfusionPostProcess extends PostProcess {
  133008. /**
  133009. * 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.
  133010. */
  133011. lensSize: number;
  133012. /**
  133013. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  133014. */
  133015. fStop: number;
  133016. /**
  133017. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  133018. */
  133019. focusDistance: number;
  133020. /**
  133021. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  133022. */
  133023. focalLength: number;
  133024. private _depthTexture;
  133025. /**
  133026. * Creates a new instance CircleOfConfusionPostProcess
  133027. * @param name The name of the effect.
  133028. * @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.
  133029. * @param options The required width/height ratio to downsize to before computing the render pass.
  133030. * @param camera The camera to apply the render pass to.
  133031. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133032. * @param engine The engine which the post process will be applied. (default: current engine)
  133033. * @param reusable If the post process can be reused on the same frame. (default: false)
  133034. * @param textureType Type of textures used when performing the post process. (default: 0)
  133035. * @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)
  133036. */
  133037. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  133038. /**
  133039. * 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.
  133040. */
  133041. set depthTexture(value: RenderTargetTexture);
  133042. }
  133043. }
  133044. declare module BABYLON {
  133045. /** @hidden */
  133046. export var colorCorrectionPixelShader: {
  133047. name: string;
  133048. shader: string;
  133049. };
  133050. }
  133051. declare module BABYLON {
  133052. /**
  133053. *
  133054. * This post-process allows the modification of rendered colors by using
  133055. * a 'look-up table' (LUT). This effect is also called Color Grading.
  133056. *
  133057. * The object needs to be provided an url to a texture containing the color
  133058. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  133059. * Use an image editing software to tweak the LUT to match your needs.
  133060. *
  133061. * For an example of a color LUT, see here:
  133062. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  133063. * For explanations on color grading, see here:
  133064. * @see http://udn.epicgames.com/Three/ColorGrading.html
  133065. *
  133066. */
  133067. export class ColorCorrectionPostProcess extends PostProcess {
  133068. private _colorTableTexture;
  133069. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  133070. }
  133071. }
  133072. declare module BABYLON {
  133073. /** @hidden */
  133074. export var convolutionPixelShader: {
  133075. name: string;
  133076. shader: string;
  133077. };
  133078. }
  133079. declare module BABYLON {
  133080. /**
  133081. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  133082. * input texture to perform effects such as edge detection or sharpening
  133083. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  133084. */
  133085. export class ConvolutionPostProcess extends PostProcess {
  133086. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  133087. kernel: number[];
  133088. /**
  133089. * Creates a new instance ConvolutionPostProcess
  133090. * @param name The name of the effect.
  133091. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  133092. * @param options The required width/height ratio to downsize to before computing the render pass.
  133093. * @param camera The camera to apply the render pass to.
  133094. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133095. * @param engine The engine which the post process will be applied. (default: current engine)
  133096. * @param reusable If the post process can be reused on the same frame. (default: false)
  133097. * @param textureType Type of textures used when performing the post process. (default: 0)
  133098. */
  133099. constructor(name: string,
  133100. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  133101. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  133102. /**
  133103. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  133104. */
  133105. static EdgeDetect0Kernel: number[];
  133106. /**
  133107. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  133108. */
  133109. static EdgeDetect1Kernel: number[];
  133110. /**
  133111. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  133112. */
  133113. static EdgeDetect2Kernel: number[];
  133114. /**
  133115. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  133116. */
  133117. static SharpenKernel: number[];
  133118. /**
  133119. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  133120. */
  133121. static EmbossKernel: number[];
  133122. /**
  133123. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  133124. */
  133125. static GaussianKernel: number[];
  133126. }
  133127. }
  133128. declare module BABYLON {
  133129. /**
  133130. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  133131. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  133132. * based on samples that have a large difference in distance than the center pixel.
  133133. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  133134. */
  133135. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  133136. direction: Vector2;
  133137. /**
  133138. * Creates a new instance CircleOfConfusionPostProcess
  133139. * @param name The name of the effect.
  133140. * @param scene The scene the effect belongs to.
  133141. * @param direction The direction the blur should be applied.
  133142. * @param kernel The size of the kernel used to blur.
  133143. * @param options The required width/height ratio to downsize to before computing the render pass.
  133144. * @param camera The camera to apply the render pass to.
  133145. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  133146. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  133147. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133148. * @param engine The engine which the post process will be applied. (default: current engine)
  133149. * @param reusable If the post process can be reused on the same frame. (default: false)
  133150. * @param textureType Type of textures used when performing the post process. (default: 0)
  133151. * @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)
  133152. */
  133153. 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);
  133154. }
  133155. }
  133156. declare module BABYLON {
  133157. /** @hidden */
  133158. export var depthOfFieldMergePixelShader: {
  133159. name: string;
  133160. shader: string;
  133161. };
  133162. }
  133163. declare module BABYLON {
  133164. /**
  133165. * Options to be set when merging outputs from the default pipeline.
  133166. */
  133167. export class DepthOfFieldMergePostProcessOptions {
  133168. /**
  133169. * The original image to merge on top of
  133170. */
  133171. originalFromInput: PostProcess;
  133172. /**
  133173. * Parameters to perform the merge of the depth of field effect
  133174. */
  133175. depthOfField?: {
  133176. circleOfConfusion: PostProcess;
  133177. blurSteps: Array<PostProcess>;
  133178. };
  133179. /**
  133180. * Parameters to perform the merge of bloom effect
  133181. */
  133182. bloom?: {
  133183. blurred: PostProcess;
  133184. weight: number;
  133185. };
  133186. }
  133187. /**
  133188. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  133189. */
  133190. export class DepthOfFieldMergePostProcess extends PostProcess {
  133191. private blurSteps;
  133192. /**
  133193. * Creates a new instance of DepthOfFieldMergePostProcess
  133194. * @param name The name of the effect.
  133195. * @param originalFromInput Post process which's input will be used for the merge.
  133196. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  133197. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  133198. * @param options The required width/height ratio to downsize to before computing the render pass.
  133199. * @param camera The camera to apply the render pass to.
  133200. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133201. * @param engine The engine which the post process will be applied. (default: current engine)
  133202. * @param reusable If the post process can be reused on the same frame. (default: false)
  133203. * @param textureType Type of textures used when performing the post process. (default: 0)
  133204. * @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)
  133205. */
  133206. 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);
  133207. /**
  133208. * Updates the effect with the current post process compile time values and recompiles the shader.
  133209. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  133210. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  133211. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  133212. * @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
  133213. * @param onCompiled Called when the shader has been compiled.
  133214. * @param onError Called if there is an error when compiling a shader.
  133215. */
  133216. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  133217. }
  133218. }
  133219. declare module BABYLON {
  133220. /**
  133221. * Specifies the level of max blur that should be applied when using the depth of field effect
  133222. */
  133223. export enum DepthOfFieldEffectBlurLevel {
  133224. /**
  133225. * Subtle blur
  133226. */
  133227. Low = 0,
  133228. /**
  133229. * Medium blur
  133230. */
  133231. Medium = 1,
  133232. /**
  133233. * Large blur
  133234. */
  133235. High = 2
  133236. }
  133237. /**
  133238. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  133239. */
  133240. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  133241. private _circleOfConfusion;
  133242. /**
  133243. * @hidden Internal, blurs from high to low
  133244. */
  133245. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  133246. private _depthOfFieldBlurY;
  133247. private _dofMerge;
  133248. /**
  133249. * @hidden Internal post processes in depth of field effect
  133250. */
  133251. _effects: Array<PostProcess>;
  133252. /**
  133253. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  133254. */
  133255. set focalLength(value: number);
  133256. get focalLength(): number;
  133257. /**
  133258. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  133259. */
  133260. set fStop(value: number);
  133261. get fStop(): number;
  133262. /**
  133263. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  133264. */
  133265. set focusDistance(value: number);
  133266. get focusDistance(): number;
  133267. /**
  133268. * 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.
  133269. */
  133270. set lensSize(value: number);
  133271. get lensSize(): number;
  133272. /**
  133273. * Creates a new instance DepthOfFieldEffect
  133274. * @param scene The scene the effect belongs to.
  133275. * @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.
  133276. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  133277. * @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)
  133278. */
  133279. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  133280. /**
  133281. * Get the current class name of the current effet
  133282. * @returns "DepthOfFieldEffect"
  133283. */
  133284. getClassName(): string;
  133285. /**
  133286. * 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.
  133287. */
  133288. set depthTexture(value: RenderTargetTexture);
  133289. /**
  133290. * Disposes each of the internal effects for a given camera.
  133291. * @param camera The camera to dispose the effect on.
  133292. */
  133293. disposeEffects(camera: Camera): void;
  133294. /**
  133295. * @hidden Internal
  133296. */
  133297. _updateEffects(): void;
  133298. /**
  133299. * Internal
  133300. * @returns if all the contained post processes are ready.
  133301. * @hidden
  133302. */
  133303. _isReady(): boolean;
  133304. }
  133305. }
  133306. declare module BABYLON {
  133307. /** @hidden */
  133308. export var displayPassPixelShader: {
  133309. name: string;
  133310. shader: string;
  133311. };
  133312. }
  133313. declare module BABYLON {
  133314. /**
  133315. * DisplayPassPostProcess which produces an output the same as it's input
  133316. */
  133317. export class DisplayPassPostProcess extends PostProcess {
  133318. /**
  133319. * Creates the DisplayPassPostProcess
  133320. * @param name The name of the effect.
  133321. * @param options The required width/height ratio to downsize to before computing the render pass.
  133322. * @param camera The camera to apply the render pass to.
  133323. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133324. * @param engine The engine which the post process will be applied. (default: current engine)
  133325. * @param reusable If the post process can be reused on the same frame. (default: false)
  133326. */
  133327. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  133328. }
  133329. }
  133330. declare module BABYLON {
  133331. /** @hidden */
  133332. export var filterPixelShader: {
  133333. name: string;
  133334. shader: string;
  133335. };
  133336. }
  133337. declare module BABYLON {
  133338. /**
  133339. * Applies a kernel filter to the image
  133340. */
  133341. export class FilterPostProcess extends PostProcess {
  133342. /** The matrix to be applied to the image */
  133343. kernelMatrix: Matrix;
  133344. /**
  133345. *
  133346. * @param name The name of the effect.
  133347. * @param kernelMatrix The matrix to be applied to the image
  133348. * @param options The required width/height ratio to downsize to before computing the render pass.
  133349. * @param camera The camera to apply the render pass to.
  133350. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133351. * @param engine The engine which the post process will be applied. (default: current engine)
  133352. * @param reusable If the post process can be reused on the same frame. (default: false)
  133353. */
  133354. constructor(name: string,
  133355. /** The matrix to be applied to the image */
  133356. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  133357. }
  133358. }
  133359. declare module BABYLON {
  133360. /** @hidden */
  133361. export var fxaaPixelShader: {
  133362. name: string;
  133363. shader: string;
  133364. };
  133365. }
  133366. declare module BABYLON {
  133367. /** @hidden */
  133368. export var fxaaVertexShader: {
  133369. name: string;
  133370. shader: string;
  133371. };
  133372. }
  133373. declare module BABYLON {
  133374. /**
  133375. * Fxaa post process
  133376. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  133377. */
  133378. export class FxaaPostProcess extends PostProcess {
  133379. /** @hidden */
  133380. texelWidth: number;
  133381. /** @hidden */
  133382. texelHeight: number;
  133383. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  133384. private _getDefines;
  133385. }
  133386. }
  133387. declare module BABYLON {
  133388. /** @hidden */
  133389. export var grainPixelShader: {
  133390. name: string;
  133391. shader: string;
  133392. };
  133393. }
  133394. declare module BABYLON {
  133395. /**
  133396. * The GrainPostProcess adds noise to the image at mid luminance levels
  133397. */
  133398. export class GrainPostProcess extends PostProcess {
  133399. /**
  133400. * The intensity of the grain added (default: 30)
  133401. */
  133402. intensity: number;
  133403. /**
  133404. * If the grain should be randomized on every frame
  133405. */
  133406. animated: boolean;
  133407. /**
  133408. * Creates a new instance of @see GrainPostProcess
  133409. * @param name The name of the effect.
  133410. * @param options The required width/height ratio to downsize to before computing the render pass.
  133411. * @param camera The camera to apply the render pass to.
  133412. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133413. * @param engine The engine which the post process will be applied. (default: current engine)
  133414. * @param reusable If the post process can be reused on the same frame. (default: false)
  133415. * @param textureType Type of textures used when performing the post process. (default: 0)
  133416. * @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)
  133417. */
  133418. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  133419. }
  133420. }
  133421. declare module BABYLON {
  133422. /** @hidden */
  133423. export var highlightsPixelShader: {
  133424. name: string;
  133425. shader: string;
  133426. };
  133427. }
  133428. declare module BABYLON {
  133429. /**
  133430. * Extracts highlights from the image
  133431. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  133432. */
  133433. export class HighlightsPostProcess extends PostProcess {
  133434. /**
  133435. * Extracts highlights from the image
  133436. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  133437. * @param name The name of the effect.
  133438. * @param options The required width/height ratio to downsize to before computing the render pass.
  133439. * @param camera The camera to apply the render pass to.
  133440. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133441. * @param engine The engine which the post process will be applied. (default: current engine)
  133442. * @param reusable If the post process can be reused on the same frame. (default: false)
  133443. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  133444. */
  133445. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  133446. }
  133447. }
  133448. declare module BABYLON {
  133449. /** @hidden */
  133450. export var mrtFragmentDeclaration: {
  133451. name: string;
  133452. shader: string;
  133453. };
  133454. }
  133455. declare module BABYLON {
  133456. /** @hidden */
  133457. export var geometryPixelShader: {
  133458. name: string;
  133459. shader: string;
  133460. };
  133461. }
  133462. declare module BABYLON {
  133463. /** @hidden */
  133464. export var geometryVertexShader: {
  133465. name: string;
  133466. shader: string;
  133467. };
  133468. }
  133469. declare module BABYLON {
  133470. /** @hidden */
  133471. interface ISavedTransformationMatrix {
  133472. world: Matrix;
  133473. viewProjection: Matrix;
  133474. }
  133475. /**
  133476. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  133477. */
  133478. export class GeometryBufferRenderer {
  133479. /**
  133480. * Constant used to retrieve the position texture index in the G-Buffer textures array
  133481. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  133482. */
  133483. static readonly POSITION_TEXTURE_TYPE: number;
  133484. /**
  133485. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  133486. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  133487. */
  133488. static readonly VELOCITY_TEXTURE_TYPE: number;
  133489. /**
  133490. * Dictionary used to store the previous transformation matrices of each rendered mesh
  133491. * in order to compute objects velocities when enableVelocity is set to "true"
  133492. * @hidden
  133493. */
  133494. _previousTransformationMatrices: {
  133495. [index: number]: ISavedTransformationMatrix;
  133496. };
  133497. /**
  133498. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  133499. * in order to compute objects velocities when enableVelocity is set to "true"
  133500. * @hidden
  133501. */
  133502. _previousBonesTransformationMatrices: {
  133503. [index: number]: Float32Array;
  133504. };
  133505. /**
  133506. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  133507. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  133508. */
  133509. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  133510. private _scene;
  133511. private _multiRenderTarget;
  133512. private _ratio;
  133513. private _enablePosition;
  133514. private _enableVelocity;
  133515. private _positionIndex;
  133516. private _velocityIndex;
  133517. protected _effect: Effect;
  133518. protected _cachedDefines: string;
  133519. /**
  133520. * Set the render list (meshes to be rendered) used in the G buffer.
  133521. */
  133522. set renderList(meshes: Mesh[]);
  133523. /**
  133524. * Gets wether or not G buffer are supported by the running hardware.
  133525. * This requires draw buffer supports
  133526. */
  133527. get isSupported(): boolean;
  133528. /**
  133529. * Returns the index of the given texture type in the G-Buffer textures array
  133530. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  133531. * @returns the index of the given texture type in the G-Buffer textures array
  133532. */
  133533. getTextureIndex(textureType: number): number;
  133534. /**
  133535. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  133536. */
  133537. get enablePosition(): boolean;
  133538. /**
  133539. * Sets whether or not objects positions are enabled for the G buffer.
  133540. */
  133541. set enablePosition(enable: boolean);
  133542. /**
  133543. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  133544. */
  133545. get enableVelocity(): boolean;
  133546. /**
  133547. * Sets wether or not objects velocities are enabled for the G buffer.
  133548. */
  133549. set enableVelocity(enable: boolean);
  133550. /**
  133551. * Gets the scene associated with the buffer.
  133552. */
  133553. get scene(): Scene;
  133554. /**
  133555. * Gets the ratio used by the buffer during its creation.
  133556. * How big is the buffer related to the main canvas.
  133557. */
  133558. get ratio(): number;
  133559. /** @hidden */
  133560. static _SceneComponentInitialization: (scene: Scene) => void;
  133561. /**
  133562. * Creates a new G Buffer for the scene
  133563. * @param scene The scene the buffer belongs to
  133564. * @param ratio How big is the buffer related to the main canvas.
  133565. */
  133566. constructor(scene: Scene, ratio?: number);
  133567. /**
  133568. * Checks wether everything is ready to render a submesh to the G buffer.
  133569. * @param subMesh the submesh to check readiness for
  133570. * @param useInstances is the mesh drawn using instance or not
  133571. * @returns true if ready otherwise false
  133572. */
  133573. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  133574. /**
  133575. * Gets the current underlying G Buffer.
  133576. * @returns the buffer
  133577. */
  133578. getGBuffer(): MultiRenderTarget;
  133579. /**
  133580. * Gets the number of samples used to render the buffer (anti aliasing).
  133581. */
  133582. get samples(): number;
  133583. /**
  133584. * Sets the number of samples used to render the buffer (anti aliasing).
  133585. */
  133586. set samples(value: number);
  133587. /**
  133588. * Disposes the renderer and frees up associated resources.
  133589. */
  133590. dispose(): void;
  133591. protected _createRenderTargets(): void;
  133592. private _copyBonesTransformationMatrices;
  133593. }
  133594. }
  133595. declare module BABYLON {
  133596. interface Scene {
  133597. /** @hidden (Backing field) */
  133598. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  133599. /**
  133600. * Gets or Sets the current geometry buffer associated to the scene.
  133601. */
  133602. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  133603. /**
  133604. * Enables a GeometryBufferRender and associates it with the scene
  133605. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  133606. * @returns the GeometryBufferRenderer
  133607. */
  133608. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  133609. /**
  133610. * Disables the GeometryBufferRender associated with the scene
  133611. */
  133612. disableGeometryBufferRenderer(): void;
  133613. }
  133614. /**
  133615. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  133616. * in several rendering techniques.
  133617. */
  133618. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  133619. /**
  133620. * The component name helpful to identify the component in the list of scene components.
  133621. */
  133622. readonly name: string;
  133623. /**
  133624. * The scene the component belongs to.
  133625. */
  133626. scene: Scene;
  133627. /**
  133628. * Creates a new instance of the component for the given scene
  133629. * @param scene Defines the scene to register the component in
  133630. */
  133631. constructor(scene: Scene);
  133632. /**
  133633. * Registers the component in a given scene
  133634. */
  133635. register(): void;
  133636. /**
  133637. * Rebuilds the elements related to this component in case of
  133638. * context lost for instance.
  133639. */
  133640. rebuild(): void;
  133641. /**
  133642. * Disposes the component and the associated ressources
  133643. */
  133644. dispose(): void;
  133645. private _gatherRenderTargets;
  133646. }
  133647. }
  133648. declare module BABYLON {
  133649. /** @hidden */
  133650. export var motionBlurPixelShader: {
  133651. name: string;
  133652. shader: string;
  133653. };
  133654. }
  133655. declare module BABYLON {
  133656. /**
  133657. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  133658. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  133659. * As an example, all you have to do is to create the post-process:
  133660. * var mb = new BABYLON.MotionBlurPostProcess(
  133661. * 'mb', // The name of the effect.
  133662. * scene, // The scene containing the objects to blur according to their velocity.
  133663. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  133664. * camera // The camera to apply the render pass to.
  133665. * );
  133666. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  133667. */
  133668. export class MotionBlurPostProcess extends PostProcess {
  133669. /**
  133670. * Defines how much the image is blurred by the movement. Default value is equal to 1
  133671. */
  133672. motionStrength: number;
  133673. /**
  133674. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  133675. */
  133676. get motionBlurSamples(): number;
  133677. /**
  133678. * Sets the number of iterations to be used for motion blur quality
  133679. */
  133680. set motionBlurSamples(samples: number);
  133681. private _motionBlurSamples;
  133682. private _geometryBufferRenderer;
  133683. /**
  133684. * Creates a new instance MotionBlurPostProcess
  133685. * @param name The name of the effect.
  133686. * @param scene The scene containing the objects to blur according to their velocity.
  133687. * @param options The required width/height ratio to downsize to before computing the render pass.
  133688. * @param camera The camera to apply the render pass to.
  133689. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133690. * @param engine The engine which the post process will be applied. (default: current engine)
  133691. * @param reusable If the post process can be reused on the same frame. (default: false)
  133692. * @param textureType Type of textures used when performing the post process. (default: 0)
  133693. * @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)
  133694. */
  133695. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  133696. /**
  133697. * Excludes the given skinned mesh from computing bones velocities.
  133698. * 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.
  133699. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  133700. */
  133701. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  133702. /**
  133703. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  133704. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  133705. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  133706. */
  133707. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  133708. /**
  133709. * Disposes the post process.
  133710. * @param camera The camera to dispose the post process on.
  133711. */
  133712. dispose(camera?: Camera): void;
  133713. }
  133714. }
  133715. declare module BABYLON {
  133716. /** @hidden */
  133717. export var refractionPixelShader: {
  133718. name: string;
  133719. shader: string;
  133720. };
  133721. }
  133722. declare module BABYLON {
  133723. /**
  133724. * Post process which applies a refractin texture
  133725. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  133726. */
  133727. export class RefractionPostProcess extends PostProcess {
  133728. /** the base color of the refraction (used to taint the rendering) */
  133729. color: Color3;
  133730. /** simulated refraction depth */
  133731. depth: number;
  133732. /** the coefficient of the base color (0 to remove base color tainting) */
  133733. colorLevel: number;
  133734. private _refTexture;
  133735. private _ownRefractionTexture;
  133736. /**
  133737. * Gets or sets the refraction texture
  133738. * Please note that you are responsible for disposing the texture if you set it manually
  133739. */
  133740. get refractionTexture(): Texture;
  133741. set refractionTexture(value: Texture);
  133742. /**
  133743. * Initializes the RefractionPostProcess
  133744. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  133745. * @param name The name of the effect.
  133746. * @param refractionTextureUrl Url of the refraction texture to use
  133747. * @param color the base color of the refraction (used to taint the rendering)
  133748. * @param depth simulated refraction depth
  133749. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  133750. * @param camera The camera to apply the render pass to.
  133751. * @param options The required width/height ratio to downsize to before computing the render pass.
  133752. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133753. * @param engine The engine which the post process will be applied. (default: current engine)
  133754. * @param reusable If the post process can be reused on the same frame. (default: false)
  133755. */
  133756. constructor(name: string, refractionTextureUrl: string,
  133757. /** the base color of the refraction (used to taint the rendering) */
  133758. color: Color3,
  133759. /** simulated refraction depth */
  133760. depth: number,
  133761. /** the coefficient of the base color (0 to remove base color tainting) */
  133762. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  133763. /**
  133764. * Disposes of the post process
  133765. * @param camera Camera to dispose post process on
  133766. */
  133767. dispose(camera: Camera): void;
  133768. }
  133769. }
  133770. declare module BABYLON {
  133771. /** @hidden */
  133772. export var sharpenPixelShader: {
  133773. name: string;
  133774. shader: string;
  133775. };
  133776. }
  133777. declare module BABYLON {
  133778. /**
  133779. * The SharpenPostProcess applies a sharpen kernel to every pixel
  133780. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  133781. */
  133782. export class SharpenPostProcess extends PostProcess {
  133783. /**
  133784. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  133785. */
  133786. colorAmount: number;
  133787. /**
  133788. * How much sharpness should be applied (default: 0.3)
  133789. */
  133790. edgeAmount: number;
  133791. /**
  133792. * Creates a new instance ConvolutionPostProcess
  133793. * @param name The name of the effect.
  133794. * @param options The required width/height ratio to downsize to before computing the render pass.
  133795. * @param camera The camera to apply the render pass to.
  133796. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  133797. * @param engine The engine which the post process will be applied. (default: current engine)
  133798. * @param reusable If the post process can be reused on the same frame. (default: false)
  133799. * @param textureType Type of textures used when performing the post process. (default: 0)
  133800. * @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)
  133801. */
  133802. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  133803. }
  133804. }
  133805. declare module BABYLON {
  133806. /**
  133807. * PostProcessRenderPipeline
  133808. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  133809. */
  133810. export class PostProcessRenderPipeline {
  133811. private engine;
  133812. private _renderEffects;
  133813. private _renderEffectsForIsolatedPass;
  133814. /**
  133815. * List of inspectable custom properties (used by the Inspector)
  133816. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  133817. */
  133818. inspectableCustomProperties: IInspectable[];
  133819. /**
  133820. * @hidden
  133821. */
  133822. protected _cameras: Camera[];
  133823. /** @hidden */
  133824. _name: string;
  133825. /**
  133826. * Gets pipeline name
  133827. */
  133828. get name(): string;
  133829. /** Gets the list of attached cameras */
  133830. get cameras(): Camera[];
  133831. /**
  133832. * Initializes a PostProcessRenderPipeline
  133833. * @param engine engine to add the pipeline to
  133834. * @param name name of the pipeline
  133835. */
  133836. constructor(engine: Engine, name: string);
  133837. /**
  133838. * Gets the class name
  133839. * @returns "PostProcessRenderPipeline"
  133840. */
  133841. getClassName(): string;
  133842. /**
  133843. * If all the render effects in the pipeline are supported
  133844. */
  133845. get isSupported(): boolean;
  133846. /**
  133847. * Adds an effect to the pipeline
  133848. * @param renderEffect the effect to add
  133849. */
  133850. addEffect(renderEffect: PostProcessRenderEffect): void;
  133851. /** @hidden */
  133852. _rebuild(): void;
  133853. /** @hidden */
  133854. _enableEffect(renderEffectName: string, cameras: Camera): void;
  133855. /** @hidden */
  133856. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  133857. /** @hidden */
  133858. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  133859. /** @hidden */
  133860. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  133861. /** @hidden */
  133862. _attachCameras(cameras: Camera, unique: boolean): void;
  133863. /** @hidden */
  133864. _attachCameras(cameras: Camera[], unique: boolean): void;
  133865. /** @hidden */
  133866. _detachCameras(cameras: Camera): void;
  133867. /** @hidden */
  133868. _detachCameras(cameras: Nullable<Camera[]>): void;
  133869. /** @hidden */
  133870. _update(): void;
  133871. /** @hidden */
  133872. _reset(): void;
  133873. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  133874. /**
  133875. * Disposes of the pipeline
  133876. */
  133877. dispose(): void;
  133878. }
  133879. }
  133880. declare module BABYLON {
  133881. /**
  133882. * PostProcessRenderPipelineManager class
  133883. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  133884. */
  133885. export class PostProcessRenderPipelineManager {
  133886. private _renderPipelines;
  133887. /**
  133888. * Initializes a PostProcessRenderPipelineManager
  133889. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  133890. */
  133891. constructor();
  133892. /**
  133893. * Gets the list of supported render pipelines
  133894. */
  133895. get supportedPipelines(): PostProcessRenderPipeline[];
  133896. /**
  133897. * Adds a pipeline to the manager
  133898. * @param renderPipeline The pipeline to add
  133899. */
  133900. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  133901. /**
  133902. * Attaches a camera to the pipeline
  133903. * @param renderPipelineName The name of the pipeline to attach to
  133904. * @param cameras the camera to attach
  133905. * @param unique if the camera can be attached multiple times to the pipeline
  133906. */
  133907. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  133908. /**
  133909. * Detaches a camera from the pipeline
  133910. * @param renderPipelineName The name of the pipeline to detach from
  133911. * @param cameras the camera to detach
  133912. */
  133913. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  133914. /**
  133915. * Enables an effect by name on a pipeline
  133916. * @param renderPipelineName the name of the pipeline to enable the effect in
  133917. * @param renderEffectName the name of the effect to enable
  133918. * @param cameras the cameras that the effect should be enabled on
  133919. */
  133920. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  133921. /**
  133922. * Disables an effect by name on a pipeline
  133923. * @param renderPipelineName the name of the pipeline to disable the effect in
  133924. * @param renderEffectName the name of the effect to disable
  133925. * @param cameras the cameras that the effect should be disabled on
  133926. */
  133927. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  133928. /**
  133929. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  133930. */
  133931. update(): void;
  133932. /** @hidden */
  133933. _rebuild(): void;
  133934. /**
  133935. * Disposes of the manager and pipelines
  133936. */
  133937. dispose(): void;
  133938. }
  133939. }
  133940. declare module BABYLON {
  133941. interface Scene {
  133942. /** @hidden (Backing field) */
  133943. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  133944. /**
  133945. * Gets the postprocess render pipeline manager
  133946. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  133947. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  133948. */
  133949. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  133950. }
  133951. /**
  133952. * Defines the Render Pipeline scene component responsible to rendering pipelines
  133953. */
  133954. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  133955. /**
  133956. * The component name helpfull to identify the component in the list of scene components.
  133957. */
  133958. readonly name: string;
  133959. /**
  133960. * The scene the component belongs to.
  133961. */
  133962. scene: Scene;
  133963. /**
  133964. * Creates a new instance of the component for the given scene
  133965. * @param scene Defines the scene to register the component in
  133966. */
  133967. constructor(scene: Scene);
  133968. /**
  133969. * Registers the component in a given scene
  133970. */
  133971. register(): void;
  133972. /**
  133973. * Rebuilds the elements related to this component in case of
  133974. * context lost for instance.
  133975. */
  133976. rebuild(): void;
  133977. /**
  133978. * Disposes the component and the associated ressources
  133979. */
  133980. dispose(): void;
  133981. private _gatherRenderTargets;
  133982. }
  133983. }
  133984. declare module BABYLON {
  133985. /**
  133986. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  133987. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  133988. */
  133989. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  133990. private _scene;
  133991. private _camerasToBeAttached;
  133992. /**
  133993. * ID of the sharpen post process,
  133994. */
  133995. private readonly SharpenPostProcessId;
  133996. /**
  133997. * @ignore
  133998. * ID of the image processing post process;
  133999. */
  134000. readonly ImageProcessingPostProcessId: string;
  134001. /**
  134002. * @ignore
  134003. * ID of the Fast Approximate Anti-Aliasing post process;
  134004. */
  134005. readonly FxaaPostProcessId: string;
  134006. /**
  134007. * ID of the chromatic aberration post process,
  134008. */
  134009. private readonly ChromaticAberrationPostProcessId;
  134010. /**
  134011. * ID of the grain post process
  134012. */
  134013. private readonly GrainPostProcessId;
  134014. /**
  134015. * Sharpen post process which will apply a sharpen convolution to enhance edges
  134016. */
  134017. sharpen: SharpenPostProcess;
  134018. private _sharpenEffect;
  134019. private bloom;
  134020. /**
  134021. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  134022. */
  134023. depthOfField: DepthOfFieldEffect;
  134024. /**
  134025. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  134026. */
  134027. fxaa: FxaaPostProcess;
  134028. /**
  134029. * Image post processing pass used to perform operations such as tone mapping or color grading.
  134030. */
  134031. imageProcessing: ImageProcessingPostProcess;
  134032. /**
  134033. * Chromatic aberration post process which will shift rgb colors in the image
  134034. */
  134035. chromaticAberration: ChromaticAberrationPostProcess;
  134036. private _chromaticAberrationEffect;
  134037. /**
  134038. * Grain post process which add noise to the image
  134039. */
  134040. grain: GrainPostProcess;
  134041. private _grainEffect;
  134042. /**
  134043. * Glow post process which adds a glow to emissive areas of the image
  134044. */
  134045. private _glowLayer;
  134046. /**
  134047. * Animations which can be used to tweak settings over a period of time
  134048. */
  134049. animations: Animation[];
  134050. private _imageProcessingConfigurationObserver;
  134051. private _sharpenEnabled;
  134052. private _bloomEnabled;
  134053. private _depthOfFieldEnabled;
  134054. private _depthOfFieldBlurLevel;
  134055. private _fxaaEnabled;
  134056. private _imageProcessingEnabled;
  134057. private _defaultPipelineTextureType;
  134058. private _bloomScale;
  134059. private _chromaticAberrationEnabled;
  134060. private _grainEnabled;
  134061. private _buildAllowed;
  134062. /**
  134063. * Gets active scene
  134064. */
  134065. get scene(): Scene;
  134066. /**
  134067. * Enable or disable the sharpen process from the pipeline
  134068. */
  134069. set sharpenEnabled(enabled: boolean);
  134070. get sharpenEnabled(): boolean;
  134071. private _resizeObserver;
  134072. private _hardwareScaleLevel;
  134073. private _bloomKernel;
  134074. /**
  134075. * Specifies the size of the bloom blur kernel, relative to the final output size
  134076. */
  134077. get bloomKernel(): number;
  134078. set bloomKernel(value: number);
  134079. /**
  134080. * Specifies the weight of the bloom in the final rendering
  134081. */
  134082. private _bloomWeight;
  134083. /**
  134084. * Specifies the luma threshold for the area that will be blurred by the bloom
  134085. */
  134086. private _bloomThreshold;
  134087. private _hdr;
  134088. /**
  134089. * The strength of the bloom.
  134090. */
  134091. set bloomWeight(value: number);
  134092. get bloomWeight(): number;
  134093. /**
  134094. * The strength of the bloom.
  134095. */
  134096. set bloomThreshold(value: number);
  134097. get bloomThreshold(): number;
  134098. /**
  134099. * The scale of the bloom, lower value will provide better performance.
  134100. */
  134101. set bloomScale(value: number);
  134102. get bloomScale(): number;
  134103. /**
  134104. * Enable or disable the bloom from the pipeline
  134105. */
  134106. set bloomEnabled(enabled: boolean);
  134107. get bloomEnabled(): boolean;
  134108. private _rebuildBloom;
  134109. /**
  134110. * If the depth of field is enabled.
  134111. */
  134112. get depthOfFieldEnabled(): boolean;
  134113. set depthOfFieldEnabled(enabled: boolean);
  134114. /**
  134115. * Blur level of the depth of field effect. (Higher blur will effect performance)
  134116. */
  134117. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  134118. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  134119. /**
  134120. * If the anti aliasing is enabled.
  134121. */
  134122. set fxaaEnabled(enabled: boolean);
  134123. get fxaaEnabled(): boolean;
  134124. private _samples;
  134125. /**
  134126. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  134127. */
  134128. set samples(sampleCount: number);
  134129. get samples(): number;
  134130. /**
  134131. * If image processing is enabled.
  134132. */
  134133. set imageProcessingEnabled(enabled: boolean);
  134134. get imageProcessingEnabled(): boolean;
  134135. /**
  134136. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  134137. */
  134138. set glowLayerEnabled(enabled: boolean);
  134139. get glowLayerEnabled(): boolean;
  134140. /**
  134141. * Gets the glow layer (or null if not defined)
  134142. */
  134143. get glowLayer(): Nullable<GlowLayer>;
  134144. /**
  134145. * Enable or disable the chromaticAberration process from the pipeline
  134146. */
  134147. set chromaticAberrationEnabled(enabled: boolean);
  134148. get chromaticAberrationEnabled(): boolean;
  134149. /**
  134150. * Enable or disable the grain process from the pipeline
  134151. */
  134152. set grainEnabled(enabled: boolean);
  134153. get grainEnabled(): boolean;
  134154. /**
  134155. * @constructor
  134156. * @param name - The rendering pipeline name (default: "")
  134157. * @param hdr - If high dynamic range textures should be used (default: true)
  134158. * @param scene - The scene linked to this pipeline (default: the last created scene)
  134159. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  134160. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  134161. */
  134162. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  134163. /**
  134164. * Get the class name
  134165. * @returns "DefaultRenderingPipeline"
  134166. */
  134167. getClassName(): string;
  134168. /**
  134169. * Force the compilation of the entire pipeline.
  134170. */
  134171. prepare(): void;
  134172. private _hasCleared;
  134173. private _prevPostProcess;
  134174. private _prevPrevPostProcess;
  134175. private _setAutoClearAndTextureSharing;
  134176. private _depthOfFieldSceneObserver;
  134177. private _buildPipeline;
  134178. private _disposePostProcesses;
  134179. /**
  134180. * Adds a camera to the pipeline
  134181. * @param camera the camera to be added
  134182. */
  134183. addCamera(camera: Camera): void;
  134184. /**
  134185. * Removes a camera from the pipeline
  134186. * @param camera the camera to remove
  134187. */
  134188. removeCamera(camera: Camera): void;
  134189. /**
  134190. * Dispose of the pipeline and stop all post processes
  134191. */
  134192. dispose(): void;
  134193. /**
  134194. * Serialize the rendering pipeline (Used when exporting)
  134195. * @returns the serialized object
  134196. */
  134197. serialize(): any;
  134198. /**
  134199. * Parse the serialized pipeline
  134200. * @param source Source pipeline.
  134201. * @param scene The scene to load the pipeline to.
  134202. * @param rootUrl The URL of the serialized pipeline.
  134203. * @returns An instantiated pipeline from the serialized object.
  134204. */
  134205. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  134206. }
  134207. }
  134208. declare module BABYLON {
  134209. /** @hidden */
  134210. export var lensHighlightsPixelShader: {
  134211. name: string;
  134212. shader: string;
  134213. };
  134214. }
  134215. declare module BABYLON {
  134216. /** @hidden */
  134217. export var depthOfFieldPixelShader: {
  134218. name: string;
  134219. shader: string;
  134220. };
  134221. }
  134222. declare module BABYLON {
  134223. /**
  134224. * BABYLON.JS Chromatic Aberration GLSL Shader
  134225. * Author: Olivier Guyot
  134226. * Separates very slightly R, G and B colors on the edges of the screen
  134227. * Inspired by Francois Tarlier & Martins Upitis
  134228. */
  134229. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  134230. /**
  134231. * @ignore
  134232. * The chromatic aberration PostProcess id in the pipeline
  134233. */
  134234. LensChromaticAberrationEffect: string;
  134235. /**
  134236. * @ignore
  134237. * The highlights enhancing PostProcess id in the pipeline
  134238. */
  134239. HighlightsEnhancingEffect: string;
  134240. /**
  134241. * @ignore
  134242. * The depth-of-field PostProcess id in the pipeline
  134243. */
  134244. LensDepthOfFieldEffect: string;
  134245. private _scene;
  134246. private _depthTexture;
  134247. private _grainTexture;
  134248. private _chromaticAberrationPostProcess;
  134249. private _highlightsPostProcess;
  134250. private _depthOfFieldPostProcess;
  134251. private _edgeBlur;
  134252. private _grainAmount;
  134253. private _chromaticAberration;
  134254. private _distortion;
  134255. private _highlightsGain;
  134256. private _highlightsThreshold;
  134257. private _dofDistance;
  134258. private _dofAperture;
  134259. private _dofDarken;
  134260. private _dofPentagon;
  134261. private _blurNoise;
  134262. /**
  134263. * @constructor
  134264. *
  134265. * Effect parameters are as follow:
  134266. * {
  134267. * chromatic_aberration: number; // from 0 to x (1 for realism)
  134268. * edge_blur: number; // from 0 to x (1 for realism)
  134269. * distortion: number; // from 0 to x (1 for realism)
  134270. * grain_amount: number; // from 0 to 1
  134271. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  134272. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  134273. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  134274. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  134275. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  134276. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  134277. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  134278. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  134279. * }
  134280. * Note: if an effect parameter is unset, effect is disabled
  134281. *
  134282. * @param name The rendering pipeline name
  134283. * @param parameters - An object containing all parameters (see above)
  134284. * @param scene The scene linked to this pipeline
  134285. * @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)
  134286. * @param cameras The array of cameras that the rendering pipeline will be attached to
  134287. */
  134288. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  134289. /**
  134290. * Get the class name
  134291. * @returns "LensRenderingPipeline"
  134292. */
  134293. getClassName(): string;
  134294. /**
  134295. * Gets associated scene
  134296. */
  134297. get scene(): Scene;
  134298. /**
  134299. * Gets or sets the edge blur
  134300. */
  134301. get edgeBlur(): number;
  134302. set edgeBlur(value: number);
  134303. /**
  134304. * Gets or sets the grain amount
  134305. */
  134306. get grainAmount(): number;
  134307. set grainAmount(value: number);
  134308. /**
  134309. * Gets or sets the chromatic aberration amount
  134310. */
  134311. get chromaticAberration(): number;
  134312. set chromaticAberration(value: number);
  134313. /**
  134314. * Gets or sets the depth of field aperture
  134315. */
  134316. get dofAperture(): number;
  134317. set dofAperture(value: number);
  134318. /**
  134319. * Gets or sets the edge distortion
  134320. */
  134321. get edgeDistortion(): number;
  134322. set edgeDistortion(value: number);
  134323. /**
  134324. * Gets or sets the depth of field distortion
  134325. */
  134326. get dofDistortion(): number;
  134327. set dofDistortion(value: number);
  134328. /**
  134329. * Gets or sets the darken out of focus amount
  134330. */
  134331. get darkenOutOfFocus(): number;
  134332. set darkenOutOfFocus(value: number);
  134333. /**
  134334. * Gets or sets a boolean indicating if blur noise is enabled
  134335. */
  134336. get blurNoise(): boolean;
  134337. set blurNoise(value: boolean);
  134338. /**
  134339. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  134340. */
  134341. get pentagonBokeh(): boolean;
  134342. set pentagonBokeh(value: boolean);
  134343. /**
  134344. * Gets or sets the highlight grain amount
  134345. */
  134346. get highlightsGain(): number;
  134347. set highlightsGain(value: number);
  134348. /**
  134349. * Gets or sets the highlight threshold
  134350. */
  134351. get highlightsThreshold(): number;
  134352. set highlightsThreshold(value: number);
  134353. /**
  134354. * Sets the amount of blur at the edges
  134355. * @param amount blur amount
  134356. */
  134357. setEdgeBlur(amount: number): void;
  134358. /**
  134359. * Sets edge blur to 0
  134360. */
  134361. disableEdgeBlur(): void;
  134362. /**
  134363. * Sets the amout of grain
  134364. * @param amount Amount of grain
  134365. */
  134366. setGrainAmount(amount: number): void;
  134367. /**
  134368. * Set grain amount to 0
  134369. */
  134370. disableGrain(): void;
  134371. /**
  134372. * Sets the chromatic aberration amount
  134373. * @param amount amount of chromatic aberration
  134374. */
  134375. setChromaticAberration(amount: number): void;
  134376. /**
  134377. * Sets chromatic aberration amount to 0
  134378. */
  134379. disableChromaticAberration(): void;
  134380. /**
  134381. * Sets the EdgeDistortion amount
  134382. * @param amount amount of EdgeDistortion
  134383. */
  134384. setEdgeDistortion(amount: number): void;
  134385. /**
  134386. * Sets edge distortion to 0
  134387. */
  134388. disableEdgeDistortion(): void;
  134389. /**
  134390. * Sets the FocusDistance amount
  134391. * @param amount amount of FocusDistance
  134392. */
  134393. setFocusDistance(amount: number): void;
  134394. /**
  134395. * Disables depth of field
  134396. */
  134397. disableDepthOfField(): void;
  134398. /**
  134399. * Sets the Aperture amount
  134400. * @param amount amount of Aperture
  134401. */
  134402. setAperture(amount: number): void;
  134403. /**
  134404. * Sets the DarkenOutOfFocus amount
  134405. * @param amount amount of DarkenOutOfFocus
  134406. */
  134407. setDarkenOutOfFocus(amount: number): void;
  134408. private _pentagonBokehIsEnabled;
  134409. /**
  134410. * Creates a pentagon bokeh effect
  134411. */
  134412. enablePentagonBokeh(): void;
  134413. /**
  134414. * Disables the pentagon bokeh effect
  134415. */
  134416. disablePentagonBokeh(): void;
  134417. /**
  134418. * Enables noise blur
  134419. */
  134420. enableNoiseBlur(): void;
  134421. /**
  134422. * Disables noise blur
  134423. */
  134424. disableNoiseBlur(): void;
  134425. /**
  134426. * Sets the HighlightsGain amount
  134427. * @param amount amount of HighlightsGain
  134428. */
  134429. setHighlightsGain(amount: number): void;
  134430. /**
  134431. * Sets the HighlightsThreshold amount
  134432. * @param amount amount of HighlightsThreshold
  134433. */
  134434. setHighlightsThreshold(amount: number): void;
  134435. /**
  134436. * Disables highlights
  134437. */
  134438. disableHighlights(): void;
  134439. /**
  134440. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  134441. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  134442. */
  134443. dispose(disableDepthRender?: boolean): void;
  134444. private _createChromaticAberrationPostProcess;
  134445. private _createHighlightsPostProcess;
  134446. private _createDepthOfFieldPostProcess;
  134447. private _createGrainTexture;
  134448. }
  134449. }
  134450. declare module BABYLON {
  134451. /** @hidden */
  134452. export var ssao2PixelShader: {
  134453. name: string;
  134454. shader: string;
  134455. };
  134456. }
  134457. declare module BABYLON {
  134458. /** @hidden */
  134459. export var ssaoCombinePixelShader: {
  134460. name: string;
  134461. shader: string;
  134462. };
  134463. }
  134464. declare module BABYLON {
  134465. /**
  134466. * Render pipeline to produce ssao effect
  134467. */
  134468. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  134469. /**
  134470. * @ignore
  134471. * The PassPostProcess id in the pipeline that contains the original scene color
  134472. */
  134473. SSAOOriginalSceneColorEffect: string;
  134474. /**
  134475. * @ignore
  134476. * The SSAO PostProcess id in the pipeline
  134477. */
  134478. SSAORenderEffect: string;
  134479. /**
  134480. * @ignore
  134481. * The horizontal blur PostProcess id in the pipeline
  134482. */
  134483. SSAOBlurHRenderEffect: string;
  134484. /**
  134485. * @ignore
  134486. * The vertical blur PostProcess id in the pipeline
  134487. */
  134488. SSAOBlurVRenderEffect: string;
  134489. /**
  134490. * @ignore
  134491. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  134492. */
  134493. SSAOCombineRenderEffect: string;
  134494. /**
  134495. * The output strength of the SSAO post-process. Default value is 1.0.
  134496. */
  134497. totalStrength: number;
  134498. /**
  134499. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  134500. */
  134501. maxZ: number;
  134502. /**
  134503. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  134504. */
  134505. minZAspect: number;
  134506. private _samples;
  134507. /**
  134508. * Number of samples used for the SSAO calculations. Default value is 8
  134509. */
  134510. set samples(n: number);
  134511. get samples(): number;
  134512. private _textureSamples;
  134513. /**
  134514. * Number of samples to use for antialiasing
  134515. */
  134516. set textureSamples(n: number);
  134517. get textureSamples(): number;
  134518. /**
  134519. * Ratio object used for SSAO ratio and blur ratio
  134520. */
  134521. private _ratio;
  134522. /**
  134523. * Dynamically generated sphere sampler.
  134524. */
  134525. private _sampleSphere;
  134526. /**
  134527. * Blur filter offsets
  134528. */
  134529. private _samplerOffsets;
  134530. private _expensiveBlur;
  134531. /**
  134532. * If bilateral blur should be used
  134533. */
  134534. set expensiveBlur(b: boolean);
  134535. get expensiveBlur(): boolean;
  134536. /**
  134537. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  134538. */
  134539. radius: number;
  134540. /**
  134541. * The base color of the SSAO post-process
  134542. * The final result is "base + ssao" between [0, 1]
  134543. */
  134544. base: number;
  134545. /**
  134546. * Support test.
  134547. */
  134548. static get IsSupported(): boolean;
  134549. private _scene;
  134550. private _depthTexture;
  134551. private _normalTexture;
  134552. private _randomTexture;
  134553. private _originalColorPostProcess;
  134554. private _ssaoPostProcess;
  134555. private _blurHPostProcess;
  134556. private _blurVPostProcess;
  134557. private _ssaoCombinePostProcess;
  134558. /**
  134559. * Gets active scene
  134560. */
  134561. get scene(): Scene;
  134562. /**
  134563. * @constructor
  134564. * @param name The rendering pipeline name
  134565. * @param scene The scene linked to this pipeline
  134566. * @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 }
  134567. * @param cameras The array of cameras that the rendering pipeline will be attached to
  134568. */
  134569. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  134570. /**
  134571. * Get the class name
  134572. * @returns "SSAO2RenderingPipeline"
  134573. */
  134574. getClassName(): string;
  134575. /**
  134576. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  134577. */
  134578. dispose(disableGeometryBufferRenderer?: boolean): void;
  134579. private _createBlurPostProcess;
  134580. /** @hidden */
  134581. _rebuild(): void;
  134582. private _bits;
  134583. private _radicalInverse_VdC;
  134584. private _hammersley;
  134585. private _hemisphereSample_uniform;
  134586. private _generateHemisphere;
  134587. private _createSSAOPostProcess;
  134588. private _createSSAOCombinePostProcess;
  134589. private _createRandomTexture;
  134590. /**
  134591. * Serialize the rendering pipeline (Used when exporting)
  134592. * @returns the serialized object
  134593. */
  134594. serialize(): any;
  134595. /**
  134596. * Parse the serialized pipeline
  134597. * @param source Source pipeline.
  134598. * @param scene The scene to load the pipeline to.
  134599. * @param rootUrl The URL of the serialized pipeline.
  134600. * @returns An instantiated pipeline from the serialized object.
  134601. */
  134602. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  134603. }
  134604. }
  134605. declare module BABYLON {
  134606. /** @hidden */
  134607. export var ssaoPixelShader: {
  134608. name: string;
  134609. shader: string;
  134610. };
  134611. }
  134612. declare module BABYLON {
  134613. /**
  134614. * Render pipeline to produce ssao effect
  134615. */
  134616. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  134617. /**
  134618. * @ignore
  134619. * The PassPostProcess id in the pipeline that contains the original scene color
  134620. */
  134621. SSAOOriginalSceneColorEffect: string;
  134622. /**
  134623. * @ignore
  134624. * The SSAO PostProcess id in the pipeline
  134625. */
  134626. SSAORenderEffect: string;
  134627. /**
  134628. * @ignore
  134629. * The horizontal blur PostProcess id in the pipeline
  134630. */
  134631. SSAOBlurHRenderEffect: string;
  134632. /**
  134633. * @ignore
  134634. * The vertical blur PostProcess id in the pipeline
  134635. */
  134636. SSAOBlurVRenderEffect: string;
  134637. /**
  134638. * @ignore
  134639. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  134640. */
  134641. SSAOCombineRenderEffect: string;
  134642. /**
  134643. * The output strength of the SSAO post-process. Default value is 1.0.
  134644. */
  134645. totalStrength: number;
  134646. /**
  134647. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  134648. */
  134649. radius: number;
  134650. /**
  134651. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  134652. * Must not be equal to fallOff and superior to fallOff.
  134653. * Default value is 0.0075
  134654. */
  134655. area: number;
  134656. /**
  134657. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  134658. * Must not be equal to area and inferior to area.
  134659. * Default value is 0.000001
  134660. */
  134661. fallOff: number;
  134662. /**
  134663. * The base color of the SSAO post-process
  134664. * The final result is "base + ssao" between [0, 1]
  134665. */
  134666. base: number;
  134667. private _scene;
  134668. private _depthTexture;
  134669. private _randomTexture;
  134670. private _originalColorPostProcess;
  134671. private _ssaoPostProcess;
  134672. private _blurHPostProcess;
  134673. private _blurVPostProcess;
  134674. private _ssaoCombinePostProcess;
  134675. private _firstUpdate;
  134676. /**
  134677. * Gets active scene
  134678. */
  134679. get scene(): Scene;
  134680. /**
  134681. * @constructor
  134682. * @param name - The rendering pipeline name
  134683. * @param scene - The scene linked to this pipeline
  134684. * @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 }
  134685. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  134686. */
  134687. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  134688. /**
  134689. * Get the class name
  134690. * @returns "SSAORenderingPipeline"
  134691. */
  134692. getClassName(): string;
  134693. /**
  134694. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  134695. */
  134696. dispose(disableDepthRender?: boolean): void;
  134697. private _createBlurPostProcess;
  134698. /** @hidden */
  134699. _rebuild(): void;
  134700. private _createSSAOPostProcess;
  134701. private _createSSAOCombinePostProcess;
  134702. private _createRandomTexture;
  134703. }
  134704. }
  134705. declare module BABYLON {
  134706. /** @hidden */
  134707. export var standardPixelShader: {
  134708. name: string;
  134709. shader: string;
  134710. };
  134711. }
  134712. declare module BABYLON {
  134713. /**
  134714. * Standard rendering pipeline
  134715. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  134716. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  134717. */
  134718. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  134719. /**
  134720. * Public members
  134721. */
  134722. /**
  134723. * Post-process which contains the original scene color before the pipeline applies all the effects
  134724. */
  134725. originalPostProcess: Nullable<PostProcess>;
  134726. /**
  134727. * Post-process used to down scale an image x4
  134728. */
  134729. downSampleX4PostProcess: Nullable<PostProcess>;
  134730. /**
  134731. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  134732. */
  134733. brightPassPostProcess: Nullable<PostProcess>;
  134734. /**
  134735. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  134736. */
  134737. blurHPostProcesses: PostProcess[];
  134738. /**
  134739. * Post-process array storing all the vertical blur post-processes used by the pipeline
  134740. */
  134741. blurVPostProcesses: PostProcess[];
  134742. /**
  134743. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  134744. */
  134745. textureAdderPostProcess: Nullable<PostProcess>;
  134746. /**
  134747. * Post-process used to create volumetric lighting effect
  134748. */
  134749. volumetricLightPostProcess: Nullable<PostProcess>;
  134750. /**
  134751. * Post-process used to smooth the previous volumetric light post-process on the X axis
  134752. */
  134753. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  134754. /**
  134755. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  134756. */
  134757. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  134758. /**
  134759. * Post-process used to merge the volumetric light effect and the real scene color
  134760. */
  134761. volumetricLightMergePostProces: Nullable<PostProcess>;
  134762. /**
  134763. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  134764. */
  134765. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  134766. /**
  134767. * Base post-process used to calculate the average luminance of the final image for HDR
  134768. */
  134769. luminancePostProcess: Nullable<PostProcess>;
  134770. /**
  134771. * Post-processes used to create down sample post-processes in order to get
  134772. * the average luminance of the final image for HDR
  134773. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  134774. */
  134775. luminanceDownSamplePostProcesses: PostProcess[];
  134776. /**
  134777. * Post-process used to create a HDR effect (light adaptation)
  134778. */
  134779. hdrPostProcess: Nullable<PostProcess>;
  134780. /**
  134781. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  134782. */
  134783. textureAdderFinalPostProcess: Nullable<PostProcess>;
  134784. /**
  134785. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  134786. */
  134787. lensFlareFinalPostProcess: Nullable<PostProcess>;
  134788. /**
  134789. * Post-process used to merge the final HDR post-process and the real scene color
  134790. */
  134791. hdrFinalPostProcess: Nullable<PostProcess>;
  134792. /**
  134793. * Post-process used to create a lens flare effect
  134794. */
  134795. lensFlarePostProcess: Nullable<PostProcess>;
  134796. /**
  134797. * Post-process that merges the result of the lens flare post-process and the real scene color
  134798. */
  134799. lensFlareComposePostProcess: Nullable<PostProcess>;
  134800. /**
  134801. * Post-process used to create a motion blur effect
  134802. */
  134803. motionBlurPostProcess: Nullable<PostProcess>;
  134804. /**
  134805. * Post-process used to create a depth of field effect
  134806. */
  134807. depthOfFieldPostProcess: Nullable<PostProcess>;
  134808. /**
  134809. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  134810. */
  134811. fxaaPostProcess: Nullable<FxaaPostProcess>;
  134812. /**
  134813. * Represents the brightness threshold in order to configure the illuminated surfaces
  134814. */
  134815. brightThreshold: number;
  134816. /**
  134817. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  134818. */
  134819. blurWidth: number;
  134820. /**
  134821. * Sets if the blur for highlighted surfaces must be only horizontal
  134822. */
  134823. horizontalBlur: boolean;
  134824. /**
  134825. * Gets the overall exposure used by the pipeline
  134826. */
  134827. get exposure(): number;
  134828. /**
  134829. * Sets the overall exposure used by the pipeline
  134830. */
  134831. set exposure(value: number);
  134832. /**
  134833. * Texture used typically to simulate "dirty" on camera lens
  134834. */
  134835. lensTexture: Nullable<Texture>;
  134836. /**
  134837. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  134838. */
  134839. volumetricLightCoefficient: number;
  134840. /**
  134841. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  134842. */
  134843. volumetricLightPower: number;
  134844. /**
  134845. * Used the set the blur intensity to smooth the volumetric lights
  134846. */
  134847. volumetricLightBlurScale: number;
  134848. /**
  134849. * Light (spot or directional) used to generate the volumetric lights rays
  134850. * The source light must have a shadow generate so the pipeline can get its
  134851. * depth map
  134852. */
  134853. sourceLight: Nullable<SpotLight | DirectionalLight>;
  134854. /**
  134855. * For eye adaptation, represents the minimum luminance the eye can see
  134856. */
  134857. hdrMinimumLuminance: number;
  134858. /**
  134859. * For eye adaptation, represents the decrease luminance speed
  134860. */
  134861. hdrDecreaseRate: number;
  134862. /**
  134863. * For eye adaptation, represents the increase luminance speed
  134864. */
  134865. hdrIncreaseRate: number;
  134866. /**
  134867. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  134868. */
  134869. get hdrAutoExposure(): boolean;
  134870. /**
  134871. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  134872. */
  134873. set hdrAutoExposure(value: boolean);
  134874. /**
  134875. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  134876. */
  134877. lensColorTexture: Nullable<Texture>;
  134878. /**
  134879. * The overall strengh for the lens flare effect
  134880. */
  134881. lensFlareStrength: number;
  134882. /**
  134883. * Dispersion coefficient for lens flare ghosts
  134884. */
  134885. lensFlareGhostDispersal: number;
  134886. /**
  134887. * Main lens flare halo width
  134888. */
  134889. lensFlareHaloWidth: number;
  134890. /**
  134891. * Based on the lens distortion effect, defines how much the lens flare result
  134892. * is distorted
  134893. */
  134894. lensFlareDistortionStrength: number;
  134895. /**
  134896. * Configures the blur intensity used for for lens flare (halo)
  134897. */
  134898. lensFlareBlurWidth: number;
  134899. /**
  134900. * Lens star texture must be used to simulate rays on the flares and is available
  134901. * in the documentation
  134902. */
  134903. lensStarTexture: Nullable<Texture>;
  134904. /**
  134905. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  134906. * flare effect by taking account of the dirt texture
  134907. */
  134908. lensFlareDirtTexture: Nullable<Texture>;
  134909. /**
  134910. * Represents the focal length for the depth of field effect
  134911. */
  134912. depthOfFieldDistance: number;
  134913. /**
  134914. * Represents the blur intensity for the blurred part of the depth of field effect
  134915. */
  134916. depthOfFieldBlurWidth: number;
  134917. /**
  134918. * Gets how much the image is blurred by the movement while using the motion blur post-process
  134919. */
  134920. get motionStrength(): number;
  134921. /**
  134922. * Sets how much the image is blurred by the movement while using the motion blur post-process
  134923. */
  134924. set motionStrength(strength: number);
  134925. /**
  134926. * Gets wether or not the motion blur post-process is object based or screen based.
  134927. */
  134928. get objectBasedMotionBlur(): boolean;
  134929. /**
  134930. * Sets wether or not the motion blur post-process should be object based or screen based
  134931. */
  134932. set objectBasedMotionBlur(value: boolean);
  134933. /**
  134934. * List of animations for the pipeline (IAnimatable implementation)
  134935. */
  134936. animations: Animation[];
  134937. /**
  134938. * Private members
  134939. */
  134940. private _scene;
  134941. private _currentDepthOfFieldSource;
  134942. private _basePostProcess;
  134943. private _fixedExposure;
  134944. private _currentExposure;
  134945. private _hdrAutoExposure;
  134946. private _hdrCurrentLuminance;
  134947. private _motionStrength;
  134948. private _isObjectBasedMotionBlur;
  134949. private _floatTextureType;
  134950. private _camerasToBeAttached;
  134951. private _ratio;
  134952. private _bloomEnabled;
  134953. private _depthOfFieldEnabled;
  134954. private _vlsEnabled;
  134955. private _lensFlareEnabled;
  134956. private _hdrEnabled;
  134957. private _motionBlurEnabled;
  134958. private _fxaaEnabled;
  134959. private _motionBlurSamples;
  134960. private _volumetricLightStepsCount;
  134961. private _samples;
  134962. /**
  134963. * @ignore
  134964. * Specifies if the bloom pipeline is enabled
  134965. */
  134966. get BloomEnabled(): boolean;
  134967. set BloomEnabled(enabled: boolean);
  134968. /**
  134969. * @ignore
  134970. * Specifies if the depth of field pipeline is enabed
  134971. */
  134972. get DepthOfFieldEnabled(): boolean;
  134973. set DepthOfFieldEnabled(enabled: boolean);
  134974. /**
  134975. * @ignore
  134976. * Specifies if the lens flare pipeline is enabed
  134977. */
  134978. get LensFlareEnabled(): boolean;
  134979. set LensFlareEnabled(enabled: boolean);
  134980. /**
  134981. * @ignore
  134982. * Specifies if the HDR pipeline is enabled
  134983. */
  134984. get HDREnabled(): boolean;
  134985. set HDREnabled(enabled: boolean);
  134986. /**
  134987. * @ignore
  134988. * Specifies if the volumetric lights scattering effect is enabled
  134989. */
  134990. get VLSEnabled(): boolean;
  134991. set VLSEnabled(enabled: boolean);
  134992. /**
  134993. * @ignore
  134994. * Specifies if the motion blur effect is enabled
  134995. */
  134996. get MotionBlurEnabled(): boolean;
  134997. set MotionBlurEnabled(enabled: boolean);
  134998. /**
  134999. * Specifies if anti-aliasing is enabled
  135000. */
  135001. get fxaaEnabled(): boolean;
  135002. set fxaaEnabled(enabled: boolean);
  135003. /**
  135004. * Specifies the number of steps used to calculate the volumetric lights
  135005. * Typically in interval [50, 200]
  135006. */
  135007. get volumetricLightStepsCount(): number;
  135008. set volumetricLightStepsCount(count: number);
  135009. /**
  135010. * Specifies the number of samples used for the motion blur effect
  135011. * Typically in interval [16, 64]
  135012. */
  135013. get motionBlurSamples(): number;
  135014. set motionBlurSamples(samples: number);
  135015. /**
  135016. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  135017. */
  135018. get samples(): number;
  135019. set samples(sampleCount: number);
  135020. /**
  135021. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  135022. * @constructor
  135023. * @param name The rendering pipeline name
  135024. * @param scene The scene linked to this pipeline
  135025. * @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)
  135026. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  135027. * @param cameras The array of cameras that the rendering pipeline will be attached to
  135028. */
  135029. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  135030. private _buildPipeline;
  135031. private _createDownSampleX4PostProcess;
  135032. private _createBrightPassPostProcess;
  135033. private _createBlurPostProcesses;
  135034. private _createTextureAdderPostProcess;
  135035. private _createVolumetricLightPostProcess;
  135036. private _createLuminancePostProcesses;
  135037. private _createHdrPostProcess;
  135038. private _createLensFlarePostProcess;
  135039. private _createDepthOfFieldPostProcess;
  135040. private _createMotionBlurPostProcess;
  135041. private _getDepthTexture;
  135042. private _disposePostProcesses;
  135043. /**
  135044. * Dispose of the pipeline and stop all post processes
  135045. */
  135046. dispose(): void;
  135047. /**
  135048. * Serialize the rendering pipeline (Used when exporting)
  135049. * @returns the serialized object
  135050. */
  135051. serialize(): any;
  135052. /**
  135053. * Parse the serialized pipeline
  135054. * @param source Source pipeline.
  135055. * @param scene The scene to load the pipeline to.
  135056. * @param rootUrl The URL of the serialized pipeline.
  135057. * @returns An instantiated pipeline from the serialized object.
  135058. */
  135059. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  135060. /**
  135061. * Luminance steps
  135062. */
  135063. static LuminanceSteps: number;
  135064. }
  135065. }
  135066. declare module BABYLON {
  135067. /** @hidden */
  135068. export var tonemapPixelShader: {
  135069. name: string;
  135070. shader: string;
  135071. };
  135072. }
  135073. declare module BABYLON {
  135074. /** Defines operator used for tonemapping */
  135075. export enum TonemappingOperator {
  135076. /** Hable */
  135077. Hable = 0,
  135078. /** Reinhard */
  135079. Reinhard = 1,
  135080. /** HejiDawson */
  135081. HejiDawson = 2,
  135082. /** Photographic */
  135083. Photographic = 3
  135084. }
  135085. /**
  135086. * Defines a post process to apply tone mapping
  135087. */
  135088. export class TonemapPostProcess extends PostProcess {
  135089. private _operator;
  135090. /** Defines the required exposure adjustement */
  135091. exposureAdjustment: number;
  135092. /**
  135093. * Creates a new TonemapPostProcess
  135094. * @param name defines the name of the postprocess
  135095. * @param _operator defines the operator to use
  135096. * @param exposureAdjustment defines the required exposure adjustement
  135097. * @param camera defines the camera to use (can be null)
  135098. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  135099. * @param engine defines the hosting engine (can be ignore if camera is set)
  135100. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  135101. */
  135102. constructor(name: string, _operator: TonemappingOperator,
  135103. /** Defines the required exposure adjustement */
  135104. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  135105. }
  135106. }
  135107. declare module BABYLON {
  135108. /** @hidden */
  135109. export var depthVertexShader: {
  135110. name: string;
  135111. shader: string;
  135112. };
  135113. }
  135114. declare module BABYLON {
  135115. /** @hidden */
  135116. export var volumetricLightScatteringPixelShader: {
  135117. name: string;
  135118. shader: string;
  135119. };
  135120. }
  135121. declare module BABYLON {
  135122. /** @hidden */
  135123. export var volumetricLightScatteringPassVertexShader: {
  135124. name: string;
  135125. shader: string;
  135126. };
  135127. }
  135128. declare module BABYLON {
  135129. /** @hidden */
  135130. export var volumetricLightScatteringPassPixelShader: {
  135131. name: string;
  135132. shader: string;
  135133. };
  135134. }
  135135. declare module BABYLON {
  135136. /**
  135137. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  135138. */
  135139. export class VolumetricLightScatteringPostProcess extends PostProcess {
  135140. private _volumetricLightScatteringPass;
  135141. private _volumetricLightScatteringRTT;
  135142. private _viewPort;
  135143. private _screenCoordinates;
  135144. private _cachedDefines;
  135145. /**
  135146. * If not undefined, the mesh position is computed from the attached node position
  135147. */
  135148. attachedNode: {
  135149. position: Vector3;
  135150. };
  135151. /**
  135152. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  135153. */
  135154. customMeshPosition: Vector3;
  135155. /**
  135156. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  135157. */
  135158. useCustomMeshPosition: boolean;
  135159. /**
  135160. * If the post-process should inverse the light scattering direction
  135161. */
  135162. invert: boolean;
  135163. /**
  135164. * The internal mesh used by the post-process
  135165. */
  135166. mesh: Mesh;
  135167. /**
  135168. * @hidden
  135169. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  135170. */
  135171. get useDiffuseColor(): boolean;
  135172. set useDiffuseColor(useDiffuseColor: boolean);
  135173. /**
  135174. * Array containing the excluded meshes not rendered in the internal pass
  135175. */
  135176. excludedMeshes: AbstractMesh[];
  135177. /**
  135178. * Controls the overall intensity of the post-process
  135179. */
  135180. exposure: number;
  135181. /**
  135182. * Dissipates each sample's contribution in range [0, 1]
  135183. */
  135184. decay: number;
  135185. /**
  135186. * Controls the overall intensity of each sample
  135187. */
  135188. weight: number;
  135189. /**
  135190. * Controls the density of each sample
  135191. */
  135192. density: number;
  135193. /**
  135194. * @constructor
  135195. * @param name The post-process name
  135196. * @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)
  135197. * @param camera The camera that the post-process will be attached to
  135198. * @param mesh The mesh used to create the light scattering
  135199. * @param samples The post-process quality, default 100
  135200. * @param samplingModeThe post-process filtering mode
  135201. * @param engine The babylon engine
  135202. * @param reusable If the post-process is reusable
  135203. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  135204. */
  135205. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  135206. /**
  135207. * Returns the string "VolumetricLightScatteringPostProcess"
  135208. * @returns "VolumetricLightScatteringPostProcess"
  135209. */
  135210. getClassName(): string;
  135211. private _isReady;
  135212. /**
  135213. * Sets the new light position for light scattering effect
  135214. * @param position The new custom light position
  135215. */
  135216. setCustomMeshPosition(position: Vector3): void;
  135217. /**
  135218. * Returns the light position for light scattering effect
  135219. * @return Vector3 The custom light position
  135220. */
  135221. getCustomMeshPosition(): Vector3;
  135222. /**
  135223. * Disposes the internal assets and detaches the post-process from the camera
  135224. */
  135225. dispose(camera: Camera): void;
  135226. /**
  135227. * Returns the render target texture used by the post-process
  135228. * @return the render target texture used by the post-process
  135229. */
  135230. getPass(): RenderTargetTexture;
  135231. private _meshExcluded;
  135232. private _createPass;
  135233. private _updateMeshScreenCoordinates;
  135234. /**
  135235. * Creates a default mesh for the Volumeric Light Scattering post-process
  135236. * @param name The mesh name
  135237. * @param scene The scene where to create the mesh
  135238. * @return the default mesh
  135239. */
  135240. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  135241. }
  135242. }
  135243. declare module BABYLON {
  135244. interface Scene {
  135245. /** @hidden (Backing field) */
  135246. _boundingBoxRenderer: BoundingBoxRenderer;
  135247. /** @hidden (Backing field) */
  135248. _forceShowBoundingBoxes: boolean;
  135249. /**
  135250. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  135251. */
  135252. forceShowBoundingBoxes: boolean;
  135253. /**
  135254. * Gets the bounding box renderer associated with the scene
  135255. * @returns a BoundingBoxRenderer
  135256. */
  135257. getBoundingBoxRenderer(): BoundingBoxRenderer;
  135258. }
  135259. interface AbstractMesh {
  135260. /** @hidden (Backing field) */
  135261. _showBoundingBox: boolean;
  135262. /**
  135263. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  135264. */
  135265. showBoundingBox: boolean;
  135266. }
  135267. /**
  135268. * Component responsible of rendering the bounding box of the meshes in a scene.
  135269. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  135270. */
  135271. export class BoundingBoxRenderer implements ISceneComponent {
  135272. /**
  135273. * The component name helpfull to identify the component in the list of scene components.
  135274. */
  135275. readonly name: string;
  135276. /**
  135277. * The scene the component belongs to.
  135278. */
  135279. scene: Scene;
  135280. /**
  135281. * Color of the bounding box lines placed in front of an object
  135282. */
  135283. frontColor: Color3;
  135284. /**
  135285. * Color of the bounding box lines placed behind an object
  135286. */
  135287. backColor: Color3;
  135288. /**
  135289. * Defines if the renderer should show the back lines or not
  135290. */
  135291. showBackLines: boolean;
  135292. /**
  135293. * @hidden
  135294. */
  135295. renderList: SmartArray<BoundingBox>;
  135296. private _colorShader;
  135297. private _vertexBuffers;
  135298. private _indexBuffer;
  135299. private _fillIndexBuffer;
  135300. private _fillIndexData;
  135301. /**
  135302. * Instantiates a new bounding box renderer in a scene.
  135303. * @param scene the scene the renderer renders in
  135304. */
  135305. constructor(scene: Scene);
  135306. /**
  135307. * Registers the component in a given scene
  135308. */
  135309. register(): void;
  135310. private _evaluateSubMesh;
  135311. private _activeMesh;
  135312. private _prepareRessources;
  135313. private _createIndexBuffer;
  135314. /**
  135315. * Rebuilds the elements related to this component in case of
  135316. * context lost for instance.
  135317. */
  135318. rebuild(): void;
  135319. /**
  135320. * @hidden
  135321. */
  135322. reset(): void;
  135323. /**
  135324. * Render the bounding boxes of a specific rendering group
  135325. * @param renderingGroupId defines the rendering group to render
  135326. */
  135327. render(renderingGroupId: number): void;
  135328. /**
  135329. * In case of occlusion queries, we can render the occlusion bounding box through this method
  135330. * @param mesh Define the mesh to render the occlusion bounding box for
  135331. */
  135332. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  135333. /**
  135334. * Dispose and release the resources attached to this renderer.
  135335. */
  135336. dispose(): void;
  135337. }
  135338. }
  135339. declare module BABYLON {
  135340. /** @hidden */
  135341. export var depthPixelShader: {
  135342. name: string;
  135343. shader: string;
  135344. };
  135345. }
  135346. declare module BABYLON {
  135347. /**
  135348. * This represents a depth renderer in Babylon.
  135349. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  135350. */
  135351. export class DepthRenderer {
  135352. private _scene;
  135353. private _depthMap;
  135354. private _effect;
  135355. private readonly _storeNonLinearDepth;
  135356. private readonly _clearColor;
  135357. /** Get if the depth renderer is using packed depth or not */
  135358. readonly isPacked: boolean;
  135359. private _cachedDefines;
  135360. private _camera;
  135361. /**
  135362. * Specifiess that the depth renderer will only be used within
  135363. * the camera it is created for.
  135364. * This can help forcing its rendering during the camera processing.
  135365. */
  135366. useOnlyInActiveCamera: boolean;
  135367. /** @hidden */
  135368. static _SceneComponentInitialization: (scene: Scene) => void;
  135369. /**
  135370. * Instantiates a depth renderer
  135371. * @param scene The scene the renderer belongs to
  135372. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  135373. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  135374. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  135375. */
  135376. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  135377. /**
  135378. * Creates the depth rendering effect and checks if the effect is ready.
  135379. * @param subMesh The submesh to be used to render the depth map of
  135380. * @param useInstances If multiple world instances should be used
  135381. * @returns if the depth renderer is ready to render the depth map
  135382. */
  135383. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135384. /**
  135385. * Gets the texture which the depth map will be written to.
  135386. * @returns The depth map texture
  135387. */
  135388. getDepthMap(): RenderTargetTexture;
  135389. /**
  135390. * Disposes of the depth renderer.
  135391. */
  135392. dispose(): void;
  135393. }
  135394. }
  135395. declare module BABYLON {
  135396. interface Scene {
  135397. /** @hidden (Backing field) */
  135398. _depthRenderer: {
  135399. [id: string]: DepthRenderer;
  135400. };
  135401. /**
  135402. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  135403. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  135404. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  135405. * @returns the created depth renderer
  135406. */
  135407. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  135408. /**
  135409. * Disables a depth renderer for a given camera
  135410. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  135411. */
  135412. disableDepthRenderer(camera?: Nullable<Camera>): void;
  135413. }
  135414. /**
  135415. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  135416. * in several rendering techniques.
  135417. */
  135418. export class DepthRendererSceneComponent implements ISceneComponent {
  135419. /**
  135420. * The component name helpfull to identify the component in the list of scene components.
  135421. */
  135422. readonly name: string;
  135423. /**
  135424. * The scene the component belongs to.
  135425. */
  135426. scene: Scene;
  135427. /**
  135428. * Creates a new instance of the component for the given scene
  135429. * @param scene Defines the scene to register the component in
  135430. */
  135431. constructor(scene: Scene);
  135432. /**
  135433. * Registers the component in a given scene
  135434. */
  135435. register(): void;
  135436. /**
  135437. * Rebuilds the elements related to this component in case of
  135438. * context lost for instance.
  135439. */
  135440. rebuild(): void;
  135441. /**
  135442. * Disposes the component and the associated ressources
  135443. */
  135444. dispose(): void;
  135445. private _gatherRenderTargets;
  135446. private _gatherActiveCameraRenderTargets;
  135447. }
  135448. }
  135449. declare module BABYLON {
  135450. /** @hidden */
  135451. export var outlinePixelShader: {
  135452. name: string;
  135453. shader: string;
  135454. };
  135455. }
  135456. declare module BABYLON {
  135457. /** @hidden */
  135458. export var outlineVertexShader: {
  135459. name: string;
  135460. shader: string;
  135461. };
  135462. }
  135463. declare module BABYLON {
  135464. interface Scene {
  135465. /** @hidden */
  135466. _outlineRenderer: OutlineRenderer;
  135467. /**
  135468. * Gets the outline renderer associated with the scene
  135469. * @returns a OutlineRenderer
  135470. */
  135471. getOutlineRenderer(): OutlineRenderer;
  135472. }
  135473. interface AbstractMesh {
  135474. /** @hidden (Backing field) */
  135475. _renderOutline: boolean;
  135476. /**
  135477. * Gets or sets a boolean indicating if the outline must be rendered as well
  135478. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  135479. */
  135480. renderOutline: boolean;
  135481. /** @hidden (Backing field) */
  135482. _renderOverlay: boolean;
  135483. /**
  135484. * Gets or sets a boolean indicating if the overlay must be rendered as well
  135485. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  135486. */
  135487. renderOverlay: boolean;
  135488. }
  135489. /**
  135490. * This class is responsible to draw bothe outline/overlay of meshes.
  135491. * It should not be used directly but through the available method on mesh.
  135492. */
  135493. export class OutlineRenderer implements ISceneComponent {
  135494. /**
  135495. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  135496. */
  135497. private static _StencilReference;
  135498. /**
  135499. * The name of the component. Each component must have a unique name.
  135500. */
  135501. name: string;
  135502. /**
  135503. * The scene the component belongs to.
  135504. */
  135505. scene: Scene;
  135506. /**
  135507. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  135508. */
  135509. zOffset: number;
  135510. private _engine;
  135511. private _effect;
  135512. private _cachedDefines;
  135513. private _savedDepthWrite;
  135514. /**
  135515. * Instantiates a new outline renderer. (There could be only one per scene).
  135516. * @param scene Defines the scene it belongs to
  135517. */
  135518. constructor(scene: Scene);
  135519. /**
  135520. * Register the component to one instance of a scene.
  135521. */
  135522. register(): void;
  135523. /**
  135524. * Rebuilds the elements related to this component in case of
  135525. * context lost for instance.
  135526. */
  135527. rebuild(): void;
  135528. /**
  135529. * Disposes the component and the associated ressources.
  135530. */
  135531. dispose(): void;
  135532. /**
  135533. * Renders the outline in the canvas.
  135534. * @param subMesh Defines the sumesh to render
  135535. * @param batch Defines the batch of meshes in case of instances
  135536. * @param useOverlay Defines if the rendering is for the overlay or the outline
  135537. */
  135538. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  135539. /**
  135540. * Returns whether or not the outline renderer is ready for a given submesh.
  135541. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  135542. * @param subMesh Defines the submesh to check readyness for
  135543. * @param useInstances Defines wheter wee are trying to render instances or not
  135544. * @returns true if ready otherwise false
  135545. */
  135546. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135547. private _beforeRenderingMesh;
  135548. private _afterRenderingMesh;
  135549. }
  135550. }
  135551. declare module BABYLON {
  135552. /**
  135553. * Defines the basic options interface of a Sprite Frame Source Size.
  135554. */
  135555. export interface ISpriteJSONSpriteSourceSize {
  135556. /**
  135557. * number of the original width of the Frame
  135558. */
  135559. w: number;
  135560. /**
  135561. * number of the original height of the Frame
  135562. */
  135563. h: number;
  135564. }
  135565. /**
  135566. * Defines the basic options interface of a Sprite Frame Data.
  135567. */
  135568. export interface ISpriteJSONSpriteFrameData {
  135569. /**
  135570. * number of the x offset of the Frame
  135571. */
  135572. x: number;
  135573. /**
  135574. * number of the y offset of the Frame
  135575. */
  135576. y: number;
  135577. /**
  135578. * number of the width of the Frame
  135579. */
  135580. w: number;
  135581. /**
  135582. * number of the height of the Frame
  135583. */
  135584. h: number;
  135585. }
  135586. /**
  135587. * Defines the basic options interface of a JSON Sprite.
  135588. */
  135589. export interface ISpriteJSONSprite {
  135590. /**
  135591. * string name of the Frame
  135592. */
  135593. filename: string;
  135594. /**
  135595. * ISpriteJSONSpriteFrame basic object of the frame data
  135596. */
  135597. frame: ISpriteJSONSpriteFrameData;
  135598. /**
  135599. * boolean to flag is the frame was rotated.
  135600. */
  135601. rotated: boolean;
  135602. /**
  135603. * boolean to flag is the frame was trimmed.
  135604. */
  135605. trimmed: boolean;
  135606. /**
  135607. * ISpriteJSONSpriteFrame basic object of the source data
  135608. */
  135609. spriteSourceSize: ISpriteJSONSpriteFrameData;
  135610. /**
  135611. * ISpriteJSONSpriteFrame basic object of the source data
  135612. */
  135613. sourceSize: ISpriteJSONSpriteSourceSize;
  135614. }
  135615. /**
  135616. * Defines the basic options interface of a JSON atlas.
  135617. */
  135618. export interface ISpriteJSONAtlas {
  135619. /**
  135620. * Array of objects that contain the frame data.
  135621. */
  135622. frames: Array<ISpriteJSONSprite>;
  135623. /**
  135624. * object basic object containing the sprite meta data.
  135625. */
  135626. meta?: object;
  135627. }
  135628. }
  135629. declare module BABYLON {
  135630. /** @hidden */
  135631. export var spriteMapPixelShader: {
  135632. name: string;
  135633. shader: string;
  135634. };
  135635. }
  135636. declare module BABYLON {
  135637. /** @hidden */
  135638. export var spriteMapVertexShader: {
  135639. name: string;
  135640. shader: string;
  135641. };
  135642. }
  135643. declare module BABYLON {
  135644. /**
  135645. * Defines the basic options interface of a SpriteMap
  135646. */
  135647. export interface ISpriteMapOptions {
  135648. /**
  135649. * Vector2 of the number of cells in the grid.
  135650. */
  135651. stageSize?: Vector2;
  135652. /**
  135653. * Vector2 of the size of the output plane in World Units.
  135654. */
  135655. outputSize?: Vector2;
  135656. /**
  135657. * Vector3 of the position of the output plane in World Units.
  135658. */
  135659. outputPosition?: Vector3;
  135660. /**
  135661. * Vector3 of the rotation of the output plane.
  135662. */
  135663. outputRotation?: Vector3;
  135664. /**
  135665. * number of layers that the system will reserve in resources.
  135666. */
  135667. layerCount?: number;
  135668. /**
  135669. * number of max animation frames a single cell will reserve in resources.
  135670. */
  135671. maxAnimationFrames?: number;
  135672. /**
  135673. * number cell index of the base tile when the system compiles.
  135674. */
  135675. baseTile?: number;
  135676. /**
  135677. * boolean flip the sprite after its been repositioned by the framing data.
  135678. */
  135679. flipU?: boolean;
  135680. /**
  135681. * Vector3 scalar of the global RGB values of the SpriteMap.
  135682. */
  135683. colorMultiply?: Vector3;
  135684. }
  135685. /**
  135686. * Defines the IDisposable interface in order to be cleanable from resources.
  135687. */
  135688. export interface ISpriteMap extends IDisposable {
  135689. /**
  135690. * String name of the SpriteMap.
  135691. */
  135692. name: string;
  135693. /**
  135694. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  135695. */
  135696. atlasJSON: ISpriteJSONAtlas;
  135697. /**
  135698. * Texture of the SpriteMap.
  135699. */
  135700. spriteSheet: Texture;
  135701. /**
  135702. * The parameters to initialize the SpriteMap with.
  135703. */
  135704. options: ISpriteMapOptions;
  135705. }
  135706. /**
  135707. * Class used to manage a grid restricted sprite deployment on an Output plane.
  135708. */
  135709. export class SpriteMap implements ISpriteMap {
  135710. /** The Name of the spriteMap */
  135711. name: string;
  135712. /** The JSON file with the frame and meta data */
  135713. atlasJSON: ISpriteJSONAtlas;
  135714. /** The systems Sprite Sheet Texture */
  135715. spriteSheet: Texture;
  135716. /** Arguments passed with the Constructor */
  135717. options: ISpriteMapOptions;
  135718. /** Public Sprite Storage array, parsed from atlasJSON */
  135719. sprites: Array<ISpriteJSONSprite>;
  135720. /** Returns the Number of Sprites in the System */
  135721. get spriteCount(): number;
  135722. /** Returns the Position of Output Plane*/
  135723. get position(): Vector3;
  135724. /** Returns the Position of Output Plane*/
  135725. set position(v: Vector3);
  135726. /** Returns the Rotation of Output Plane*/
  135727. get rotation(): Vector3;
  135728. /** Returns the Rotation of Output Plane*/
  135729. set rotation(v: Vector3);
  135730. /** Sets the AnimationMap*/
  135731. get animationMap(): RawTexture;
  135732. /** Sets the AnimationMap*/
  135733. set animationMap(v: RawTexture);
  135734. /** Scene that the SpriteMap was created in */
  135735. private _scene;
  135736. /** Texture Buffer of Float32 that holds tile frame data*/
  135737. private _frameMap;
  135738. /** Texture Buffers of Float32 that holds tileMap data*/
  135739. private _tileMaps;
  135740. /** Texture Buffer of Float32 that holds Animation Data*/
  135741. private _animationMap;
  135742. /** Custom ShaderMaterial Central to the System*/
  135743. private _material;
  135744. /** Custom ShaderMaterial Central to the System*/
  135745. private _output;
  135746. /** Systems Time Ticker*/
  135747. private _time;
  135748. /**
  135749. * Creates a new SpriteMap
  135750. * @param name defines the SpriteMaps Name
  135751. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  135752. * @param spriteSheet is the Texture that the Sprites are on.
  135753. * @param options a basic deployment configuration
  135754. * @param scene The Scene that the map is deployed on
  135755. */
  135756. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  135757. /**
  135758. * Returns tileID location
  135759. * @returns Vector2 the cell position ID
  135760. */
  135761. getTileID(): Vector2;
  135762. /**
  135763. * Gets the UV location of the mouse over the SpriteMap.
  135764. * @returns Vector2 the UV position of the mouse interaction
  135765. */
  135766. getMousePosition(): Vector2;
  135767. /**
  135768. * Creates the "frame" texture Buffer
  135769. * -------------------------------------
  135770. * Structure of frames
  135771. * "filename": "Falling-Water-2.png",
  135772. * "frame": {"x":69,"y":103,"w":24,"h":32},
  135773. * "rotated": true,
  135774. * "trimmed": true,
  135775. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  135776. * "sourceSize": {"w":32,"h":32}
  135777. * @returns RawTexture of the frameMap
  135778. */
  135779. private _createFrameBuffer;
  135780. /**
  135781. * Creates the tileMap texture Buffer
  135782. * @param buffer normally and array of numbers, or a false to generate from scratch
  135783. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  135784. * @returns RawTexture of the tileMap
  135785. */
  135786. private _createTileBuffer;
  135787. /**
  135788. * Modifies the data of the tileMaps
  135789. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  135790. * @param pos is the iVector2 Coordinates of the Tile
  135791. * @param tile The SpriteIndex of the new Tile
  135792. */
  135793. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  135794. /**
  135795. * Creates the animationMap texture Buffer
  135796. * @param buffer normally and array of numbers, or a false to generate from scratch
  135797. * @returns RawTexture of the animationMap
  135798. */
  135799. private _createTileAnimationBuffer;
  135800. /**
  135801. * Modifies the data of the animationMap
  135802. * @param cellID is the Index of the Sprite
  135803. * @param _frame is the target Animation frame
  135804. * @param toCell is the Target Index of the next frame of the animation
  135805. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  135806. * @param speed is a global scalar of the time variable on the map.
  135807. */
  135808. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  135809. /**
  135810. * Exports the .tilemaps file
  135811. */
  135812. saveTileMaps(): void;
  135813. /**
  135814. * Imports the .tilemaps file
  135815. * @param url of the .tilemaps file
  135816. */
  135817. loadTileMaps(url: string): void;
  135818. /**
  135819. * Release associated resources
  135820. */
  135821. dispose(): void;
  135822. }
  135823. }
  135824. declare module BABYLON {
  135825. /**
  135826. * Class used to manage multiple sprites of different sizes on the same spritesheet
  135827. * @see http://doc.babylonjs.com/babylon101/sprites
  135828. */
  135829. export class SpritePackedManager extends SpriteManager {
  135830. /** defines the packed manager's name */
  135831. name: string;
  135832. /**
  135833. * Creates a new sprite manager from a packed sprite sheet
  135834. * @param name defines the manager's name
  135835. * @param imgUrl defines the sprite sheet url
  135836. * @param capacity defines the maximum allowed number of sprites
  135837. * @param scene defines the hosting scene
  135838. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  135839. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  135840. * @param samplingMode defines the smapling mode to use with spritesheet
  135841. * @param fromPacked set to true; do not alter
  135842. */
  135843. constructor(
  135844. /** defines the packed manager's name */
  135845. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  135846. }
  135847. }
  135848. declare module BABYLON {
  135849. /**
  135850. * Defines the list of states available for a task inside a AssetsManager
  135851. */
  135852. export enum AssetTaskState {
  135853. /**
  135854. * Initialization
  135855. */
  135856. INIT = 0,
  135857. /**
  135858. * Running
  135859. */
  135860. RUNNING = 1,
  135861. /**
  135862. * Done
  135863. */
  135864. DONE = 2,
  135865. /**
  135866. * Error
  135867. */
  135868. ERROR = 3
  135869. }
  135870. /**
  135871. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  135872. */
  135873. export abstract class AbstractAssetTask {
  135874. /**
  135875. * Task name
  135876. */ name: string;
  135877. /**
  135878. * Callback called when the task is successful
  135879. */
  135880. onSuccess: (task: any) => void;
  135881. /**
  135882. * Callback called when the task is not successful
  135883. */
  135884. onError: (task: any, message?: string, exception?: any) => void;
  135885. /**
  135886. * Creates a new AssetsManager
  135887. * @param name defines the name of the task
  135888. */
  135889. constructor(
  135890. /**
  135891. * Task name
  135892. */ name: string);
  135893. private _isCompleted;
  135894. private _taskState;
  135895. private _errorObject;
  135896. /**
  135897. * Get if the task is completed
  135898. */
  135899. get isCompleted(): boolean;
  135900. /**
  135901. * Gets the current state of the task
  135902. */
  135903. get taskState(): AssetTaskState;
  135904. /**
  135905. * Gets the current error object (if task is in error)
  135906. */
  135907. get errorObject(): {
  135908. message?: string;
  135909. exception?: any;
  135910. };
  135911. /**
  135912. * Internal only
  135913. * @hidden
  135914. */
  135915. _setErrorObject(message?: string, exception?: any): void;
  135916. /**
  135917. * Execute the current task
  135918. * @param scene defines the scene where you want your assets to be loaded
  135919. * @param onSuccess is a callback called when the task is successfully executed
  135920. * @param onError is a callback called if an error occurs
  135921. */
  135922. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  135923. /**
  135924. * Execute the current task
  135925. * @param scene defines the scene where you want your assets to be loaded
  135926. * @param onSuccess is a callback called when the task is successfully executed
  135927. * @param onError is a callback called if an error occurs
  135928. */
  135929. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  135930. /**
  135931. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  135932. * This can be used with failed tasks that have the reason for failure fixed.
  135933. */
  135934. reset(): void;
  135935. private onErrorCallback;
  135936. private onDoneCallback;
  135937. }
  135938. /**
  135939. * Define the interface used by progress events raised during assets loading
  135940. */
  135941. export interface IAssetsProgressEvent {
  135942. /**
  135943. * Defines the number of remaining tasks to process
  135944. */
  135945. remainingCount: number;
  135946. /**
  135947. * Defines the total number of tasks
  135948. */
  135949. totalCount: number;
  135950. /**
  135951. * Defines the task that was just processed
  135952. */
  135953. task: AbstractAssetTask;
  135954. }
  135955. /**
  135956. * Class used to share progress information about assets loading
  135957. */
  135958. export class AssetsProgressEvent implements IAssetsProgressEvent {
  135959. /**
  135960. * Defines the number of remaining tasks to process
  135961. */
  135962. remainingCount: number;
  135963. /**
  135964. * Defines the total number of tasks
  135965. */
  135966. totalCount: number;
  135967. /**
  135968. * Defines the task that was just processed
  135969. */
  135970. task: AbstractAssetTask;
  135971. /**
  135972. * Creates a AssetsProgressEvent
  135973. * @param remainingCount defines the number of remaining tasks to process
  135974. * @param totalCount defines the total number of tasks
  135975. * @param task defines the task that was just processed
  135976. */
  135977. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  135978. }
  135979. /**
  135980. * Define a task used by AssetsManager to load meshes
  135981. */
  135982. export class MeshAssetTask extends AbstractAssetTask {
  135983. /**
  135984. * Defines the name of the task
  135985. */
  135986. name: string;
  135987. /**
  135988. * Defines the list of mesh's names you want to load
  135989. */
  135990. meshesNames: any;
  135991. /**
  135992. * Defines the root url to use as a base to load your meshes and associated resources
  135993. */
  135994. rootUrl: string;
  135995. /**
  135996. * Defines the filename of the scene to load from
  135997. */
  135998. sceneFilename: string;
  135999. /**
  136000. * Gets the list of loaded meshes
  136001. */
  136002. loadedMeshes: Array<AbstractMesh>;
  136003. /**
  136004. * Gets the list of loaded particle systems
  136005. */
  136006. loadedParticleSystems: Array<IParticleSystem>;
  136007. /**
  136008. * Gets the list of loaded skeletons
  136009. */
  136010. loadedSkeletons: Array<Skeleton>;
  136011. /**
  136012. * Gets the list of loaded animation groups
  136013. */
  136014. loadedAnimationGroups: Array<AnimationGroup>;
  136015. /**
  136016. * Callback called when the task is successful
  136017. */
  136018. onSuccess: (task: MeshAssetTask) => void;
  136019. /**
  136020. * Callback called when the task is successful
  136021. */
  136022. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  136023. /**
  136024. * Creates a new MeshAssetTask
  136025. * @param name defines the name of the task
  136026. * @param meshesNames defines the list of mesh's names you want to load
  136027. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  136028. * @param sceneFilename defines the filename of the scene to load from
  136029. */
  136030. constructor(
  136031. /**
  136032. * Defines the name of the task
  136033. */
  136034. name: string,
  136035. /**
  136036. * Defines the list of mesh's names you want to load
  136037. */
  136038. meshesNames: any,
  136039. /**
  136040. * Defines the root url to use as a base to load your meshes and associated resources
  136041. */
  136042. rootUrl: string,
  136043. /**
  136044. * Defines the filename of the scene to load from
  136045. */
  136046. sceneFilename: string);
  136047. /**
  136048. * Execute the current task
  136049. * @param scene defines the scene where you want your assets to be loaded
  136050. * @param onSuccess is a callback called when the task is successfully executed
  136051. * @param onError is a callback called if an error occurs
  136052. */
  136053. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136054. }
  136055. /**
  136056. * Define a task used by AssetsManager to load text content
  136057. */
  136058. export class TextFileAssetTask extends AbstractAssetTask {
  136059. /**
  136060. * Defines the name of the task
  136061. */
  136062. name: string;
  136063. /**
  136064. * Defines the location of the file to load
  136065. */
  136066. url: string;
  136067. /**
  136068. * Gets the loaded text string
  136069. */
  136070. text: string;
  136071. /**
  136072. * Callback called when the task is successful
  136073. */
  136074. onSuccess: (task: TextFileAssetTask) => void;
  136075. /**
  136076. * Callback called when the task is successful
  136077. */
  136078. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  136079. /**
  136080. * Creates a new TextFileAssetTask object
  136081. * @param name defines the name of the task
  136082. * @param url defines the location of the file to load
  136083. */
  136084. constructor(
  136085. /**
  136086. * Defines the name of the task
  136087. */
  136088. name: string,
  136089. /**
  136090. * Defines the location of the file to load
  136091. */
  136092. url: string);
  136093. /**
  136094. * Execute the current task
  136095. * @param scene defines the scene where you want your assets to be loaded
  136096. * @param onSuccess is a callback called when the task is successfully executed
  136097. * @param onError is a callback called if an error occurs
  136098. */
  136099. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136100. }
  136101. /**
  136102. * Define a task used by AssetsManager to load binary data
  136103. */
  136104. export class BinaryFileAssetTask extends AbstractAssetTask {
  136105. /**
  136106. * Defines the name of the task
  136107. */
  136108. name: string;
  136109. /**
  136110. * Defines the location of the file to load
  136111. */
  136112. url: string;
  136113. /**
  136114. * Gets the lodaded data (as an array buffer)
  136115. */
  136116. data: ArrayBuffer;
  136117. /**
  136118. * Callback called when the task is successful
  136119. */
  136120. onSuccess: (task: BinaryFileAssetTask) => void;
  136121. /**
  136122. * Callback called when the task is successful
  136123. */
  136124. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  136125. /**
  136126. * Creates a new BinaryFileAssetTask object
  136127. * @param name defines the name of the new task
  136128. * @param url defines the location of the file to load
  136129. */
  136130. constructor(
  136131. /**
  136132. * Defines the name of the task
  136133. */
  136134. name: string,
  136135. /**
  136136. * Defines the location of the file to load
  136137. */
  136138. url: string);
  136139. /**
  136140. * Execute the current task
  136141. * @param scene defines the scene where you want your assets to be loaded
  136142. * @param onSuccess is a callback called when the task is successfully executed
  136143. * @param onError is a callback called if an error occurs
  136144. */
  136145. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136146. }
  136147. /**
  136148. * Define a task used by AssetsManager to load images
  136149. */
  136150. export class ImageAssetTask extends AbstractAssetTask {
  136151. /**
  136152. * Defines the name of the task
  136153. */
  136154. name: string;
  136155. /**
  136156. * Defines the location of the image to load
  136157. */
  136158. url: string;
  136159. /**
  136160. * Gets the loaded images
  136161. */
  136162. image: HTMLImageElement;
  136163. /**
  136164. * Callback called when the task is successful
  136165. */
  136166. onSuccess: (task: ImageAssetTask) => void;
  136167. /**
  136168. * Callback called when the task is successful
  136169. */
  136170. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  136171. /**
  136172. * Creates a new ImageAssetTask
  136173. * @param name defines the name of the task
  136174. * @param url defines the location of the image to load
  136175. */
  136176. constructor(
  136177. /**
  136178. * Defines the name of the task
  136179. */
  136180. name: string,
  136181. /**
  136182. * Defines the location of the image to load
  136183. */
  136184. url: string);
  136185. /**
  136186. * Execute the current task
  136187. * @param scene defines the scene where you want your assets to be loaded
  136188. * @param onSuccess is a callback called when the task is successfully executed
  136189. * @param onError is a callback called if an error occurs
  136190. */
  136191. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136192. }
  136193. /**
  136194. * Defines the interface used by texture loading tasks
  136195. */
  136196. export interface ITextureAssetTask<TEX extends BaseTexture> {
  136197. /**
  136198. * Gets the loaded texture
  136199. */
  136200. texture: TEX;
  136201. }
  136202. /**
  136203. * Define a task used by AssetsManager to load 2D textures
  136204. */
  136205. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  136206. /**
  136207. * Defines the name of the task
  136208. */
  136209. name: string;
  136210. /**
  136211. * Defines the location of the file to load
  136212. */
  136213. url: string;
  136214. /**
  136215. * Defines if mipmap should not be generated (default is false)
  136216. */
  136217. noMipmap?: boolean | undefined;
  136218. /**
  136219. * Defines if texture must be inverted on Y axis (default is false)
  136220. */
  136221. invertY?: boolean | undefined;
  136222. /**
  136223. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  136224. */
  136225. samplingMode: number;
  136226. /**
  136227. * Gets the loaded texture
  136228. */
  136229. texture: Texture;
  136230. /**
  136231. * Callback called when the task is successful
  136232. */
  136233. onSuccess: (task: TextureAssetTask) => void;
  136234. /**
  136235. * Callback called when the task is successful
  136236. */
  136237. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  136238. /**
  136239. * Creates a new TextureAssetTask object
  136240. * @param name defines the name of the task
  136241. * @param url defines the location of the file to load
  136242. * @param noMipmap defines if mipmap should not be generated (default is false)
  136243. * @param invertY defines if texture must be inverted on Y axis (default is false)
  136244. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  136245. */
  136246. constructor(
  136247. /**
  136248. * Defines the name of the task
  136249. */
  136250. name: string,
  136251. /**
  136252. * Defines the location of the file to load
  136253. */
  136254. url: string,
  136255. /**
  136256. * Defines if mipmap should not be generated (default is false)
  136257. */
  136258. noMipmap?: boolean | undefined,
  136259. /**
  136260. * Defines if texture must be inverted on Y axis (default is false)
  136261. */
  136262. invertY?: boolean | undefined,
  136263. /**
  136264. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  136265. */
  136266. samplingMode?: number);
  136267. /**
  136268. * Execute the current task
  136269. * @param scene defines the scene where you want your assets to be loaded
  136270. * @param onSuccess is a callback called when the task is successfully executed
  136271. * @param onError is a callback called if an error occurs
  136272. */
  136273. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136274. }
  136275. /**
  136276. * Define a task used by AssetsManager to load cube textures
  136277. */
  136278. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  136279. /**
  136280. * Defines the name of the task
  136281. */
  136282. name: string;
  136283. /**
  136284. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  136285. */
  136286. url: string;
  136287. /**
  136288. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  136289. */
  136290. extensions?: string[] | undefined;
  136291. /**
  136292. * Defines if mipmaps should not be generated (default is false)
  136293. */
  136294. noMipmap?: boolean | undefined;
  136295. /**
  136296. * Defines the explicit list of files (undefined by default)
  136297. */
  136298. files?: string[] | undefined;
  136299. /**
  136300. * Gets the loaded texture
  136301. */
  136302. texture: CubeTexture;
  136303. /**
  136304. * Callback called when the task is successful
  136305. */
  136306. onSuccess: (task: CubeTextureAssetTask) => void;
  136307. /**
  136308. * Callback called when the task is successful
  136309. */
  136310. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  136311. /**
  136312. * Creates a new CubeTextureAssetTask
  136313. * @param name defines the name of the task
  136314. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  136315. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  136316. * @param noMipmap defines if mipmaps should not be generated (default is false)
  136317. * @param files defines the explicit list of files (undefined by default)
  136318. */
  136319. constructor(
  136320. /**
  136321. * Defines the name of the task
  136322. */
  136323. name: string,
  136324. /**
  136325. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  136326. */
  136327. url: string,
  136328. /**
  136329. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  136330. */
  136331. extensions?: string[] | undefined,
  136332. /**
  136333. * Defines if mipmaps should not be generated (default is false)
  136334. */
  136335. noMipmap?: boolean | undefined,
  136336. /**
  136337. * Defines the explicit list of files (undefined by default)
  136338. */
  136339. files?: string[] | undefined);
  136340. /**
  136341. * Execute the current task
  136342. * @param scene defines the scene where you want your assets to be loaded
  136343. * @param onSuccess is a callback called when the task is successfully executed
  136344. * @param onError is a callback called if an error occurs
  136345. */
  136346. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136347. }
  136348. /**
  136349. * Define a task used by AssetsManager to load HDR cube textures
  136350. */
  136351. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  136352. /**
  136353. * Defines the name of the task
  136354. */
  136355. name: string;
  136356. /**
  136357. * Defines the location of the file to load
  136358. */
  136359. url: string;
  136360. /**
  136361. * Defines the desired size (the more it increases the longer the generation will be)
  136362. */
  136363. size: number;
  136364. /**
  136365. * Defines if mipmaps should not be generated (default is false)
  136366. */
  136367. noMipmap: boolean;
  136368. /**
  136369. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  136370. */
  136371. generateHarmonics: boolean;
  136372. /**
  136373. * 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)
  136374. */
  136375. gammaSpace: boolean;
  136376. /**
  136377. * Internal Use Only
  136378. */
  136379. reserved: boolean;
  136380. /**
  136381. * Gets the loaded texture
  136382. */
  136383. texture: HDRCubeTexture;
  136384. /**
  136385. * Callback called when the task is successful
  136386. */
  136387. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  136388. /**
  136389. * Callback called when the task is successful
  136390. */
  136391. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  136392. /**
  136393. * Creates a new HDRCubeTextureAssetTask object
  136394. * @param name defines the name of the task
  136395. * @param url defines the location of the file to load
  136396. * @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.
  136397. * @param noMipmap defines if mipmaps should not be generated (default is false)
  136398. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  136399. * @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)
  136400. * @param reserved Internal use only
  136401. */
  136402. constructor(
  136403. /**
  136404. * Defines the name of the task
  136405. */
  136406. name: string,
  136407. /**
  136408. * Defines the location of the file to load
  136409. */
  136410. url: string,
  136411. /**
  136412. * Defines the desired size (the more it increases the longer the generation will be)
  136413. */
  136414. size: number,
  136415. /**
  136416. * Defines if mipmaps should not be generated (default is false)
  136417. */
  136418. noMipmap?: boolean,
  136419. /**
  136420. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  136421. */
  136422. generateHarmonics?: boolean,
  136423. /**
  136424. * 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)
  136425. */
  136426. gammaSpace?: boolean,
  136427. /**
  136428. * Internal Use Only
  136429. */
  136430. reserved?: boolean);
  136431. /**
  136432. * Execute the current task
  136433. * @param scene defines the scene where you want your assets to be loaded
  136434. * @param onSuccess is a callback called when the task is successfully executed
  136435. * @param onError is a callback called if an error occurs
  136436. */
  136437. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136438. }
  136439. /**
  136440. * Define a task used by AssetsManager to load Equirectangular cube textures
  136441. */
  136442. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  136443. /**
  136444. * Defines the name of the task
  136445. */
  136446. name: string;
  136447. /**
  136448. * Defines the location of the file to load
  136449. */
  136450. url: string;
  136451. /**
  136452. * Defines the desired size (the more it increases the longer the generation will be)
  136453. */
  136454. size: number;
  136455. /**
  136456. * Defines if mipmaps should not be generated (default is false)
  136457. */
  136458. noMipmap: boolean;
  136459. /**
  136460. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  136461. * but the standard material would require them in Gamma space) (default is true)
  136462. */
  136463. gammaSpace: boolean;
  136464. /**
  136465. * Gets the loaded texture
  136466. */
  136467. texture: EquiRectangularCubeTexture;
  136468. /**
  136469. * Callback called when the task is successful
  136470. */
  136471. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  136472. /**
  136473. * Callback called when the task is successful
  136474. */
  136475. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  136476. /**
  136477. * Creates a new EquiRectangularCubeTextureAssetTask object
  136478. * @param name defines the name of the task
  136479. * @param url defines the location of the file to load
  136480. * @param size defines the desired size (the more it increases the longer the generation will be)
  136481. * If the size is omitted this implies you are using a preprocessed cubemap.
  136482. * @param noMipmap defines if mipmaps should not be generated (default is false)
  136483. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  136484. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  136485. * (default is true)
  136486. */
  136487. constructor(
  136488. /**
  136489. * Defines the name of the task
  136490. */
  136491. name: string,
  136492. /**
  136493. * Defines the location of the file to load
  136494. */
  136495. url: string,
  136496. /**
  136497. * Defines the desired size (the more it increases the longer the generation will be)
  136498. */
  136499. size: number,
  136500. /**
  136501. * Defines if mipmaps should not be generated (default is false)
  136502. */
  136503. noMipmap?: boolean,
  136504. /**
  136505. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  136506. * but the standard material would require them in Gamma space) (default is true)
  136507. */
  136508. gammaSpace?: boolean);
  136509. /**
  136510. * Execute the current task
  136511. * @param scene defines the scene where you want your assets to be loaded
  136512. * @param onSuccess is a callback called when the task is successfully executed
  136513. * @param onError is a callback called if an error occurs
  136514. */
  136515. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  136516. }
  136517. /**
  136518. * This class can be used to easily import assets into a scene
  136519. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  136520. */
  136521. export class AssetsManager {
  136522. private _scene;
  136523. private _isLoading;
  136524. protected _tasks: AbstractAssetTask[];
  136525. protected _waitingTasksCount: number;
  136526. protected _totalTasksCount: number;
  136527. /**
  136528. * Callback called when all tasks are processed
  136529. */
  136530. onFinish: (tasks: AbstractAssetTask[]) => void;
  136531. /**
  136532. * Callback called when a task is successful
  136533. */
  136534. onTaskSuccess: (task: AbstractAssetTask) => void;
  136535. /**
  136536. * Callback called when a task had an error
  136537. */
  136538. onTaskError: (task: AbstractAssetTask) => void;
  136539. /**
  136540. * Callback called when a task is done (whatever the result is)
  136541. */
  136542. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  136543. /**
  136544. * Observable called when all tasks are processed
  136545. */
  136546. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  136547. /**
  136548. * Observable called when a task had an error
  136549. */
  136550. onTaskErrorObservable: Observable<AbstractAssetTask>;
  136551. /**
  136552. * Observable called when all tasks were executed
  136553. */
  136554. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  136555. /**
  136556. * Observable called when a task is done (whatever the result is)
  136557. */
  136558. onProgressObservable: Observable<IAssetsProgressEvent>;
  136559. /**
  136560. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  136561. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  136562. */
  136563. useDefaultLoadingScreen: boolean;
  136564. /**
  136565. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  136566. * when all assets have been downloaded.
  136567. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  136568. */
  136569. autoHideLoadingUI: boolean;
  136570. /**
  136571. * Creates a new AssetsManager
  136572. * @param scene defines the scene to work on
  136573. */
  136574. constructor(scene: Scene);
  136575. /**
  136576. * Add a MeshAssetTask to the list of active tasks
  136577. * @param taskName defines the name of the new task
  136578. * @param meshesNames defines the name of meshes to load
  136579. * @param rootUrl defines the root url to use to locate files
  136580. * @param sceneFilename defines the filename of the scene file
  136581. * @returns a new MeshAssetTask object
  136582. */
  136583. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  136584. /**
  136585. * Add a TextFileAssetTask to the list of active tasks
  136586. * @param taskName defines the name of the new task
  136587. * @param url defines the url of the file to load
  136588. * @returns a new TextFileAssetTask object
  136589. */
  136590. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  136591. /**
  136592. * Add a BinaryFileAssetTask to the list of active tasks
  136593. * @param taskName defines the name of the new task
  136594. * @param url defines the url of the file to load
  136595. * @returns a new BinaryFileAssetTask object
  136596. */
  136597. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  136598. /**
  136599. * Add a ImageAssetTask to the list of active tasks
  136600. * @param taskName defines the name of the new task
  136601. * @param url defines the url of the file to load
  136602. * @returns a new ImageAssetTask object
  136603. */
  136604. addImageTask(taskName: string, url: string): ImageAssetTask;
  136605. /**
  136606. * Add a TextureAssetTask to the list of active tasks
  136607. * @param taskName defines the name of the new task
  136608. * @param url defines the url of the file to load
  136609. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  136610. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  136611. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  136612. * @returns a new TextureAssetTask object
  136613. */
  136614. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  136615. /**
  136616. * Add a CubeTextureAssetTask to the list of active tasks
  136617. * @param taskName defines the name of the new task
  136618. * @param url defines the url of the file to load
  136619. * @param extensions defines the extension to use to load the cube map (can be null)
  136620. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  136621. * @param files defines the list of files to load (can be null)
  136622. * @returns a new CubeTextureAssetTask object
  136623. */
  136624. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  136625. /**
  136626. *
  136627. * Add a HDRCubeTextureAssetTask to the list of active tasks
  136628. * @param taskName defines the name of the new task
  136629. * @param url defines the url of the file to load
  136630. * @param size defines the size you want for the cubemap (can be null)
  136631. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  136632. * @param generateHarmonics defines if you want to automatically generate (true by default)
  136633. * @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)
  136634. * @param reserved Internal use only
  136635. * @returns a new HDRCubeTextureAssetTask object
  136636. */
  136637. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  136638. /**
  136639. *
  136640. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  136641. * @param taskName defines the name of the new task
  136642. * @param url defines the url of the file to load
  136643. * @param size defines the size you want for the cubemap (can be null)
  136644. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  136645. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  136646. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  136647. * @returns a new EquiRectangularCubeTextureAssetTask object
  136648. */
  136649. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  136650. /**
  136651. * Remove a task from the assets manager.
  136652. * @param task the task to remove
  136653. */
  136654. removeTask(task: AbstractAssetTask): void;
  136655. private _decreaseWaitingTasksCount;
  136656. private _runTask;
  136657. /**
  136658. * Reset the AssetsManager and remove all tasks
  136659. * @return the current instance of the AssetsManager
  136660. */
  136661. reset(): AssetsManager;
  136662. /**
  136663. * Start the loading process
  136664. * @return the current instance of the AssetsManager
  136665. */
  136666. load(): AssetsManager;
  136667. /**
  136668. * Start the loading process as an async operation
  136669. * @return a promise returning the list of failed tasks
  136670. */
  136671. loadAsync(): Promise<void>;
  136672. }
  136673. }
  136674. declare module BABYLON {
  136675. /**
  136676. * Wrapper class for promise with external resolve and reject.
  136677. */
  136678. export class Deferred<T> {
  136679. /**
  136680. * The promise associated with this deferred object.
  136681. */
  136682. readonly promise: Promise<T>;
  136683. private _resolve;
  136684. private _reject;
  136685. /**
  136686. * The resolve method of the promise associated with this deferred object.
  136687. */
  136688. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  136689. /**
  136690. * The reject method of the promise associated with this deferred object.
  136691. */
  136692. get reject(): (reason?: any) => void;
  136693. /**
  136694. * Constructor for this deferred object.
  136695. */
  136696. constructor();
  136697. }
  136698. }
  136699. declare module BABYLON {
  136700. /**
  136701. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  136702. */
  136703. export class MeshExploder {
  136704. private _centerMesh;
  136705. private _meshes;
  136706. private _meshesOrigins;
  136707. private _toCenterVectors;
  136708. private _scaledDirection;
  136709. private _newPosition;
  136710. private _centerPosition;
  136711. /**
  136712. * Explodes meshes from a center mesh.
  136713. * @param meshes The meshes to explode.
  136714. * @param centerMesh The mesh to be center of explosion.
  136715. */
  136716. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  136717. private _setCenterMesh;
  136718. /**
  136719. * Get class name
  136720. * @returns "MeshExploder"
  136721. */
  136722. getClassName(): string;
  136723. /**
  136724. * "Exploded meshes"
  136725. * @returns Array of meshes with the centerMesh at index 0.
  136726. */
  136727. getMeshes(): Array<Mesh>;
  136728. /**
  136729. * Explodes meshes giving a specific direction
  136730. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  136731. */
  136732. explode(direction?: number): void;
  136733. }
  136734. }
  136735. declare module BABYLON {
  136736. /**
  136737. * Class used to help managing file picking and drag'n'drop
  136738. */
  136739. export class FilesInput {
  136740. /**
  136741. * List of files ready to be loaded
  136742. */
  136743. static get FilesToLoad(): {
  136744. [key: string]: File;
  136745. };
  136746. /**
  136747. * Callback called when a file is processed
  136748. */
  136749. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  136750. private _engine;
  136751. private _currentScene;
  136752. private _sceneLoadedCallback;
  136753. private _progressCallback;
  136754. private _additionalRenderLoopLogicCallback;
  136755. private _textureLoadingCallback;
  136756. private _startingProcessingFilesCallback;
  136757. private _onReloadCallback;
  136758. private _errorCallback;
  136759. private _elementToMonitor;
  136760. private _sceneFileToLoad;
  136761. private _filesToLoad;
  136762. /**
  136763. * Creates a new FilesInput
  136764. * @param engine defines the rendering engine
  136765. * @param scene defines the hosting scene
  136766. * @param sceneLoadedCallback callback called when scene is loaded
  136767. * @param progressCallback callback called to track progress
  136768. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  136769. * @param textureLoadingCallback callback called when a texture is loading
  136770. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  136771. * @param onReloadCallback callback called when a reload is requested
  136772. * @param errorCallback callback call if an error occurs
  136773. */
  136774. 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);
  136775. private _dragEnterHandler;
  136776. private _dragOverHandler;
  136777. private _dropHandler;
  136778. /**
  136779. * Calls this function to listen to drag'n'drop events on a specific DOM element
  136780. * @param elementToMonitor defines the DOM element to track
  136781. */
  136782. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  136783. /**
  136784. * Release all associated resources
  136785. */
  136786. dispose(): void;
  136787. private renderFunction;
  136788. private drag;
  136789. private drop;
  136790. private _traverseFolder;
  136791. private _processFiles;
  136792. /**
  136793. * Load files from a drop event
  136794. * @param event defines the drop event to use as source
  136795. */
  136796. loadFiles(event: any): void;
  136797. private _processReload;
  136798. /**
  136799. * Reload the current scene from the loaded files
  136800. */
  136801. reload(): void;
  136802. }
  136803. }
  136804. declare module BABYLON {
  136805. /**
  136806. * Defines the root class used to create scene optimization to use with SceneOptimizer
  136807. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136808. */
  136809. export class SceneOptimization {
  136810. /**
  136811. * Defines the priority of this optimization (0 by default which means first in the list)
  136812. */
  136813. priority: number;
  136814. /**
  136815. * Gets a string describing the action executed by the current optimization
  136816. * @returns description string
  136817. */
  136818. getDescription(): string;
  136819. /**
  136820. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136821. * @param scene defines the current scene where to apply this optimization
  136822. * @param optimizer defines the current optimizer
  136823. * @returns true if everything that can be done was applied
  136824. */
  136825. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136826. /**
  136827. * Creates the SceneOptimization object
  136828. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  136829. * @param desc defines the description associated with the optimization
  136830. */
  136831. constructor(
  136832. /**
  136833. * Defines the priority of this optimization (0 by default which means first in the list)
  136834. */
  136835. priority?: number);
  136836. }
  136837. /**
  136838. * Defines an optimization used to reduce the size of render target textures
  136839. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136840. */
  136841. export class TextureOptimization extends SceneOptimization {
  136842. /**
  136843. * Defines the priority of this optimization (0 by default which means first in the list)
  136844. */
  136845. priority: number;
  136846. /**
  136847. * 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
  136848. */
  136849. maximumSize: number;
  136850. /**
  136851. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  136852. */
  136853. step: number;
  136854. /**
  136855. * Gets a string describing the action executed by the current optimization
  136856. * @returns description string
  136857. */
  136858. getDescription(): string;
  136859. /**
  136860. * Creates the TextureOptimization object
  136861. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  136862. * @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
  136863. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  136864. */
  136865. constructor(
  136866. /**
  136867. * Defines the priority of this optimization (0 by default which means first in the list)
  136868. */
  136869. priority?: number,
  136870. /**
  136871. * 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
  136872. */
  136873. maximumSize?: number,
  136874. /**
  136875. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  136876. */
  136877. step?: number);
  136878. /**
  136879. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136880. * @param scene defines the current scene where to apply this optimization
  136881. * @param optimizer defines the current optimizer
  136882. * @returns true if everything that can be done was applied
  136883. */
  136884. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136885. }
  136886. /**
  136887. * Defines an optimization used to increase or decrease the rendering resolution
  136888. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136889. */
  136890. export class HardwareScalingOptimization extends SceneOptimization {
  136891. /**
  136892. * Defines the priority of this optimization (0 by default which means first in the list)
  136893. */
  136894. priority: number;
  136895. /**
  136896. * Defines the maximum scale to use (2 by default)
  136897. */
  136898. maximumScale: number;
  136899. /**
  136900. * Defines the step to use between two passes (0.5 by default)
  136901. */
  136902. step: number;
  136903. private _currentScale;
  136904. private _directionOffset;
  136905. /**
  136906. * Gets a string describing the action executed by the current optimization
  136907. * @return description string
  136908. */
  136909. getDescription(): string;
  136910. /**
  136911. * Creates the HardwareScalingOptimization object
  136912. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  136913. * @param maximumScale defines the maximum scale to use (2 by default)
  136914. * @param step defines the step to use between two passes (0.5 by default)
  136915. */
  136916. constructor(
  136917. /**
  136918. * Defines the priority of this optimization (0 by default which means first in the list)
  136919. */
  136920. priority?: number,
  136921. /**
  136922. * Defines the maximum scale to use (2 by default)
  136923. */
  136924. maximumScale?: number,
  136925. /**
  136926. * Defines the step to use between two passes (0.5 by default)
  136927. */
  136928. step?: number);
  136929. /**
  136930. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136931. * @param scene defines the current scene where to apply this optimization
  136932. * @param optimizer defines the current optimizer
  136933. * @returns true if everything that can be done was applied
  136934. */
  136935. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136936. }
  136937. /**
  136938. * Defines an optimization used to remove shadows
  136939. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136940. */
  136941. export class ShadowsOptimization extends SceneOptimization {
  136942. /**
  136943. * Gets a string describing the action executed by the current optimization
  136944. * @return description string
  136945. */
  136946. getDescription(): string;
  136947. /**
  136948. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136949. * @param scene defines the current scene where to apply this optimization
  136950. * @param optimizer defines the current optimizer
  136951. * @returns true if everything that can be done was applied
  136952. */
  136953. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136954. }
  136955. /**
  136956. * Defines an optimization used to turn post-processes off
  136957. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136958. */
  136959. export class PostProcessesOptimization extends SceneOptimization {
  136960. /**
  136961. * Gets a string describing the action executed by the current optimization
  136962. * @return description string
  136963. */
  136964. getDescription(): string;
  136965. /**
  136966. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136967. * @param scene defines the current scene where to apply this optimization
  136968. * @param optimizer defines the current optimizer
  136969. * @returns true if everything that can be done was applied
  136970. */
  136971. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136972. }
  136973. /**
  136974. * Defines an optimization used to turn lens flares off
  136975. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136976. */
  136977. export class LensFlaresOptimization extends SceneOptimization {
  136978. /**
  136979. * Gets a string describing the action executed by the current optimization
  136980. * @return description string
  136981. */
  136982. getDescription(): string;
  136983. /**
  136984. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  136985. * @param scene defines the current scene where to apply this optimization
  136986. * @param optimizer defines the current optimizer
  136987. * @returns true if everything that can be done was applied
  136988. */
  136989. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  136990. }
  136991. /**
  136992. * Defines an optimization based on user defined callback.
  136993. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  136994. */
  136995. export class CustomOptimization extends SceneOptimization {
  136996. /**
  136997. * Callback called to apply the custom optimization.
  136998. */
  136999. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  137000. /**
  137001. * Callback called to get custom description
  137002. */
  137003. onGetDescription: () => string;
  137004. /**
  137005. * Gets a string describing the action executed by the current optimization
  137006. * @returns description string
  137007. */
  137008. getDescription(): string;
  137009. /**
  137010. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  137011. * @param scene defines the current scene where to apply this optimization
  137012. * @param optimizer defines the current optimizer
  137013. * @returns true if everything that can be done was applied
  137014. */
  137015. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  137016. }
  137017. /**
  137018. * Defines an optimization used to turn particles off
  137019. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  137020. */
  137021. export class ParticlesOptimization extends SceneOptimization {
  137022. /**
  137023. * Gets a string describing the action executed by the current optimization
  137024. * @return description string
  137025. */
  137026. getDescription(): string;
  137027. /**
  137028. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  137029. * @param scene defines the current scene where to apply this optimization
  137030. * @param optimizer defines the current optimizer
  137031. * @returns true if everything that can be done was applied
  137032. */
  137033. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  137034. }
  137035. /**
  137036. * Defines an optimization used to turn render targets off
  137037. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  137038. */
  137039. export class RenderTargetsOptimization extends SceneOptimization {
  137040. /**
  137041. * Gets a string describing the action executed by the current optimization
  137042. * @return description string
  137043. */
  137044. getDescription(): string;
  137045. /**
  137046. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  137047. * @param scene defines the current scene where to apply this optimization
  137048. * @param optimizer defines the current optimizer
  137049. * @returns true if everything that can be done was applied
  137050. */
  137051. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  137052. }
  137053. /**
  137054. * Defines an optimization used to merge meshes with compatible materials
  137055. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  137056. */
  137057. export class MergeMeshesOptimization extends SceneOptimization {
  137058. private static _UpdateSelectionTree;
  137059. /**
  137060. * Gets or sets a boolean which defines if optimization octree has to be updated
  137061. */
  137062. static get UpdateSelectionTree(): boolean;
  137063. /**
  137064. * Gets or sets a boolean which defines if optimization octree has to be updated
  137065. */
  137066. static set UpdateSelectionTree(value: boolean);
  137067. /**
  137068. * Gets a string describing the action executed by the current optimization
  137069. * @return description string
  137070. */
  137071. getDescription(): string;
  137072. private _canBeMerged;
  137073. /**
  137074. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  137075. * @param scene defines the current scene where to apply this optimization
  137076. * @param optimizer defines the current optimizer
  137077. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  137078. * @returns true if everything that can be done was applied
  137079. */
  137080. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  137081. }
  137082. /**
  137083. * Defines a list of options used by SceneOptimizer
  137084. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  137085. */
  137086. export class SceneOptimizerOptions {
  137087. /**
  137088. * Defines the target frame rate to reach (60 by default)
  137089. */
  137090. targetFrameRate: number;
  137091. /**
  137092. * Defines the interval between two checkes (2000ms by default)
  137093. */
  137094. trackerDuration: number;
  137095. /**
  137096. * Gets the list of optimizations to apply
  137097. */
  137098. optimizations: SceneOptimization[];
  137099. /**
  137100. * Creates a new list of options used by SceneOptimizer
  137101. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  137102. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  137103. */
  137104. constructor(
  137105. /**
  137106. * Defines the target frame rate to reach (60 by default)
  137107. */
  137108. targetFrameRate?: number,
  137109. /**
  137110. * Defines the interval between two checkes (2000ms by default)
  137111. */
  137112. trackerDuration?: number);
  137113. /**
  137114. * Add a new optimization
  137115. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  137116. * @returns the current SceneOptimizerOptions
  137117. */
  137118. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  137119. /**
  137120. * Add a new custom optimization
  137121. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  137122. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  137123. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  137124. * @returns the current SceneOptimizerOptions
  137125. */
  137126. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  137127. /**
  137128. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  137129. * @param targetFrameRate defines the target frame rate (60 by default)
  137130. * @returns a SceneOptimizerOptions object
  137131. */
  137132. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  137133. /**
  137134. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  137135. * @param targetFrameRate defines the target frame rate (60 by default)
  137136. * @returns a SceneOptimizerOptions object
  137137. */
  137138. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  137139. /**
  137140. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  137141. * @param targetFrameRate defines the target frame rate (60 by default)
  137142. * @returns a SceneOptimizerOptions object
  137143. */
  137144. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  137145. }
  137146. /**
  137147. * Class used to run optimizations in order to reach a target frame rate
  137148. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  137149. */
  137150. export class SceneOptimizer implements IDisposable {
  137151. private _isRunning;
  137152. private _options;
  137153. private _scene;
  137154. private _currentPriorityLevel;
  137155. private _targetFrameRate;
  137156. private _trackerDuration;
  137157. private _currentFrameRate;
  137158. private _sceneDisposeObserver;
  137159. private _improvementMode;
  137160. /**
  137161. * Defines an observable called when the optimizer reaches the target frame rate
  137162. */
  137163. onSuccessObservable: Observable<SceneOptimizer>;
  137164. /**
  137165. * Defines an observable called when the optimizer enables an optimization
  137166. */
  137167. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  137168. /**
  137169. * Defines an observable called when the optimizer is not able to reach the target frame rate
  137170. */
  137171. onFailureObservable: Observable<SceneOptimizer>;
  137172. /**
  137173. * Gets a boolean indicating if the optimizer is in improvement mode
  137174. */
  137175. get isInImprovementMode(): boolean;
  137176. /**
  137177. * Gets the current priority level (0 at start)
  137178. */
  137179. get currentPriorityLevel(): number;
  137180. /**
  137181. * Gets the current frame rate checked by the SceneOptimizer
  137182. */
  137183. get currentFrameRate(): number;
  137184. /**
  137185. * Gets or sets the current target frame rate (60 by default)
  137186. */
  137187. get targetFrameRate(): number;
  137188. /**
  137189. * Gets or sets the current target frame rate (60 by default)
  137190. */
  137191. set targetFrameRate(value: number);
  137192. /**
  137193. * Gets or sets the current interval between two checks (every 2000ms by default)
  137194. */
  137195. get trackerDuration(): number;
  137196. /**
  137197. * Gets or sets the current interval between two checks (every 2000ms by default)
  137198. */
  137199. set trackerDuration(value: number);
  137200. /**
  137201. * Gets the list of active optimizations
  137202. */
  137203. get optimizations(): SceneOptimization[];
  137204. /**
  137205. * Creates a new SceneOptimizer
  137206. * @param scene defines the scene to work on
  137207. * @param options defines the options to use with the SceneOptimizer
  137208. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  137209. * @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)
  137210. */
  137211. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  137212. /**
  137213. * Stops the current optimizer
  137214. */
  137215. stop(): void;
  137216. /**
  137217. * Reset the optimizer to initial step (current priority level = 0)
  137218. */
  137219. reset(): void;
  137220. /**
  137221. * Start the optimizer. By default it will try to reach a specific framerate
  137222. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  137223. */
  137224. start(): void;
  137225. private _checkCurrentState;
  137226. /**
  137227. * Release all resources
  137228. */
  137229. dispose(): void;
  137230. /**
  137231. * Helper function to create a SceneOptimizer with one single line of code
  137232. * @param scene defines the scene to work on
  137233. * @param options defines the options to use with the SceneOptimizer
  137234. * @param onSuccess defines a callback to call on success
  137235. * @param onFailure defines a callback to call on failure
  137236. * @returns the new SceneOptimizer object
  137237. */
  137238. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  137239. }
  137240. }
  137241. declare module BABYLON {
  137242. /**
  137243. * Class used to serialize a scene into a string
  137244. */
  137245. export class SceneSerializer {
  137246. /**
  137247. * Clear cache used by a previous serialization
  137248. */
  137249. static ClearCache(): void;
  137250. /**
  137251. * Serialize a scene into a JSON compatible object
  137252. * @param scene defines the scene to serialize
  137253. * @returns a JSON compatible object
  137254. */
  137255. static Serialize(scene: Scene): any;
  137256. /**
  137257. * Serialize a mesh into a JSON compatible object
  137258. * @param toSerialize defines the mesh to serialize
  137259. * @param withParents defines if parents must be serialized as well
  137260. * @param withChildren defines if children must be serialized as well
  137261. * @returns a JSON compatible object
  137262. */
  137263. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  137264. }
  137265. }
  137266. declare module BABYLON {
  137267. /**
  137268. * Class used to host texture specific utilities
  137269. */
  137270. export class TextureTools {
  137271. /**
  137272. * Uses the GPU to create a copy texture rescaled at a given size
  137273. * @param texture Texture to copy from
  137274. * @param width defines the desired width
  137275. * @param height defines the desired height
  137276. * @param useBilinearMode defines if bilinear mode has to be used
  137277. * @return the generated texture
  137278. */
  137279. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  137280. }
  137281. }
  137282. declare module BABYLON {
  137283. /**
  137284. * This represents the different options available for the video capture.
  137285. */
  137286. export interface VideoRecorderOptions {
  137287. /** Defines the mime type of the video. */
  137288. mimeType: string;
  137289. /** Defines the FPS the video should be recorded at. */
  137290. fps: number;
  137291. /** Defines the chunk size for the recording data. */
  137292. recordChunckSize: number;
  137293. /** The audio tracks to attach to the recording. */
  137294. audioTracks?: MediaStreamTrack[];
  137295. }
  137296. /**
  137297. * This can help with recording videos from BabylonJS.
  137298. * This is based on the available WebRTC functionalities of the browser.
  137299. *
  137300. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  137301. */
  137302. export class VideoRecorder {
  137303. private static readonly _defaultOptions;
  137304. /**
  137305. * Returns whether or not the VideoRecorder is available in your browser.
  137306. * @param engine Defines the Babylon Engine.
  137307. * @returns true if supported otherwise false.
  137308. */
  137309. static IsSupported(engine: Engine): boolean;
  137310. private readonly _options;
  137311. private _canvas;
  137312. private _mediaRecorder;
  137313. private _recordedChunks;
  137314. private _fileName;
  137315. private _resolve;
  137316. private _reject;
  137317. /**
  137318. * True when a recording is already in progress.
  137319. */
  137320. get isRecording(): boolean;
  137321. /**
  137322. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  137323. * @param engine Defines the BabylonJS Engine you wish to record.
  137324. * @param options Defines options that can be used to customize the capture.
  137325. */
  137326. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  137327. /**
  137328. * Stops the current recording before the default capture timeout passed in the startRecording function.
  137329. */
  137330. stopRecording(): void;
  137331. /**
  137332. * Starts recording the canvas for a max duration specified in parameters.
  137333. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  137334. * If null no automatic download will start and you can rely on the promise to get the data back.
  137335. * @param maxDuration Defines the maximum recording time in seconds.
  137336. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  137337. * @return A promise callback at the end of the recording with the video data in Blob.
  137338. */
  137339. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  137340. /**
  137341. * Releases internal resources used during the recording.
  137342. */
  137343. dispose(): void;
  137344. private _handleDataAvailable;
  137345. private _handleError;
  137346. private _handleStop;
  137347. }
  137348. }
  137349. declare module BABYLON {
  137350. /**
  137351. * Class containing a set of static utilities functions for screenshots
  137352. */
  137353. export class ScreenshotTools {
  137354. /**
  137355. * Captures a screenshot of the current rendering
  137356. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  137357. * @param engine defines the rendering engine
  137358. * @param camera defines the source camera
  137359. * @param size This parameter can be set to a single number or to an object with the
  137360. * following (optional) properties: precision, width, height. If a single number is passed,
  137361. * it will be used for both width and height. If an object is passed, the screenshot size
  137362. * will be derived from the parameters. The precision property is a multiplier allowing
  137363. * rendering at a higher or lower resolution
  137364. * @param successCallback defines the callback receives a single parameter which contains the
  137365. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  137366. * src parameter of an <img> to display it
  137367. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  137368. * Check your browser for supported MIME types
  137369. */
  137370. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  137371. /**
  137372. * Captures a screenshot of the current rendering
  137373. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  137374. * @param engine defines the rendering engine
  137375. * @param camera defines the source camera
  137376. * @param size This parameter can be set to a single number or to an object with the
  137377. * following (optional) properties: precision, width, height. If a single number is passed,
  137378. * it will be used for both width and height. If an object is passed, the screenshot size
  137379. * will be derived from the parameters. The precision property is a multiplier allowing
  137380. * rendering at a higher or lower resolution
  137381. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  137382. * Check your browser for supported MIME types
  137383. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  137384. * to the src parameter of an <img> to display it
  137385. */
  137386. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  137387. /**
  137388. * Generates an image screenshot from the specified camera.
  137389. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  137390. * @param engine The engine to use for rendering
  137391. * @param camera The camera to use for rendering
  137392. * @param size This parameter can be set to a single number or to an object with the
  137393. * following (optional) properties: precision, width, height. If a single number is passed,
  137394. * it will be used for both width and height. If an object is passed, the screenshot size
  137395. * will be derived from the parameters. The precision property is a multiplier allowing
  137396. * rendering at a higher or lower resolution
  137397. * @param successCallback The callback receives a single parameter which contains the
  137398. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  137399. * src parameter of an <img> to display it
  137400. * @param mimeType The MIME type of the screenshot image (default: image/png).
  137401. * Check your browser for supported MIME types
  137402. * @param samples Texture samples (default: 1)
  137403. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  137404. * @param fileName A name for for the downloaded file.
  137405. */
  137406. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  137407. /**
  137408. * Generates an image screenshot from the specified camera.
  137409. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  137410. * @param engine The engine to use for rendering
  137411. * @param camera The camera to use for rendering
  137412. * @param size This parameter can be set to a single number or to an object with the
  137413. * following (optional) properties: precision, width, height. If a single number is passed,
  137414. * it will be used for both width and height. If an object is passed, the screenshot size
  137415. * will be derived from the parameters. The precision property is a multiplier allowing
  137416. * rendering at a higher or lower resolution
  137417. * @param mimeType The MIME type of the screenshot image (default: image/png).
  137418. * Check your browser for supported MIME types
  137419. * @param samples Texture samples (default: 1)
  137420. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  137421. * @param fileName A name for for the downloaded file.
  137422. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  137423. * to the src parameter of an <img> to display it
  137424. */
  137425. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  137426. /**
  137427. * Gets height and width for screenshot size
  137428. * @private
  137429. */
  137430. private static _getScreenshotSize;
  137431. }
  137432. }
  137433. declare module BABYLON {
  137434. /**
  137435. * Interface for a data buffer
  137436. */
  137437. export interface IDataBuffer {
  137438. /**
  137439. * Reads bytes from the data buffer.
  137440. * @param byteOffset The byte offset to read
  137441. * @param byteLength The byte length to read
  137442. * @returns A promise that resolves when the bytes are read
  137443. */
  137444. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  137445. /**
  137446. * The byte length of the buffer.
  137447. */
  137448. readonly byteLength: number;
  137449. }
  137450. /**
  137451. * Utility class for reading from a data buffer
  137452. */
  137453. export class DataReader {
  137454. /**
  137455. * The data buffer associated with this data reader.
  137456. */
  137457. readonly buffer: IDataBuffer;
  137458. /**
  137459. * The current byte offset from the beginning of the data buffer.
  137460. */
  137461. byteOffset: number;
  137462. private _dataView;
  137463. private _dataByteOffset;
  137464. /**
  137465. * Constructor
  137466. * @param buffer The buffer to read
  137467. */
  137468. constructor(buffer: IDataBuffer);
  137469. /**
  137470. * Loads the given byte length.
  137471. * @param byteLength The byte length to load
  137472. * @returns A promise that resolves when the load is complete
  137473. */
  137474. loadAsync(byteLength: number): Promise<void>;
  137475. /**
  137476. * Read a unsigned 32-bit integer from the currently loaded data range.
  137477. * @returns The 32-bit integer read
  137478. */
  137479. readUint32(): number;
  137480. /**
  137481. * Read a byte array from the currently loaded data range.
  137482. * @param byteLength The byte length to read
  137483. * @returns The byte array read
  137484. */
  137485. readUint8Array(byteLength: number): Uint8Array;
  137486. /**
  137487. * Read a string from the currently loaded data range.
  137488. * @param byteLength The byte length to read
  137489. * @returns The string read
  137490. */
  137491. readString(byteLength: number): string;
  137492. /**
  137493. * Skips the given byte length the currently loaded data range.
  137494. * @param byteLength The byte length to skip
  137495. */
  137496. skipBytes(byteLength: number): void;
  137497. }
  137498. }
  137499. declare module BABYLON {
  137500. /**
  137501. * A cursor which tracks a point on a path
  137502. */
  137503. export class PathCursor {
  137504. private path;
  137505. /**
  137506. * Stores path cursor callbacks for when an onchange event is triggered
  137507. */
  137508. private _onchange;
  137509. /**
  137510. * The value of the path cursor
  137511. */
  137512. value: number;
  137513. /**
  137514. * The animation array of the path cursor
  137515. */
  137516. animations: Animation[];
  137517. /**
  137518. * Initializes the path cursor
  137519. * @param path The path to track
  137520. */
  137521. constructor(path: Path2);
  137522. /**
  137523. * Gets the cursor point on the path
  137524. * @returns A point on the path cursor at the cursor location
  137525. */
  137526. getPoint(): Vector3;
  137527. /**
  137528. * Moves the cursor ahead by the step amount
  137529. * @param step The amount to move the cursor forward
  137530. * @returns This path cursor
  137531. */
  137532. moveAhead(step?: number): PathCursor;
  137533. /**
  137534. * Moves the cursor behind by the step amount
  137535. * @param step The amount to move the cursor back
  137536. * @returns This path cursor
  137537. */
  137538. moveBack(step?: number): PathCursor;
  137539. /**
  137540. * Moves the cursor by the step amount
  137541. * If the step amount is greater than one, an exception is thrown
  137542. * @param step The amount to move the cursor
  137543. * @returns This path cursor
  137544. */
  137545. move(step: number): PathCursor;
  137546. /**
  137547. * Ensures that the value is limited between zero and one
  137548. * @returns This path cursor
  137549. */
  137550. private ensureLimits;
  137551. /**
  137552. * Runs onchange callbacks on change (used by the animation engine)
  137553. * @returns This path cursor
  137554. */
  137555. private raiseOnChange;
  137556. /**
  137557. * Executes a function on change
  137558. * @param f A path cursor onchange callback
  137559. * @returns This path cursor
  137560. */
  137561. onchange(f: (cursor: PathCursor) => void): PathCursor;
  137562. }
  137563. }
  137564. declare module BABYLON {
  137565. /** @hidden */
  137566. export var blurPixelShader: {
  137567. name: string;
  137568. shader: string;
  137569. };
  137570. }
  137571. declare module BABYLON {
  137572. /** @hidden */
  137573. export var pointCloudVertexDeclaration: {
  137574. name: string;
  137575. shader: string;
  137576. };
  137577. }
  137578. // Mixins
  137579. interface Window {
  137580. mozIndexedDB: IDBFactory;
  137581. webkitIndexedDB: IDBFactory;
  137582. msIndexedDB: IDBFactory;
  137583. webkitURL: typeof URL;
  137584. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  137585. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  137586. WebGLRenderingContext: WebGLRenderingContext;
  137587. MSGesture: MSGesture;
  137588. CANNON: any;
  137589. AudioContext: AudioContext;
  137590. webkitAudioContext: AudioContext;
  137591. PointerEvent: any;
  137592. Math: Math;
  137593. Uint8Array: Uint8ArrayConstructor;
  137594. Float32Array: Float32ArrayConstructor;
  137595. mozURL: typeof URL;
  137596. msURL: typeof URL;
  137597. VRFrameData: any; // WebVR, from specs 1.1
  137598. DracoDecoderModule: any;
  137599. setImmediate(handler: (...args: any[]) => void): number;
  137600. }
  137601. interface HTMLCanvasElement {
  137602. requestPointerLock(): void;
  137603. msRequestPointerLock?(): void;
  137604. mozRequestPointerLock?(): void;
  137605. webkitRequestPointerLock?(): void;
  137606. /** Track wether a record is in progress */
  137607. isRecording: boolean;
  137608. /** Capture Stream method defined by some browsers */
  137609. captureStream(fps?: number): MediaStream;
  137610. }
  137611. interface CanvasRenderingContext2D {
  137612. msImageSmoothingEnabled: boolean;
  137613. }
  137614. interface MouseEvent {
  137615. mozMovementX: number;
  137616. mozMovementY: number;
  137617. webkitMovementX: number;
  137618. webkitMovementY: number;
  137619. msMovementX: number;
  137620. msMovementY: number;
  137621. }
  137622. interface Navigator {
  137623. mozGetVRDevices: (any: any) => any;
  137624. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  137625. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  137626. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  137627. webkitGetGamepads(): Gamepad[];
  137628. msGetGamepads(): Gamepad[];
  137629. webkitGamepads(): Gamepad[];
  137630. }
  137631. interface HTMLVideoElement {
  137632. mozSrcObject: any;
  137633. }
  137634. interface Math {
  137635. fround(x: number): number;
  137636. imul(a: number, b: number): number;
  137637. }
  137638. interface WebGLRenderingContext {
  137639. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  137640. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  137641. vertexAttribDivisor(index: number, divisor: number): void;
  137642. createVertexArray(): any;
  137643. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  137644. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  137645. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  137646. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  137647. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  137648. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  137649. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  137650. // Queries
  137651. createQuery(): WebGLQuery;
  137652. deleteQuery(query: WebGLQuery): void;
  137653. beginQuery(target: number, query: WebGLQuery): void;
  137654. endQuery(target: number): void;
  137655. getQueryParameter(query: WebGLQuery, pname: number): any;
  137656. getQuery(target: number, pname: number): any;
  137657. MAX_SAMPLES: number;
  137658. RGBA8: number;
  137659. READ_FRAMEBUFFER: number;
  137660. DRAW_FRAMEBUFFER: number;
  137661. UNIFORM_BUFFER: number;
  137662. HALF_FLOAT_OES: number;
  137663. RGBA16F: number;
  137664. RGBA32F: number;
  137665. R32F: number;
  137666. RG32F: number;
  137667. RGB32F: number;
  137668. R16F: number;
  137669. RG16F: number;
  137670. RGB16F: number;
  137671. RED: number;
  137672. RG: number;
  137673. R8: number;
  137674. RG8: number;
  137675. UNSIGNED_INT_24_8: number;
  137676. DEPTH24_STENCIL8: number;
  137677. MIN: number;
  137678. MAX: number;
  137679. /* Multiple Render Targets */
  137680. drawBuffers(buffers: number[]): void;
  137681. readBuffer(src: number): void;
  137682. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  137683. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  137684. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  137685. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  137686. // Occlusion Query
  137687. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  137688. ANY_SAMPLES_PASSED: number;
  137689. QUERY_RESULT_AVAILABLE: number;
  137690. QUERY_RESULT: number;
  137691. }
  137692. interface WebGLProgram {
  137693. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  137694. }
  137695. interface EXT_disjoint_timer_query {
  137696. QUERY_COUNTER_BITS_EXT: number;
  137697. TIME_ELAPSED_EXT: number;
  137698. TIMESTAMP_EXT: number;
  137699. GPU_DISJOINT_EXT: number;
  137700. QUERY_RESULT_EXT: number;
  137701. QUERY_RESULT_AVAILABLE_EXT: number;
  137702. queryCounterEXT(query: WebGLQuery, target: number): void;
  137703. createQueryEXT(): WebGLQuery;
  137704. beginQueryEXT(target: number, query: WebGLQuery): void;
  137705. endQueryEXT(target: number): void;
  137706. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  137707. deleteQueryEXT(query: WebGLQuery): void;
  137708. }
  137709. interface WebGLUniformLocation {
  137710. _currentState: any;
  137711. }
  137712. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  137713. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  137714. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  137715. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  137716. interface WebGLRenderingContext {
  137717. readonly RASTERIZER_DISCARD: number;
  137718. readonly DEPTH_COMPONENT24: number;
  137719. readonly TEXTURE_3D: number;
  137720. readonly TEXTURE_2D_ARRAY: number;
  137721. readonly TEXTURE_COMPARE_FUNC: number;
  137722. readonly TEXTURE_COMPARE_MODE: number;
  137723. readonly COMPARE_REF_TO_TEXTURE: number;
  137724. readonly TEXTURE_WRAP_R: number;
  137725. readonly HALF_FLOAT: number;
  137726. readonly RGB8: number;
  137727. readonly RED_INTEGER: number;
  137728. readonly RG_INTEGER: number;
  137729. readonly RGB_INTEGER: number;
  137730. readonly RGBA_INTEGER: number;
  137731. readonly R8_SNORM: number;
  137732. readonly RG8_SNORM: number;
  137733. readonly RGB8_SNORM: number;
  137734. readonly RGBA8_SNORM: number;
  137735. readonly R8I: number;
  137736. readonly RG8I: number;
  137737. readonly RGB8I: number;
  137738. readonly RGBA8I: number;
  137739. readonly R8UI: number;
  137740. readonly RG8UI: number;
  137741. readonly RGB8UI: number;
  137742. readonly RGBA8UI: number;
  137743. readonly R16I: number;
  137744. readonly RG16I: number;
  137745. readonly RGB16I: number;
  137746. readonly RGBA16I: number;
  137747. readonly R16UI: number;
  137748. readonly RG16UI: number;
  137749. readonly RGB16UI: number;
  137750. readonly RGBA16UI: number;
  137751. readonly R32I: number;
  137752. readonly RG32I: number;
  137753. readonly RGB32I: number;
  137754. readonly RGBA32I: number;
  137755. readonly R32UI: number;
  137756. readonly RG32UI: number;
  137757. readonly RGB32UI: number;
  137758. readonly RGBA32UI: number;
  137759. readonly RGB10_A2UI: number;
  137760. readonly R11F_G11F_B10F: number;
  137761. readonly RGB9_E5: number;
  137762. readonly RGB10_A2: number;
  137763. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  137764. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  137765. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  137766. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  137767. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  137768. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  137769. 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;
  137770. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  137771. readonly TRANSFORM_FEEDBACK: number;
  137772. readonly INTERLEAVED_ATTRIBS: number;
  137773. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  137774. createTransformFeedback(): WebGLTransformFeedback;
  137775. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  137776. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  137777. beginTransformFeedback(primitiveMode: number): void;
  137778. endTransformFeedback(): void;
  137779. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  137780. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  137781. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  137782. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  137783. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  137784. }
  137785. interface ImageBitmap {
  137786. readonly width: number;
  137787. readonly height: number;
  137788. close(): void;
  137789. }
  137790. interface WebGLQuery extends WebGLObject {
  137791. }
  137792. declare var WebGLQuery: {
  137793. prototype: WebGLQuery;
  137794. new(): WebGLQuery;
  137795. };
  137796. interface WebGLSampler extends WebGLObject {
  137797. }
  137798. declare var WebGLSampler: {
  137799. prototype: WebGLSampler;
  137800. new(): WebGLSampler;
  137801. };
  137802. interface WebGLSync extends WebGLObject {
  137803. }
  137804. declare var WebGLSync: {
  137805. prototype: WebGLSync;
  137806. new(): WebGLSync;
  137807. };
  137808. interface WebGLTransformFeedback extends WebGLObject {
  137809. }
  137810. declare var WebGLTransformFeedback: {
  137811. prototype: WebGLTransformFeedback;
  137812. new(): WebGLTransformFeedback;
  137813. };
  137814. interface WebGLVertexArrayObject extends WebGLObject {
  137815. }
  137816. declare var WebGLVertexArrayObject: {
  137817. prototype: WebGLVertexArrayObject;
  137818. new(): WebGLVertexArrayObject;
  137819. };
  137820. // Type definitions for WebVR API
  137821. // Project: https://w3c.github.io/webvr/
  137822. // Definitions by: six a <https://github.com/lostfictions>
  137823. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  137824. interface VRDisplay extends EventTarget {
  137825. /**
  137826. * Dictionary of capabilities describing the VRDisplay.
  137827. */
  137828. readonly capabilities: VRDisplayCapabilities;
  137829. /**
  137830. * z-depth defining the far plane of the eye view frustum
  137831. * enables mapping of values in the render target depth
  137832. * attachment to scene coordinates. Initially set to 10000.0.
  137833. */
  137834. depthFar: number;
  137835. /**
  137836. * z-depth defining the near plane of the eye view frustum
  137837. * enables mapping of values in the render target depth
  137838. * attachment to scene coordinates. Initially set to 0.01.
  137839. */
  137840. depthNear: number;
  137841. /**
  137842. * An identifier for this distinct VRDisplay. Used as an
  137843. * association point in the Gamepad API.
  137844. */
  137845. readonly displayId: number;
  137846. /**
  137847. * A display name, a user-readable name identifying it.
  137848. */
  137849. readonly displayName: string;
  137850. readonly isConnected: boolean;
  137851. readonly isPresenting: boolean;
  137852. /**
  137853. * If this VRDisplay supports room-scale experiences, the optional
  137854. * stage attribute contains details on the room-scale parameters.
  137855. */
  137856. readonly stageParameters: VRStageParameters | null;
  137857. /**
  137858. * Passing the value returned by `requestAnimationFrame` to
  137859. * `cancelAnimationFrame` will unregister the callback.
  137860. * @param handle Define the hanle of the request to cancel
  137861. */
  137862. cancelAnimationFrame(handle: number): void;
  137863. /**
  137864. * Stops presenting to the VRDisplay.
  137865. * @returns a promise to know when it stopped
  137866. */
  137867. exitPresent(): Promise<void>;
  137868. /**
  137869. * Return the current VREyeParameters for the given eye.
  137870. * @param whichEye Define the eye we want the parameter for
  137871. * @returns the eye parameters
  137872. */
  137873. getEyeParameters(whichEye: string): VREyeParameters;
  137874. /**
  137875. * Populates the passed VRFrameData with the information required to render
  137876. * the current frame.
  137877. * @param frameData Define the data structure to populate
  137878. * @returns true if ok otherwise false
  137879. */
  137880. getFrameData(frameData: VRFrameData): boolean;
  137881. /**
  137882. * Get the layers currently being presented.
  137883. * @returns the list of VR layers
  137884. */
  137885. getLayers(): VRLayer[];
  137886. /**
  137887. * Return a VRPose containing the future predicted pose of the VRDisplay
  137888. * when the current frame will be presented. The value returned will not
  137889. * change until JavaScript has returned control to the browser.
  137890. *
  137891. * The VRPose will contain the position, orientation, velocity,
  137892. * and acceleration of each of these properties.
  137893. * @returns the pose object
  137894. */
  137895. getPose(): VRPose;
  137896. /**
  137897. * Return the current instantaneous pose of the VRDisplay, with no
  137898. * prediction applied.
  137899. * @returns the current instantaneous pose
  137900. */
  137901. getImmediatePose(): VRPose;
  137902. /**
  137903. * The callback passed to `requestAnimationFrame` will be called
  137904. * any time a new frame should be rendered. When the VRDisplay is
  137905. * presenting the callback will be called at the native refresh
  137906. * rate of the HMD. When not presenting this function acts
  137907. * identically to how window.requestAnimationFrame acts. Content should
  137908. * make no assumptions of frame rate or vsync behavior as the HMD runs
  137909. * asynchronously from other displays and at differing refresh rates.
  137910. * @param callback Define the eaction to run next frame
  137911. * @returns the request handle it
  137912. */
  137913. requestAnimationFrame(callback: FrameRequestCallback): number;
  137914. /**
  137915. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  137916. * Repeat calls while already presenting will update the VRLayers being displayed.
  137917. * @param layers Define the list of layer to present
  137918. * @returns a promise to know when the request has been fulfilled
  137919. */
  137920. requestPresent(layers: VRLayer[]): Promise<void>;
  137921. /**
  137922. * Reset the pose for this display, treating its current position and
  137923. * orientation as the "origin/zero" values. VRPose.position,
  137924. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  137925. * updated when calling resetPose(). This should be called in only
  137926. * sitting-space experiences.
  137927. */
  137928. resetPose(): void;
  137929. /**
  137930. * The VRLayer provided to the VRDisplay will be captured and presented
  137931. * in the HMD. Calling this function has the same effect on the source
  137932. * canvas as any other operation that uses its source image, and canvases
  137933. * created without preserveDrawingBuffer set to true will be cleared.
  137934. * @param pose Define the pose to submit
  137935. */
  137936. submitFrame(pose?: VRPose): void;
  137937. }
  137938. declare var VRDisplay: {
  137939. prototype: VRDisplay;
  137940. new(): VRDisplay;
  137941. };
  137942. interface VRLayer {
  137943. leftBounds?: number[] | Float32Array | null;
  137944. rightBounds?: number[] | Float32Array | null;
  137945. source?: HTMLCanvasElement | null;
  137946. }
  137947. interface VRDisplayCapabilities {
  137948. readonly canPresent: boolean;
  137949. readonly hasExternalDisplay: boolean;
  137950. readonly hasOrientation: boolean;
  137951. readonly hasPosition: boolean;
  137952. readonly maxLayers: number;
  137953. }
  137954. interface VREyeParameters {
  137955. /** @deprecated */
  137956. readonly fieldOfView: VRFieldOfView;
  137957. readonly offset: Float32Array;
  137958. readonly renderHeight: number;
  137959. readonly renderWidth: number;
  137960. }
  137961. interface VRFieldOfView {
  137962. readonly downDegrees: number;
  137963. readonly leftDegrees: number;
  137964. readonly rightDegrees: number;
  137965. readonly upDegrees: number;
  137966. }
  137967. interface VRFrameData {
  137968. readonly leftProjectionMatrix: Float32Array;
  137969. readonly leftViewMatrix: Float32Array;
  137970. readonly pose: VRPose;
  137971. readonly rightProjectionMatrix: Float32Array;
  137972. readonly rightViewMatrix: Float32Array;
  137973. readonly timestamp: number;
  137974. }
  137975. interface VRPose {
  137976. readonly angularAcceleration: Float32Array | null;
  137977. readonly angularVelocity: Float32Array | null;
  137978. readonly linearAcceleration: Float32Array | null;
  137979. readonly linearVelocity: Float32Array | null;
  137980. readonly orientation: Float32Array | null;
  137981. readonly position: Float32Array | null;
  137982. readonly timestamp: number;
  137983. }
  137984. interface VRStageParameters {
  137985. sittingToStandingTransform?: Float32Array;
  137986. sizeX?: number;
  137987. sizeY?: number;
  137988. }
  137989. interface Navigator {
  137990. getVRDisplays(): Promise<VRDisplay[]>;
  137991. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  137992. }
  137993. interface Window {
  137994. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  137995. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  137996. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  137997. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  137998. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  137999. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  138000. }
  138001. interface Gamepad {
  138002. readonly displayId: number;
  138003. }
  138004. type XRSessionMode =
  138005. | "inline"
  138006. | "immersive-vr"
  138007. | "immersive-ar";
  138008. type XRReferenceSpaceType =
  138009. | "viewer"
  138010. | "local"
  138011. | "local-floor"
  138012. | "bounded-floor"
  138013. | "unbounded";
  138014. type XREnvironmentBlendMode =
  138015. | "opaque"
  138016. | "additive"
  138017. | "alpha-blend";
  138018. type XRVisibilityState =
  138019. | "visible"
  138020. | "visible-blurred"
  138021. | "hidden";
  138022. type XRHandedness =
  138023. | "none"
  138024. | "left"
  138025. | "right";
  138026. type XRTargetRayMode =
  138027. | "gaze"
  138028. | "tracked-pointer"
  138029. | "screen";
  138030. type XREye =
  138031. | "none"
  138032. | "left"
  138033. | "right";
  138034. interface XRSpace extends EventTarget {
  138035. }
  138036. interface XRRenderState {
  138037. depthNear?: number;
  138038. depthFar?: number;
  138039. inlineVerticalFieldOfView?: number;
  138040. baseLayer?: XRWebGLLayer;
  138041. }
  138042. interface XRInputSource {
  138043. handedness: XRHandedness;
  138044. targetRayMode: XRTargetRayMode;
  138045. targetRaySpace: XRSpace;
  138046. gripSpace: XRSpace | undefined;
  138047. gamepad: Gamepad | undefined;
  138048. profiles: Array<string>;
  138049. }
  138050. interface XRSession extends XRAnchorCreator {
  138051. addEventListener: Function;
  138052. removeEventListener: Function;
  138053. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  138054. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  138055. requestAnimationFrame: Function;
  138056. end(): Promise<void>;
  138057. renderState: XRRenderState;
  138058. inputSources: Array<XRInputSource>;
  138059. // AR hit test
  138060. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  138061. updateWorldTrackingState(options: {
  138062. planeDetectionState?: { enabled: boolean; }
  138063. }): void;
  138064. }
  138065. interface XRReferenceSpace extends XRSpace {
  138066. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  138067. onreset: any;
  138068. }
  138069. type XRPlaneSet = Set<XRPlane>;
  138070. type XRAnchorSet = Set<XRAnchor>;
  138071. interface XRFrame {
  138072. session: XRSession;
  138073. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  138074. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  138075. // Anchors
  138076. trackedAnchors?: XRAnchorSet;
  138077. // Planes
  138078. worldInformation: {
  138079. detectedPlanes?: XRPlaneSet;
  138080. };
  138081. }
  138082. interface XRViewerPose extends XRPose {
  138083. views: Array<XRView>;
  138084. }
  138085. interface XRPose {
  138086. transform: XRRigidTransform;
  138087. emulatedPosition: boolean;
  138088. }
  138089. interface XRWebGLLayerOptions {
  138090. antialias?: boolean;
  138091. depth?: boolean;
  138092. stencil?: boolean;
  138093. alpha?: boolean;
  138094. multiview?: boolean;
  138095. framebufferScaleFactor?: number;
  138096. }
  138097. declare var XRWebGLLayer: {
  138098. prototype: XRWebGLLayer;
  138099. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  138100. };
  138101. interface XRWebGLLayer {
  138102. framebuffer: WebGLFramebuffer;
  138103. framebufferWidth: number;
  138104. framebufferHeight: number;
  138105. getViewport: Function;
  138106. }
  138107. declare class XRRigidTransform {
  138108. constructor(matrix: Float32Array);
  138109. position: DOMPointReadOnly;
  138110. orientation: DOMPointReadOnly;
  138111. matrix: Float32Array;
  138112. inverse: XRRigidTransform;
  138113. }
  138114. interface XRView {
  138115. eye: XREye;
  138116. projectionMatrix: Float32Array;
  138117. transform: XRRigidTransform;
  138118. }
  138119. interface XRInputSourceChangeEvent {
  138120. session: XRSession;
  138121. removed: Array<XRInputSource>;
  138122. added: Array<XRInputSource>;
  138123. }
  138124. interface XRInputSourceEvent extends Event {
  138125. readonly frame: XRFrame;
  138126. readonly inputSource: XRInputSource;
  138127. }
  138128. // Experimental(er) features
  138129. declare class XRRay {
  138130. constructor(transformOrOrigin: XRRigidTransform | DOMPointReadOnly, direction?: DOMPointReadOnly);
  138131. origin: DOMPointReadOnly;
  138132. direction: DOMPointReadOnly;
  138133. matrix: Float32Array;
  138134. }
  138135. interface XRHitResult {
  138136. hitMatrix: Float32Array;
  138137. }
  138138. interface XRAnchor {
  138139. // remove?
  138140. id?: string;
  138141. anchorSpace: XRSpace;
  138142. lastChangedTime: number;
  138143. detach(): void;
  138144. }
  138145. interface XRPlane extends XRAnchorCreator {
  138146. orientation: "Horizontal" | "Vertical";
  138147. planeSpace: XRSpace;
  138148. polygon: Array<DOMPointReadOnly>;
  138149. lastChangedTime: number;
  138150. }
  138151. interface XRAnchorCreator {
  138152. // AR Anchors
  138153. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  138154. }